diff --git a/.ci/after-failure.sh b/.ci/after-failure.sh index bb5a3ea54a..9c41abefc9 100755 --- a/.ci/after-failure.sh +++ b/.ci/after-failure.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # # This file is part of the Zephir. # @@ -15,9 +15,28 @@ shopt -s nullglob export LC_ALL=C -for i in /tmp/core.*; do - if [ -f "$i" -a "$(file "$i" | grep -o 'core file')" ]; then - gdb -q $(phpenv which php) "$i" <&1 echo "Compiler log:") + (>&1 printf "%s\\n" "$log_contents") + } +fi + +# for some reason Ubuntu 18.04 on Travis CI doesn't install gdb +function install_gcc() { + if [ "${CI}" = "true" ] && [ "$(command -v gdb 2>/dev/null)" = "" ] + then + (>&1 echo "Install gdb...") + sudo apt-get install --no-install-recommends --quiet --assume-yes gdb 1> /dev/null + fi +} + +for i in /tmp/core.php.*; do + install_gcc + (>&1 printf "Found core dump file: %s\\n\\n" "$i") + gdb -q "$(phpenv which php)" "$i" < -# -# For the full copyright and license information, please view -# the LICENSE file that was distributed with this source code. - -# -e Exit immediately if a command exits with a non-zero status. -# -u Treat unset variables as an error when substituting. -set -eu - -project_root=$(readlink -enq "$(dirname $0)/../") - -gcov_report=${project_root}/unit-tests/output/lcov.info -phpunit_report=${project_root}/unit-tests/output/clover.xml - -if [ -z ${COLLECT_COVERAGE+x} ] || [ "$COLLECT_COVERAGE" != "true" ]; then - printf "Uploading coverage data is not enabled.\nSkip uploading reports to Codecov.\n" - exit 0 -fi - -if [ $(command -v lcov 2>/dev/null) = "" ]; then - printf "lcov does not exist.\nSkip capturing coverage data.\n" -else - # Capture coverage data - lcov \ - --quiet \ - --no-checksum \ - --directory ext \ - --base-directory=${project_root} \ - --capture \ - --compat-libtool \ - --output-file ${gcov_report} 2>/dev/null - - # Remove files matching non-project patterns - lcov \ - --quiet \ - --remove ${gcov_report} "/usr*" \ - --remove ${gcov_report} "${HOME}/.phpenv/*" \ - --compat-libtool \ - --output-file ${gcov_report} 2>/dev/null - - # FIXME: Fix the report - # Cannot open source file ${PROJECT_ROOT}/kernel/fcall.h - sed -i.bak s_${project_root}/kernel_${project_root}/ext/kernel_g ${gcov_report} -fi - -# Note: to upload a coverage report, set the CODECOV_TOKEN environment variable -# export CODECOV_TOKEN= - -curl -sSl https://codecov.io/bash -o "${HOME}/bin/codecov" -chmod +x "${HOME}/bin/codecov" - -if [ -f ${gcov_report} ]; then - codecov -f ${gcov_report} -fi - -if [ -f ${phpunit_report} ]; then - codecov -f ${phpunit_report} -fi diff --git a/.ci/build-phar.sh b/.ci/build-phar.sh index 4de28b6001..fff2792ca2 100755 --- a/.ci/build-phar.sh +++ b/.ci/build-phar.sh @@ -11,24 +11,20 @@ # -u Treat unset variables as an error when substituting. set -eu -project_root=$(readlink -enq "$(dirname $0)/../") - -if [ $(command -v box 2>/dev/null) = "" ]; then - >&2 printf "To use this script you need to install humbug/box.\n" - >&2 printf "You can learn all about humbug/box on https://github.com/humbug/box.\n" - >&2 printf "Aborting.\n" +if [ "$(command -v box 2>/dev/null)" = "" ]; then + (>&2 printf "To use this script you need to install humbug/box: %s \\n" \ + "https://github.com/humbug/box") + (>&2 echo "Aborting.") exit 1 fi -box compile --working-dir=${project_root} +box compile -if [ ! -f "${project_root}/zephir.phar" ] || [ ! -x "${project_root}/zephir.phar" ]; then - >&2 printf "Something went wrong when building Zephir.\n" - >&2 printf "Aborting.\n" +if [ ! -f "./zephir.phar" ] || [ ! -x "./zephir.phar" ]; then + (>&2 echo "Something went wrong when building zephir.phar") + (>&2 echo "Aborting.") exit 1 fi -mkdir -p ${HOME}/bin -rm -f ${HOME}/bin/zephir - -ln -s "${project_root}/zephir.phar" ${HOME}/bin/zephir +mkdir -p "$HOME/bin" +mv "./zephir.phar" "$HOME/bin/zephir" diff --git a/.ci/build-test-ext.sh b/.ci/build-test-ext.sh index 7a2fcc4145..59639d4148 100755 --- a/.ci/build-test-ext.sh +++ b/.ci/build-test-ext.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # # This file is part of the Zephir. # @@ -14,89 +14,53 @@ set -eu # This allows the configuration of the executable path as follows: # ZEPHIR_BIN=zephir.phar .ci/build-test-ext.sh # ZEPHIR_BIN=./zephir .ci/build-test-ext.sh -: ${ZEPHIR_BIN:=zephir} +: "${ZEPHIR_BIN:=zephir}" -project_root=$(readlink -enq "$(dirname $0)/../") -gcov_report=${project_root}/unit-tests/output/lcov.info +# Some defaults +: "${REPORT_COVERAGE:=0}" +: "${CFLAGS:=}" +: "${CXXFLAGS:=}" +: "${LDFLAGS:=}" -alias zephir="${ZEPHIR_BIN}" - -zephir clean 2>&1 || exit 1 -zephir fullclean 2>&1 || exit 1 +$ZEPHIR_BIN clean 2>&1 || exit 1 +$ZEPHIR_BIN fullclean 2>&1 || exit 1 # TODO: Export ZFLAGS and process by Config class ZFLAGS="" # ZFLAGS="${ZFLAGS} -Wnonexistent-function -Wnonexistent-class -Wunused-variable -Wnonexistent-constant" # ZFLAGS="${ZFLAGS} -Wunreachable-code -Wnot-supported-magic-constant -Wnon-valid-decrement" -zephir generate ${ZFLAGS} 2>&1 || exit 1 -zephir stubs ${ZFLAGS} 2>&1 || exit 1 -zephir api ${ZFLAGS} 2>&1 || exit 1 +$ZEPHIR_BIN generate ${ZFLAGS} 2>&1 || exit 1 +$ZEPHIR_BIN stubs ${ZFLAGS} 2>&1 || exit 1 +$ZEPHIR_BIN api ${ZFLAGS} 2>&1 || exit 1 -cd ext +cd ext || exit 1 phpize -if [ ! -z ${COLLECT_COVERAGE+x} ] && [ "$COLLECT_COVERAGE" = "true" ]; then - # The ltmain.sh which bundled with PHP it's from libtool 1.5.26. - # However, the version of libtool that claims to no longer remove - # ".gcno" profiler information is libtool 2.2.6. The fix is probably - # in later libtool versions as well. - if [ "$(uname -s 2>/dev/null)" = "Darwin" ]; then - # macOS - libtoolize_bin=$(command -v glibtoolize 2>/dev/null) - else - # Linux, Gentoo, etc - libtoolize_bin=$(command -v libtoolize 2>/dev/null) - fi - - aclocal && ${libtoolize_bin} --copy --force && autoheader && autoconf - - CFLAGS=`echo "${CFLAGS}" | sed -e 's/-O[0-9s]*//g'` - CXXFLAGS=`echo "${CXXFLAGS}" | sed -e 's/-O[0-9s]*//g'` - LDFLAGS=`echo "${LDFLAGS}" | sed -e 's/--coverage//g'` +if [ "$REPORT_COVERAGE" -eq 1 ] +then + CFLAGS=${CFLAGS//-O[0-9s]/} + CXXFLAGS=${CXXFLAGS//-O[0-9s]/} + LDFLAGS=${LDFLAGS//--coverage/} LDFLAGS="${LDFLAGS} --coverage" CFLAGS="${CFLAGS} -O0 -ggdb -fprofile-arcs -ftest-coverage" CXXFLAGS="${CXXFLAGS} -O0 -ggdb -fprofile-arcs -ftest-coverage" fi -if [ ! -z ${CFLAGS+x} ] && [ ! -z ${LDFLAGS+x} ]; then +if [ -n "$CFLAGS" ] && [ -n "$LDFLAGS" ] +then ./configure --enable-test CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" else ./configure --enable-test fi -make -j"$(getconf _NPROCESSORS_ONLN)" - -cd .. +make -j"$(getconf _NPROCESSORS_ONLN)" 2> ./compile-errors.log +exitcode=$? -if [ ! -z ${COLLECT_COVERAGE+x} ] && [ "$COLLECT_COVERAGE" = "true" ]; then - if [ $(command -v lcov 2>/dev/null) = "" ]; then - printf "lcov does not exist.\nSkip capturing coverage data.\n" - else - # Reset all execution counts to zero - lcov \ - --quiet \ - --directory ext \ - --base-directory=${project_root} \ - --zerocounters 2>/dev/null - - # Capture coverage data - lcov \ - --quiet \ - --directory ext \ - --base-directory=${project_root} \ - --capture \ - --compat-libtool \ - --initial \ - --output-file ${gcov_report} 2>/dev/null - - # FIXME: Fix the report - # geninfo: WARNING: could not open ${PROJECT_ROOT}/kernel/fcall.h - # geninfo: WARNING: some exclusion markers may be ignored - sed -i.bak s_${project_root}/kernel_${project_root}/ext/kernel_g ${gcov_report} - fi -fi +test "$exitcode" = 0 || { + test -f ./compile-errors.log && cat ./compile-errors.log +} -exit $? +exit $exitcode diff --git a/.ci/install-prereqs.sh b/.ci/install-prereqs.sh index 649720a498..f1302e7553 100755 --- a/.ci/install-prereqs.sh +++ b/.ci/install-prereqs.sh @@ -12,41 +12,39 @@ set -eu # Ensure that this is being run inside a CI container -if [ "${CI}" != "true" ]; +if [ "${CI}" != "true" ] then - >&2 echo "This script is designed to run inside a CI container only." - >&2 echo "Aborting." + (>&2 echo "This script is designed to run inside a CI container only.") + (>&2 echo "Aborting.") exit 1 fi -PHP_INI="$(phpenv root)/versions/$(phpenv version-name)/etc/php.ini" - -: ${ZEPHIR_PARSER_VERSION:=master} +: "${ZEPHIR_PARSER_VERSION:=master}" # Install psr extension -printf "Install psr extension\n" -printf "\n" | pecl install --force psr 1> /dev/null +(>&1 echo "Install psr extension...") +printf "\\n" | pecl install --force psr 1> /dev/null # Install Zephir Parser -printf "Install Zephir Parser\n" -git clone -b "${ZEPHIR_PARSER_VERSION}" --depth 1 -q https://github.com/phalcon/php-zephir-parser +(>&1 echo "Install Zephir Parser...") +git clone -b "$ZEPHIR_PARSER_VERSION" --depth 1 -q https://github.com/phalcon/php-zephir-parser cd php-zephir-parser +# shellcheck disable=SC2091 $(phpenv which phpize) -./configure --silent --with-php-config=$(phpenv which php-config) --enable-zephir_parser +./configure --silent --with-php-config="$(phpenv which php-config)" --enable-zephir_parser make --silent -j"$(getconf _NPROCESSORS_ONLN)" make --silent install echo 'extension="zephir_parser.so"' > "$(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/zephir_parser.ini" # Install Box -if [ "$BUILD_PHAR" = "true" ]; then - printf "Install Box\n" - printf "PHP version number is ${PHP_VERNUM}\nDownloading humbug/box...\n" +if [ "$BUILD_PHAR" -eq "1" ] +then + (>&1 echo "Install Box...") wget \ "https://github.com/humbug/box/releases/download/${BOX_VERSION}/box.phar" \ --quiet \ -O "${HOME}/bin/box" chmod +x "${HOME}/bin/box" - box --version fi diff --git a/.ci/install-re2c.sh b/.ci/install-re2c.sh index 54dc6f8dc4..328466a6e0 100755 --- a/.ci/install-re2c.sh +++ b/.ci/install-re2c.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/usr/bin/env bash # # This file is part of the Zephir. # @@ -7,22 +7,17 @@ # For the full copyright and license information, please view # the LICENSE file that was distributed with this source code. -# -e Exit immediately if a command exits with a non-zero status. -# -u Treat unset variables as an error when substituting. -set -eu - -if [ -z ${CI+x} ] || [ "$CI" != "true" ]; then - >&2 printf "This script is designed to run inside a CI container only.\nAborting.\n" +if [ -z ${RE2C_VERSION+x} ] +then + (>&2 echo "The RE2C_VERSION is unset.") + (>&2 echo "Aborting.") exit 1 fi -if [ -z ${RE2C_VERSION+x} ]; then - >&2 printf "The RE2C_VERSION is unset.\nAborting.\n" - exit 1 -fi - -if [ "${RE2C_VERSION}" = "system" ]; then - printf "Use system re2c.\nSkip.\n" +if [ "${RE2C_VERSION}" == "system" ] +then + (>&2 echo "Use system re2c.") + (>&2 echo "Skip.") exit 0 fi @@ -32,53 +27,60 @@ downloaddir="${HOME}/.cache/${pkgname}/${pkgname}-${RE2C_VERSION}" prefix="${HOME}/.local/opt/${pkgname}/${pkgname}-${RE2C_VERSION}" bindir="${prefix}/bin" -if [ ! -f "${bindir}/re2c" ]; then - if [ ! -d `dirname ${downloaddir}` ]; then - mkdir -p `dirname ${downloaddir}` +if [ ! -f "${bindir}/re2c" ] +then + if [ ! -d "$(dirname "$downloaddir")" ] + then + mkdir -p "$(dirname "$downloaddir")" fi - cd `dirname ${downloaddir}` + cd "$(dirname "$downloaddir")" || exit 1 - if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.gz" ]; then + if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.gz" ] + then curl -sSL "$source" -o "${pkgname}-${RE2C_VERSION}.tar.gz" fi - if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.gz" ]; then - >&2 printf "Aborting.\n" - >&2 printf "Unable to locate ${pkgname}-${RE2C_VERSION}.tar.gz file.\n" + if [ ! -f "${pkgname}-${RE2C_VERSION}.tar.gz" ] + then + (>&2 printf "Unable to locate %s-%s .tar.gz file.\\n" "$pkgname" "$RE2C_VERSION") + (>&2 echo "Stop.") exit 1 fi - if [ ! -d "${downloaddir}" ]; then - mkdir -p "${downloaddir}" + if [ ! -d "$downloaddir" ] + then + mkdir -p "$downloaddir" tar -zxf "${pkgname}-${RE2C_VERSION}.tar.gz" fi - if [ ! -d "${downloaddir}" ]; then - >&2 printf "Unable to locate re2c source.\nAborting.\n" + if [ ! -d "$downloaddir" ] + then + (>&2 echo "Unable to locate re2c source.") + (>&2 echo "Stop.") exit 1 fi - if [ ! -d "${prefix}" ]; then - mkdir -p "${prefix}" + if [ ! -d "$prefix" ] + then + mkdir -p "$prefix" fi - cd "${downloaddir}" - ./configure --prefix="${prefix}" + cd "$downloaddir" || exit 1 + ./configure --silent --prefix="${prefix}" - make -j"$(getconf _NPROCESSORS_ONLN)" - make install + make --silent -j"$(getconf _NPROCESSORS_ONLN)" + make --silent install fi -if [ ! -x "${bindir}/re2c" ]; then - >&2 printf "Unable to locate re2c executable.\nAborting.\n" +if [ ! -x "$bindir/re2c" ]; then + (>&2 echo "Unable to locate re2c executable.") + (>&2 echo "Stop.") exit 1 fi -cd ${TRAVIS_BUILD_DIR} - -mkdir -p ${HOME}/bin -ln -s "${bindir}/re2c" ${HOME}/bin/re2c +mkdir -p "$HOME/bin" +ln -s "$bindir/re2c" "$HOME/bin/re2c" re2c --version exit 0 diff --git a/.ci/memcheck.sh b/.ci/memcheck.sh index 351e6d4684..3ce12874d3 100755 --- a/.ci/memcheck.sh +++ b/.ci/memcheck.sh @@ -7,9 +7,9 @@ # For the full copyright and license information, please view # the LICENSE file that was distributed with this source code. -if [ $(command -v valgrind 2>/dev/null) = "" ]; then - >&2 printf "Valgring does not exist. Can not check for memory leaks.\n" - >&2 printf "Aborting.\n" +if [ "$(command -v valgrind 2>/dev/null)" = "" ]; then + (>&2 echo "Valgring does not exist. Can not check for memory leaks.") + (>&2 echo "Aborting.") exit 1 fi @@ -22,9 +22,7 @@ export USE_ZEND_ALLOC=0 # Do not stop testing on failures export PHPUNIT_DONT_EXIT=1 -project_root=$(readlink -enq "$(dirname $0)/../") - -valgrind +valgrind \ --read-var-info=yes \ --error-exitcode=1 \ --fullpath-after= \ @@ -32,8 +30,8 @@ valgrind --leak-check=full \ --num-callers=20 \ --run-libc-freeres=no \ - $(phpenv which php) - -d "extension=${project_root}/ext/modules/test.so" \ - "${project_root}/unit-tests/phpunit" \ + "$(phpenv which php)" \ + -d "extension=ext/modules/test.so" \ + "unit-tests/phpunit" \ --no-coverage \ --testsuite "Extension Test Suite" diff --git a/.ci/run-tests.sh b/.ci/run-tests.sh index eea50dccea..4002eb6d0d 100755 --- a/.ci/run-tests.sh +++ b/.ci/run-tests.sh @@ -11,26 +11,20 @@ # -u Treat unset variables as an error when substituting. set -eu -if [ -z ${CI+x} ] || [ "$CI" != "true" ]; then - >&2 printf "This script is designed to run inside a CI container only.\n" - >&2 printf "Aborting.\n" - exit 1 -fi - -if [ "$(php-config --vernum)" -lt "70200" ]; then +if [ "$($(phpenv which php-config) --vernum)" -lt "70200" ]; then test_suite="Extension_Php70" else test_suite="Extension_Php72" fi -php \ +"$(phpenv which php)" \ -d extension=ext/modules/test.so \ vendor/bin/simple-phpunit \ --colors=always \ --bootstrap unit-tests/ext-bootstrap.php \ --testsuite ${test_suite} -php \ +"$(phpenv which php)" \ vendor/bin/simple-phpunit \ --colors=always \ --testsuite Zephir diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 0000000000..17f04fa14e --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,40 @@ +codecov: + notify: + require_ci_to_pass: yes + +coverage: + precision: 2 + round: down + range: "33...90" + + status: + project: + default: + # Allow the coverage to drop by threshold %, and posting a success status. + threshold: 0.5 + patch: + default: + # trial operation + target: 0% + changes: no + +comment: + layout: "header, diff" + behavior: default + require_changes: no + +ignore: + - ".git" + - "*.yml" + - "*.json" + - "*.md" + # ignore folders and all its contents + - ".ci/.*" + - ".github/.*" + - ".zephir/.*" + - "ide/.*" + - "/home/travis/.phpenv/.*" + - "php-zephir-parser/.*" + - ".phpunit/.*" + - "tests/.*" + - "vendor/.*" diff --git a/.editorconfig b/.editorconfig index bf900bfd5d..3ca35c6d40 100644 --- a/.editorconfig +++ b/.editorconfig @@ -15,14 +15,14 @@ trim_trailing_whitespace = true indent_style = tab tab_width = 4 -[*.{mk,c,h,awk,frag,lemon,re}] +[*.{mk,c,h,awk,bat,frag,lemon,re}] indent_style = tab tab_width = 4 [*.md] trim_trailing_whitespace = false -[*.{yml,sh}] +[*.{yml,m4,json,xml,sh}] indent_size = 2 [zephir-autocomplete] diff --git a/.travis.yml b/.travis.yml index 3e258737f4..18d0150b06 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,8 @@ php: - '7.1' - '7.0' +dist: xenial + git: depth: 5 quiet: true @@ -14,7 +16,7 @@ addons: apt: packages: - gdb - - lcov + - shellcheck matrix: fast_finish: true @@ -32,108 +34,94 @@ cache: env: global: - RE2C_VERSION="1.1.1" - - ZEPHIR_PARSER_VERSION="v1.3.0" + - ZEPHIR_PARSER_VERSION="v1.3.1" # TODO: See Library/StatementsBlock.php # - ZEPHIR_DEBUG=true - - COLLECT_COVERAGE=true + - REPORT_COVERAGE=1 - BOX_VERSION=3.3.1 - - BUILD_PHAR=false + - BUILD_PHAR=0 - PATH="${HOME}/bin:${PATH}" - - TRAVIS_COMMIT_LOG=`git log --format=fuller -5` + - TRAVIS_COMMIT_LOG="$(git log --format=fuller -5)" before_install: - | - # General settings - stty cols 120 - - # Export build/test environment variables - export SYMFONY_PHPUNIT_DIR=$(pwd)/.phpunit - export PHP_VERNUM="$(php-config --vernum)" + # Core dump settings + ulimit -c unlimited -S || true + echo '/tmp/core.%e.%p.%t' | sudo tee /proc/sys/kernel/core_pattern + + if [ -n "$GITHUB_TOKEN" ] + then + composer config github-oauth.github.com "$GITHUB_TOKEN" + echo 'Add Github token' + fi - if [ ! -z "${GITHUB_TOKEN}" ]; then - composer config github-oauth.github.com ${GITHUB_TOKEN} - printf "Add Github token\n" - fi + # Export build/test environment variables + export SYMFONY_PHPUNIT_DIR="$(pwd)/.phpunit" + export PHP_VERNUM="$(php-config --vernum)" - [ -d ~/bin ] || mkdir ~/bin + [ -d ~/bin ] || mkdir ~/bin + export DEFAULT_COMPOSER_FLAGS=("--no-interaction" "--no-ansi" "--no-progress" "--no-suggest") - # Core dump settings - ulimit -c unlimited -S || true - echo '/tmp/core.%e.%p.%t' | sudo tee /proc/sys/kernel/core_pattern + # Hide "You are in 'detached HEAD' state" message + git config --global advice.detachedHead false - # Hide "You are in 'detached HEAD' state" message - git config --global advice.detachedHead false + # Box does not work with PHP 7.4 + if [ "$PHP_VERNUM" -ge "70100" ] && [ "$PHP_VERNUM" -lt "70400" ] + then + export BUILD_PHAR=1 + fi - # Box does not work with PHP 7.4 - if [ "$PHP_VERNUM" -ge "70100" ] && [ "$PHP_VERNUM" -lt "70400" ]; then - export BUILD_PHAR=true - fi + if [ "$PHP_VERNUM" -ge "70400" ] + then + # Temporary until we release parser with PHP 7.4 support + export ZEPHIR_PARSER_VERSION=development + fi - if [ "$PHP_VERNUM" -ge "70400" ]; then - # Do not collect code coverage for PHP 7.4 - export COLLECT_COVERAGE=false + if [ "$TRAVIS_PHP_VERSION" = "7.2" ] + then + echo 'Choose a suitable PHP version to build PHAR' + composer config platform.php 7.0.33 + fi - # Temporary until we release parser with PHP 7.4 support - export ZEPHIR_PARSER_VERSION=development - fi install: - .ci/install-prereqs.sh - - .ci/install-re2c.sh $RE2C_VERSION - - flags="--ansi --prefer-dist --no-interaction --optimize-autoloader --no-suggest --no-progress" - - if [ "$TRAVIS_PHP_VERSION" = "7.2" ]; then composer config platform.php 7.0.33; echo "Preparing to deploy"; fi - - travis_retry composer install $flags + - .ci/install-re2c.sh "$RE2C_VERSION" + - travis_retry composer install ${DEFAULT_COMPOSER_FLAGS[*]} - | # Prepare Zephir executable - if [ "$BUILD_PHAR" = "true" ]; then - printf "Build Zephit PHAR\n" + if [ "$BUILD_PHAR" -eq 1 ] + then + echo "Build Zephit PHAR" .ci/build-phar.sh else - printf "Use Zephir from source\n" - ln -s $(pwd)/zephir ${HOME}/bin/zephir + echo "Use Zephir from source" + ln -s "$(pwd)/zephir" "$HOME/bin/zephir" fi before_script: - .ci/build-test-ext.sh - - cat .ci/travis.ini >> $(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/travis.ini - # Does not ready yet - - if [ "$PHP_VERNUM" -ge "70400" ]; then phpenv config-rm xdebug.ini || true; fi + - cat .ci/travis.ini >> "$(phpenv root)/versions/$(phpenv version-name)/etc/conf.d/travis.ini" script: - - zephir - .ci/run-tests.sh - - (cd unit-tests/sharness && make) - -after_success: - - .ci/after-success.sh - -after_failure: - - .ci/after-failure.sh + - (cd unit-tests/sharness && PHP=$(phpenv which php) make) jobs: include: - stage: Static Code Analysis - php: 7.2 - env: - - CHECK=php-cs-fixer - - COLLECT_COVERAGE=false - install: - - wget --no-clobber -O $HOME/bin/php-cs-fixer https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar - before_script: - - chmod +x $HOME/bin/php-cs-fixer - script: - - php-cs-fixer fix --diff --dry-run -v - - - stage: Static Code Analysis - php: 7.2 + php: '7.2' env: - - CHECK=PHP_CodeSniffer - - COLLECT_COVERAGE=false + - REPORT_COVERAGE=0 install: - - wget --no-clobber -O $HOME/bin/phpcs https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar + - wget --quiet -O "$HOME/bin/php-cs-fixer" https://cs.sensiolabs.org/download/php-cs-fixer-v2.phar + - wget --quiet -O "$HOME/bin/phpcs" https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar before_script: - - chmod +x $HOME/bin/phpcs + - chmod +x "$HOME/bin/php-cs-fixer" + - chmod +x "$HOME/bin/phpcs" script: - phpcs + - php-cs-fixer fix --diff --dry-run -v + - shellcheck .ci/*.sh notifications: email: false @@ -142,6 +130,15 @@ after_script: - printf "$TRAVIS_COMMIT_RANGE\n" - printf "$TRAVIS_COMMIT_LOG\n" +after_success: + - .ci/after-success.sh + - '[[ "$REPORT_COVERAGE" -eq 1 ]] && bash <(curl -s https://codecov.io/bash)' + +after_failure: + - echo "$($(phpenv which php) -v)" + - echo "$($(phpenv which php) -m)" + - .ci/after-failure.sh + before_deploy: - git config --global user.name cicdbot - git config --global user.email team@zephir-lang.com diff --git a/CHANGELOG.md b/CHANGELOG.md index 0233fdf871..8fff14dc2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [0.12.2] - 2019-08-05 +### Added +- Introduced initial ability to generate `zend_module_deps` + [#1900](https://github.com/phalcon/zephir/pull/1900), + [phalcon/cphalcon#13702](https://github.com/phalcon/cphalcon/issues/13702), + [phalcon/cphalcon#13794](https://github.com/phalcon/cphalcon/pull/13794) + +### Changed +- Write errors compiler to stderr if available + ## [0.12.1] - 2019-07-30 ### Added - Added initial bash completion support (see `zephir-autocomplete` file) @@ -200,7 +210,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - Fixed casting resource to int (only ZendEngine 3) [#1524](https://github.com/phalcon/zephir/issues/1524) -[Unreleased]: https://github.com/phalcon/zephir/compare/0.12.1...HEAD +[Unreleased]: https://github.com/phalcon/zephir/compare/0.12.2...HEAD +[0.12.2]: https://github.com/phalcon/zephir/compare/0.12.1...0.12.2 [0.12.1]: https://github.com/phalcon/zephir/compare/0.12.0...0.12.1 [0.12.0]: https://github.com/phalcon/zephir/compare/0.11.12...0.12.0 [0.11.12]: https://github.com/phalcon/zephir/compare/0.11.11...0.11.12 diff --git a/Library/Compiler.php b/Library/Compiler.php index ed099370ee..07d71b7951 100644 --- a/Library/Compiler.php +++ b/Library/Compiler.php @@ -121,7 +121,12 @@ public function __construct( $this->stringManager = $this->backend->getStringsManager(); $this->fcallManager = $this->backend->getFcallManager(); - $this->assertRequiredExtensionsIsPresent(); + try { + $this->assertRequiredExtensionsIsPresent(); + } catch (RuntimeException $e) { + fwrite(STDERR, trim($e->getMessage()).PHP_EOL); + exit(1); + } } /** @@ -1672,6 +1677,10 @@ public function createProjectFiles($project) } } + $modRequires = array_map(function ($mod) { + return sprintf('ZEND_MOD_REQUIRED("%s")', strtolower($mod)); + }, $this->config->get('extensions', 'requires') ?: []); + $toReplace = [ '%PROJECT_LOWER_SAFE%' => strtolower($safeProject), '%PROJECT_LOWER%' => strtolower($project), @@ -1719,6 +1728,7 @@ public function createProjectFiles($project) '%FE_HEADER%' => $feHeader, '%FE_ENTRIES%' => $feEntries, '%PROJECT_INI_ENTRIES%' => implode(PHP_EOL."\t", $initEntries), + '%PROJECT_DEPENDENCIES%' => implode(PHP_EOL."\t", $modRequires), ]; foreach ($toReplace as $mark => $replace) { $content = str_replace($mark, $replace, $content); @@ -2160,6 +2170,11 @@ private function assertRequiredExtensionsIsPresent() $extensions = []; foreach ($extensionRequires as $key => $value) { + // TODO: We'll use this as an object in the future. + // Right not it should be a string. + if (!\is_string($value)) { + continue; + } if (false === \extension_loaded($value)) { $extensions[] = $value; } @@ -2168,7 +2183,7 @@ private function assertRequiredExtensionsIsPresent() if (false === empty($extensions)) { throw new RuntimeException( sprintf( - 'Could not load extension: %s. You must add extensions above before build this extension.', + 'Could not load extension(s): %s. You must load extensions above before build this extension.', implode(', ', $extensions) ) ); diff --git a/Library/Config.php b/Library/Config.php index 0645df53ce..1d5fe9a99d 100644 --- a/Library/Config.php +++ b/Library/Config.php @@ -24,6 +24,7 @@ class Config implements \ArrayAccess, \JsonSerializable * @var bool */ protected $changed = false; + /** * Default configuration for project. * @@ -90,7 +91,7 @@ class Config implements \ArrayAccess, \JsonSerializable 'namespace' => '', 'name' => '', 'description' => '', - 'author' => '', + 'author' => 'Zephir Team', 'version' => '0.0.1', 'verbose' => false, 'requires' => [ @@ -108,7 +109,7 @@ public function __construct() $this->populate(); $this->changed = false; - $this->registerShutdownFunction(); + register_shutdown_function([$this, 'dumpToFile']); } /** @@ -327,14 +328,6 @@ public function jsonSerialize() return $this->container; } - /** - * Registers shutdown function. - */ - public function registerShutdownFunction() - { - register_shutdown_function([$this, 'dumpToFile']); - } - /** * Populate project configuration. * diff --git a/Library/Console/Command/BuildCommand.php b/Library/Console/Command/BuildCommand.php index d75b2549b8..116b0834c7 100644 --- a/Library/Console/Command/BuildCommand.php +++ b/Library/Console/Command/BuildCommand.php @@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; /** * Zephir\Console\Command\BuildCommand. @@ -41,6 +42,7 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $command = $this->getApplication()->find('install'); + $io = new SymfonyStyle($input, $output); $arguments = [ 'command' => 'install', @@ -50,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output) try { return $command->run(new ArrayInput($arguments), $output); } catch (\Exception $e) { - $output->writeln("{$e->getMessage()}"); + $io->getErrorStyle()->error($e->getMessage()); return 1; } diff --git a/Library/Console/Command/CleanCommand.php b/Library/Console/Command/CleanCommand.php index 93a41facca..a3aaa8bb4e 100644 --- a/Library/Console/Command/CleanCommand.php +++ b/Library/Console/Command/CleanCommand.php @@ -45,7 +45,6 @@ protected function configure() protected function execute(InputInterface $input, OutputInterface $output) { $this->filesystem->clean(); - $io = new SymfonyStyle($input, $output); try { @@ -57,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output) system('cd ext && make clean > /dev/null'); } } catch (FileSystemException $e) { - $io->error( + $io->getErrorStyle()->error( sprintf( "For reasons beyond Zephir's control, a filesystem error has occurred. ". 'Please note: On Linux/Unix systems the current user must have the delete and execute '. @@ -69,11 +68,11 @@ protected function execute(InputInterface $input, OutputInterface $output) return 1; } catch (\Exception $e) { - $io->error($e->getMessage()); + $io->getErrorStyle()->error($e->getMessage()); return 1; } catch (\Throwable $e) { - $io->error($e->getMessage()); + $io->getErrorStyle()->error($e->getMessage()); return 1; } diff --git a/Library/Console/Command/CompileCommand.php b/Library/Console/Command/CompileCommand.php index 0bd54b19fb..1dcba92e19 100644 --- a/Library/Console/Command/CompileCommand.php +++ b/Library/Console/Command/CompileCommand.php @@ -59,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->isDevelopmentModeEnabled($input) ); } catch (CompilerException $e) { - $io->error($e->getMessage()); + $io->getErrorStyle()->error($e->getMessage()); return 1; } diff --git a/Library/Console/Command/FullCleanCommand.php b/Library/Console/Command/FullCleanCommand.php index 36f0387f33..80c26b99c2 100644 --- a/Library/Console/Command/FullCleanCommand.php +++ b/Library/Console/Command/FullCleanCommand.php @@ -59,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output) } } } catch (FileSystemException $e) { - $io->error( + $io->getErrorStyle()->error( sprintf( "For reasons beyond Zephir's control, a filesystem error has occurred. ". 'Please note: On Linux/Unix systems the current user must have the delete and execute '. diff --git a/Library/Console/Command/GenerateCommand.php b/Library/Console/Command/GenerateCommand.php index 6874f4f2e4..54c2918603 100644 --- a/Library/Console/Command/GenerateCommand.php +++ b/Library/Console/Command/GenerateCommand.php @@ -17,6 +17,7 @@ use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Zephir\Compiler; +use Zephir\Exception; use Zephir\Exception\CompilerException; use Zephir\Exception\InvalidArgumentException; @@ -55,7 +56,7 @@ protected function execute(InputInterface $input, OutputInterface $output) // TODO: Move all the stuff from the compiler $this->compiler->generate(true); } catch (InvalidArgumentException $e) { - $io->error( + $io->getErrorStyle()->error( sprintf( 'Internal error: %s at %s:%d', $e->getMessage(), @@ -66,7 +67,11 @@ protected function execute(InputInterface $input, OutputInterface $output) return 1; } catch (CompilerException $e) { - $io->error($e->getMessage()); + $io->getErrorStyle()->error($e->getMessage()); + + return 1; + } catch (Exception $e) { + $io->getErrorStyle()->error($e->getMessage()); return 1; } diff --git a/Library/Console/Command/InitCommand.php b/Library/Console/Command/InitCommand.php index 62ce14ec5f..9f9c96176b 100644 --- a/Library/Console/Command/InitCommand.php +++ b/Library/Console/Command/InitCommand.php @@ -65,14 +65,11 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->config->set('namespace', $namespace); $this->config->set('name', $namespace); - if (!is_dir($namespace)) { - mkdir($namespace, 0755); + if (!is_dir("{$namespace}/{$namespace}")) { + mkdir("{$namespace}/{$namespace}", 0755, true); } chdir($namespace); - if (!is_dir($namespace)) { - mkdir($namespace, 0755); - } // Create 'kernel' if (!is_dir('ext/kernel')) { diff --git a/Library/Console/Command/InstallCommand.php b/Library/Console/Command/InstallCommand.php index 32223c1cdc..7e00a4e6a2 100644 --- a/Library/Console/Command/InstallCommand.php +++ b/Library/Console/Command/InstallCommand.php @@ -61,15 +61,15 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->isDevelopmentModeEnabled($input) ); } catch (NotImplementedException $e) { - $io->note($e->getMessage()); + $io->getErrorStyle()->note($e->getMessage()); return 0; } catch (CompilerException $e) { - $io->error($e->getMessage()); + $io->getErrorStyle()->error($e->getMessage()); return 1; } catch (Exception $e) { - $io->error($e->getMessage()); + $io->getErrorStyle()->error($e->getMessage()); return 1; } diff --git a/Library/Zephir.php b/Library/Zephir.php index f079cc9ecf..cb29a73a8c 100644 --- a/Library/Zephir.php +++ b/Library/Zephir.php @@ -16,9 +16,7 @@ */ final class Zephir { - const VERSION = '0.12.1-$Id$'; - - const RELEASE_DATE = '$release-date$'; + const VERSION = '0.12.2-$Id$'; const LOGO = <<<'ASCII' _____ __ _ diff --git a/appveyor.yml b/appveyor.yml index 5d03ef9d33..544c310136 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.12.1-{build} +version: 0.12.2-{build} environment: matrix: diff --git a/config.json b/config.json index 8e4e3c57bb..136fabc730 100644 --- a/config.json +++ b/config.json @@ -1,157 +1,167 @@ { - "namespace": "test", - "name": "Test Extension", - "description": "Description test forTest Extension.", - "author": "Zephir Team and contributors", - "version": "1.0.0", - "verbose": true, + "namespace": "test", + "name": "Test Extension", + "description": "Description test forTest Extension.", + "author": "Zephir Team and contributors", + "version": "1.0.0", + "verbose": true, - "stubs": { - "path": "ide\/%version%\/%namespace%\/", - "stubs-run-after-generate": false - }, + "requires": { + "extensions": [ + "PDO", + "SPL", + "standard", + "hash", + "json" + ] + }, - "api": { - "path" : "doc/%version%", - "theme" : { - "name":"zephir", - "options" :{ - "github":"https://github.com/user/repo", - "analytics":null, - "main_color": "#3E6496", - "link_color": "#3E6496", - "link_hover_color": "#5F9AE7" - } - } - }, + "stubs": { + "path": "ide\/%version%\/%namespace%\/", + "stubs-run-after-generate": false + }, - "warnings": { - "unused-variable": true, - "unused-variable-external": false, - "possible-wrong-parameter": true, - "possible-wrong-parameter-undefined": false, - "nonexistent-function": true, - "nonexistent-class": true, - "non-valid-isset": true, - "non-array-update": true, - "non-valid-objectupdate": true, - "non-valid-fetch": true, - "invalid-array-index": true, - "non-array-append": true, - "invalid-return-type": true, - "unreachable-code": true, - "nonexistent-constant": true, - "not-supported-magic-constant": true, - "non-valid-decrement": true, - "non-valid-increment": true, - "non-valid-clone": true, - "non-valid-new": true, - "non-array-access": true, - "invalid-reference": true, - "invalid-typeof-comparison": true, - "conditional-initialization": true - }, + "api": { + "path" : "doc/%version%", + "theme" : { + "name":"zephir", + "options" :{ + "github":"https://github.com/user/repo", + "analytics":null, + "main_color": "#3E6496", + "link_color": "#3E6496", + "link_hover_color": "#5F9AE7" + } + } + }, - "optimizations": { - "static-type-inference": true, - "static-type-inference-second-pass": true, - "local-context-pass": true, - "constant-folding": true, - "static-constant-class-folding": true, - "call-gatherer-pass": true, - "check-invalid-reads": false, - "private-internal-methods": false, - "public-internal-methods": false, - "public-internal-functions": true - }, + "warnings": { + "unused-variable": true, + "unused-variable-external": false, + "possible-wrong-parameter": true, + "possible-wrong-parameter-undefined": false, + "nonexistent-function": true, + "nonexistent-class": true, + "non-valid-isset": true, + "non-array-update": true, + "non-valid-objectupdate": true, + "non-valid-fetch": true, + "invalid-array-index": true, + "non-array-append": true, + "invalid-return-type": true, + "unreachable-code": true, + "nonexistent-constant": true, + "not-supported-magic-constant": true, + "non-valid-decrement": true, + "non-valid-increment": true, + "non-valid-clone": true, + "non-valid-new": true, + "non-array-access": true, + "invalid-reference": true, + "invalid-typeof-comparison": true, + "conditional-initialization": true + }, - "globals": { - "my_setting_1": { - "type": "bool", - "default": true, - "ini-entry": { - "name": "ini-entry.my_setting_1", - "scope": "PHP_INI_ALL" - } - }, - "test_setting_1": { - "type": "bool", - "default": true - }, - "my_setting_2": { - "type": "int", - "default": 10 - }, - "my_setting_3": { - "type": "double", - "default": 15.2 - }, - "my_setting_4": { - "type": "char", - "default": "A" - }, - "db.my_setting_1": { - "type": "bool", - "default": false - }, - "db.my_setting_2": { - "type": "int", - "default": 100 - }, - "db.my_setting_3": { - "type": "double", - "default": 7.5 - }, - "orm.cache_level": { - "type": "int", - "default": 3 - }, - "orm.cache_enable": { - "type": "bool", - "default": true - }, - "extension.test_ini_variable": { - "type": "bool", - "default": true, - "ini-entry": { - "name": "extension.test_ini_variable", - "scope": "PHP_INI_ALL" - } - } + "optimizations": { + "static-type-inference": true, + "static-type-inference-second-pass": true, + "local-context-pass": true, + "constant-folding": true, + "static-constant-class-folding": true, + "call-gatherer-pass": true, + "check-invalid-reads": false, + "private-internal-methods": false, + "public-internal-methods": false, + "public-internal-functions": true + }, + + "globals": { + "my_setting_1": { + "type": "bool", + "default": true, + "ini-entry": { + "name": "ini-entry.my_setting_1", + "scope": "PHP_INI_ALL" + } + }, + "test_setting_1": { + "type": "bool", + "default": true + }, + "my_setting_2": { + "type": "int", + "default": 10 + }, + "my_setting_3": { + "type": "double", + "default": 15.2 }, + "my_setting_4": { + "type": "char", + "default": "A" + }, + "db.my_setting_1": { + "type": "bool", + "default": false + }, + "db.my_setting_2": { + "type": "int", + "default": 100 + }, + "db.my_setting_3": { + "type": "double", + "default": 7.5 + }, + "orm.cache_level": { + "type": "int", + "default": 3 + }, + "orm.cache_enable": { + "type": "bool", + "default": true + }, + "extension.test_ini_variable": { + "type": "bool", + "default": true, + "ini-entry": { + "name": "extension.test_ini_variable", + "scope": "PHP_INI_ALL" + } + } + }, - "info": [ - { - "header": [ - "Test Extension support", - "Value" - ], - "rows": [ - [ - "Lifecycle hooks", - "PHP provides several lifecycle events, which extensions can use to perform common initialization or shutdown tasks." - ], - [ - "Static Analysis", - "Test extensions' compiler provides static analysis of the compiled code." - ] - ] - }, - { - "header": [ - "Test variable", - "Value" - ], - "rows": [ - [ - "Extension", - "Installed" - ], - [ - "NFR", - "Contributions are welcome!" - ] - ] - } - ] + "info": [ + { + "header": [ + "Test Extension support", + "Value" + ], + "rows": [ + [ + "Lifecycle hooks", + "PHP provides several lifecycle events, which extensions can use to perform common initialization or shutdown tasks." + ], + [ + "Static Analysis", + "Test extensions' compiler provides static analysis of the compiled code." + ] + ] + }, + { + "header": [ + "Test variable", + "Value" + ], + "rows": [ + [ + "Extension", + "Installed" + ], + [ + "NFR", + "Contributions are welcome!" + ] + ] + } + ] } diff --git a/ext/php_test.h b/ext/php_test.h index ca84bac924..f56b06d665 100644 --- a/ext/php_test.h +++ b/ext/php_test.h @@ -14,7 +14,7 @@ #define PHP_TEST_VERSION "1.0.0" #define PHP_TEST_EXTNAME "test" #define PHP_TEST_AUTHOR "Zephir Team and contributors" -#define PHP_TEST_ZEPVERSION "0.12.1-$Id$" +#define PHP_TEST_ZEPVERSION "0.12.2-$Id$" #define PHP_TEST_DESCRIPTION "Description test for
Test Extension." typedef struct _zephir_struct_db { diff --git a/ext/test.c b/ext/test.c index 862bc262fd..c5ff5316f9 100644 --- a/ext/test.c +++ b/ext/test.c @@ -581,10 +581,19 @@ ZEND_FE_END }; +static const zend_module_dep php_test_deps[] = { + ZEND_MOD_REQUIRED("pdo") + ZEND_MOD_REQUIRED("spl") + ZEND_MOD_REQUIRED("standard") + ZEND_MOD_REQUIRED("hash") + ZEND_MOD_REQUIRED("json") + ZEND_MOD_END +}; + zend_module_entry test_module_entry = { STANDARD_MODULE_HEADER_EX, NULL, - NULL, + php_test_deps, PHP_TEST_EXTNAME, php_test_functions, PHP_MINIT(test), diff --git a/phpcs.xml.dist b/phpcs.xml.dist index c3fd26d70c..b8a53d6645 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -1,7 +1,7 @@ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 242e18c383..add9fbd602 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,7 @@ + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +if (!function_exists('apache_child_terminate')) { + /** + * Terminate apache process after this request. + * + * @see https://www.php.net/manual/en/function.apache-child-terminate.php + * + * @return bool + */ + function apache_child_terminate() + { + } +} + +if (!function_exists('apache_get_modules')) { + /** + * Get a list of loaded Apache modules. + * + * @see https://www.php.net/manual/en/function.apache-get-modules.php + * + * @return array + */ + function apache_get_modules() + { + } +} + +if (!function_exists('apache_get_version')) { + /** + * Fetch Apache version. + * + * @see https://www.php.net/manual/en/function.apache-get-version.php + * + * @return string + */ + function apache_get_version() + { + } +} + +if (!function_exists('apache_getenv')) { + /** + * Get an Apache subprocess_env variable. + * + * @see https://www.php.net/manual/en/function.apache-getenv.php + * + * @param string $variable + * @param bool $walk_to_top + * + * @return string + */ + function apache_getenv($variable, $walk_to_top = false) + { + } +} + +if (!function_exists('apache_lookup_uri')) { + /** + * Perform a partial request for the specified URI and return all info about it. + * + * @see https://www.php.net/manual/en/function.apache-lookup-uri.php + * + * @param string $filename + * + * @return object + */ + function apache_lookup_uri($filename) + { + } +} + +if (!function_exists('apache_note')) { + /** + * Get and set apache request notes. + * + * @see https://www.php.net/manual/en/function.apache-note.php + * + * @param string $note_name + * @param string $note_value + * + * @return object + */ + function apache_note($note_name, $note_value = '') + { + } +} + +if (!function_exists('apache_request_headers')) { + /** + * Fetch all HTTP request headers. + * + * @see https://www.php.net/manual/en/function.apache-request-headers.php + * + * @return array|bool + */ + function apache_request_headers() + { + } +} + +if (!function_exists('apache_reset_timeout')) { + /** + * Reset the Apache write timer. + * + * @see https://www.php.net/manual/en/function.apache-reset-timeout.php + * + * @return bool + */ + function apache_reset_timeout() + { + } +} + +if (!function_exists('apache_response_headers')) { + /** + * Fetch all HTTP response headers. + * + * @see https://www.php.net/manual/en/function.apache-response-headers.php + * + * @return array|bool + */ + function apache_response_headers() + { + } +} + +if (!function_exists('apache_setenv')) { + /** + * Set an Apache subprocess_env variable. + * + * @see https://www.php.net/manual/en/function.apache-setenv.php + * + * @param string $variable + * @param string $value + * @param bool $walk_to_top + * + * @return bool + */ + function apache_setenv($variable, $value, $walk_to_top = false) + { + } +} + +if (!function_exists('getallheaders')) { + /** + * Fetch all HTTP request headers. + * + * @see https://www.php.net/manual/en/function.getallheaders.php + * + * @return array|bool + */ + function getallheaders() + { + } +} + +if (!function_exists('virtual')) { + /** + * Perform an Apache sub-request. + * + * @see https://www.php.net/manual/en/function.virtual.php + * + * @param string $filename + * + * @return bool + */ + function virtual($filename) + { + } +} diff --git a/prototypes/gd.php b/prototypes/gd.php index ae13318432..55ba59b8df 100644 --- a/prototypes/gd.php +++ b/prototypes/gd.php @@ -5,500 +5,632 @@ * * (c) Zephir Team * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -if (function_exists('gd_info')) { - return false; + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +if (!function_exists('gd_info')) { + /** + * Retrieve information about the currently installed GD library. + * + * @see http://www.php.net/manual/en/function.gd-info.php + * + * @return array + */ + function gd_info() + { + } } -/** - * Function was prototyped by docs. - * - * @see http://www.php.net/manual/ru/ref.image.php - */ - -/** - * @see http://www.php.net/manual/ru/function.gd-info.php - */ -function gd_info() -{ +if (!function_exists('getimagesize')) { + /** + * Get the size of an image. + * + * @see https://www.php.net/manual/en/function.getimagesize.php + * + * @param string $filename + * @param array $imageinfo + * + * @return array + */ + function getimagesize($filename, array &$imageinfo) + { + } } -/** - * @see http://www.php.net/manual/ru/function.getimagesize.php - * - * @param string $filename - * @param array $imageinfo - * @param mixed $image - * @param mixed $threshold - */ -//function getimagesize($filename, array &$imageinfo) {} - -/** - * @see http://www.php.net/manual/ru/function.getimagesizefromstring.php - * - * @param string $imagedata - * @param array $imageinfo - */ -//function getimagesizefromstring($imagedata, array &$imageinfo) {} +if (!function_exists('getimagesizefromstring')) { + /** + * Get the size of an image from a string. + * + * @see https://www.php.net/manual/en/function.getimagesizefromstring.php + * + * @param string $imagedata + * @param array $imageinfo + * + * @return array + */ + function getimagesizefromstring($imagedata, array &$imageinfo) + { + } +} -/** - * @see http://www.php.net/manual/ru/function.image-type-to-extension.php - * - * @param $imagetype - * @param bool $include_dot - */ -//function image_type_to_extension($imagetype, $include_dot = true) {} +if (!function_exists('image_type_to_extension')) { + /** + * Get file extension for image type. + * + * @see https://www.php.net/manual/en/function.image-type-to-extension.php + * + * @param $imagetype + * @param bool $include_dot + * + * @return string + */ + function image_type_to_extension($imagetype, $include_dot = true) + { + } +} -/** - * @see http://www.php.net/manual/ru/function.image-type-to-mime-type.php - * - * @param int $imagetype - * - * @return string - */ -//function image_type_to_mime_type($imagetype) {} +if (!function_exists('image_type_to_mime_type')) { + /** + * Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype. + * + * @see https://www.php.net/manual/en/function.image-type-to-mime-type.php + * + * @param int $imagetype + * + * @return string + */ + function image_type_to_mime_type($imagetype) + { + } +} -/** - * @see http://www.php.net/manual/ru/function.image2wbmp.php - * - * @param resource $image - * @param string $filename - * @param int $threshold - * - * @return bool - */ -function image2wbmp($image, $filename, $threshold) -{ +if (!function_exists('image2wbmp') && PHP_VERSION_ID < 70400) { + /** + * Output image to browser or file. + * + * @see https://www.php.net/manual/en/function.image2wbmp.php + * + * @param resource $image + * @param string $filename + * @param int $threshold + * + * @return bool + */ + function image2wbmp($image, $filename, $threshold) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imageaffine.php - * - * @param $image - * @param array $affline - * @param array $clip - */ -function imageaffine($image, array $affline, array $clip) -{ +if (!function_exists('imageaffine')) { + /** + * Return an image containing the affine transformed src image, using an optional clipping area. + * + * @see https://www.php.net/manual/en/function.imageaffine.php + * + * @param resource $image + * @param array $affline + * @param array $clip + * + * @return resource|bool + */ + function imageaffine($image, array $affline, array $clip = []) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imageaffinematrixconcat.php - * - * @param array $m1 - * @param array $m2 - * - * @return array - */ -function imageaffinematrixconcat(array $m1, array $m2) -{ +if (!function_exists('imageaffinematrixconcat')) { + /** + * Concatenate two affine transformation matrices. + * + * @see https://www.php.net/manual/en/function.imageaffinematrixconcat.php + * + * @param array $m1 + * @param array $m2 + * + * @return array|bool + */ + function imageaffinematrixconcat(array $m1, array $m2) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imageaffinematrixget.php - * - * @param int $type - * @param mixed $options - * - * @return array - */ -function imageaffinematrixget($type, $options) -{ +if (!function_exists('imageaffinematrixget')) { + /** + * Get an affine transformation matrix. + * + * @see https://www.php.net/manual/en/function.imageaffinematrixget.php + * + * @param int $type + * @param mixed $options + * + * @return array|bool + */ + function imageaffinematrixget($type, $options) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagealphablending.php - * - * @param resource $image - * @param bool $blendmode - * - * @return bool - */ -function imagealphablending($image, $blendmode) -{ +if (!function_exists('imagealphablending')) { + /** + * Set the blending mode for an image. + * + * @see https://www.php.net/manual/en/function.imagealphablending.php + * + * @param resource $image + * @param bool $blendmode + * + * @return bool + */ + function imagealphablending($image, $blendmode) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imageantialias.php - * - * @param resource $image - * @param bool $enabled - * - * @return bool - */ -function imageantialias($image, $enabled) -{ +if (!function_exists('imageantialias')) { + /** + * Should antialias functions be used or not. + * + * @see https://www.php.net/manual/en/function.imageantialias.php + * + * @param resource $image + * @param bool $enabled + * + * @return bool + */ + function imageantialias($image, $enabled) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagearc.php - * - * @param resource $image - * @param int $cx - * @param int $cy - * @param int $width - * @param int $height - * @param int $start - * @param int $end - * @param int $color - * - * @return bool - */ -function imagearc($image, $cx, $cy, $width, $height, $start, $end, $color) -{ +if (!function_exists('imagearc')) { + /** + * Draws an arc. + * + * @see http://www.php.net/manual/ru/function.imagearc.php + * + * @param resource $image + * @param int $cx + * @param int $cy + * @param int $width + * @param int $height + * @param int $start + * @param int $end + * @param int $color + * + * @return bool + */ + function imagearc($image, $cx, $cy, $width, $height, $start, $end, $color) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagechar.php - * - * @param resource $image - * @param int $font - * @param int $x - * @param int $y - * @param string $c - * @param int $color - * - * @return bool - */ -function imagechar($image, $font, $x, $y, $c, $color) -{ +if (!function_exists('imagechar')) { + /** + * Draw a character horizontally. + * + * @see https://www.php.net/manual/en/function.imagechar.php + * + * @param resource $image + * @param int $font + * @param int $x + * @param int $y + * @param string $c + * @param int $color + * + * @return bool + */ + function imagechar($image, $font, $x, $y, $c, $color) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecharup.php - * - * @param resource $image - * @param int $font - * @param int $x - * @param int $y - * @param string $c - * @param int $color - * - * @return bool - */ -function imagecharup($image, $font, $x, $y, $c, $color) -{ +if (!function_exists('imagecharup')) { + /** + * Draw a character vertically. + * + * @see https://www.php.net/manual/en/function.imagecharup.php + * + * @param resource $image + * @param int $font + * @param int $x + * @param int $y + * @param string $c + * @param int $color + * + * @return bool + */ + function imagecharup($image, $font, $x, $y, $c, $color) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorallocate.php - * - * @param resource $image - * @param int $red - * @param int $green - * @param int $blue - * - * @return int - */ -function imagecolorallocate($image, $red, $green, $blue) -{ +if (!function_exists('imagecolorallocate')) { + /** + * Allocate a color for an image. + * + * @see https://www.php.net/manual/en/function.imagecolorallocate.php + * + * @param resource $image + * @param int $red + * @param int $green + * @param int $blue + * + * @return int|bool + */ + function imagecolorallocate($image, $red, $green, $blue) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorallocatealpha.php - * - * @param resource $image - * @param int $red - * @param int $green - * @param int $blue - * @param int $alpha - * - * @return int - */ -function imagecolorallocatealpha($image, $red, $green, $blue, $alpha) -{ +if (!function_exists('imagecolorallocatealpha')) { + /** + * Allocate a color for an image. + * + * @see https://www.php.net/manual/en/function.imagecolorallocatealpha.php + * + * @param resource $image + * @param int $red + * @param int $green + * @param int $blue + * @param int $alpha + * + * @return int|bool + */ + function imagecolorallocatealpha($image, $red, $green, $blue, $alpha) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorat.php - * - * @param resource $image - * @param int $x - * @param int $y - * - * @return int - */ -function imagecolorat($image, $x, $y) -{ +if (!function_exists('imagecolorat')) { + /** + * Get the index of the color of a pixel. + * + * @see https://www.php.net/manual/en/function.imagecolorat.php + * + * @param resource $image + * @param int $x + * @param int $y + * + * @return int|false + */ + function imagecolorat($image, $x, $y) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorclosest.php - * - * @param resource $image - * @param int $red - * @param int $green - * @param int $blue - * - * @return int - */ -function imagecolorclosest($image, $red, $green, $blue) -{ +if (!function_exists('imagecolorclosest')) { + /** + * Get the index of the closest color to the specified color. + * + * @see https://www.php.net/manual/en/function.imagecolorclosest.php + * + * @param resource $image + * @param int $red + * @param int $green + * @param int $blue + * + * @return int + */ + function imagecolorclosest($image, $red, $green, $blue) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorclosestalpha.php - * - * @param resource $image - * @param int $red - * @param int $green - * @param int $blue - * @param int $alpha - * - * @return int - */ -function imagecolorclosestalpha($image, $red, $green, $blue, $alpha) -{ +if (!function_exists('imagecolorclosestalpha')) { + /** + * Get the index of the closest color to the specified color + alpha. + * + * @see https://www.php.net/manual/en/function.imagecolorclosestalpha.php + * + * @param resource $image + * @param int $red + * @param int $green + * @param int $blue + * @param int $alpha + * + * @return int + */ + function imagecolorclosestalpha($image, $red, $green, $blue, $alpha) + { + } } -/** - * @param resource $image - * @param int $red - * @param int $green - * @param int $blue - * - * @return int - */ -function imagecolorclosesthwb($image, $red, $green, $blue) -{ +if (!function_exists('imagecolorclosesthwb')) { + /** + * Get the index of the color which has the hue, white and blackness. + * + * @see https://www.php.net/manual/en/function.imagecolorclosesthwb.php + * + * @param resource $image + * @param int $red + * @param int $green + * @param int $blue + * + * @return int + */ + function imagecolorclosesthwb($image, $red, $green, $blue) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolordeallocate.php - * - * @param resource $image - * @param int $color - * - * @return bool - */ -function imagecolordeallocate($image, $color) -{ +if (!function_exists('imagecolordeallocate')) { + /** + * De-allocate a color for an image. + * + * @see https://www.php.net/manual/en/function.imagecolordeallocate.php + * + * @param resource $image + * @param int $color + * + * @return bool + */ + function imagecolordeallocate($image, $color) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorexact.php - * - * @param resource $image - * @param int $red - * @param int $green - * @param int $blue - * - * @return int - */ -function imagecolorexact($image, $red, $green, $blue) -{ +if (!function_exists('imagecolorexact')) { + /** + * Get the index of the specified color. + * + * @see http://www.php.net/manual/ru/function.imagecolorexact.php + * + * @param resource $image + * @param int $red + * @param int $green + * @param int $blue + * + * @return int + */ + function imagecolorexact($image, $red, $green, $blue) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorexactalpha.php - * - * @param resource $image - * @param int $red - * @param int $green - * @param int $blue - * @param int $alpha - * - * @return int - */ -function imagecolorexactalpha($image, $red, $green, $blue, $alpha) -{ +if (!function_exists('imagecolorexactalpha')) { + /** + * Get the index of the specified color + alpha. + * + * @see https://www.php.net/manual/en/function.imagecolorexactalpha.php + * + * @param resource $image + * @param int $red + * @param int $green + * @param int $blue + * @param int $alpha + * + * @return int + */ + function imagecolorexactalpha($image, $red, $green, $blue, $alpha) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolormatch.php - * - * @param resource $image1 - * @param resource $image2 - * - * @return bool - */ -function imagecolormatch($image1, $image2) -{ +if (!function_exists('imagecolormatch')) { + /** + * Makes the colors of the palette version of an image more closely match the true color version. + * + * @see http://www.php.net/manual/ru/function.imagecolormatch.php + * + * @param resource $image1 + * @param resource $image2 + * + * @return bool + */ + function imagecolormatch($image1, $image2) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorresolve.php - * - * @param resource $image - * @param int $red - * @param int $green - * @param int $blue - * - * @return int - */ -function imagecolorresolve($image, $red, $green, $blue) -{ +if (!function_exists('imagecolorresolve')) { + /** + * Get the index of the specified color or its closest possible alternative. + * + * @see http://www.php.net/manual/ru/function.imagecolorresolve.php + * + * @param resource $image + * @param int $red + * @param int $green + * @param int $blue + * + * @return int + */ + function imagecolorresolve($image, $red, $green, $blue) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorresolvealpha.php - * - * @param resource $image - * @param int $red - * @param int $green - * @param int $blue - * @param int $alpha - * - * @return int - */ -function imagecolorresolvealpha($image, $red, $green, $blue, $alpha) -{ +if (!function_exists('imagecolorresolvealpha')) { + /** + * Get the index of the specified color + alpha or its closest possible alternative. + * + * @see https://www.php.net/manual/en/function.imagecolorresolvealpha.php + * + * @param resource $image + * @param int $red + * @param int $green + * @param int $blue + * @param int $alpha + * + * @return int + */ + function imagecolorresolvealpha($image, $red, $green, $blue, $alpha) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorset.php - * - * @param resource $image - * @param int $index - * @param int $red - * @param int $green - * @param int $blue - * @param int $alpha - */ -function imagecolorset($image, $index, $red, $green, $blue, $alpha = 0) -{ +if (!function_exists('imagecolorset')) { + /** + * Set the color for the specified palette index. + * + * @see https://www.php.net/manual/en/function.imagecolorset.php + * + * @param resource $image + * @param int $index + * @param int $red + * @param int $green + * @param int $blue + * @param int $alpha + */ + function imagecolorset($image, $index, $red, $green, $blue, $alpha = 0) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecolorsforindex.php - * - * @param resource $image - * @param int $index - * - * @return array - */ -function imagecolorsforindex($image, $index) -{ +if (!function_exists('imagecolorsforindex')) { + /** + * Get the colors for an index. + * + * @see https://www.php.net/manual/en/function.imagecolorsforindex.php + * + * @param resource $image + * @param int $index + * + * @return array + */ + function imagecolorsforindex($image, $index) + { + } } -/** - * @see http://www.php.net/manual/ru/function.imagecreate.php - * - * @param $width - * @param $height - * - * @return resource - */ -function imagecreate($width, $height) -{ +if (!function_exists('imagecreate')) { + /** + * Create a new palette based image. + * + * @see https://www.php.net/manual/en/function.imagecreate.php + * + * @param $width + * @param $height + * + * @return resource|bool + */ + function imagecreate($width, $height) + { + } } -/** - * http://php.net/manual/en/function.imagettfbbox.php. - * - * @param float $size - * @param float $angle - * @param string $fontfile - * @param string $text - * - * @return array|bool - */ -function imagettfbbox($size, $angle, $fontfile, $text) -{ +if (!function_exists('imagettfbbox')) { + /** + * Give the bounding box of a text using TrueType fonts. + * + * @see https://www.php.net/manual/en/function.imagettfbbox.php + * + * @param float $size + * @param float $angle + * @param string $fontfile + * @param string $text + * + * @return array|bool + */ + function imagettfbbox($size, $angle, $fontfile, $text) + { + } } -/** - * @see http://php.net/manual/en/function.imagettftext.php - * - * @param resource $image - * @param float $size - * @param float $angle - * @param int $x - * @param int $y - * @param int $color - * @param string $fontfile - * @param string $text - * - * @return array|bool - */ -function imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text) -{ +if (!function_exists('imagettftext')) { + /** + * Write text to the image using TrueType fonts. + * + * @see https://www.php.net/manual/en/function.imagettftext.php + * + * @param resource $image + * @param float $size + * @param float $angle + * @param int $x + * @param int $y + * @param int $color + * @param string $fontfile + * @param string $text + * + * @return array|bool + */ + function imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $text) + { + } } /* - * @link http://php.net/manual/en/image.constants.php - */ -define('IMG_GIF', 1); -define('IMG_JPG', 2); -define('IMG_JPEG', 2); -define('IMG_PNG', 4); -define('IMG_WBMP', 8); -define('IMG_XPM', 16); -define('IMG_COLOR_TILED', -5); -define('IMG_COLOR_STYLED', -2); -define('IMG_COLOR_BRUSHED', -3); -define('IMG_COLOR_STYLEDBRUSHED', -4); -define('IMG_COLOR_TRANSPARENT', -6); -define('IMG_ARC_ROUNDED', 0); -define('IMG_ARC_PIE', 0); -define('IMG_ARC_CHORD', 1); -define('IMG_ARC_NOFILL', 2); -define('IMG_ARC_EDGED', 4); -define('IMG_GD2_RAW', 1); -define('IMG_GD2_COMPRESSED', 2); -define('IMG_EFFECT_REPLACE', 0); -define('IMG_EFFECT_ALPHABLEND', 1); -define('IMG_EFFECT_NORMAL', 2); -define('IMG_EFFECT_OVERLAY', 3); -define('GD_BUNDLED', 1); -define('IMG_FILTER_NEGATE', 0); -define('IMG_FILTER_GRAYSCALE', 1); -define('IMG_FILTER_BRIGHTNESS', 2); -define('IMG_FILTER_CONTRAST', 3); -define('IMG_FILTER_COLORIZE', 4); -define('IMG_FILTER_EDGEDETECT', 5); -define('IMG_FILTER_GAUSSIAN_BLUR', 7); -define('IMG_FILTER_SELECTIVE_BLUR', 8); -define('IMG_FILTER_EMBOSS', 6); -define('IMG_FILTER_MEAN_REMOVAL', 9); -define('IMG_FILTER_SMOOTH', 10); -define('IMG_FILTER_PIXELATE', 11); -define('GD_VERSION', '2.0.35'); -define('GD_MAJOR_VERSION', 2); -define('GD_MINOR_VERSION', 0); -define('GD_RELEASE_VERSION', 35); -define('GD_EXTRA_VERSION', ''); -define('PNG_NO_FILTER', 0); -define('PNG_FILTER_NONE', 8); -define('PNG_FILTER_SUB', 16); -define('PNG_FILTER_UP', 32); -define('PNG_FILTER_AVG', 64); -define('PNG_FILTER_PAETH', 128); -define('PNG_ALL_FILTERS', 248); -define('IMG_AFFINE_TRANSLATE', 0); -define('IMG_AFFINE_SCALE', 1); -define('IMG_AFFINE_ROTATE', 2); -define('IMG_AFFINE_SHEAR_HORIZONTAL', 3); -define('IMG_AFFINE_SHEAR_VERTICAL', 4); -define('IMG_CROP_DEFAULT', 0); -define('IMG_CROP_TRANSPARENT', 1); -define('IMG_CROP_BLACK', 2); -define('IMG_CROP_WHITE', 3); -define('IMG_CROP_SIDES', 4); -define('IMG_FLIP_BOTH', 3); -define('IMG_FLIP_HORIZONTAL', 1); -define('IMG_FLIP_VERTICAL', 2); -define('IMG_BELL', 1); -define('IMG_BESSEL', 2); -define('IMG_BICUBIC', 4); -define('IMG_BICUBIC_FIXED', 5); -define('IMG_BILINEAR_FIXED', 3); -define('IMG_BLACKMAN', 6); -define('IMG_BOX', 7); -define('IMG_BSPLINE', 8); -define('IMG_CATMULLROM', 9); -define('IMG_GAUSSIAN', 10); -define('IMG_GENERALIZED_CUBIC', 11); -define('IMG_HERMITE', 12); -define('IMG_HAMMING', 13); -define('IMG_HANNING', 14); -define('IMG_MITCHELL', 15); -define('IMG_POWER', 17); -define('IMG_QUADRATIC', 18); -define('IMG_SINC', 19); -define('IMG_NEAREST_NEIGHBOUR', 16); -define('IMG_WEIGHTED4', 21); -define('IMG_TRIANGLE', 20); + * @link https://www.php.net/manual/en/image.constants.php + */ +defined('IMG_GIF') || define('IMG_GIF', 1); +defined('IMG_JPG') || define('IMG_JPG', 2); +defined('IMG_JPEG') || define('IMG_JPEG', 2); +defined('IMG_PNG') || define('IMG_PNG', 4); +defined('IMG_WBMP') || define('IMG_WBMP', 8); +defined('IMG_XPM') || define('IMG_XPM', 16); +defined('IMG_COLOR_TILED') || define('IMG_COLOR_TILED', -5); +defined('IMG_COLOR_STYLED') || define('IMG_COLOR_STYLED', -2); +defined('IMG_COLOR_BRUSHED') || define('IMG_COLOR_BRUSHED', -3); +defined('IMG_COLOR_STYLEDBRUSHED') || define('IMG_COLOR_STYLEDBRUSHED', -4); +defined('IMG_COLOR_TRANSPARENT') || define('IMG_COLOR_TRANSPARENT', -6); +defined('IMG_ARC_ROUNDED') || define('IMG_ARC_ROUNDED', 0); +defined('IMG_ARC_PIE') || define('IMG_ARC_PIE', 0); +defined('IMG_ARC_CHORD') || define('IMG_ARC_CHORD', 1); +defined('IMG_ARC_NOFILL') || define('IMG_ARC_NOFILL', 2); +defined('IMG_ARC_EDGED') || define('IMG_ARC_EDGED', 4); +defined('IMG_GD2_RAW') || define('IMG_GD2_RAW', 1); +defined('IMG_GD2_COMPRESSED') || define('IMG_GD2_COMPRESSED', 2); +defined('IMG_EFFECT_REPLACE') || define('IMG_EFFECT_REPLACE', 0); +defined('IMG_EFFECT_ALPHABLEND') || define('IMG_EFFECT_ALPHABLEND', 1); +defined('IMG_EFFECT_NORMAL') || define('IMG_EFFECT_NORMAL', 2); +defined('IMG_EFFECT_OVERLAY') || define('IMG_EFFECT_OVERLAY', 3); +defined('GD_BUNDLED') || define('GD_BUNDLED', 1); +defined('IMG_FILTER_NEGATE') || define('IMG_FILTER_NEGATE', 0); +defined('IMG_FILTER_GRAYSCALE') || define('IMG_FILTER_GRAYSCALE', 1); +defined('IMG_FILTER_BRIGHTNESS') || define('IMG_FILTER_BRIGHTNESS', 2); +defined('IMG_FILTER_CONTRAST') || define('IMG_FILTER_CONTRAST', 3); +defined('IMG_FILTER_COLORIZE') || define('IMG_FILTER_COLORIZE', 4); +defined('IMG_FILTER_EDGEDETECT') || define('IMG_FILTER_EDGEDETECT', 5); +defined('IMG_FILTER_GAUSSIAN_BLUR') || define('IMG_FILTER_GAUSSIAN_BLUR', 7); +defined('IMG_FILTER_SELECTIVE_BLUR') || define('IMG_FILTER_SELECTIVE_BLUR', 8); +defined('IMG_FILTER_EMBOSS') || define('IMG_FILTER_EMBOSS', 6); +defined('IMG_FILTER_MEAN_REMOVAL') || define('IMG_FILTER_MEAN_REMOVAL', 9); +defined('IMG_FILTER_SMOOTH') || define('IMG_FILTER_SMOOTH', 10); +defined('IMG_FILTER_PIXELATE') || define('IMG_FILTER_PIXELATE', 11); +defined('GD_VERSION') || define('GD_VERSION', '2.0.35'); +defined('GD_MAJOR_VERSION') || define('GD_MAJOR_VERSION', 2); +defined('GD_MINOR_VERSION') || define('GD_MINOR_VERSION', 0); +defined('GD_RELEASE_VERSION') || define('GD_RELEASE_VERSION', 35); +defined('GD_EXTRA_VERSION') || define('GD_EXTRA_VERSION', ''); +defined('PNG_NO_FILTER') || define('PNG_NO_FILTER', 0); +defined('PNG_FILTER_NONE') || define('PNG_FILTER_NONE', 8); +defined('PNG_FILTER_SUB') || define('PNG_FILTER_SUB', 16); +defined('PNG_FILTER_UP') || define('PNG_FILTER_UP', 32); +defined('PNG_FILTER_AVG') || define('PNG_FILTER_AVG', 64); +defined('PNG_FILTER_PAETH') || define('PNG_FILTER_PAETH', 128); +defined('PNG_ALL_FILTERS') || define('PNG_ALL_FILTERS', 248); +defined('IMG_AFFINE_TRANSLATE') || define('IMG_AFFINE_TRANSLATE', 0); +defined('IMG_AFFINE_SCALE') || define('IMG_AFFINE_SCALE', 1); +defined('IMG_AFFINE_ROTATE') || define('IMG_AFFINE_ROTATE', 2); +defined('IMG_AFFINE_SHEAR_HORIZONTAL') || define('IMG_AFFINE_SHEAR_HORIZONTAL', 3); +defined('IMG_AFFINE_SHEAR_VERTICAL') || define('IMG_AFFINE_SHEAR_VERTICAL', 4); +defined('IMG_CROP_DEFAULT') || define('IMG_CROP_DEFAULT', 0); +defined('IMG_CROP_TRANSPARENT') || define('IMG_CROP_TRANSPARENT', 1); +defined('IMG_CROP_BLACK') || define('IMG_CROP_BLACK', 2); +defined('IMG_CROP_WHITE') || define('IMG_CROP_WHITE', 3); +defined('IMG_CROP_SIDES') || define('IMG_CROP_SIDES', 4); +defined('IMG_FLIP_BOTH') || define('IMG_FLIP_BOTH', 3); +defined('IMG_FLIP_HORIZONTAL') || define('IMG_FLIP_HORIZONTAL', 1); +defined('IMG_FLIP_VERTICAL') || define('IMG_FLIP_VERTICAL', 2); +defined('IMG_BELL') || define('IMG_BELL', 1); +defined('IMG_BESSEL') || define('IMG_BESSEL', 2); +defined('IMG_BICUBIC') || define('IMG_BICUBIC', 4); +defined('IMG_BICUBIC_FIXED') || define('IMG_BICUBIC_FIXED', 5); +defined('IMG_BILINEAR_FIXED') || define('IMG_BILINEAR_FIXED', 3); +defined('IMG_BLACKMAN') || define('IMG_BLACKMAN', 6); +defined('IMG_BOX') || define('IMG_BOX', 7); +defined('IMG_BSPLINE') || define('IMG_BSPLINE', 8); +defined('IMG_CATMULLROM') || define('IMG_CATMULLROM', 9); +defined('IMG_GAUSSIAN') || define('IMG_GAUSSIAN', 10); +defined('IMG_GENERALIZED_CUBIC') || define('IMG_GENERALIZED_CUBIC', 11); +defined('IMG_HERMITE') || define('IMG_HERMITE', 12); +defined('IMG_HAMMING') || define('IMG_HAMMING', 13); +defined('IMG_HANNING') || define('IMG_HANNING', 14); +defined('IMG_MITCHELL') || define('IMG_MITCHELL', 15); +defined('IMG_POWER') || define('IMG_POWER', 17); +defined('IMG_QUADRATIC') || define('IMG_QUADRATIC', 18); +defined('IMG_SINC') || define('IMG_SINC', 19); +defined('IMG_NEAREST_NEIGHBOUR') || define('IMG_NEAREST_NEIGHBOUR', 16); +defined('IMG_WEIGHTED4') || define('IMG_WEIGHTED4', 21); +defined('IMG_TRIANGLE') || define('IMG_TRIANGLE', 20); diff --git a/prototypes/manage.php b/prototypes/manage.php deleted file mode 100644 index 76cd54046a..0000000000 --- a/prototypes/manage.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace MongoDB\Driver; - -class manage -{ - public function __construct($uri, $options, $driverOptions) - { - } - - public function executeQuery($namespace, $query, $readPreference) - { - } - - public function executeBulkWrite($namespace, $bulk, $writeConcern) - { - } - - public function executeCommand($db, $command, $readPreference) - { - } - - public function getServers() - { - } - - public function selectServer($readPreference) - { - } -} diff --git a/prototypes/mongo.php b/prototypes/mongo.php index 51fe2cf372..af15830f58 100644 --- a/prototypes/mongo.php +++ b/prototypes/mongo.php @@ -5,63 +5,74 @@ * * (c) Zephir Team * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. */ -class MongoClient -{ - const VERSION = ''; - const DEFAULT_HOST = 'localhost'; - const DEFAULT_PORT = 27017; - const RP_PRIMARY = 'primary'; - const RP_PRIMARY_PREFERRED = 'primaryPreferred'; - const RP_SECONDARY = 'secondary'; - const RP_SECONDARY_PREFERRED = 'secondaryPreferred'; - const RP_NEAREST = 'nearest'; +namespace { + if (!class_exists('MongoRegex', false)) { + class MongoRegex + { + } + } - /** - * @see http://www.php.net/manual/en/mongoclient.selectdb.php - * - * @param string $name - * - * @return MongoDB - */ - public function selectDB($name) - { - return new MongoDB($this, $name); + if (!class_exists('MongoDate', false)) { + class MongoDate + { + } } -} -class MongoDate -{ -} + if (!class_exists('MongoId', false)) { + class MongoId + { + } + } -class MongoDB -{ - const PROFILING_OFF = 0; - const PROFILING_SLOW = 1; - const PROFILING_ON = 2; + if (!class_exists('MongoDB', false)) { + class MongoDB + { + const PROFILING_OFF = 0; + const PROFILING_SLOW = 1; + const PROFILING_ON = 2; - /** - * @see http://www.php.net/manual/en/mongodb.construct.php - * - * @param MongoClient $conn - * @param string $name - */ - public function __construct(MongoClient $conn, $name) - { + /** + * Creates a new database. + * + * @see https://www.php.net/manual/en/mongodb.construct.php + * + * @param MongoClient $conn + * @param string $name + */ + public function __construct(MongoClient $conn, $name) + { + } + } } -} -class Mongo extends MongoClient -{ -} - -class MongoId -{ -} + if (!class_exists('MongoClient', false)) { + class MongoClient + { + const VERSION = ''; + const DEFAULT_HOST = 'localhost'; + const DEFAULT_PORT = 27017; + const RP_PRIMARY = 'primary'; + const RP_PRIMARY_PREFERRED = 'primaryPreferred'; + const RP_SECONDARY = 'secondary'; + const RP_SECONDARY_PREFERRED = 'secondaryPreferred'; + const RP_NEAREST = 'nearest'; -class MongoRegex -{ + /** + * Gets a database. + * + * @see https://www.php.net/manual/en/mongoclient.selectdb.php + * + * @param string $name + * + * @return MongoDB + */ + public function selectDB($name) + { + } + } + } } diff --git a/prototypes/mongodb.php b/prototypes/mongodb.php new file mode 100644 index 0000000000..dea3a25171 --- /dev/null +++ b/prototypes/mongodb.php @@ -0,0 +1,71 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace MongoDB\Driver { + if (!class_exists('MongoDB\Driver\Manager', false)) { + class mongodb + { + public function __construct($uri = 'mongodb://127.0.0.1/', array $options = [], array $driverOptions = []) + { + } + + public function executeQuery($namespace, $query, $readPreference) + { + } + + public function executeBulkWrite($namespace, $bulk, $writeConcern) + { + } + + public function executeCommand($db, $command, $readPreference) + { + } + + public function getServers() + { + } + + public function selectServer($readPreference) + { + } + + public function executeReadCommand($db, $command, array $options = []) + { + } + + public function executeReadWriteCommand($db, $command, array $options = []) + { + } + + public function executeWriteCommand($db, $command, array $options = []) + { + } + + public function getReadConcern() + { + } + + public function getReadPreference() + { + } + + public function getWriteConcern() + { + } + + public function startSession(array $options = []) + { + } + } + } +} diff --git a/templates/ZendEngine3/project.c b/templates/ZendEngine3/project.c index bc8b2a0ef2..098fef5b0d 100644 --- a/templates/ZendEngine3/project.c +++ b/templates/ZendEngine3/project.c @@ -134,10 +134,15 @@ zend_function_entry php_%PROJECT_LOWER_SAFE%_functions[] = { %FE_ENTRIES% }; +static const zend_module_dep php_%PROJECT_LOWER_SAFE%_deps[] = { + %PROJECT_DEPENDENCIES% + ZEND_MOD_END +}; + zend_module_entry %PROJECT_LOWER_SAFE%_module_entry = { STANDARD_MODULE_HEADER_EX, NULL, - NULL, + php_%PROJECT_LOWER_SAFE%_deps, PHP_%PROJECT_UPPER%_EXTNAME, php_%PROJECT_LOWER_SAFE%_functions, PHP_MINIT(%PROJECT_LOWER%), diff --git a/unit-tests/fixtures/deps/config.json b/unit-tests/fixtures/deps/config.json new file mode 100644 index 0000000000..0bf29c2f3e --- /dev/null +++ b/unit-tests/fixtures/deps/config.json @@ -0,0 +1,14 @@ +{ + "namespace": "deps", + "name": "deps", + "version": "0.0.1", + "verbose": false, + + "requires": { + "extensions": [ + "foo", + "bar", + "baz" + ] + } +} diff --git a/unit-tests/fixtures/deps/deps/test.zep b/unit-tests/fixtures/deps/deps/test.zep new file mode 100644 index 0000000000..7345f36a33 --- /dev/null +++ b/unit-tests/fixtures/deps/deps/test.zep @@ -0,0 +1,5 @@ +namespace Deps; + +class Test +{ +} diff --git a/unit-tests/fixtures/genfailure1 b/unit-tests/fixtures/genfailure1 new file mode 100644 index 0000000000..964e8e746f --- /dev/null +++ b/unit-tests/fixtures/genfailure1 @@ -0,0 +1,4 @@ + + [ERROR] Zephir files to compile couldn't be found. Did you add a first class to + the extension? + diff --git a/unit-tests/fixtures/genfailure2 b/unit-tests/fixtures/genfailure2 new file mode 100644 index 0000000000..de097ac7e9 --- /dev/null +++ b/unit-tests/fixtures/genfailure2 @@ -0,0 +1 @@ +Could not load extension(s): foo, bar, baz. You must load extensions above before build this extension. diff --git a/unit-tests/fixtures/lifecycle/.editorconfig b/unit-tests/fixtures/lifecycle/.editorconfig new file mode 100644 index 0000000000..059d88d4f2 --- /dev/null +++ b/unit-tests/fixtures/lifecycle/.editorconfig @@ -0,0 +1,4 @@ +# EditorConfig is awesome: http://EditorConfig.org + +[*.{c,h}] +trim_trailing_whitespace = false diff --git a/unit-tests/fixtures/lifecycle/expected2.c b/unit-tests/fixtures/lifecycle/expected2.c deleted file mode 100644 index 252863d6d0..0000000000 --- a/unit-tests/fixtures/lifecycle/expected2.c +++ /dev/null @@ -1,206 +0,0 @@ - -/* This file was generated automatically by Zephir do not modify it! */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -// TODO: Deprecated. Will be removed in future -#if PHP_VERSION_ID < 50500 -#include -#endif - -#include "php_ext.h" -#include "lifecycle.h" - -#include - -#include -#include -#include - -#include "kernel/globals.h" -#include "kernel/main.h" -#include "kernel/fcall.h" -#include "kernel/memory.h" - - -#include "takedown_funcs.h" -#include "setup_funcs.h" -#include "prep_funcs.h" - -zend_class_entry *lifecycle_test_ce; - -ZEND_DECLARE_MODULE_GLOBALS(lifecycle) - -PHP_INI_BEGIN() - -PHP_INI_END() - -static PHP_MINIT_FUNCTION(lifecycle) -{ -// TODO: Deprecated. Will be removed in future -#if PHP_VERSION_ID < 50500 - char* old_lc_all = setlocale(LC_ALL, NULL); - if (old_lc_all) { - size_t len = strlen(old_lc_all); - char *tmp = calloc(len+1, 1); - if (UNEXPECTED(!tmp)) { - return FAILURE; - } - - memcpy(tmp, old_lc_all, len); - old_lc_all = tmp; - } - - setlocale(LC_ALL, "C"); -#endif - REGISTER_INI_ENTRIES(); - ZEPHIR_INIT(Lifecycle_Test); - ext_setup_module(); - ext_prep_module(); - -// TODO: Deprecated. Will be removed in future -#if PHP_VERSION_ID < 50500 - setlocale(LC_ALL, old_lc_all); - free(old_lc_all); -#endif - return SUCCESS; -} - -#ifndef ZEPHIR_RELEASE -static PHP_MSHUTDOWN_FUNCTION(lifecycle) -{ - ext_takedown_module(); - ext_kill_module(); - zephir_deinitialize_memory(TSRMLS_C); - UNREGISTER_INI_ENTRIES(); - return SUCCESS; -} -#endif - -/** - * Initialize globals on each request or each thread started - */ -static void php_zephir_init_globals(zend_lifecycle_globals *lifecycle_globals TSRMLS_DC) -{ - lifecycle_globals->initialized = 0; - - /* Memory options */ - lifecycle_globals->active_memory = NULL; - - /* Virtual Symbol Tables */ - lifecycle_globals->active_symbol_table = NULL; - - /* Cache Enabled */ - lifecycle_globals->cache_enabled = 1; - - /* Recursive Lock */ - lifecycle_globals->recursive_lock = 0; - - /* Static cache */ - memset(lifecycle_globals->scache, '\0', sizeof(zephir_fcall_cache_entry*) * ZEPHIR_MAX_CACHE_SLOTS); - - - ext_setup_globals(); -} - -/** - * Initialize globals only on each thread started - */ -static void php_zephir_init_module_globals(zend_lifecycle_globals *lifecycle_globals TSRMLS_DC) -{ - -} - -static PHP_RINIT_FUNCTION(lifecycle) -{ - zend_lifecycle_globals *lifecycle_globals_ptr = ZEPHIR_VGLOBAL; - - php_zephir_init_globals(lifecycle_globals_ptr TSRMLS_CC); - //zephir_init_interned_strings(TSRMLS_C); - zephir_initialize_memory(lifecycle_globals_ptr TSRMLS_CC); - - ext_setup_request(); - return SUCCESS; -} - -static PHP_RSHUTDOWN_FUNCTION(lifecycle) -{ - ext_takedown_request(); - zephir_deinitialize_memory(TSRMLS_C); - return SUCCESS; -} - -#define ZEPHIR_POST_REQUEST 1 -static PHP_PRSHUTDOWN_FUNCTION(lifecycle) -{ - ext_takedown_request(); -} - -static PHP_MINFO_FUNCTION(lifecycle) -{ - php_info_print_box_start(0); - php_printf("%s", PHP_LIFECYCLE_DESCRIPTION); - php_info_print_box_end(); - - php_info_print_table_start(); - php_info_print_table_header(2, PHP_LIFECYCLE_NAME, "enabled"); - php_info_print_table_row(2, "Author", PHP_LIFECYCLE_AUTHOR); - php_info_print_table_row(2, "Version", PHP_LIFECYCLE_VERSION); - php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ ); - php_info_print_table_row(2, "Powered by Zephir", "Version " PHP_LIFECYCLE_ZEPVERSION); - php_info_print_table_end(); - - DISPLAY_INI_ENTRIES(); -} - -static PHP_GINIT_FUNCTION(lifecycle) -{ - php_zephir_init_globals(lifecycle_globals TSRMLS_CC); - php_zephir_init_module_globals(lifecycle_globals TSRMLS_CC); -} - -static PHP_GSHUTDOWN_FUNCTION(lifecycle) -{ - ext_takedown_globals(); -} - - -zend_function_entry php_lifecycle_functions[] = { - ZEND_FE_END - -}; - -zend_module_entry lifecycle_module_entry = { - STANDARD_MODULE_HEADER_EX, - NULL, - NULL, - PHP_LIFECYCLE_EXTNAME, - php_lifecycle_functions, - PHP_MINIT(lifecycle), -#ifndef ZEPHIR_RELEASE - PHP_MSHUTDOWN(lifecycle), -#else - NULL, -#endif - PHP_RINIT(lifecycle), - PHP_RSHUTDOWN(lifecycle), - PHP_MINFO(lifecycle), - PHP_LIFECYCLE_VERSION, - ZEND_MODULE_GLOBALS(lifecycle), - PHP_GINIT(lifecycle), - PHP_GSHUTDOWN(lifecycle), -#ifdef ZEPHIR_POST_REQUEST - PHP_PRSHUTDOWN(lifecycle), -#else - NULL, -#endif - STANDARD_MODULE_PROPERTIES_EX -}; - -#ifdef COMPILE_DL_LIFECYCLE -ZEND_GET_MODULE(lifecycle) -#endif diff --git a/unit-tests/fixtures/lifecycle/expected3.c b/unit-tests/fixtures/lifecycle/expected3.c index 4e960654b9..596fd0ce56 100644 --- a/unit-tests/fixtures/lifecycle/expected3.c +++ b/unit-tests/fixtures/lifecycle/expected3.c @@ -145,10 +145,15 @@ zend_function_entry php_lifecycle_functions[] = { }; +static const zend_module_dep php_lifecycle_deps[] = { + + ZEND_MOD_END +}; + zend_module_entry lifecycle_module_entry = { STANDARD_MODULE_HEADER_EX, NULL, - NULL, + php_lifecycle_deps, PHP_LIFECYCLE_EXTNAME, php_lifecycle_functions, PHP_MINIT(lifecycle), diff --git a/unit-tests/fixtures/typehints/.editorconfig b/unit-tests/fixtures/typehints/.editorconfig index e29dd1f55d..059d88d4f2 100644 --- a/unit-tests/fixtures/typehints/.editorconfig +++ b/unit-tests/fixtures/typehints/.editorconfig @@ -1,7 +1,4 @@ # EditorConfig is awesome: http://EditorConfig.org -root = false - [*.{c,h}] trim_trailing_whitespace = false -indent_style = tab diff --git a/unit-tests/fixtures/typehints/expected2.c b/unit-tests/fixtures/typehints/expected2.c deleted file mode 100644 index 33313fbb26..0000000000 --- a/unit-tests/fixtures/typehints/expected2.c +++ /dev/null @@ -1,257 +0,0 @@ - -/* This file was generated automatically by Zephir do not modify it! */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -// TODO: Deprecated. Will be removed in future -#if PHP_VERSION_ID < 50500 -#include -#endif - -#include "php_ext.h" -#include "typehints.h" - -#include - -#include -#include -#include - -#include "kernel/globals.h" -#include "kernel/main.h" -#include "kernel/fcall.h" -#include "kernel/memory.h" - - - -zend_class_entry *typehints_args_ce; -zend_class_entry *typehints_both_ce; -zend_class_entry *typehints_retval_ce; - -ZEND_DECLARE_MODULE_GLOBALS(typehints) - -PHP_INI_BEGIN() - -PHP_INI_END() - -static PHP_MINIT_FUNCTION(typehints) -{ -// TODO: Deprecated. Will be removed in future -#if PHP_VERSION_ID < 50500 - char* old_lc_all = setlocale(LC_ALL, NULL); - if (old_lc_all) { - size_t len = strlen(old_lc_all); - char *tmp = calloc(len+1, 1); - if (UNEXPECTED(!tmp)) { - return FAILURE; - } - - memcpy(tmp, old_lc_all, len); - old_lc_all = tmp; - } - - setlocale(LC_ALL, "C"); -#endif - REGISTER_INI_ENTRIES(); - ZEPHIR_INIT(TypeHints_Args); - ZEPHIR_INIT(TypeHints_Both); - ZEPHIR_INIT(TypeHints_RetVal); - - -// TODO: Deprecated. Will be removed in future -#if PHP_VERSION_ID < 50500 - setlocale(LC_ALL, old_lc_all); - free(old_lc_all); -#endif - return SUCCESS; -} - -#ifndef ZEPHIR_RELEASE -static PHP_MSHUTDOWN_FUNCTION(typehints) -{ - - zephir_deinitialize_memory(TSRMLS_C); - UNREGISTER_INI_ENTRIES(); - return SUCCESS; -} -#endif - -/** - * Initialize globals on each request or each thread started - */ -static void php_zephir_init_globals(zend_typehints_globals *typehints_globals TSRMLS_DC) -{ - typehints_globals->initialized = 0; - - /* Memory options */ - typehints_globals->active_memory = NULL; - - /* Virtual Symbol Tables */ - typehints_globals->active_symbol_table = NULL; - - /* Cache Enabled */ - typehints_globals->cache_enabled = 1; - - /* Recursive Lock */ - typehints_globals->recursive_lock = 0; - - /* Static cache */ - memset(typehints_globals->scache, '\0', sizeof(zephir_fcall_cache_entry*) * ZEPHIR_MAX_CACHE_SLOTS); - - - -} - -/** - * Initialize globals only on each thread started - */ -static void php_zephir_init_module_globals(zend_typehints_globals *typehints_globals TSRMLS_DC) -{ - -} - -static PHP_RINIT_FUNCTION(typehints) -{ - zend_typehints_globals *typehints_globals_ptr = ZEPHIR_VGLOBAL; - - php_zephir_init_globals(typehints_globals_ptr TSRMLS_CC); - //zephir_init_interned_strings(TSRMLS_C); - zephir_initialize_memory(typehints_globals_ptr TSRMLS_CC); - - - return SUCCESS; -} - -static PHP_RSHUTDOWN_FUNCTION(typehints) -{ - - zephir_deinitialize_memory(TSRMLS_C); - return SUCCESS; -} - - - -static PHP_MINFO_FUNCTION(typehints) -{ - php_info_print_box_start(0); - php_printf("%s", PHP_TYPEHINTS_DESCRIPTION); - php_info_print_box_end(); - - php_info_print_table_start(); - php_info_print_table_header(2, PHP_TYPEHINTS_NAME, "enabled"); - php_info_print_table_row(2, "Author", PHP_TYPEHINTS_AUTHOR); - php_info_print_table_row(2, "Version", PHP_TYPEHINTS_VERSION); - php_info_print_table_row(2, "Build Date", __DATE__ " " __TIME__ ); - php_info_print_table_row(2, "Powered by Zephir", "Version " PHP_TYPEHINTS_ZEPVERSION); - php_info_print_table_end(); - - DISPLAY_INI_ENTRIES(); -} - -static PHP_GINIT_FUNCTION(typehints) -{ - php_zephir_init_globals(typehints_globals TSRMLS_CC); - php_zephir_init_module_globals(typehints_globals TSRMLS_CC); -} - -static PHP_GSHUTDOWN_FUNCTION(typehints) -{ - -} - -PHP_FUNCTION(f_TypeHints_args); -ZEND_BEGIN_ARG_INFO_EX(arginfo_f_typehints_args, 0, 0, 7) - ZEND_ARG_INFO(0, _var) - ZEND_ARG_INFO(0, _string) - ZEND_ARG_INFO(0, _bool) - ZEND_ARG_INFO(0, _int) - ZEND_ARG_INFO(0, _long) - ZEND_ARG_INFO(0, _double) - ZEND_ARG_OBJ_INFO(0, _args, TypeHints\\Args, 0) -ZEND_END_ARG_INFO() - -PHP_FUNCTION(f_TypeHints_both); -ZEND_BEGIN_ARG_INFO_EX(arginfo_f_typehints_both, 0, 0, 1) - ZEND_ARG_INFO(0, _string) -ZEND_END_ARG_INFO() - -PHP_FUNCTION(f_TypeHints_retval_var_var_builit_1); -PHP_FUNCTION(f_TypeHints_retval_var_var_builit_2); -PHP_FUNCTION(f_TypeHints_retval_var); -PHP_FUNCTION(f_TypeHints_retval_string); -PHP_FUNCTION(f_TypeHints_retval_boolean); -PHP_FUNCTION(f_TypeHints_retval_int); -PHP_FUNCTION(f_TypeHints_retval_long); -PHP_FUNCTION(f_TypeHints_retval_double); -PHP_FUNCTION(f_TypeHints_retval_retval); -PHP_FUNCTION(f_TypeHints_retval_nullable_int); -PHP_FUNCTION(f_TypeHints_retval_nullable_uint); -PHP_FUNCTION(f_TypeHints_retval_nullable_long); -PHP_FUNCTION(f_TypeHints_retval_nullable_float); -PHP_FUNCTION(f_TypeHints_retval_nullable_double); -PHP_FUNCTION(f_TypeHints_retval_nullable_string); -PHP_FUNCTION(f_TypeHints_retval_nullable_boolean); -PHP_FUNCTION(f_TypeHints_retval_nullable_char); -PHP_FUNCTION(f_TypeHints_retval_object_or_scalar); -PHP_FUNCTION(f_TypeHints_retval_array_of_objects); - -zend_function_entry php_typehints_functions[] = { - ZEND_NS_NAMED_FE("TypeHints", args, ZEND_FN(f_TypeHints_args), arginfo_f_typehints_args) -ZEND_NS_NAMED_FE("TypeHints", both, ZEND_FN(f_TypeHints_both), arginfo_f_typehints_both) -ZEND_NS_NAMED_FE("TypeHints", retval_var_var_builit_1, ZEND_FN(f_TypeHints_retval_var_var_builit_1), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_var_var_builit_2, ZEND_FN(f_TypeHints_retval_var_var_builit_2), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_var, ZEND_FN(f_TypeHints_retval_var), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_string, ZEND_FN(f_TypeHints_retval_string), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_boolean, ZEND_FN(f_TypeHints_retval_boolean), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_int, ZEND_FN(f_TypeHints_retval_int), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_long, ZEND_FN(f_TypeHints_retval_long), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_double, ZEND_FN(f_TypeHints_retval_double), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_retval, ZEND_FN(f_TypeHints_retval_retval), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_nullable_int, ZEND_FN(f_TypeHints_retval_nullable_int), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_nullable_uint, ZEND_FN(f_TypeHints_retval_nullable_uint), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_nullable_long, ZEND_FN(f_TypeHints_retval_nullable_long), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_nullable_float, ZEND_FN(f_TypeHints_retval_nullable_float), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_nullable_double, ZEND_FN(f_TypeHints_retval_nullable_double), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_nullable_string, ZEND_FN(f_TypeHints_retval_nullable_string), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_nullable_boolean, ZEND_FN(f_TypeHints_retval_nullable_boolean), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_nullable_char, ZEND_FN(f_TypeHints_retval_nullable_char), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_object_or_scalar, ZEND_FN(f_TypeHints_retval_object_or_scalar), NULL) -ZEND_NS_NAMED_FE("TypeHints", retval_array_of_objects, ZEND_FN(f_TypeHints_retval_array_of_objects), NULL) -ZEND_FE_END - -}; - -zend_module_entry typehints_module_entry = { - STANDARD_MODULE_HEADER_EX, - NULL, - NULL, - PHP_TYPEHINTS_EXTNAME, - php_typehints_functions, - PHP_MINIT(typehints), -#ifndef ZEPHIR_RELEASE - PHP_MSHUTDOWN(typehints), -#else - NULL, -#endif - PHP_RINIT(typehints), - PHP_RSHUTDOWN(typehints), - PHP_MINFO(typehints), - PHP_TYPEHINTS_VERSION, - ZEND_MODULE_GLOBALS(typehints), - PHP_GINIT(typehints), - PHP_GSHUTDOWN(typehints), -#ifdef ZEPHIR_POST_REQUEST - PHP_PRSHUTDOWN(typehints), -#else - NULL, -#endif - STANDARD_MODULE_PROPERTIES_EX -}; - -#ifdef COMPILE_DL_TYPEHINTS -ZEND_GET_MODULE(typehints) -#endif diff --git a/unit-tests/fixtures/typehints/expected3.c b/unit-tests/fixtures/typehints/expected3.c index e1241be5fb..8f6254520e 100644 --- a/unit-tests/fixtures/typehints/expected3.c +++ b/unit-tests/fixtures/typehints/expected3.c @@ -329,10 +329,15 @@ ZEND_FE_END }; +static const zend_module_dep php_typehints_deps[] = { + + ZEND_MOD_END +}; + zend_module_entry typehints_module_entry = { STANDARD_MODULE_HEADER_EX, NULL, - NULL, + php_typehints_deps, PHP_TYPEHINTS_EXTNAME, php_typehints_functions, PHP_MINIT(typehints), diff --git a/unit-tests/fixtures/typehints/expected_args2.h b/unit-tests/fixtures/typehints/expected_args2.h deleted file mode 100644 index e936c74ab6..0000000000 --- a/unit-tests/fixtures/typehints/expected_args2.h +++ /dev/null @@ -1,21 +0,0 @@ - -extern zend_class_entry *typehints_args_ce; - -ZEPHIR_INIT_CLASS(TypeHints_Args); - -PHP_METHOD(TypeHints_Args, args); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_typehints_args_args, 0, 0, 7) - ZEND_ARG_INFO(0, _var) - ZEND_ARG_INFO(0, _string) - ZEND_ARG_INFO(0, _bool) - ZEND_ARG_INFO(0, _int) - ZEND_ARG_INFO(0, _long) - ZEND_ARG_INFO(0, _double) - ZEND_ARG_OBJ_INFO(0, _args, TypeHints\\Args, 0) -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(typehints_args_method_entry) { - PHP_ME(TypeHints_Args, args, arginfo_typehints_args_args, ZEND_ACC_PUBLIC) - PHP_FE_END -}; diff --git a/unit-tests/fixtures/typehints/expected_both2.h b/unit-tests/fixtures/typehints/expected_both2.h deleted file mode 100644 index 8560db5523..0000000000 --- a/unit-tests/fixtures/typehints/expected_both2.h +++ /dev/null @@ -1,15 +0,0 @@ - -extern zend_class_entry *typehints_both_ce; - -ZEPHIR_INIT_CLASS(TypeHints_Both); - -PHP_METHOD(TypeHints_Both, both); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_typehints_both_both, 0, 0, 1) - ZEND_ARG_INFO(0, _string) -ZEND_END_ARG_INFO() - -ZEPHIR_INIT_FUNCS(typehints_both_method_entry) { - PHP_ME(TypeHints_Both, both, arginfo_typehints_both_both, ZEND_ACC_PUBLIC) - PHP_FE_END -}; diff --git a/unit-tests/fixtures/typehints/expected_retval2.h b/unit-tests/fixtures/typehints/expected_retval2.h deleted file mode 100644 index 57283beeeb..0000000000 --- a/unit-tests/fixtures/typehints/expected_retval2.h +++ /dev/null @@ -1,63 +0,0 @@ - -extern zend_class_entry *typehints_retval_ce; - -ZEPHIR_INIT_CLASS(TypeHints_RetVal); - -PHP_METHOD(TypeHints_RetVal, getMyVar); -PHP_METHOD(TypeHints_RetVal, getMyString); -PHP_METHOD(TypeHints_RetVal, getMyArray); -PHP_METHOD(TypeHints_RetVal, retval_var_var); -PHP_METHOD(TypeHints_RetVal, retval_var_var_builit_1); -PHP_METHOD(TypeHints_RetVal, retval_var_var_builit_2); -PHP_METHOD(TypeHints_RetVal, retval_var); -PHP_METHOD(TypeHints_RetVal, retval_string); -PHP_METHOD(TypeHints_RetVal, retval_boolean); -PHP_METHOD(TypeHints_RetVal, retval_int); -PHP_METHOD(TypeHints_RetVal, retval_long); -PHP_METHOD(TypeHints_RetVal, retval_double); -PHP_METHOD(TypeHints_RetVal, retval_array); -PHP_METHOD(TypeHints_RetVal, retval_array_of_objects); -PHP_METHOD(TypeHints_RetVal, retval_collection); -PHP_METHOD(TypeHints_RetVal, retval_retval); -PHP_METHOD(TypeHints_RetVal, retval_nullable_int); -PHP_METHOD(TypeHints_RetVal, retval_nullable_uint); -PHP_METHOD(TypeHints_RetVal, retval_nullable_long); -PHP_METHOD(TypeHints_RetVal, retval_nullable_float); -PHP_METHOD(TypeHints_RetVal, retval_nullable_double); -PHP_METHOD(TypeHints_RetVal, retval_nullable_string); -PHP_METHOD(TypeHints_RetVal, retval_nullable_boolean); -PHP_METHOD(TypeHints_RetVal, retval_nullable_char); -PHP_METHOD(TypeHints_RetVal, retval_nullable_array); -PHP_METHOD(TypeHints_RetVal, retval_object_or_scalar); -PHP_METHOD(TypeHints_RetVal, retval_static_object_or_scalar); - -ZEPHIR_INIT_FUNCS(typehints_retval_method_entry) { - PHP_ME(TypeHints_RetVal, getMyVar, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, getMyString, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, getMyArray, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_var_var, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_var_var_builit_1, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_var_var_builit_2, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_var, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_string, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_boolean, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_int, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_long, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_double, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_array, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_array_of_objects, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_collection, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_retval, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_nullable_int, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_nullable_uint, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_nullable_long, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_nullable_float, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_nullable_double, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_nullable_string, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_nullable_boolean, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_nullable_char, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_nullable_array, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_object_or_scalar, NULL, ZEND_ACC_PUBLIC) - PHP_ME(TypeHints_RetVal, retval_static_object_or_scalar, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - PHP_FE_END -}; diff --git a/unit-tests/sharness/Makefile b/unit-tests/sharness/Makefile index 99886f0b9e..0c50a92eb5 100644 --- a/unit-tests/sharness/Makefile +++ b/unit-tests/sharness/Makefile @@ -14,7 +14,7 @@ SHARNESS = $(LIBDIR)/$(SHARNESSDIR)/sharness.sh AGGREGATE = $(LIBDIR)/$(SHARNESSDIR)/aggregate-results.sh PROJECTDIR=$(LIBDIR)/../../.. -TESTSDIR=$(PROJECTDIR)/unit-tests +TESTSDIR=$(shell cd $(PROJECTDIR)/unit-tests || exit 1; pwd) BINS = $(PROJECTDIR)/zephir @@ -23,9 +23,11 @@ all: aggregate .PHONY: clean clean: clean-test-results - find $(TESTSDIR)/fixtures -name compile-errors.log -o -name compile.log | xargs rm -f - find $(TESTSDIR)/fixtures -name .zephir -type d | xargs rm -rf - find $(TESTSDIR)/fixtures -name ext -type d | xargs rm -rf + find $(TESTSDIR)/fixtures -name compile-errors.log -o -name compile.log -delete + find $(TESTSDIR)/fixtures -name .zephir -type d -exec rm -rf {} + + find $(TESTSDIR)/fixtures -name ext -type d -exec rm -rf {} + + find $(TESTSDIR)/output/* -type d -exec rm -rf {} + + find $(TESTSDIR)/output -type f -not -name .gitignore -delete -rm -rf "trash "directory.* .PHONY: clean-test-results @@ -41,7 +43,7 @@ $(T): clean-test-results deps .PHONY: aggregate aggregate: clean-test-results $(T) @echo "*** $@ ***" - ls test-results/t*-*.sh.*.counts | $(AGGREGATE) + find ./test-results -name 't*-*.sh.*.counts' | $(AGGREGATE) .PHONY: deps deps: $(SHARNESS) $(BINS) diff --git a/unit-tests/sharness/setup.sh b/unit-tests/sharness/setup.sh index 9d79a8f1b2..5a13ecf328 100644 --- a/unit-tests/sharness/setup.sh +++ b/unit-tests/sharness/setup.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # This file is part of the Zephir. # # (c) Zephir Team @@ -8,29 +10,35 @@ # set sharness verbosity. we set the env var directly as # it's too late to pass in --verbose, and --verbose is harder # to pass through in some cases. +# shellcheck disable=SC2034 test "$TEST_VERBOSE" = 1 && verbose=t -SHARNESS_LIB="./lib/sharness/sharness.sh" +readonly SHARNESS_LIB="./lib/sharness/sharness.sh" -. "$SHARNESS_LIB" || { - echo >&2 "Cannot source: $SHARNESS_LIB" - echo >&2 "Please check Sharness installation." - exit 1 +# shellcheck source=lib/sharness/sharness.sh +source "$SHARNESS_LIB" || { + echo >&2 "Cannot source: $SHARNESS_LIB" + echo >&2 "Please check Sharness installation." + exit 1 } if test "$TEST_VERBOSE" = 1; then - echo '# TEST_VERBOSE='"$TEST_VERBOSE" + (>&1 printf "# TEST_VERBOSE='%s'\n" "$TEST_VERBOSE") fi -export ZEPHIRDIR=$(cd "$(dirname $0)/../../../"; pwd) -export TESTSDIR=$(cd "$(dirname $0)/../../"; pwd) -export FIXTURESDIR="$TESTSDIR/fixtures" -export OUTPUTDIR="$TESTSDIR/output" - -export ZEPHIR_BIN="${ZEPHIRDIR}/zephir" +ZEPHIRDIR=$(cd "$(dirname "$0")/../../../" || exit 1; pwd) +TESTSDIR=$(cd "$(dirname "$0")/../../" || exit 1; pwd) +export ZEPHIRDIR TESTSDIR -: ${PHP:=php} +FIXTURESDIR="$TESTSDIR/fixtures" +OUTPUTDIR="$TESTSDIR/output" +ZEPHIR_BIN="$ZEPHIRDIR/zephir" +PHP_VERSION_ID=$(php -r 'echo PHP_VERSION_ID;') +export FIXTURESDIR OUTPUTDIR ZEPHIR_BIN PHP_VERSION_ID -export PHP_VERSION_ID=$(${PHP} -r 'echo PHP_VERSION_ID;') +: "${PHP:=$(command -v php 2>/dev/null)}" -alias zephir="${PHP} ${ZEPHIR_BIN}" +function zephirc() { + test "$TEST_VERBOSE" = 1 && (>&1 printf "# %s\\n" "$PHP $ZEPHIR_BIN $*") + eval "$PHP $ZEPHIR_BIN $*" +} diff --git a/unit-tests/sharness/t0001-compile.sh b/unit-tests/sharness/t0001-compile.sh index fc0cf8ba12..ed04045449 100755 --- a/unit-tests/sharness/t0001-compile.sh +++ b/unit-tests/sharness/t0001-compile.sh @@ -1,23 +1,24 @@ -#!/bin/sh +#!/usr/bin/env bash +# shellcheck disable=SC2034 test_description="Test compile commands" -. ./setup.sh +source ./setup.sh -cflags="'-O2 -fvisibility=hidden -Wparentheses\( -flto\)\? -DZEPHIR_RELEASE=1'" -test_expect_success "Compile the extension in production mode" ' - cd $FIXTURESDIR/devmode && - zephir fullclean 2>&1 >/dev/null && - zephir compile --no-dev 2>&1 >/dev/null && - cat ext/config.nice | grep -e "^CFLAGS=$cflags" -' +regexp="'-O2 -fvisibility=hidden -Wparentheses\( -flto\)\? -DZEPHIR_RELEASE=1'" +test_expect_success "Compile the extension in production mode" " + cd $FIXTURESDIR/devmode && + zephirc fullclean 2>&1 >/dev/null && + zephirc compile --no-dev 2>&1 >/dev/null && + grep -q -e \"^CFLAGS=$regexp\" ext/config.nice +" -cflags="'-O0 -g3'" -test_expect_success "Compile the extension in development mode" ' - cd $FIXTURESDIR/devmode && - zephir fullclean 2>&1 >/dev/null && - zephir compile --dev 2>&1 >/dev/null && - cat ext/config.nice | grep -e "^CFLAGS=$cflags" -' +regexp="'-O0 -g3'" +test_expect_success "Compile the extension in development mode" " + cd $FIXTURESDIR/devmode && + zephirc fullclean 2>&1 >/dev/null && + zephirc compile --dev 2>&1 >/dev/null && + grep -q -e \"^CFLAGS=$regexp\" ext/config.nice +" test_done diff --git a/unit-tests/sharness/t0002-generate.sh b/unit-tests/sharness/t0002-generate.sh index 6ca0721f6e..ea75d6e439 100755 --- a/unit-tests/sharness/t0002-generate.sh +++ b/unit-tests/sharness/t0002-generate.sh @@ -1,32 +1,33 @@ -#!/bin/sh +#!/usr/bin/env bash +# shellcheck disable=SC2034 test_description="Test generate commands" -. ./setup.sh +source ./setup.sh -test_expect_success "Should correctly specify ARGINFO" ' - cd $FIXTURESDIR/typehints && - zephir fullclean 2>&1 >/dev/null && - zephir generate --backend=ZendEngine3 2>&1 >/dev/null && - test_cmp ext/typehints.c expected3.c && - test_cmp ext/typehints/args.zep.h expected_args3.h && - test_cmp ext/typehints/retval.zep.h expected_retval3.h && - test_cmp ext/typehints/both.zep.h expected_both3.h -' +test_expect_success "Should correctly specify ARGINFO" " + cd $FIXTURESDIR/typehints && + zephirc fullclean 2>&1 >/dev/null && + zephirc generate --backend=ZendEngine3 2>&1 >/dev/null && + test_cmp ext/typehints.c expected3.c && + test_cmp ext/typehints/args.zep.h expected_args3.h && + test_cmp ext/typehints/retval.zep.h expected_retval3.h && + test_cmp ext/typehints/both.zep.h expected_both3.h +" -test_expect_success "Life Cycle Test" ' - cd $FIXTURESDIR/lifecycle && - zephir fullclean 2>&1 >/dev/null && - zephir generate --backend=ZendEngine3 2>&1 >/dev/null && - test_cmp ext/lifecycle.c expected3.c -' +test_expect_success "Life Cycle Test" " + cd $FIXTURESDIR/lifecycle && + zephirc fullclean 2>&1 >/dev/null && + zephirc generate --backend=ZendEngine3 2>&1 >/dev/null && + test_cmp ext/lifecycle.c expected3.c +" # See: https://github.com/phalcon/zephir/issues/1758 -test_expect_success "Should generate valid code with inheritance of prototype interfaces" ' - cd $FIXTURESDIR/protodir && - zephir fullclean 2>&1 >/dev/null && - zephir generate --backend=ZendEngine3 2>&1 >/dev/null && - test_cmp ext/protodir/connectionexception.zep.h connectionexception.h -' +test_expect_success "Should generate valid code with inheritance of prototype interfaces" " + cd $FIXTURESDIR/protodir && + zephirc fullclean 2>&1 >/dev/null && + zephirc generate --backend=ZendEngine3 2>&1 >/dev/null && + test_cmp ext/protodir/connectionexception.zep.h connectionexception.h +" test_done diff --git a/unit-tests/sharness/t0003-init-errors.sh b/unit-tests/sharness/t0003-init-errors.sh index 71d5ad6c50..b530d2e4a8 100755 --- a/unit-tests/sharness/t0003-init-errors.sh +++ b/unit-tests/sharness/t0003-init-errors.sh @@ -1,18 +1,15 @@ -#!/bin/sh +#!/usr/bin/env bash +# shellcheck disable=SC2034 test_description="Test init command for failures" -. ./setup.sh +source ./setup.sh -test_expect_success "Should fail when not enough arguments" ' - cd $OUTPUTDIR && - echo "Not enough arguments (missing: \"namespace\")." >expected && - test_expect_code 1 ${PHP} ${ZEPHIR_BIN} init 2>actual && - test_cmp expected actual -' - -for f in expected actual; do - test -f $OUTPUTDIR/$f && rm -f $OUTPUTDIR/$f -done +test_expect_success "Should fail when not enough arguments" " + cd $OUTPUTDIR && + echo 'Not enough arguments (missing: \"namespace\").' >expected && + test_expect_code 1 zephirc init 2>actual && + test_cmp expected actual +" test_done diff --git a/unit-tests/sharness/t0004-generate-errors.sh b/unit-tests/sharness/t0004-generate-errors.sh new file mode 100755 index 0000000000..52c7dace12 --- /dev/null +++ b/unit-tests/sharness/t0004-generate-errors.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# shellcheck disable=SC2034 +test_description="Test generate command for failures" + +source ./setup.sh + +test_expect_success "Should fail when Zephir files to compile couldn't be found" " + cd $OUTPUTDIR && + zephirc init genfailure1 && + cd genfailure1 && + test_expect_code 1 zephirc generate --no-ansi 2>$OUTPUTDIR/actual && + test_cmp $FIXTURESDIR/genfailure1 $OUTPUTDIR/actual +" + +test_expect_success "Should fail when there are no required modules" " + cd $FIXTURESDIR/deps && + test_expect_code 1 zephirc generate --no-ansi 2>$OUTPUTDIR/actual && + test_cmp $FIXTURESDIR/genfailure2 $OUTPUTDIR/actual +" + +test_done diff --git a/zephir-autocomplete b/zephir-autocomplete index 43d06afaae..18c6039da0 100644 --- a/zephir-autocomplete +++ b/zephir-autocomplete @@ -33,18 +33,18 @@ function _zephir_completion() { if [[ $COMP_CWORD -gt 1 ]] then - local prev="${COMP_WORDS[$COMP_CWORD-1]}" local first="${COMP_WORDS[1]}" if [[ "$cur" == -* ]] then - declare -a a_commands=( $( echo $commands | tr " " "\n" ) ) + declare -a a_commands=( "$( echo "$commands" | tr " " "\\n" )" ) for i in "${a_commands[@]}" do if [ "$i" = "$first" ] then - local opts=$( zephir $first -h --no-ansi | \ + local opts + opts=$( zephir "$first" -h --no-ansi | \ tr -cs '[=-=][:alpha:]_' '[\n*]' | \ grep '^-' ) COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) ) @@ -55,7 +55,8 @@ function _zephir_completion() { fi elif [[ "$cur" == -* ]] then - local opts="--help --quiet --verbose --version --ansi --no-ansi" + local opts + opts="--help --quiet --verbose --version --ansi --no-ansi" opts+=" --dumpversion" COMPREPLY=( $( compgen -W "${opts}" -- "${cur}" ) ) diff --git a/zephir.bat b/zephir.bat index cf3728455e..354888efed 100644 --- a/zephir.bat +++ b/zephir.bat @@ -1,10 +1,10 @@ @echo off -REM This file is part of the Zephir. -REM -REM (c) Zephir Team -REM -REM For the full copyright and license information, please view the LICENSE -REM file that was distributed with this source code. +rem This file is part of the Zephir. +rem +rem (c) Zephir Team +rem +rem For the full copyright and license information, please view the LICENSE +rem file that was distributed with this source code. cls if "%PHP_PEAR_PHP_BIN%" neq "" (