diff --git a/.appveyor.yml b/.appveyor.yml
deleted file mode 100644
index effb11b0..00000000
--- a/.appveyor.yml
+++ /dev/null
@@ -1,43 +0,0 @@
-image: Visual Studio 2019
-version: '{branch}.{build}'
-
-clone_folder: c:\projects\amqp
-
-install:
- - ps: appveyor\install.ps1
-
-cache:
- - c:\build-cache -> .appveyor.yml, appveyor\install.ps1
-
-environment:
- BIN_SDK_VER: 2.2.0
- matrix:
- - PHP_VER: 8.0.8
- ARCH: x64
- TS: 1
- VC: vs16
- DEP: librabbitmq-0.11.0
- - PHP_VER: 8.0.8
- ARCH: x64
- TS: 0
- VC: vs16
- DEP: librabbitmq-0.11.0
- - PHP_VER: 8.0.8
- ARCH: x86
- TS: 1
- VC: vs16
- DEP: librabbitmq-0.11.0
- - PHP_VER: 8.0.8
- ARCH: x86
- TS: 1
- VC: vs16
- DEP: librabbitmq-0.11.0
-
-build_script:
- - ps: appveyor\build.ps1
-
-after_build:
- - ps: appveyor\package.ps1
-
-notifications:
- - provider: GitHubPullRequest
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 00000000..84b8b71a
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,91 @@
+# Generated from CLion C/C++ Code Style settings
+BasedOnStyle: LLVM
+AccessModifierOffset: -4
+AlignConsecutiveAssignments: None
+AlignOperands: Align
+
+AllowAllArgumentsOnNextLine: false
+BinPackArguments: false
+BinPackParameters: false
+AlignAfterOpenBracket: BlockIndent
+AllowAllConstructorInitializersOnNextLine: false
+AllowAllParametersOfDeclarationOnNextLine: false
+
+AllowShortBlocksOnASingleLine: Never
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: Never
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: true
+AlwaysBreakAfterReturnType: None
+AlwaysBreakTemplateDeclarations: Yes
+BreakBeforeBraces: Custom
+MacroBlockBegin: "(ZEND_BEGIN_ARG_(INFO|WITH_RETURN_(TYPE|OBJ)_INFO)(_EX)?|PHP_INI_BEGIN)"
+MacroBlockEnd: "(ZEND_END_ARG_INFO|PHP_INI_END)"
+Macros:
+ - "PHP_ME(a, b, c, d)={a, b, c, d, e},"
+ - "PHP_MALIAS(a, b, c, d, e)={a, b, c, d, e},"
+ - "PHP_ABSTRACT_ME(a, b, c)={a, b, c, d, e},"
+ - "ZEND_HASH_FOREACH_KEY_VAL(a, b, c, d)=do {"
+ - "ZEND_HASH_FOREACH_STR_KEY(a, b)=do {"
+ - "ZEND_HASH_FOREACH_STR_KEY_VAL(a, b, c)=do {"
+ - "ZEND_HASH_FOREACH_END=} while(true)"
+ - "PHP_AMQP_MAYBE_ERROR(a, b)=(a && b)"
+StatementMacros:
+ - PHP_AMQP_NOPARAMS
+WhitespaceSensitiveMacros:
+ - PHP_ME
+BraceWrapping:
+ AfterCaseLabel: false
+ AfterClass: false
+ AfterControlStatement: Never
+ AfterEnum: false
+ AfterFunction: true
+ AfterNamespace: false
+ AfterUnion: false
+ BeforeCatch: false
+ BeforeElse: false
+ IndentBraces: false
+ SplitEmptyFunction: false
+ SplitEmptyRecord: true
+BreakBeforeBinaryOperators: None
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakInheritanceList: BeforeColon
+ColumnLimit: 120
+CompactNamespaces: false
+IndentCaseLabels: true
+IndentPPDirectives: BeforeHash
+IndentWidth: 4
+KeepEmptyLinesAtTheStartOfBlocks: true
+MaxEmptyLinesToKeep: 2
+NamespaceIndentation: All
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PointerAlignment: Right
+ReferenceAlignment: Right
+ReflowComments: false
+SpaceAfterCStyleCast: true
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: false
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 0
+SpacesInAngles: false
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+TabWidth: 4
+UseTab: Never
+AlignArrayOfStructures: Left
+SortIncludes: Never
+IndentWrappedFunctionNames: true
+InsertNewlineAtEOF: true
+PenaltyReturnTypeOnItsOwnLine: 9999
+PenaltyExcessCharacter: 999
diff --git a/.env b/.env
new file mode 100644
index 00000000..39753f40
--- /dev/null
+++ b/.env
@@ -0,0 +1,7 @@
+PHP_AMQP_HOST=rabbitmq
+PHP_AMQP_SSL_HOST=rabbitmq.example.org
+MAKEFLAGS="-j16 PHP_EXECUTABLE=/src/infra/tools/pamqp-php-cli-deterministic"
+CFLAGS="-g -O0 -fstack-protector-strong -Wall -Werror -D_GNU_SOURCE"
+TEST_PHP_ARGS="-j16 -q"
+CC=clang
+VALGRIND_OPTS="--suppressions=infra/tools/valgrind-suppressions"
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 00000000..1d98aec4
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,2 @@
+# Codebase reformatting
+7b6a6443d6fea0dce155ab67cbd7640177a152ca
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 00000000..3f6eb6b7
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,15 @@
+version: 2
+updates:
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: daily
+ open-pull-requests-limit: 30
+
+ - package-ecosystem: composer
+ directory: /
+ schedule:
+ interval: daily
+ open-pull-requests-limit: 30
+ allow:
+ - dependency-type: all
diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 7e117477..0161f983 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -1,177 +1,183 @@
name: Test
on:
- push:
- pull_request:
- types: [opened, synchronize, edited, reopened]
+ push:
+ pull_request:
+ types: [ opened, synchronize, reopened ]
env:
- ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- TEST_TIMEOUT: 120
+ TEST_TIMEOUT: 120
+ CFLAGS: -g -O0 -fstack-protector-strong -Wall -Werror -D_GNU_SOURCE
+ MAKEFLAGS: -j4 PHP_EXECUTABLE=./infra/tools/pamqp-php-cli-deterministic
jobs:
- test:
- name: php-${{ matrix.php-version }} librabbitmq-${{ matrix.librabbitmq-version }} ${{ matrix.test-php-args == '-m' && 'memory leaks' || '' }}
+ prep:
+ name: Prepare
+ continue-on-error: true
+ runs-on: ubuntu-24.04
+ outputs:
+ should_skip: ${{ steps.skip_check.outputs.should_skip }}
+ php_versions: ${{ steps.matrix.outputs.php_versions }}
+ librabbitmq_versions: ${{ steps.matrix.outputs.librabbitmq_versions }}
+ memory_build_matrix: ${{ steps.matrix.outputs.memory_build_matrix }}
+ steps:
+ - id: skip_check
+ name: Prevent duplicate builds
+ uses: fkirc/skip-duplicate-actions@v5.3.1
+ with:
+ skip_after_successful_duplicate: 'true'
+ cancel_others: 'true'
+ concurrent_skipping: 'same_content_newer'
+
+ - name: Checkout
+ uses: actions/checkout@v6.0.2
+
+ - name: Prepare matrix
+ id: matrix
+ run: |
+ infra/tools/pamqp-matrix >> "$GITHUB_OUTPUT"
+
+ checkstyle:
+ name: Check C formatting
+ runs-on: ubuntu-24.04
+ needs: prep
+ if: needs.prep.outputs.should_skip != 'true'
+
+ steps:
+ - name: Install clang-format
+ uses: myci-actions/add-deb-repo@11
+ with:
+ repo: 'deb https://apt.llvm.org/jammy/ llvm-toolchain-jammy-20 main'
+ repo-name: llvm
+ keys-asc: https://apt.llvm.org/llvm-snapshot.gpg.key
+ install: clang-format-20
+
+ - name: Checkout
+ uses: actions/checkout@v6.0.2
+
+ - name: Check style
+ run: ./infra/tools/pamqp-format-check
+
+ stubs:
+ name: Check stubs php-${{ matrix.php-version }}
+ runs-on: ubuntu-24.04
+ needs: prep
+ if: needs.prep.outputs.should_skip != 'true'
+
+ strategy:
+ fail-fast: false
+ matrix:
+ php-version: ${{ fromJson(needs.prep.outputs.php_versions) }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6.0.2
+
+ - name: Install packages
+ uses: awalsh128/cache-apt-pkgs-action@v1.6.0
+ with:
+ packages: cmake
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@2.36.0
+ with:
+ php-version: ${{ matrix.php-version }}
+ extensions: json
+ coverage: none
+ env:
+ debug: true
+
+ - name: Check stubs
+ run: ./infra/tools/pamqp-stubs-lint
+
+ - name: Build librabbitmq
+ run: ./infra/tools/pamqp-install-librabbitmq master
+
+ - name: Build PHP extension
+ run: phpize && ./configure && make
+
+ - name: Validate stubs
+ run: ./infra/tools/pamqp-stubs-validate
+
+ - name: Check stub coding style
+ run: ./infra/tools/pamqp-stubs-format-check
+
+ - name: Validate argument parsing
+ run: ./infra/tools/pamqp-php-cli-deterministic -d extension=modules/amqp.so ./infra/tools/pamqp-arguments-validate
+
+ test:
+ name: ${{ matrix.test-php-args == '-m' && 'Memtest' || 'Test' }} php-${{ matrix.php-version }}${{ matrix.php-thread-safe && '-ts' || '-nts' }} librabbitmq-${{ matrix.librabbitmq-version }} ${{ matrix.compiler }}
+ runs-on: ubuntu-24.04
+ needs: prep
+ if: needs.prep.outputs.should_skip != 'true'
+
+ env:
+ CC: ${{ matrix.compiler }}
+ TEST_PHP_ARGS: -j4 ${{ matrix.test-php-args }}
+ PHP_AMQP_HOST: localhost
+ PHP_AMQP_SSL_HOST: rabbitmq.example.org
+ VALGRIND_OPTS: '--suppressions=infra/tools/valgrind-suppressions'
+
+ strategy:
+ fail-fast: false
+ matrix:
+ php-version: ${{ fromJson(needs.prep.outputs.php_versions) }}
+ php-thread-safe: [ true, false ]
+ librabbitmq-version: ${{ fromJson(needs.prep.outputs.librabbitmq_versions) }}
+ compiler: [gcc, clang]
+ include: ${{ fromJson(needs.prep.outputs.memory_build_matrix) }}
+
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v6.0.2
+
+ - name: Configure hostnames
+ run: sudo echo "127.0.0.1 ${{ env.PHP_AMQP_SSL_HOST }}" | sudo tee -a /etc/hosts
+
+ - name: Generate test certificates
+ run: docker compose up ca
+
+ - name: Start RabbitMQ
+ run: docker compose up -d rabbitmq
+
+ - name: Install packages
+ uses: awalsh128/cache-apt-pkgs-action@v1.6.0
+ with:
+ packages: cmake valgrind libc6-dbg gcc clang
+ version: ubuntu-24.04
+
+ - name: Setup PHP
+ uses: shivammathur/setup-php@2.36.0
+ with:
+ php-version: ${{ matrix.php-version }}
+ coverage: none
+ extensions: simplexml
+ env:
+ phpts: ${{ matrix.php-thread-safe && 'ts' || 'nts' }}
+ debug: true
+
+ - name: Build librabbitmq
+ run: ./infra/tools/pamqp-install-librabbitmq ${{ matrix.librabbitmq-version }}
- runs-on: ubuntu-latest
+ - name: Print librabbitmq version
+ run: pkg-config librabbitmq --debug
- continue-on-error: ${{ matrix.experimental }}
+ - name: Build PHP extension
+ run: phpize && ./configure && make
+ - name: Run minimal test suite
+ run: make test | tee result-minimal.txt
env:
- TEST_PHP_ARGS: ${{ matrix.test-php-args }}
-
- strategy:
- fail-fast: false
- matrix:
- include:
- - php-version: '8.1'
- librabbitmq-version: 'master'
- experimental: false
- - php-version: '8.1'
- librabbitmq-version: 'master'
- test-php-args: '-m'
- experimental: true
- - php-version: '8.1'
- librabbitmq-version: 'v0.11.0'
- experimental: false
- - php-version: '8.1'
- librabbitmq-version: 'v0.9.0'
- experimental: false
-
- - php-version: '8.0'
- librabbitmq-version: 'master'
- experimental: false
- - php-version: '8.0'
- librabbitmq-version: 'master'
- test-php-args: '-m'
- experimental: true
- - php-version: '8.0'
- librabbitmq-version: 'v0.11.0'
- experimental: false
- - php-version: '8.0'
- librabbitmq-version: 'v0.9.0'
- experimental: false
-
- - php-version: '7.4'
- librabbitmq-version: 'master'
- experimental: false
- - php-version: '7.4'
- librabbitmq-version: 'v0.11.0'
- experimental: false
- - php-version: '7.4'
- librabbitmq-version: 'v0.11.0'
- test-php-args: '-m'
- experimental: true
- - php-version: '7.4'
- librabbitmq-version: 'v0.9.0'
- experimental: false
-
- - php-version: '7.3'
- librabbitmq-version: 'master'
- experimental: false
- - php-version: '7.3'
- librabbitmq-version: 'v0.11.0'
- experimental: false
- - php-version: '7.3'
- librabbitmq-version: 'v0.9.0'
- experimental: false
- - php-version: '7.3'
- librabbitmq-version: 'v0.9.0'
- test-php-args: '-m'
- experimental: true
-
- - php-version: '7.2'
- librabbitmq-version: 'master'
- experimental: false
- - php-version: '7.2'
- librabbitmq-version: 'master'
- test-php-args: '-m'
- experimental: true
- - php-version: '7.2'
- librabbitmq-version: 'v0.11.0'
- experimental: false
- - php-version: '7.2'
- librabbitmq-version: 'v0.9.0'
- experimental: false
-
- - php-version: '7.1'
- librabbitmq-version: 'master'
- experimental: false
- - php-version: '7.1'
- librabbitmq-version: 'v0.11.0'
- experimental: false
- - php-version: '7.1'
- librabbitmq-version: 'v0.11.0'
- test-php-args: '-m'
- experimental: true
- - php-version: '7.1'
- librabbitmq-version: 'v0.9.0'
- experimental: false
-
- - php-version: '7.0'
- librabbitmq-version: 'master'
- experimental: false
- - php-version: '7.0'
- librabbitmq-version: 'v0.11.0'
- experimental: false
- - php-version: '7.0'
- librabbitmq-version: 'v0.9.0'
- experimental: false
- - php-version: '7.0'
- librabbitmq-version: 'v0.9.0'
- test-php-args: '-m'
- experimental: true
-
- - php-version: '5.6'
- librabbitmq-version: 'master'
- experimental: false
- - php-version: '5.6'
- librabbitmq-version: 'master'
- test-php-args: '-m'
- experimental: true
- - php-version: '5.6'
- librabbitmq-version: 'v0.11.0'
- experimental: false
- - php-version: '5.6'
- librabbitmq-version: 'v0.9.0'
- experimental: false
-
- services:
- rabbitmq:
- image: rabbitmq:3
- ports:
- - 5671:5671
- - 5672:5672
- - 15671:15671
- - 15672:15672
-
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Install packages
- run: sudo apt-get install -y cmake valgrind
-
- - name: Setup PHP
- uses: shivammathur/setup-php@v2
- with:
- php-version: ${{ matrix.php-version }}
- coverage: none
-
- - name: Build librabbitmq
- run: sudo ./provision/install_rabbitmq-c.sh ${{ matrix.librabbitmq-version }}
-
- - name: Debug librabbitmq
- run: pkg-config librabbitmq --debug
-
- - name: Build PHP extension
- run: phpize && ./configure && make
-
- - name: Test PHP extension
- run: make test | tee result.txt
-
- - name: Benchmark PHP extension
- run: php -n -c './tmp-php.ini' -d "extension_dir=./modules/" -d "extension=amqp.so" benchmark.php
-
- - name: Dump report
- run: sh test-report.sh
+ # Reset defaults to a) only run local tests, b) don’t run memory checks as the full test suite run will do so
+ TEST_PHP_ARGS: '-j4 -q'
+ PHP_AMQP_HOST: ''
+ PHP_AMQP_SSL_HOST: ''
+
+ - name: Test full test suite
+ run: make test | tee result-full.txt
+
+ - name: Benchmark PHP extension
+ run: ./infra/tools/pamqp-php-cli-deterministic -d extension=modules/amqp.so benchmark.php
+
+ - name: Dump report
+ run: ./infra/tools/pamqp-test-report
diff --git a/.gitignore b/.gitignore
index 108619ac..bd8518a9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
.deps
+*.dep
.libs/*
.vagrant
Makefile
@@ -28,7 +29,7 @@ ltmain.sh
missing
mkinstalldirs
modules/*
-run-tests.php
+infra/tools/run-tests.php
tests/*
!tests/*.phpt
!tests/_test_helpers.php.inc
@@ -43,4 +44,10 @@ CMakeLists.txt
# CLion
.idea/
/vendor/
-/composer.lock
+
+/config.h.in~
+/configure~
+/impl.json
+/stubs.json
+/run-tests.php
+/stubs-old
diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md
new file mode 100644
index 00000000..1ef33564
--- /dev/null
+++ b/DEVELOPMENT.md
@@ -0,0 +1,118 @@
+# PHP AMQP extension development
+
+PHP AMQP comes with a Docker based development environment that offers containers with multiple PHP versions as well
+as a properly configured RabbitMQ instance. The development environment supports building the library against multiple
+PHP versions in parallel.
+
+## Getting started
+
+To start the development environment, run this command:
+
+```commandline
+docker compose up
+```
+
+For the impatient to not wait for all containers to finish building, only start a single container:
+
+```commandline
+docker compose up debian-82
+```
+
+The command will start the development environment in the foreground. This is quite nice as it will conveniently surface
+all the logs, especially the RabbitMQ logs.
+
+## The environment
+
+Various development containers are provided:
+
+- `debian-74`: PHP 7.4 on Debian 11 ("Bullseye") with debug build enabled
+- `debian-80`: PHP 8.0 on Debian 12 ("Bookworm") with debug build enabled
+- `debian-81`: PHP 8.1 on Debian 12 ("Bookworm") with debug build enabled
+- `debian-82`: PHP 8.2 on Debian 12 ("Bookworm") with debug build enabled
+- `ubuntu-74`: PHP 7.4 on Ubuntu 20 ("Jammy")
+- `ubuntu-80`: PHP 8.0 on Ubuntu 22 ("Jammy")
+- `ubuntu-81`: PHP 8.1 on Ubuntu 22 ("Jammy")
+- `ubuntu-82`: PHP 8.2 on Ubuntu 22 ("Jammy")
+- `centos-74`: PHP 7.4 on Centos Stream 9
+- `centos-80`: PHP 8.0 on Centos Stream 9
+- `centos-81`: PHP 8.1 on Centos Stream 9
+- `centos-82`: PHP 8.2 on Centos Stream 9
+
+To enter the container, run this command:
+
+```
+docker compose exec debian-82 bash
+```
+
+You will automatically land in `/src/build/debian-82`, which is the container specific build dir. The whole source
+tree is mounted to `/src`.
+
+### Building the extension
+
+To build the extension, a helper tool is available:
+
+```commandline
+pamqp-build
+```
+
+Once you have made a change, run `pamqp-build` again. `pamqp-build` will try and only build what is necessary. If you
+want to build from scratch, run `pamqp-build`.
+
+🧠 The few development tools available all start with `pamqp-`, so typing `pamqp` and then hitting Tab
+gives you a list of tools available.
+
+### Running tests
+
+Once you have built the extension it’s a good idea to make sure that all tests are passing before you make your change.
+
+Run this command:
+
+```commandline
+make test
+```
+
+To inspect a test failure, you can view the result file relative from the container build directory, as there is a
+symlink available to make that as simple as possible:
+
+```commandline
+cat tests/amqp_some_test.out
+```
+
+### Run all checks locally
+
+Before pushing a change, run tests, lint and validate stubs, validates argument parsing, and checks formatting of both C
+and PHP code:
+
+```commandline
+pamqp-check
+```
+
+### Formatting
+
+Discussing coding style is as much as it is futile, so PHP AMQP using clang-format to automatically format the source
+code. Run this command to format C code:
+
+```commandline
+pamqp-format
+```
+
+Run this to format the stubs:
+```commandline
+pamqp-stubs-format
+```
+
+### Validating stubs
+
+When PHP AMQP’s API changes, it is very important that reflection info is correct and in sync with the stubs. For that
+reason `pamqp-stubs-validate` exists to validate that the two sources of information are in sync.
+
+```commandline
+pamqp-stubs-validate
+```
+
+# Release management
+
+Say we want to release "1.10.11" next. We first run `./infra/tools/pamqp-release-cut 1.10.11`. This will update the
+version numbers and pre-populate the changelog with the latest git commits between the previous version and now. It will
+prompt you to edit the changelog. Once the release is done it tells you what to do next.
+Run `./infra/tools/pamqp-release-finalize 1.10.12dev` to bring latest back into development mode afterward.
diff --git a/README.md b/README.md
index c67d919e..859d6918 100644
--- a/README.md
+++ b/README.md
@@ -1,164 +1,97 @@
-# PHP AMQP bindings [](https://travis-ci.org/php-amqp/php-amqp) [](https://ci.appveyor.com/project/lstrojny/php-amqp-7lf47/branch/master)
+# PHP AMQP bindings [](https://github.com/php-amqp/php-amqp/actions/workflows/test.yaml)
Object-oriented PHP bindings for the AMQP C library (https://github.com/alanxz/rabbitmq-c)
-
### Requirements:
- - PHP >= 5.6 (PHP 7 included) with either ZTS or non-ZTS version.
- - [RabbitMQ C library](https://github.com/alanxz/rabbitmq-c), commonly known as librabbitmq
- (since php-amqp>=1.9.4 librabbitmq >= 0.7.1,
- see [release notes](https://pecl.php.net/package-changelog.php?package=amqp)).
- - to run tests [RabbitMQ server](https://www.rabbitmq.com/) >= 3.4.0 required.
-
+- PHP >= 7.4 with either ZTS or non-ZTS version.
+- Starting with php-amqp 2.0.0 at least version 0.8.0 of [librabbitmq](https://github.com/alanxz/rabbitmq-c) is
+ required (at least 0.10.0 is recommended)
+- to run tests [RabbitMQ server](https://www.rabbitmq.com/) >= 3.4.0 required.
### Installation
#### Linux
- Some systems has php-amqp extension in their repo or available via external repositories, so it is MAY be the preferable
- way to install.
-
- RPM packages are available in Fedora and EPEL (for RHEL and CentOS) official repositories,
- see [php-pecl-amqp](https://apps.fedoraproject.org/packages/php-pecl-amqp)
-
- Fresh `php-pecl-amqp` and `librabbitmq` RPMs available via [remi repo](http://rpms.remirepo.net/).
-
- If you want to stay on the bleeding edge and have the latest version, install php-amqp extension from
- [PECL](http://pecl.php.net/package/amqp) or compile from sources
- (follow [PHP official docs instruction](http://us1.php.net/manual/en/install.pecl.phpize.php)).
-
-#### Windows
- - Before download, check if your PHP installation is thread safe or non-thread safe by entering php -i|findstr "Thread" in your terminal
- - Download thread safe or non-thread safe version of the extension for your PHP version from https://pecl.php.net/package/amqp. Look for the "DLL" link next to each release in the list of available releases
- - After download, copy the `rabbitmq.4.dll` and `rabbitmq.4.pdb` files to the PHP root folder and copy `php_amqp.dll` and `php_amqp.pdb` files to `PHP\ext` folder
- - Add `extension=amqp` to the `php.ini` file
- - Check if the module is properly installed with php -m
-
-### Documentation
-
-View [RabbitMQ official tutorials](http://www.rabbitmq.com/getstarted.html)
-and [php-amqp specific examples](https://github.com/rabbitmq/rabbitmq-tutorials/tree/master/php-amqp).
-There are also available [stub files](https://github.com/php-amqp/php-amqp/tree/master/stubs) with accurate PHPDoc which
-may be also used in your IDE for code completion, navigation and documentation in-place.
+Some systems have php-amqp extension available in their package repositories or available via an external repository so it is MAY be the preferable
+way to install.
-Finally, check out the [tests](https://github.com/php-amqp/php-amqp/tree/master/tests) to see typical usage and edge cases.
-
-### Notes
+Fresh `php-pecl-amqp` and `librabbitmq` RPMs available via [remi repo](http://rpms.remirepo.net/).
- - Max channels per connection means how many concurrent channels per connection may be opened at the same time
- (this limit may be increased later to max AMQP protocol number - 65532 without any problem).
-
- - Nested header arrays may contain only string values.
-
- - You can't share none of AMQP API objects (none of `AMQPConnection`, `AMQPChannel`, `AMQPQueue`, `AMQPExchange`) between threads.
- You have to use separate connection and so on per thread.
-
-### Related libraries
+If you want to stay on the bleeding edge and have the latest version, install php-amqp extension from
+[PECL](http://pecl.php.net/package/amqp) or compile from sources
+(follow [PHP official docs instruction](http://us1.php.net/manual/en/install.pecl.phpize.php)).
-* [enqueue/amqp-ext](https://github.com/php-enqueue/amqp-ext) is a [amqp interop](https://github.com/queue-interop/queue-interop#amqp-interop) compatible wrapper.
-
-#### Persistent connection
-
- Limitations:
-
- - there may be only one persistent connection per unique credentials (login+password+host+port+vhost).
- If there will be an attempt to create another persistent connection with the same credentials, an exception will be thrown.
- - channels on persistent connections are not persistent: they are destroyed between requests.
- - heartbeats are limited to blocking calls only, so if there are no any operations on a connection or no active
- consumer set, connection may be closed by the broker as dead.
-
-*Developers note: alternatively for built-in persistent connection support [raphf](http://pecl.php.net/package/raphf) pecl extension may be used.*
-
-### How to report a problem
-
- 1. First, search through the closed issues and [stackoverflow.com](http://stackoverflow.com).
- 3. Submit an issue with short and definitive title that describe your problem
- 4. Provide platform info, PHP interpreter version, SAPI mode (cli, fpm, cgi, etc) extension is used in, php-amqp extension version, librabbitmq version, make tools version.
- 5. Description should provide information on how to reproduce a problem ([gist](https://gist.github.com/) is the most preferable way to include large sources) in a definitive way. Use [Vagrant](http://www.vagrantup.com/) to replicate unusual environments.
- 6. If stack trace is generated, include it in full via [gist](https://gist.github.com/) or the important part (if you definitely know what you are doing) directly in the description.
-
-#### Things to check before reporting a problem
-
- Some of them, the list is not complete.
-
- 1. You are running on correct machine in correct environment and your platform meets your application requirement.
- 2. librabbimq is installed and discoverable in your environment so php-amqp extension can load it.
- 3. php-amqp extension present in system (find `amqp.so` or `amqp.dll` if you are on windows), it is loaded (`php --ri amqp` produced some info), and there are no underlying abstraction that MAY emulate php-amqp work.
- 5. You hav correct RabbitMQ credentials.
- 6. You are using the latest php-amqp, librabbitmq, RabbitMQ and sometimes PHP version itself. Sometimes your problem is already solved.
- 7. Other extensions disabled (especially useful when PHP interpreter crashes and you get stack trace and segmentation fault).
-
-
-## Development
-
- There is a Vagrant environment with pre-installed software and libraries necessary to build, test and run the php-amqp extension.
-
- To start it, just type `vagrant up` and then `vagrant ssh` in php-amqp directory.
-
- Services available out of the box are:
+#### Windows
- - Apache2 - on [192.168.33.10:8080](http://192.168.33.10:8080)
- - nginx - on [192.168.33.10:80](http://192.168.33.10:80)
- - RabbitMQ on [192.168.33.10:15672](http://192.168.33.10:15672/#/login/guest/guest) with guest access (login: `guest`, password: `guest`)
+- Before download, check if your PHP installation is thread safe or non-thread safe by entering php -i|findstr "
+ Thread" in your terminal
+- Download thread safe or non-thread safe version of the extension for your PHP version
+ from https://pecl.php.net/package/amqp. Look for the "DLL" link next to each release in the list of available releases
+- After download, copy the `rabbitmq.4.dll` and `rabbitmq.4.pdb` files to the PHP root folder and copy `php_amqp.dll`
+ and `php_amqp.pdb` files to `PHP\ext` folder
+- Add `extension=amqp` to the `php.ini` file
+- Check if the module is properly installed with php -m
-Additional tools are pre-installed to make development process as simple as possible:
+### Documentation
-##### valgrind
+Check out the official [RabbitMQ tutorials](http://www.rabbitmq.com/getstarted.html)
+as well as the [php-amqp specific examples](https://github.com/rabbitmq/rabbitmq-tutorials/tree/main/php-amqp).
-Valgrind is ready to help find memory-related problems if you `export TEST_PHP_ARGS=-m` before running tests.
+There are also [stub files](https://github.com/php-amqp/php-amqp/tree/latest/stubs) available that document the API of
+PHP AMQP. These stubs can also be used in your IDE for code completion, navigation and documentation.
-##### phpbrew
+Check out the [upgrading guide](https://github.com/php-amqp/php-amqp/tree/latest/UPGRADING.md) to check
+breaking changes between versions, e.g. from 1.x to 2.x.
-[phpbrew](https://github.com/phpbrew/phpbrew) waits to help you to test extension on various PHP versions.
-`phpbrew install 5.6 +debug+default+fpm` is a nice start. To switch to some version just use `phpbrew switch `.
+Finally, check out the [tests](https://github.com/php-amqp/php-amqp/tree/latest/tests) to see usage examples and edge
+cases.
-To start php-fpm just run `phpbrew fpm start` (don't forget to run `sudo service stop php5-fpm` befor).
+### Notes & limitations
-This development environment out of the box ready for php-fpm and cli extension usage, if need to test it when php
-used as apache module, refer to [Apache2 support on phpbrew wiki](https://github.com/phpbrew/phpbrew/wiki/Cookbook#apache2-support).
-Keep in mind that `+apxs2` conficts with `+fpm` and it is a bit tricky to specify which libphp .so will be loaded.
+- You can't share any of AMQP API objects (`AMQPConnection`, `AMQPChannel`, `AMQPQueue`, `AMQPExchange`)
+ between threads. Use a separate connection per thread.
+- There may only be one persistent connection
+ per [connection information](https://github.com/search?q=repo%3Aphp-amqp%2Fphp-amqp+amqp_conn_res_h&type=code).
+ If there will be an attempt to create another persistent connection with the same credentials, an exception will be
+ thrown.
+- Channels on persistent connections are not persistent: they are destroyed between requests.
+- Heartbeats are limited to blocking calls only, so if there are no any operations on a connection or no active
+ consumer set, connection may be closed by the broker as dead.
-##### tshark
+### Related libraries
-> [tshark](https://www.wireshark.org/docs/man-pages/tshark.html) - Dump and analyze network traffic
->
-> ... TShark is able to detect, read and write the same capture files that are supported by Wireshark.
-
-To use it you probably have to set network privileges for dumpcap first(see
-[Platform-Specific information about capture privileges](https://wiki.wireshark.org/CaptureSetup/CapturePrivileges) Wireshark docs page
-and [running wireshark “Lua: Error during loading”](http://askubuntu.com/questions/454734/running-wireshark-lua-error-during-loading) SO question):
-
- `sudo setcap 'CAP_NET_RAW+eip CAP_NET_ADMIN+eip' /usr/bin/dumpcap`
+- [enqueue/amqp-ext](https://github.com/php-enqueue/amqp-ext) is
+ an [amqp interop](https://github.com/queue-interop/queue-interop#amqp-interop) compatible wrapper
+- [symfony/amqp-messenger](https://symfony.com/components/AMQP%20Messenger) provides AMQP integration
+ for [symfony/messenger](https://symfony.com/doc/current/messenger.html), the popular messaging component by Symfony.
-To start capturing, run `tshark -i lo` to see output in terminal or `tshark -i lo -w capture.log` to save capture and
-analyze it later (even with [AMQP](https://wiki.wireshark.org/AMQP) protocol Wireshark plugin). You may filter AMQP packages
-using `-Y amqp` attribute, just give a try - `tshark -i lo -Y amqp`.
-
-> NOTE: -w provides raw packet data, not text. If you want text output you need to redirect stdout (e.g. using '>'), don't use the -w option for this.
+### How to report a problem
+1. First, search through the closed issues and [stackoverflow.com](http://stackoverflow.com).
+2. Submit an issue with short and definitive title that describe your problem
+3. Provide platform info, PHP interpreter version, SAPI mode (cli, fpm, cgi, etc) the extension is used in, php-amqp
+ extension version, librabbitmq version, make tools version.
+4. Description should provide information on how to reproduce a problem ([gist](https://gist.github.com/) is the most
+ preferable way to include large sources) in a definitive way. Use [Vagrant](http://www.vagrantup.com/) to replicate
+ unusual environments.
+5. If stack trace is generated, include it in full via [gist](https://gist.github.com/) or the important part (if you
+ definitely know what you are doing) directly in the description.
-#### Configuring a RabbitMQ server
+#### Things to check before reporting a problem
-If you need to tweek RabbitMQ server params use default config
-[rabbitmq.config.example](https://github.com/rabbitmq/rabbitmq-server/blob/master/docs/rabbitmq.config.example)
-([raw](https://raw.githubusercontent.com/rabbitmq/rabbitmq-server/master/docs/rabbitmq.config.example))
-from [official RabbitmMQ repo](https://github.com/rabbitmq/rabbitmq-server), so it may looks like
-`sudo curl https://raw.githubusercontent.com/rabbitmq/rabbitmq-server/master/docs/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config`
-
-To reset RabbitMQ application run in CLI (as privileged user) `rabbitmqctl stop_app && rabbitmqctl reset && rabbitmqctl start_app`.
+Some of them, the list is not complete.
-#### Keeping track of the workers
- It is a good practice to keep php processes (i.e workers/consumers) under control. Usually, system administrators write their own scripts which ask services about current status or performs some desired actions. Usually request is sent via UNIX signals.
- Because amqp consume method is blocking, pcntl extension seems to be useless.
-
- [php-signal-handler](https://github.com/RST-com-pl/php-signal-handler) extension uses signal syscall,
- so it will work even if blocking method was executed.
- Some use cases are presented on extension's github page and examples are available [here](https://github.com/php-amqp/php-amqp/pull/89).
+1. You are running on correct machine in correct environment and your platform meets your application requirement.
+2. librabbitmq is installed and discoverable in your environment so php-amqp extension can load it.
+3. php-amqp extension present in system (find `amqp.so` or `amqp.dll` if you are on windows), it is
+ loaded (`php --ri amqp` produced some info), and there are no underlying abstraction that MAY emulate php-amqp work.
+4. You hav correct RabbitMQ credentials.
+5. You are using the latest php-amqp, librabbitmq, RabbitMQ and sometimes PHP version itself. Sometimes your problem is
+ already solved.
+6. Other extensions disabled (especially useful when PHP interpreter crashes, and you get a stack trace and segmentation
+ fault).
+## Development
-#### Rolling a release
-Say we want to release "1.1000.0" next. We first run `php tools/make-release.php 1.1000.0`. This will update the version
-numbers and pre-populate the changelog with the latest git commits between the previous version and now. It will prompt
-you to edit the changelog in between. Once the release is done it tells you what to do next.
-Run `php tools/make-dev.php 1.1000.1` to bring master back into development mode afterwards.
+See [DEVELOPMENT.md](DEVELOPMENT.md) for details.
diff --git a/UPGRADING.md b/UPGRADING.md
new file mode 100644
index 00000000..41c2ce39
--- /dev/null
+++ b/UPGRADING.md
@@ -0,0 +1,567 @@
+# Breaking changes in 2.0.0
+
+## `AMQPBasicProperties` breaking changes
+
+### Public method type changes
+
+```diff
+ __construct(
+- string $content_type = '',
++ ?string $contentType = null,
+- string $content_encoding = '',
++ ?string $contentEncoding = null,
+ array $headers = [],
+- int $delivery_mode = 2,
++ int $deliveryMode = 1,
+ int $priority = 0,
+- string $correlation_id = '',
++ ?string $correlationId = null,
+- string $reply_to = '',
++ ?string $replyTo = null,
+- string $expiration = '',
++ ?string $expiration = null,
+- string $message_id = '',
++ ?string $messageId = null,
+- int $timestamp = 0,
++ ?int $timestamp = null,
+- string $type = '',
++ ?string $type = null,
+- string $user_id = '',
++ ?string $userId = null,
+- string $app_id = '',
++ ?string $appId = null,
+- string $cluster_id = ''
++ ?string $clusterId = null
+ )
+```
+```diff
+- getContentType(): string
++ getContentType(): ?string
+
+```
+```diff
+- getContentEncoding(): string
++ getContentEncoding(): ?string
+
+```
+```diff
+- getCorrelationId(): string
++ getCorrelationId(): ?string
+
+```
+```diff
+- getReplyTo(): string
++ getReplyTo(): ?string
+
+```
+```diff
+- getExpiration(): string
++ getExpiration(): ?string
+
+```
+```diff
+- getMessageId(): string
++ getMessageId(): ?string
+
+```
+```diff
+- getTimestamp(): string
++ getTimestamp(): ?int
+
+```
+```diff
+- getType(): string
++ getType(): ?string
+
+```
+```diff
+- getUserId(): string
++ getUserId(): ?string
+
+```
+```diff
+- getAppId(): string
++ getAppId(): ?string
+
+```
+```diff
+- getClusterId(): string
++ getClusterId(): ?string
+
+```
+
+## `AMQPChannel` breaking changes
+
+### Public method type changes
+
+```diff
+- commitTransaction(): bool
++ commitTransaction(): void
+
+```
+```diff
+- qos(int $size, int $count, bool $global): bool
++ qos(int $size, int $count, bool $global = false): void
+
+```
+```diff
+- rollbackTransaction(): bool
++ rollbackTransaction(): void
+
+```
+```diff
+- setPrefetchCount(int $count): bool
++ setPrefetchCount(int $count): void
+
+```
+```diff
+- setPrefetchSize(int $size): bool
++ setPrefetchSize(int $size): void
+
+```
+```diff
+- setGlobalPrefetchCount(int $count): bool
++ setGlobalPrefetchCount(int $count): void
+
+```
+```diff
+- setGlobalPrefetchSize(int $size): bool
++ setGlobalPrefetchSize(int $size): void
+
+```
+```diff
+- startTransaction(): bool
++ startTransaction(): void
+
+```
+```diff
+- setConfirmCallback(?callable $ack_callback = null, ?callable $nack_callback = null): void
++ setConfirmCallback(?callable $ackCallback, ?callable $nackCallback = null): void
+
+```
+```diff
+- setReturnCallback(?callable $return_callback = null): void
++ setReturnCallback(?callable $returnCallback): void
+
+```
+
+### Parameter name changes
+
+```diff
+- __construct(AMQPConnection $amqp_connection)
++ __construct(AMQPConnection $connection)
+
+```
+
+
+## `AMQPConnection` breaking changes
+
+### Change in semantics
+
+* `connect()`, `pconnect()`, `disconnect()`, `set*()` etc. no longer return true or throw an exception but instead are void and throw
+
+### Public method additions
+
+ * `getConnectTimeout(): float`
+ * `setConnectionName(?string $connectionName): void`
+ * `getConnectionName(): ?string`
+
+### Public method type changes
+
+```diff
+- connect(): bool
++ connect(): void
+
+```
+```diff
+- disconnect(): bool
++ disconnect(): void
+
+```
+```diff
+- pconnect(): bool
++ pconnect(): void
+
+```
+```diff
+- pdisconnect(): bool
++ pdisconnect(): void
+
+```
+```diff
+- reconnect(): bool
++ reconnect(): void
+
+```
+```diff
+- preconnect(): bool
++ preconnect(): void
+
+```
+```diff
+- setHost(string $host): bool
++ setHost(string $host): void
+
+```
+```diff
+- setLogin(string $login): bool
++ setLogin(string $login): void
+
+```
+```diff
+- setPassword(string $password): bool
++ setPassword(string $password): void
+
+```
+```diff
+- setPort(int $port): bool
++ setPort(int $port): void
+
+```
+```diff
+- setVhost(string $vhost): bool
++ setVhost(string $vhost): void
+
+```
+```diff
+- setTimeout(float $timeout): bool
++ setTimeout(float $timeout): void
+
+```
+```diff
+- setReadTimeout(float $timeout): bool
++ setReadTimeout(float $timeout): void
+
+```
+```diff
+- setWriteTimeout(float $timeout): bool
++ setWriteTimeout(float $timeout): void
+
+```
+```diff
+- setRpcTimeout(float $timeout): bool
++ setRpcTimeout(float $timeout): void
+
+```
+```diff
+- getCACert(): string
++ getCACert(): ?string
+
+```
+```diff
+- setCACert(string $cacert): void
++ setCACert(?string $cacert): void
+
+```
+```diff
+- getCert(): string
++ getCert(): ?string
+
+```
+```diff
+- setCert(string $cert): void
++ setCert(?string $cert): void
+
+```
+```diff
+- getKey(): string
++ getKey(): ?string
+
+```
+```diff
+- setKey(string $key): void
++ setKey(?string $key): void
+
+```
+
+### Parameter name changes
+
+```diff
+- setSaslMethod(int $method): void
++ setSaslMethod(int $saslMethod): void
+
+```
+
+
+## `AMQPDecimal` breaking changes
+
+### Public method type changes
+
+```diff
+- __construct(unknown $exponent, unknown $significand)
++ __construct(int $exponent, int $significand)
+
+```
+
+## `AMQPEnvelope` breaking changes
+
+### Public method type changes
+
+```diff
+- getConsumerTag(): string
++ getConsumerTag(): ?string
+
+```
+```diff
+- getDeliveryTag(): string
++ getDeliveryTag(): ?int
+
+```
+```diff
+- getExchangeName(): string
++ getExchangeName(): ?string
+
+```
+```diff
+- getHeader(string $header_key): bool|string
++ getHeader(string $headerName): ?string
+
+```
+
+### Parameter name changes
+
+```diff
+- hasHeader(string $header_key): bool
++ hasHeader(string $headerName): bool
+
+```
+
+
+## `AMQPEnvelopeException` breaking changes
+
+### Public method additions
+
+ * `getEnvelope(): AMQPEnvelope`
+
+## `AMQPExchange` breaking changes
+
+### Change in semantics
+
+* `declareExchange()`, `bind()` , etc. no longer return true or throw an exception but instead are void and throw
+* `setArgument(string $argumentName, null)` no longer unsets the argument `$key` but sets it to `null` instead. To remove an argument use `removeArgument(string $argumentName)` instead
+* `getArgument(string $argumentName)` now throws an `AMQPExchangeException` if the argument does not exist. It returned false previously
+
+### Public method additions
+
+* `declare(): void`
+* `removeArgument(string $argumentName): void`
+
+### Public method type changes
+
+```diff
+- bind(string $exchange_name, string $routing_key = '', array $arguments = []): bool
++ bind(string $exchangeName, ?string $routingKey = null, array $arguments = []): void
+
+```
+```diff
+- unbind(string $exchange_name, string $routing_key = '', array $arguments = []): bool
++ unbind(string $exchangeName, ?string $routingKey = null, array $arguments = []): void
+
+```
+```diff
+- declareExchange(): bool
++ declareExchange(): void
+
+```
+```diff
+- delete(string $exchangeName = null, int $flags = 0): bool
++ delete(?string $exchangeName = null, ?int $flags = null): void
+
+```
+```diff
+- getArgument(string $key): bool|int|string
++ getArgument(string $argumentName): bool|float|int|string|null
+
+```
+```diff
+- getName(): string
++ getName(): ?string
+
+```
+```diff
+- getType(): string
++ getType(): ?string
+
+```
+```diff
+- publish(string $message, string $routing_key = null, int $flags = 0, array $attributes = []): bool
++ publish(string $message, ?string $routingKey = null, ?int $flags = null, array $headers = []): void
+
+```
+```diff
+- setArgument(string $key, int|string $value): bool
++ setArgument(string $argumentName, bool|float|int|string|null $argumentValue): void
+
+```
+```diff
+- setArguments(array $arguments): bool
++ setArguments(array $arguments): void
+
+```
+```diff
+- setName(string $exchange_name): void
++ setName(?string $exchangeName): void
+
+```
+```diff
+- setType(string $exchange_type): void
++ setType(?string $exchangeType): void
+
+```
+
+### Parameter name changes
+
+```diff
+- __construct(AMQPChannel $amqp_channel)
++ __construct(AMQPChannel $channel)
+
+```
+
+```diff
+- hasArgument(string $key): bool
++ hasArgument(string $argumentName): bool
+
+```
+
+
+## `AMQPQueue` breaking changes
+
+### Change in semantics
+
+* `declareQueue`, `ack()`, `nack()`, `bind()`, etc. etc. methods no longer return true or throw an exception but instead are void and throw
+* `get()` now either return null instead of false if no message was received
+* `setArgument(string $key, null)` no longer unsets the argument `$key` but sets it to `null` instead. To remove an argument use `removeArgument(string $key)` instead
+* `getArgument(string $argumentName)` now throws an `AMQPQueueException` if the argument does not exist. It returned false previously
+
+### Public method additions
+
+* `declare(): int`
+* `removeArgument(string $argumentName): void`
+
+### Public method type changes
+
+```diff
+- ack(string $delivery_tag, int $flags = 0): bool
++ ack(int $deliveryTag, ?int $flags = null): void
+
+```
+```diff
+- bind(string $exchange_name, string $routing_key = null, array $arguments = []): bool
++ bind(string $exchangeName, ?string $routingKey = null, array $arguments = []): void
+
+```
+```diff
+- cancel(string $consumer_tag = ''): bool
++ cancel(string $consumerTag = ''): void
+
+```
+```diff
+- consume(?callable $callback = null, int $flags = 0, string $consumerTag = null): void
++ consume(?callable $callback = null, ?int $flags = null, ?string $consumerTag = null): void
+
+```
+```diff
+- delete(int $flags = 0): int
++ delete(?int $flags = null): int
+
+```
+```diff
+- get(int $flags = 0): AMQPEnvelope|bool
++ get(?int $flags = null): ?AMQPEnvelope
+
+```
+```diff
+- getArgument(string $key): bool|int|string
++ getArgument(string $argumentName): bool|float|int|string|null
+
+```
+```diff
+- getName(): string
++ getName(): ?string
+
+```
+```diff
+- nack(string $delivery_tag, int $flags = 0): bool
++ nack(int $deliveryTag, ?int $flags = null): void
+
+```
+```diff
+- reject(string $delivery_tag, int $flags = 0): bool
++ reject(int $deliveryTag, ?int $flags = null): void
+
+```
+```diff
+- purge(): bool
++ purge(): int
+
+```
+```diff
+- setArgument(string $key, mixed $value): bool
++ setArgument(string $argumentName, bool|float|int|string|null $argumentValue): void
+
+```
+```diff
+- setArguments(array $arguments): bool
++ setArguments(array $arguments): void
+
+```
+```diff
+- setFlags(int $flags): bool
++ setFlags(?int $flags): void
+
+```
+```diff
+- setName(string $queue_name): bool
++ setName(string $name): void
+
+```
+```diff
+- unbind(string $exchange_name, string $routing_key = null, array $arguments = []): bool
++ unbind(string $exchangeName, ?string $routingKey = null, array $arguments = []): void
+
+```
+
+### Parameter name changes
+
+```diff
+- __construct(AMQPChannel $amqp_channel)
++ __construct(AMQPChannel $channel)
+
+```
+
+```diff
+- hasArgument(string $key): bool
++ hasArgument(string $argumentName): bool
+
+```
+
+
+## `AMQPTimestamp` breaking changes
+
+### Public constant changes
+
+```diff
+- const MIN = '0'
++ const MIN = 0.0
+
+```
+
+```diff
+- const MAX = '18446744073709551616'
++ const MAX = 1.8446744073709552E+19
+
+```
+
+
+### Public method type changes
+
+```diff
+- __construct(string $timestamp)
++ __construct(float $timestamp)
+
+```
+```diff
+- getTimestamp(): string
++ getTimestamp(): float
+
+```
diff --git a/Vagrantfile b/Vagrantfile
deleted file mode 100644
index 9339fa78..00000000
--- a/Vagrantfile
+++ /dev/null
@@ -1,128 +0,0 @@
-# -*- mode: ruby -*-
-# vi: set ft=ruby :
-
-# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
-VAGRANTFILE_API_VERSION = "2"
-
-Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
- # All Vagrant configuration is done here. The most common configuration
- # options are documented and commented below. For a complete reference,
- # please see the online documentation at vagrantup.com.
-
- # Every Vagrant virtual environment requires a box to build off of.
-
- config.vm.box = "bento/ubuntu-16.04"
-
- # Disable automatic box update checking. If you disable this, then
- # boxes will only be checked for updates when the user runs
- # `vagrant box outdated`. This is not recommended.
- # config.vm.box_check_update = false
-
- # Create a forwarded port mapping which allows access to a specific port
- # within the machine from a port on the host machine. In the example below,
- # accessing "localhost:8080" will access port 80 on the guest machine.
- # config.vm.network "forwarded_port", guest: 80, host: 8080
-
- # Create a private network, which allows host-only access to the machine
- # using a specific IP.
- config.vm.network "private_network", ip: "192.168.33.10"
-
- # Create a public network, which generally matched to bridged network.
- # Bridged networks make the machine appear as another physical device on
- # your network.
- # config.vm.network "public_network"
-
- # If true, then any SSH connections made will enable agent forwarding.
- # Default value: false
- # config.ssh.forward_agent = true
-
- # Share an additional folder to the guest VM. The first argument is
- # the path on the host to the actual folder. The second argument is
- # the path on the guest to mount the folder. And the optional third
- # argument is a set of non-required options.
- # config.vm.synced_folder "../data", "/vagrant_data"
-
- # Provider-specific configuration so you can fine-tune various
- # backing providers for Vagrant. These expose provider-specific options.
- # Example for VirtualBox:
- #
- config.vm.provider "virtualbox" do |vb|
- # Don't boot with headless mode
- # vb.gui = true
-
- # Use VBoxManage to customize the VM. For example to change memory:
- vb.customize ["modifyvm", :id, "--memory", "2048"]
- end
- #
- # View the documentation for the provider you're using for more
- # information on available options.
-
- # Enable provisioning with CFEngine. CFEngine Community packages are
- # automatically installed. For example, configure the host as a
- # policy server and optionally a policy file to run:
- #
- # config.vm.provision "cfengine" do |cf|
- # cf.am_policy_hub = true
- # # cf.run_file = "motd.cf"
- # end
- #
- # You can also configure and bootstrap a client to an existing
- # policy server:
- #
- # config.vm.provision "cfengine" do |cf|
- # cf.policy_server_address = "10.0.2.15"
- # end
-
- # Enable provisioning with Puppet stand alone. Puppet manifests
- # are contained in a directory path relative to this Vagrantfile.
- # You will need to create the manifests directory and a manifest in
- # the file default.pp in the manifests_path directory.
- #
- # config.vm.provision "puppet" do |puppet|
- # puppet.manifests_path = "manifests"
- # puppet.manifest_file = "default.pp"
- # end
-
- # Enable provisioning with chef solo, specifying a cookbooks path, roles
- # path, and data_bags path (all relative to this Vagrantfile), and adding
- # some recipes and/or roles.
- #
- # config.vm.provision "chef_solo" do |chef|
- # chef.cookbooks_path = "../my-recipes/cookbooks"
- # chef.roles_path = "../my-recipes/roles"
- # chef.data_bags_path = "../my-recipes/data_bags"
- # chef.add_recipe "mysql"
- # chef.add_role "web"
- #
- # # You may also specify custom JSON attributes:
- # chef.json = { mysql_password: "foo" }
- # end
-
- # Enable provisioning with chef server, specifying the chef server URL,
- # and the path to the validation key (relative to this Vagrantfile).
- #
- # The Opscode Platform uses HTTPS. Substitute your organization for
- # ORGNAME in the URL and validation key.
- #
- # If you have your own Chef Server, use the appropriate URL, which may be
- # HTTP instead of HTTPS depending on your configuration. Also change the
- # validation key to validation.pem.
- #
- # config.vm.provision "chef_client" do |chef|
- # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
- # chef.validation_key_path = "ORGNAME-validator.pem"
- # end
- #
- # If you're using the Opscode platform, your validator client is
- # ORGNAME-validator, replacing ORGNAME with your organization name.
- #
- # If you have your own Chef Server, the default validation client name is
- # chef-validator, unless you changed the configuration.
- #
- # chef.validation_client_name = "ORGNAME-validator"
-
- config.vm.synced_folder ".", "/home/vagrant/php-amqp"
- #config.vm.synced_folder "../rabbitmq-c", "/home/vagrant/rabbitmq-c"
-
- config.vm.provision "shell", path: './provision/provision.sh', privileged: false
-end
diff --git a/amqp.c b/amqp.c
index 37393bf7..b22809c1 100644
--- a/amqp.c
+++ b/amqp.c
@@ -21,7 +21,7 @@
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
@@ -31,18 +31,24 @@
#include "zend_exceptions.h"
#ifdef PHP_WIN32
-# if PHP_VERSION_ID >= 80000
-# include "main/php_stdint.h"
-# else
-# include "win32/php_stdint.h"
-# endif
-# include "win32/signal.h"
+ #if PHP_VERSION_ID >= 80000
+ #include
+ #else
+ #include "win32/php_stdint.h"
+ #endif
+ #include "win32/signal.h"
#else
-# include
-# include
+ #include
+ #include
+#endif
+
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+ #include
+#else
+ #include
+ #include
#endif
-#include
-#include
#include "php_amqp.h"
#include "amqp_connection.h"
@@ -50,308 +56,500 @@
#include "amqp_connection_resource.h"
#include "amqp_channel.h"
#include "amqp_envelope.h"
+#include "amqp_envelope_exception.h"
#include "amqp_exchange.h"
#include "amqp_queue.h"
+#include "amqp_value.h"
#include "amqp_timestamp.h"
#include "amqp_decimal.h"
#ifdef PHP_WIN32
-# include "win32/unistd.h"
+ #include "win32/unistd.h"
#else
-# include
+ #include
#endif
/* True global resources - no need for thread safety here */
-
-zend_class_entry *amqp_exception_class_entry,
- *amqp_connection_exception_class_entry,
- *amqp_channel_exception_class_entry,
- *amqp_queue_exception_class_entry,
- *amqp_exchange_exception_class_entry,
- *amqp_envelope_exception_class_entry,
- *amqp_value_exception_class_entry;
+zend_class_entry *amqp_exception_class_entry, *amqp_connection_exception_class_entry,
+ *amqp_channel_exception_class_entry, *amqp_exchange_exception_class_entry, *amqp_queue_exception_class_entry,
+ *amqp_value_exception_class_entry;
/* {{{ amqp_functions[]
*
*Every user visible function must have an entry in amqp_functions[].
*/
zend_function_entry amqp_functions[] = {
- {NULL, NULL, NULL}
+ {NULL, NULL, NULL}
};
/* }}} */
-PHP_INI_BEGIN()
- PHP_INI_ENTRY("amqp.host", DEFAULT_HOST, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.vhost", DEFAULT_VHOST, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.port", DEFAULT_PORT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.timeout", DEFAULT_TIMEOUT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.read_timeout", DEFAULT_READ_TIMEOUT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.write_timeout", DEFAULT_WRITE_TIMEOUT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.connect_timeout", DEFAULT_CONNECT_TIMEOUT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.rpc_timeout", DEFAULT_RPC_TIMEOUT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.login", DEFAULT_LOGIN, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.password", DEFAULT_PASSWORD, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.auto_ack", DEFAULT_AUTOACK, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.prefetch_count", DEFAULT_PREFETCH_COUNT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.prefetch_size", DEFAULT_PREFETCH_SIZE, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.global_prefetch_count", DEFAULT_GLOBAL_PREFETCH_COUNT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.global_prefetch_size", DEFAULT_GLOBAL_PREFETCH_SIZE, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.channel_max", DEFAULT_CHANNEL_MAX, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.frame_max", DEFAULT_FRAME_MAX, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.heartbeat", DEFAULT_HEARTBEAT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.cacert", DEFAULT_CACERT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.capath", DEFAULT_CAPATH, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.use_default_cacert", DEFAULT_USE_DEFAULT_CACERT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.use_default_capath", DEFAULT_USE_DEFAULT_CAPATH, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.cert", DEFAULT_CERT, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.key", DEFAULT_KEY, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.verify", DEFAULT_VERIFY, PHP_INI_ALL, NULL)
- PHP_INI_ENTRY("amqp.sasl_method", DEFAULT_SASL_METHOD, PHP_INI_ALL, NULL)
-PHP_INI_END()
+bool php_amqp_is_valid_identifier(zend_string *val)
+{
+ return ZSTR_LEN(val) > 0 && ZSTR_LEN(val) <= PHP_AMQP_MAX_IDENTIFIER_LENGTH;
+}
-ZEND_DECLARE_MODULE_GLOBALS(amqp);
+bool php_amqp_is_valid_credential(zend_string *val)
+{
+ return ZSTR_LEN(val) > 0 && ZSTR_LEN(val) <= PHP_AMQP_MAX_CREDENTIALS_LENGTH;
+}
-static PHP_GINIT_FUNCTION(amqp) /* {{{ */
+bool php_amqp_is_valid_port(zend_long val) { return val >= PHP_AMQP_MIN_PORT && val <= PHP_AMQP_MAX_PORT; }
+
+bool php_amqp_is_valid_timeout(double timeout) { return timeout >= 0; }
+
+bool php_amqp_is_valid_channel_max(zend_long val) { return val > 0 && val <= PHP_AMQP_DEFAULT_CHANNEL_MAX; }
+
+bool php_amqp_is_valid_frame_size_max(zend_long val) { return val > 0 && val <= PHP_AMQP_MAX_FRAME_SIZE; }
+
+bool php_amqp_is_valid_heartbeat(zend_long val) { return val >= 0 && val <= PHP_AMQP_MAX_HEARTBEAT; }
+
+bool php_amqp_is_valid_prefetch_size(zend_long val) { return val >= 0 && val <= PHP_AMQP_MAX_PREFETCH_SIZE; }
+
+bool php_amqp_is_valid_prefetch_count(zend_long val) { return val >= 0 && val <= PHP_AMQP_MAX_PREFETCH_COUNT; }
+
+static ZEND_INI_MH(onUpdateIdentifier)
{
- amqp_globals->error_message = NULL;
- amqp_globals->error_code = 0;
-} /* }}} */
+ if (new_value != NULL && !php_amqp_is_valid_identifier(new_value)) {
+ return FAILURE;
+ }
-static PHP_MINIT_FUNCTION(amqp) /* {{{ */
+ return SUCCESS;
+}
+
+static ZEND_INI_MH(onUpdateCredentials)
+{
+ if (new_value != NULL && !php_amqp_is_valid_credential(new_value)) {
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+static ZEND_INI_MH(onUpdatePort)
+{
+ zend_long val = zend_ini_parse_quantity_warn(new_value, entry->name);
+ if (!php_amqp_is_valid_port(val)) {
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+static ZEND_INI_MH(onUpdateTimeout)
+{
+ if (!php_amqp_is_valid_timeout(zend_strtod(ZSTR_VAL(new_value), NULL))) {
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+static ZEND_INI_MH(onUpdateChannelMax)
+{
+ zend_long val = zend_ini_parse_quantity_warn(new_value, entry->name);
+ if (!php_amqp_is_valid_channel_max(val)) {
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+static ZEND_INI_MH(onUpdateFrameSizeMax)
+{
+ zend_long val = zend_ini_parse_quantity_warn(new_value, entry->name);
+ if (!php_amqp_is_valid_frame_size_max(val)) {
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+static ZEND_INI_MH(onUpdateHeartbeat)
+{
+ zend_long val = zend_ini_parse_quantity_warn(new_value, entry->name);
+ if (!php_amqp_is_valid_heartbeat(val)) {
+ return FAILURE;
+ }
+
+ return SUCCESS;
+}
+
+static ZEND_INI_MH(onUpdatePrefetchCount)
{
- zend_class_entry ce;
+ zend_long val = zend_ini_parse_quantity_warn(new_value, entry->name);
+ if (!php_amqp_is_valid_prefetch_count(val)) {
+ return FAILURE;
+ }
- /* Set up the connection resource */
- le_amqp_connection_resource = zend_register_list_destructors_ex(amqp_connection_resource_dtor, NULL, PHP_AMQP_CONNECTION_RES_NAME, module_number);
- le_amqp_connection_resource_persistent = zend_register_list_destructors_ex(NULL, amqp_connection_resource_dtor_persistent, PHP_AMQP_CONNECTION_RES_NAME, module_number);
+ return SUCCESS;
+}
- PHP_MINIT(amqp_connection)(INIT_FUNC_ARGS_PASSTHRU);
- PHP_MINIT(amqp_channel)(INIT_FUNC_ARGS_PASSTHRU);
- PHP_MINIT(amqp_queue)(INIT_FUNC_ARGS_PASSTHRU);
- PHP_MINIT(amqp_exchange)(INIT_FUNC_ARGS_PASSTHRU);
- PHP_MINIT(amqp_basic_properties)(INIT_FUNC_ARGS_PASSTHRU);
- PHP_MINIT(amqp_envelope)(INIT_FUNC_ARGS_PASSTHRU);
- PHP_MINIT(amqp_timestamp)(INIT_FUNC_ARGS_PASSTHRU);
- PHP_MINIT(amqp_decimal)(INIT_FUNC_ARGS_PASSTHRU);
+static ZEND_INI_MH(onUpdatePrefetchSize)
+{
+ zend_long val = zend_ini_parse_quantity_warn(new_value, entry->name);
+ if (!php_amqp_is_valid_prefetch_size(val)) {
+ return FAILURE;
+ }
- /* Class Exceptions */
- INIT_CLASS_ENTRY(ce, "AMQPException", NULL);
- amqp_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, zend_exception_get_default(TSRMLS_C));
+ return SUCCESS;
+}
- INIT_CLASS_ENTRY(ce, "AMQPConnectionException", NULL);
- amqp_connection_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+PHP_INI_BEGIN()
+ PHP_INI_ENTRY("amqp.host", DEFAULT_HOST, PHP_INI_ALL, onUpdateIdentifier)
+ PHP_INI_ENTRY("amqp.vhost", DEFAULT_VHOST, PHP_INI_ALL, onUpdateIdentifier)
+ PHP_INI_ENTRY("amqp.port", DEFAULT_PORT, PHP_INI_ALL, onUpdatePort)
+ PHP_INI_ENTRY("amqp.timeout", DEFAULT_TIMEOUT, PHP_INI_ALL, onUpdateTimeout)
+ PHP_INI_ENTRY("amqp.read_timeout", DEFAULT_READ_TIMEOUT, PHP_INI_ALL, onUpdateTimeout)
+ PHP_INI_ENTRY("amqp.write_timeout", DEFAULT_WRITE_TIMEOUT, PHP_INI_ALL, onUpdateTimeout)
+ PHP_INI_ENTRY("amqp.connect_timeout", DEFAULT_CONNECT_TIMEOUT, PHP_INI_ALL, onUpdateTimeout)
+ PHP_INI_ENTRY("amqp.rpc_timeout", DEFAULT_RPC_TIMEOUT, PHP_INI_ALL, onUpdateTimeout)
+ PHP_INI_ENTRY("amqp.login", DEFAULT_LOGIN, PHP_INI_ALL, onUpdateCredentials)
+ PHP_INI_ENTRY("amqp.password", DEFAULT_PASSWORD, PHP_INI_ALL, onUpdateCredentials)
+ PHP_INI_ENTRY("amqp.auto_ack", DEFAULT_AUTOACK, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.prefetch_count", DEFAULT_PREFETCH_COUNT, PHP_INI_ALL, onUpdatePrefetchCount)
+ PHP_INI_ENTRY("amqp.prefetch_size", DEFAULT_PREFETCH_SIZE, PHP_INI_ALL, onUpdatePrefetchSize)
+ PHP_INI_ENTRY("amqp.global_prefetch_count", DEFAULT_GLOBAL_PREFETCH_COUNT, PHP_INI_ALL, onUpdatePrefetchCount)
+ PHP_INI_ENTRY("amqp.global_prefetch_size", DEFAULT_GLOBAL_PREFETCH_SIZE, PHP_INI_ALL, onUpdatePrefetchSize)
+ PHP_INI_ENTRY("amqp.channel_max", DEFAULT_CHANNEL_MAX, PHP_INI_ALL, onUpdateChannelMax)
+ PHP_INI_ENTRY("amqp.frame_max", DEFAULT_FRAME_MAX, PHP_INI_ALL, onUpdateFrameSizeMax)
+ PHP_INI_ENTRY("amqp.heartbeat", DEFAULT_HEARTBEAT, PHP_INI_ALL, onUpdateHeartbeat)
+ PHP_INI_ENTRY("amqp.cacert", DEFAULT_CACERT, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.capath", DEFAULT_CAPATH, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.use_default_cacert", DEFAULT_USE_DEFAULT_CACERT, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.use_default_capath", DEFAULT_USE_DEFAULT_CAPATH, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.cert", DEFAULT_CERT, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.key", DEFAULT_KEY, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.verify", DEFAULT_VERIFY, PHP_INI_ALL, NULL)
+ PHP_INI_ENTRY("amqp.sasl_method", PHP_AMQP_STRINGIFY(DEFAULT_SASL_METHOD), PHP_INI_ALL, NULL)
+ STD_PHP_INI_ENTRY(
+ "amqp.serialization_depth",
+ DEFAULT_SERIALIZATION_DEPTH,
+ PHP_INI_ALL,
+ OnUpdateLongGEZero,
+ serialization_depth,
+ zend_amqp_globals,
+ amqp_globals
+ )
+ STD_PHP_INI_ENTRY(
+ "amqp.deserialization_depth",
+ DEFAULT_SERIALIZATION_DEPTH,
+ PHP_INI_ALL,
+ OnUpdateLongGEZero,
+ deserialization_depth,
+ zend_amqp_globals,
+ amqp_globals
+ )
+PHP_INI_END()
- INIT_CLASS_ENTRY(ce, "AMQPChannelException", NULL);
- amqp_channel_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+ZEND_DECLARE_MODULE_GLOBALS(amqp)
- INIT_CLASS_ENTRY(ce, "AMQPQueueException", NULL);
- amqp_queue_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+static PHP_GINIT_FUNCTION(amqp) /* {{{ */
+{
+#if defined(COMPILE_DL_AMQP) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
- INIT_CLASS_ENTRY(ce, "AMQPEnvelopeException", NULL);
- amqp_envelope_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
- zend_declare_property_null(amqp_envelope_exception_class_entry, ZEND_STRL("envelope"), ZEND_ACC_PUBLIC TSRMLS_CC);
+ memset(amqp_globals, 0, sizeof(*amqp_globals));
- INIT_CLASS_ENTRY(ce, "AMQPExchangeException", NULL);
- amqp_exchange_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+ amqp_globals->error_message = NULL;
+ amqp_globals->error_code = 0;
+} /* }}} */
- INIT_CLASS_ENTRY(ce, "AMQPValueException", NULL);
- amqp_value_exception_class_entry = PHP5to7_zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+static PHP_MINIT_FUNCTION(amqp) /* {{{ */
+{
+#if defined(COMPILE_DL_AMQP) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
- REGISTER_INI_ENTRIES();
+ zend_class_entry ce;
+
+ /* Set up the connection resource */
+ le_amqp_connection_resource = zend_register_list_destructors_ex(
+ amqp_connection_resource_dtor,
+ NULL,
+ PHP_AMQP_CONNECTION_RES_NAME,
+ module_number
+ );
+ le_amqp_connection_resource_persistent = zend_register_list_destructors_ex(
+ NULL,
+ amqp_connection_resource_dtor_persistent,
+ PHP_AMQP_CONNECTION_RES_NAME,
+ module_number
+ );
+
+ /* Exceptions */
+ INIT_CLASS_ENTRY(ce, "AMQPException", NULL);
+ amqp_exception_class_entry = zend_register_internal_class_ex(&ce, zend_ce_exception);
+
+ INIT_CLASS_ENTRY(ce, "AMQPConnectionException", NULL);
+ amqp_connection_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+
+ INIT_CLASS_ENTRY(ce, "AMQPChannelException", NULL);
+ amqp_channel_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+
+ INIT_CLASS_ENTRY(ce, "AMQPQueueException", NULL);
+ amqp_queue_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+
+ INIT_CLASS_ENTRY(ce, "AMQPExchangeException", NULL);
+ amqp_exchange_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+
+ INIT_CLASS_ENTRY(ce, "AMQPValueException", NULL);
+ amqp_value_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+
+ PHP_MINIT(amqp_connection)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(amqp_channel)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(amqp_queue)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(amqp_exchange)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(amqp_basic_properties)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(amqp_envelope)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(amqp_envelope_exception)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(amqp_value)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(amqp_timestamp)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(amqp_decimal)(INIT_FUNC_ARGS_PASSTHRU);
+
+ REGISTER_INI_ENTRIES();
REGISTER_LONG_CONSTANT("AMQP_TOCHKA_EXTENSION", AMQP_TOCHKA_EXTENSION, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_NOPARAM", AMQP_NOPARAM, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_JUST_CONSUME", AMQP_JUST_CONSUME, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_DURABLE", AMQP_DURABLE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_PASSIVE", AMQP_PASSIVE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_EXCLUSIVE", AMQP_EXCLUSIVE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_AUTODELETE", AMQP_AUTODELETE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_INTERNAL", AMQP_INTERNAL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_NOLOCAL", AMQP_NOLOCAL, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_AUTOACK", AMQP_AUTOACK, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_IFEMPTY", AMQP_IFEMPTY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_IFUNUSED", AMQP_IFUNUSED, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_MANDATORY", AMQP_MANDATORY, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_IMMEDIATE", AMQP_IMMEDIATE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_MULTIPLE", AMQP_MULTIPLE, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_NOWAIT", AMQP_NOWAIT, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_REQUEUE", AMQP_REQUEUE, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_DIRECT", AMQP_EX_TYPE_DIRECT, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_FANOUT", AMQP_EX_TYPE_FANOUT, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_TOPIC", AMQP_EX_TYPE_TOPIC, CONST_CS | CONST_PERSISTENT);
- REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_HEADERS",AMQP_EX_TYPE_HEADERS, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("AMQP_OS_SOCKET_TIMEOUT_ERRNO", AMQP_OS_SOCKET_TIMEOUT_ERRNO, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("PHP_AMQP_MAX_CHANNELS", PHP_AMQP_MAX_CHANNELS, CONST_CS | CONST_PERSISTENT);
-
- REGISTER_LONG_CONSTANT("AMQP_SASL_METHOD_PLAIN", AMQP_SASL_METHOD_PLAIN, CONST_CS | CONST_PERSISTENT);
- REGISTER_LONG_CONSTANT("AMQP_SASL_METHOD_EXTERNAL", AMQP_SASL_METHOD_EXTERNAL, CONST_CS | CONST_PERSISTENT);
- return SUCCESS;
+ REGISTER_STRING_CONSTANT("AMQP_EXTENSION_VERSION", PHP_AMQP_VERSION, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_EXTENSION_VERSION_MAJOR", PHP_AMQP_VERSION_MAJOR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_EXTENSION_VERSION_MINOR", PHP_AMQP_VERSION_MINOR, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_EXTENSION_VERSION_PATCH", PHP_AMQP_VERSION_PATCH, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("AMQP_EXTENSION_VERSION_EXTRA", PHP_AMQP_VERSION_EXTRA, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_EXTENSION_VERSION_ID", PHP_AMQP_VERSION_ID, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("AMQP_NOPARAM", AMQP_NOPARAM, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_JUST_CONSUME", AMQP_JUST_CONSUME, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_DURABLE", AMQP_DURABLE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_PASSIVE", AMQP_PASSIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_EXCLUSIVE", AMQP_EXCLUSIVE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_AUTODELETE", AMQP_AUTODELETE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_INTERNAL", AMQP_INTERNAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_NOLOCAL", AMQP_NOLOCAL, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_AUTOACK", AMQP_AUTOACK, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_IFEMPTY", AMQP_IFEMPTY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_IFUNUSED", AMQP_IFUNUSED, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_MANDATORY", AMQP_MANDATORY, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_IMMEDIATE", AMQP_IMMEDIATE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_MULTIPLE", AMQP_MULTIPLE, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_NOWAIT", AMQP_NOWAIT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_REQUEUE", AMQP_REQUEUE, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_DIRECT", AMQP_EX_TYPE_DIRECT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_FANOUT", AMQP_EX_TYPE_FANOUT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_TOPIC", AMQP_EX_TYPE_TOPIC, CONST_CS | CONST_PERSISTENT);
+ REGISTER_STRING_CONSTANT("AMQP_EX_TYPE_HEADERS", AMQP_EX_TYPE_HEADERS, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("AMQP_OS_SOCKET_TIMEOUT_ERRNO", AMQP_OS_SOCKET_TIMEOUT_ERRNO, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("PHP_AMQP_MAX_CHANNELS", PHP_AMQP_MAX_CHANNELS, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("AMQP_SASL_METHOD_PLAIN", AMQP_SASL_METHOD_PLAIN, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_SASL_METHOD_EXTERNAL", AMQP_SASL_METHOD_EXTERNAL, CONST_CS | CONST_PERSISTENT);
+
+ REGISTER_LONG_CONSTANT("AMQP_DELIVERY_MODE_TRANSIENT", AMQP_DELIVERY_NONPERSISTENT, CONST_CS | CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("AMQP_DELIVERY_MODE_PERSISTENT", AMQP_DELIVERY_PERSISTENT, CONST_CS | CONST_PERSISTENT);
+
+ return SUCCESS;
} /* }}} */
static PHP_MSHUTDOWN_FUNCTION(amqp) /* {{{ */
{
- UNREGISTER_INI_ENTRIES();
+ UNREGISTER_INI_ENTRIES();
- return SUCCESS;
+ return SUCCESS;
} /* }}} */
static PHP_RSHUTDOWN_FUNCTION(amqp) /* {{{ */
{
- if (NULL != PHP_AMQP_G(error_message)) {
- efree(PHP_AMQP_G(error_message));
- PHP_AMQP_G(error_message) = NULL;
- }
+ if (NULL != PHP_AMQP_G(error_message)) {
+ efree(PHP_AMQP_G(error_message));
+ PHP_AMQP_G(error_message) = NULL;
+ }
- PHP_AMQP_G(error_code) = 0;
+ PHP_AMQP_G(error_code) = 0;
- return SUCCESS;
+ return SUCCESS;
} /* }}} */
static PHP_MINFO_FUNCTION(amqp) /* {{{ */
{
- php_info_print_table_start();
- php_info_print_table_header(2, "Version", PHP_AMQP_VERSION);
- php_info_print_table_header(2, "Revision", PHP_AMQP_REVISION);
- php_info_print_table_header(2, "Compiled", __DATE__ " @ " __TIME__);
- php_info_print_table_header(2, "AMQP protocol version", "0-9-1");
- php_info_print_table_header(2, "librabbitmq version", amqp_version());
- php_info_print_table_header(2, "Default max channels per connection", DEFAULT_CHANNEL_MAX);
- php_info_print_table_header(2, "Default max frame size", DEFAULT_FRAME_MAX);
- php_info_print_table_header(2, "Default heartbeats interval", DEFAULT_HEARTBEAT);
- DISPLAY_INI_ENTRIES();
+ php_info_print_table_start();
+ php_info_print_table_header(2, "Version", PHP_AMQP_VERSION);
+ php_info_print_table_header(2, "Compiled", __DATE__ " @ " __TIME__);
+ php_info_print_table_header(2, "AMQP protocol version", "0-9-1");
+ php_info_print_table_header(2, "librabbitmq version", amqp_version());
+ php_info_print_table_header(2, "Default max channels per connection", DEFAULT_CHANNEL_MAX);
+ php_info_print_table_header(2, "Default max frame size", DEFAULT_FRAME_MAX);
+ php_info_print_table_header(2, "Default heartbeats interval", DEFAULT_HEARTBEAT);
+ DISPLAY_INI_ENTRIES();
} /* }}} */
/* {{{ amqp_module_entry
*/
zend_module_entry amqp_module_entry = {
- STANDARD_MODULE_HEADER,
- "amqp",
- amqp_functions,
- PHP_MINIT(amqp),
- PHP_MSHUTDOWN(amqp),
- NULL,
- PHP_RSHUTDOWN(amqp),
- PHP_MINFO(amqp),
- PHP_AMQP_VERSION,
- PHP_MODULE_GLOBALS(amqp),
- PHP_GINIT(amqp),
- NULL,
- NULL,
- STANDARD_MODULE_PROPERTIES_EX
+ STANDARD_MODULE_HEADER,
+ "amqp",
+ amqp_functions,
+ PHP_MINIT(amqp),
+ PHP_MSHUTDOWN(amqp),
+ NULL,
+ PHP_RSHUTDOWN(amqp),
+ PHP_MINFO(amqp),
+ PHP_AMQP_VERSION,
+ PHP_MODULE_GLOBALS(amqp),
+ PHP_GINIT(amqp),
+ NULL,
+ NULL,
+ STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
#ifdef COMPILE_DL_AMQP
- ZEND_GET_MODULE(amqp)
+ZEND_GET_MODULE(amqp)
#endif
-int php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource TSRMLS_DC)
+int php_amqp_error(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *connection_resource,
+ amqp_channel_resource *channel_resource
+)
{
- return php_amqp_error_advanced(reply, message, connection_resource, channel_resource, 1 TSRMLS_CC);
+ return php_amqp_error_advanced(reply, message, connection_resource, channel_resource, 1);
}
-int php_amqp_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource, int fail_on_errors TSRMLS_DC)
+int php_amqp_error_advanced(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *connection_resource,
+ amqp_channel_resource *channel_resource,
+ int fail_on_errors
+)
{
- assert(connection_resource != NULL);
-
- PHP_AMQP_G(error_code) = 0;
- if (*message != NULL) {
- efree(*message);
- }
-
- int res = php_amqp_connection_resource_error(reply, message, connection_resource, (amqp_channel_t)(channel_resource ? channel_resource->channel_id : 0) TSRMLS_CC);
-
- switch (res) {
- case PHP_AMQP_RESOURCE_RESPONSE_OK:
- break;
- case PHP_AMQP_RESOURCE_RESPONSE_ERROR:
- if (!fail_on_errors) {
- break;
- }
- /* Library or other non-protocol or even protocol related errors may be here. */
- /* In most cases it designate some underlying hard errors. Fail fast. */
- case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED:
- /* Mark connection resource as closed to prevent sending any further requests */
- connection_resource->is_connected = '\0';
-
- /* Close connection with all its channels */
- php_amqp_disconnect_force(connection_resource TSRMLS_CC);
-
- break;
- case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED:
- /* Mark channel as closed to prevent sending channel.close request */
- assert(channel_resource != NULL);
- if (channel_resource) {
- channel_resource->is_connected = '\0';
-
- /* Close channel */
- php_amqp_close_channel(channel_resource, 1 TSRMLS_CC);
- }
- /* No more error handling necessary, returning. */
- break;
- default:
- spprintf(message, 0, "Unknown server error, method id 0x%08X (not handled by extension)", reply.reply.id);
- break;
- }
-
- return res;
+ assert(connection_resource != NULL);
+
+ PHP_AMQP_G(error_code) = 0;
+ if (*message != NULL) {
+ efree(*message);
+ }
+
+ int res = php_amqp_connection_resource_error(
+ reply,
+ message,
+ connection_resource,
+ (amqp_channel_t) (channel_resource ? channel_resource->channel_id : 0)
+ );
+
+ switch (res) {
+ case PHP_AMQP_RESOURCE_RESPONSE_OK:
+ break;
+ case PHP_AMQP_RESOURCE_RESPONSE_ERROR:
+ if (!fail_on_errors) {
+ break;
+ }
+ /* Library or other non-protocol or even protocol related errors may be here. */
+ /* In most cases it indicates some underlying hard errors. Fail fast. */
+ case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED:
+ /* Mark connection resource as closed to prevent sending any further requests */
+ connection_resource->is_connected = '\0';
+
+ /* Close connection with all its channels */
+ php_amqp_disconnect_force(connection_resource);
+
+ break;
+ case PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED:
+ /* Mark channel as closed to prevent sending channel.close request */
+ assert(channel_resource != NULL);
+ if (channel_resource) {
+ channel_resource->is_connected = '\0';
+
+ /* Close channel */
+ php_amqp_close_channel(channel_resource, 1);
+ }
+ /* No more error handling necessary, returning. */
+ break;
+ default:
+ spprintf(message, 0, "Unknown server error, method id 0x%08X (not handled by extension)", reply.reply.id);
+ break;
+ }
+
+ return res;
}
-void php_amqp_zend_throw_exception_short(amqp_rpc_reply_t reply, zend_class_entry *exception_ce TSRMLS_DC) {
- php_amqp_zend_throw_exception(reply, exception_ce, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
+void php_amqp_zend_throw_exception_short(amqp_rpc_reply_t reply, zend_class_entry *exception_ce)
+{
+ php_amqp_zend_throw_exception(reply, exception_ce, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code));
}
-void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, PHP5to7_param_long_type_t code TSRMLS_DC)
+void php_amqp_zend_throw_exception(
+ amqp_rpc_reply_t reply,
+ zend_class_entry *exception_ce,
+ const char *message,
+ zend_long code
+)
{
- switch (reply.reply_type) {
- case AMQP_RESPONSE_NORMAL:
- break;
- case AMQP_RESPONSE_NONE:
- exception_ce = amqp_exception_class_entry;
- break;
- case AMQP_RESPONSE_LIBRARY_EXCEPTION:
- exception_ce = amqp_exception_class_entry;
- break;
- case AMQP_RESPONSE_SERVER_EXCEPTION:
- switch (reply.reply.id) {
- case AMQP_CONNECTION_CLOSE_METHOD:
- /* Fatal errors - pass them to connection level */
- exception_ce = amqp_connection_exception_class_entry;
- break;
- case AMQP_CHANNEL_CLOSE_METHOD:
- /* Most channel-level errors occurs due to previously known action and thus their kind can be predicted. */
- /* exception_ce = amqp_channel_exception_class_entry; */
- break;
- }
- break;
- /* Default for the above switch should be handled by the below default. */
- default:
- exception_ce = amqp_exception_class_entry;
- break;
- }
-
- zend_throw_exception(exception_ce, message, code TSRMLS_CC);
+ switch (reply.reply_type) {
+ case AMQP_RESPONSE_NORMAL:
+ break;
+ case AMQP_RESPONSE_NONE:
+ exception_ce = amqp_exception_class_entry;
+ break;
+ case AMQP_RESPONSE_LIBRARY_EXCEPTION:
+ switch (reply.library_error) {
+ case AMQP_STATUS_BROKER_UNSUPPORTED_SASL_METHOD:
+ case AMQP_STATUS_CONNECTION_CLOSED:
+ case AMQP_STATUS_HOSTNAME_RESOLUTION_FAILED:
+ case AMQP_STATUS_SOCKET_ERROR:
+ case AMQP_STATUS_SOCKET_CLOSED:
+ case AMQP_STATUS_SOCKET_INUSE:
+ case AMQP_STATUS_SSL_CONNECTION_FAILED:
+ case AMQP_STATUS_SSL_ERROR:
+ case AMQP_STATUS_SSL_HOSTNAME_VERIFY_FAILED:
+ case AMQP_STATUS_SSL_PEER_VERIFY_FAILED:
+#if AMQP_VERSION >= AMQP_VERSION_CODE(0, 11, 0, 1)
+ case AMQP_STATUS_SSL_SET_ENGINE_FAILED:
+#endif
+#if AMQP_VERSION >= AMQP_VERSION_CODE(0, 14, 0, 1)
+ case AMQP_STATUS_SSL_UNIMPLEMENTED:
+#endif
+ case AMQP_STATUS_TCP_ERROR:
+ exception_ce = amqp_connection_exception_class_entry;
+ break;
+ default:
+ exception_ce = amqp_exception_class_entry;
+ }
+ break;
+ case AMQP_RESPONSE_SERVER_EXCEPTION:
+ switch (reply.reply.id) {
+ case AMQP_CONNECTION_CLOSE_METHOD:
+ /* Fatal errors - pass them to connection level */
+ exception_ce = amqp_connection_exception_class_entry;
+ break;
+ case AMQP_CHANNEL_CLOSE_METHOD:
+ /* Most channel-level errors occurs due to previously known action and thus their kind can be predicted. */
+ /* exception_ce = amqp_channel_exception_class_entry; */
+ break;
+ }
+ break;
+ /* Default for the above switch should be handled by the below default. */
+ default:
+ exception_ce = amqp_exception_class_entry;
+ break;
+ }
+
+ zend_throw_exception(exception_ce, message, code);
}
-void php_amqp_maybe_release_buffers_on_channel(amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource)
+void php_amqp_maybe_release_buffers_on_channel(
+ amqp_connection_resource *connection_resource,
+ amqp_channel_resource *channel_resource
+)
{
- assert(channel_resource != NULL);
- assert(channel_resource->channel_id > 0);
+ assert(channel_resource != NULL);
+ assert(channel_resource->channel_id > 0);
- if (connection_resource) {
- amqp_maybe_release_buffers_on_channel(connection_resource->connection_state, channel_resource->channel_id);
- }
+ if (connection_resource) {
+ amqp_maybe_release_buffers_on_channel(connection_resource->connection_state, channel_resource->channel_id);
+ }
}
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_basic_properties.c b/amqp_basic_properties.c
index dd46426c..ac4056ed 100644
--- a/amqp_basic_properties.c
+++ b/amqp_basic_properties.c
@@ -22,34 +22,37 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
#include "zend_exceptions.h"
#include "Zend/zend_interfaces.h"
-#include
-#include
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+ #include
+#else
+ #include
+ #include
+#endif
#ifdef PHP_WIN32
-# include "win32/unistd.h"
-# if PHP_VERSION_ID >= 80000
-# include "main/php_stdint.h"
-# else
-# include "win32/php_stdint.h"
-# endif
-# include "win32/signal.h"
+ #include "win32/unistd.h"
+ #if PHP_VERSION_ID >= 80000
+ #include
+ #else
+ #include "win32/php_stdint.h"
+ #endif
+ #include "win32/signal.h"
#else
-# include
-# include
-# include
+ #include
+ #include
+ #include
#endif
#if HAVE_INTTYPES_H
-# include
+ #include
#endif
#include "amqp_basic_properties.h"
@@ -57,253 +60,466 @@
#include "amqp_timestamp.h"
#include "amqp_decimal.h"
+void php_amqp_basic_properties_table_to_zval_internal(amqp_table_t *table, zval *result, zend_ulong depth);
+void php_amqp_basic_properties_array_to_zval_internal(amqp_array_t *array, zval *result, zend_ulong depth);
+bool php_amqp_basic_properties_value_to_zval_internal(amqp_field_value_t *value, zval *result, zend_ulong depth);
+
zend_class_entry *amqp_basic_properties_class_entry;
#define this_ce amqp_basic_properties_class_entry
-
-void php_amqp_basic_properties_convert_to_zval(amqp_basic_properties_t *props, zval *obj TSRMLS_DC)
+void php_amqp_basic_properties_to_zval(amqp_basic_properties_t *props, zval *obj)
{
object_init_ex(obj, this_ce);
- php_amqp_basic_properties_extract(props, obj TSRMLS_CC);
+ php_amqp_basic_properties_extract(props, obj);
}
-void php_amqp_basic_properties_set_empty_headers(zval *obj TSRMLS_DC) {
- PHP5to7_zval_t headers PHP5to7_MAYBE_SET_TO_NULL;
+void php_amqp_basic_properties_set_empty_headers(zval *obj)
+{
+ zval headers;
- PHP5to7_MAYBE_INIT(headers);
- PHP5to7_ARRAY_INIT(headers);
+ ZVAL_UNDEF(&headers);
+ array_init(&headers);
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("headers"), PHP5to7_MAYBE_PTR(headers) TSRMLS_CC);
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("headers"), &headers);
- PHP5to7_MAYBE_DESTROY(headers);
+ zval_ptr_dtor(&headers);
}
/* {{{ proto AMQPBasicProperties::__construct() */
-static PHP_METHOD(AMQPBasicProperties, __construct) {
+static PHP_METHOD(AMQPBasicProperties, __construct)
+{
+ char *content_type = NULL;
+ size_t content_type_len = 0;
- char *content_type = NULL; PHP5to7_param_str_len_type_t content_type_len = 0;
- char *content_encoding = NULL; PHP5to7_param_str_len_type_t content_encoding_len = 0;
+ char *content_encoding = NULL;
+ size_t content_encoding_len = 0;
zval *headers = NULL;
- PHP5to7_param_long_type_t delivery_mode = AMQP_DELIVERY_NONPERSISTENT;
- PHP5to7_param_long_type_t priority = 0;
-
- char *correlation_id = NULL; PHP5to7_param_str_len_type_t correlation_id_len = 0;
- char *reply_to = NULL; PHP5to7_param_str_len_type_t reply_to_len = 0;
- char *expiration = NULL; PHP5to7_param_str_len_type_t expiration_len = 0;
- char *message_id = NULL; PHP5to7_param_str_len_type_t message_id_len = 0;
-
- PHP5to7_param_long_type_t timestamp = 0;
-
- char *type = NULL; PHP5to7_param_str_len_type_t type_len = 0;
- char *user_id = NULL; PHP5to7_param_str_len_type_t user_id_len = 0;
- char *app_id = NULL; PHP5to7_param_str_len_type_t app_id_len = 0;
- char *cluster_id = NULL; PHP5to7_param_str_len_type_t cluster_id_len = 0;
-
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|ssallsssslssss",
- /* s */ &content_type, &content_type_len,
- /* s */ &content_encoding, &content_encoding_len,
- /* a */ &headers,
- /* l */ &delivery_mode,
- /* l */ &priority,
- /* s */ &correlation_id, &correlation_id_len,
- /* s */ &reply_to, &reply_to_len,
- /* s */ &expiration, &expiration_len,
- /* s */ &message_id, &message_id_len,
- /* l */ ×tamp,
- /* s */ &type, &type_len,
- /* s */ &user_id, &user_id_len,
- /* s */ &app_id, &app_id_len,
- /* s */ &cluster_id, &cluster_id_len
- ) == FAILURE) {
- return;
+ zend_long delivery_mode = AMQP_DELIVERY_NONPERSISTENT;
+ zend_long priority = 0;
+
+ char *correlation_id = NULL;
+ size_t correlation_id_len = 0;
+
+ char *reply_to = NULL;
+ size_t reply_to_len = 0;
+
+ char *expiration = NULL;
+ size_t expiration_len = 0;
+
+ char *message_id = NULL;
+ size_t message_id_len = 0;
+
+ zend_long timestamp = 0;
+ bool timestamp_is_null = 1;
+
+ char *type = NULL;
+ size_t type_len = 0;
+
+ char *user_id = NULL;
+ size_t user_id_len = 0;
+
+ char *app_id = NULL;
+ size_t app_id_len = 0;
+
+ char *cluster_id = NULL;
+ size_t cluster_id_len = 0;
+
+ if (zend_parse_parameters(
+ ZEND_NUM_ARGS(),
+ "|s!s!alls!s!s!s!l!s!s!s!s!",
+ /* s */ &content_type,
+ &content_type_len,
+ /* s */ &content_encoding,
+ &content_encoding_len,
+ /* a */ &headers,
+ /* l */ &delivery_mode,
+ /* l */ &priority,
+ /* s */ &correlation_id,
+ &correlation_id_len,
+ /* s */ &reply_to,
+ &reply_to_len,
+ /* s */ &expiration,
+ &expiration_len,
+ /* s */ &message_id,
+ &message_id_len,
+ /* l */ ×tamp,
+ ×tamp_is_null,
+ /* s */ &type,
+ &type_len,
+ /* s */ &user_id,
+ &user_id_len,
+ /* s */ &app_id,
+ &app_id_len,
+ /* s */ &cluster_id,
+ &cluster_id_len
+ ) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ if (content_type != NULL) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("contentType"),
+ content_type,
+ content_type_len
+ );
+ }
+
+ if (content_encoding != NULL) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("contentEncoding"),
+ content_encoding,
+ content_encoding_len
+ );
}
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("content_type"), content_type, content_type_len TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("content_encoding"), content_encoding, content_encoding_len TSRMLS_CC);
if (headers != NULL) {
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("headers"), headers TSRMLS_CC);
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("headers"), headers);
} else {
- php_amqp_basic_properties_set_empty_headers(getThis() TSRMLS_CC);
+ php_amqp_basic_properties_set_empty_headers(getThis());
+ }
+
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("deliveryMode"), delivery_mode);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("priority"), priority);
+
+ if (correlation_id != NULL) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("correlationId"),
+ correlation_id,
+ correlation_id_len
+ );
+ }
+
+ if (reply_to != NULL) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("replyTo"),
+ reply_to,
+ reply_to_len
+ );
+ }
+
+ if (expiration != NULL) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("expiration"),
+ expiration,
+ expiration_len
+ );
+ }
+
+ if (message_id != NULL) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("messageId"),
+ message_id,
+ message_id_len
+ );
+ }
+
+ if (!timestamp_is_null) {
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("timestamp"), timestamp);
}
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("delivery_mode"), delivery_mode TSRMLS_CC);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("priority"), priority TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("correlation_id"), correlation_id, correlation_id_len TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("reply_to"), reply_to, reply_to_len TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("expiration"), expiration, expiration_len TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("message_id"), message_id, message_id_len TSRMLS_CC);
+ if (type != NULL) {
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("type"), type, type_len);
+ }
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("timestamp"), timestamp TSRMLS_CC);
+ if (user_id != NULL) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("userId"),
+ user_id,
+ user_id_len
+ );
+ }
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("type"), type, type_len TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("user_id"), user_id, user_id_len TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("app_id"), app_id, app_id_len TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("cluster_id"), cluster_id, cluster_id_len TSRMLS_CC);
+ if (app_id != NULL) {
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("appId"), app_id, app_id_len);
+ }
+
+ if (cluster_id != NULL) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("clusterId"),
+ cluster_id,
+ cluster_id_len
+ );
+ }
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getContentType() */
-static PHP_METHOD(AMQPBasicProperties, getContentType) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("content_type");
+static PHP_METHOD(AMQPBasicProperties, getContentType)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("contentType");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getContentEncoding() */
-static PHP_METHOD(AMQPBasicProperties, getContentEncoding) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("content_encoding");
+static PHP_METHOD(AMQPBasicProperties, getContentEncoding)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("contentEncoding");
}
/* }}} */
-/* {{{ proto AMQPBasicProperties::getCorrelationId() */
-static PHP_METHOD(AMQPBasicProperties, getHeaders) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
+/* {{{ proto AMQPBasicProperties::getHeaders() */
+static PHP_METHOD(AMQPBasicProperties, getHeaders)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
PHP_AMQP_RETURN_THIS_PROP("headers");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getDeliveryMode() */
-static PHP_METHOD(AMQPBasicProperties, getDeliveryMode) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("delivery_mode");
+static PHP_METHOD(AMQPBasicProperties, getDeliveryMode)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("deliveryMode");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getPriority() */
-static PHP_METHOD(AMQPBasicProperties, getPriority) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
+static PHP_METHOD(AMQPBasicProperties, getPriority)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
PHP_AMQP_RETURN_THIS_PROP("priority");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getCorrelationId() */
-static PHP_METHOD(AMQPBasicProperties, getCorrelationId) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("correlation_id");
+static PHP_METHOD(AMQPBasicProperties, getCorrelationId)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("correlationId");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getReplyTo() */
-static PHP_METHOD(AMQPBasicProperties, getReplyTo) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("reply_to");
+static PHP_METHOD(AMQPBasicProperties, getReplyTo)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("replyTo");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getExpiration()
check amqp envelope */
-static PHP_METHOD(AMQPBasicProperties, getExpiration) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
+static PHP_METHOD(AMQPBasicProperties, getExpiration)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
PHP_AMQP_RETURN_THIS_PROP("expiration");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getMessageId() */
-static PHP_METHOD(AMQPBasicProperties, getMessageId) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("message_id");
+static PHP_METHOD(AMQPBasicProperties, getMessageId)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("messageId");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getTimestamp() */
-static PHP_METHOD(AMQPBasicProperties, getTimestamp) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
+static PHP_METHOD(AMQPBasicProperties, getTimestamp)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
PHP_AMQP_RETURN_THIS_PROP("timestamp");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getType() */
-static PHP_METHOD(AMQPBasicProperties, getType) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
+static PHP_METHOD(AMQPBasicProperties, getType)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
PHP_AMQP_RETURN_THIS_PROP("type");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getUserId() */
-static PHP_METHOD(AMQPBasicProperties, getUserId) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("user_id");
+static PHP_METHOD(AMQPBasicProperties, getUserId)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("userId");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getAppId() */
-static PHP_METHOD(AMQPBasicProperties, getAppId) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("app_id");
+static PHP_METHOD(AMQPBasicProperties, getAppId)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("appId");
}
/* }}} */
/* {{{ proto AMQPBasicProperties::getClusterId() */
-static PHP_METHOD(AMQPBasicProperties, getClusterId) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("cluster_id");
+static PHP_METHOD(AMQPBasicProperties, getClusterId)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("clusterId");
}
/* }}} */
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, contentType, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, contentEncoding, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, headers, IS_ARRAY, 0, "[]")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, deliveryMode, IS_LONG, 0, "AMQP_DELIVERY_MODE_TRANSIENT")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, priority, IS_LONG, 0, "0")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, correlationId, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, replyTo, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, expiration, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, messageId, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timestamp, IS_LONG, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, type, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, userId, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, appId, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, clusterId, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getContentType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getContentType,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_STRING,
+ 1
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getContentEncoding, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getContentEncoding,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_STRING,
+ 1
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getHeaders, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getHeaders,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_ARRAY,
+ 0
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getDeliveryMode, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getDeliveryMode,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_LONG,
+ 0
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getPriority, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getPriority,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_LONG,
+ 0
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getCorrelationId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getCorrelationId,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_STRING,
+ 1
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getReplyTo, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getReplyTo,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_STRING,
+ 1
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getExpiration, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getExpiration,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_STRING,
+ 1
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getMessageId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getMessageId,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_STRING,
+ 1
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getTimestamp, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getTimestamp,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_LONG,
+ 1
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_basic_properties_class_getType, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getUserId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getUserId,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_STRING,
+ 1
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getAppId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_basic_properties_class_getAppId, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_basic_properties_class_getClusterId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_basic_properties_class_getClusterId,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_STRING,
+ 1
+)
ZEND_END_ARG_INFO()
@@ -330,303 +546,398 @@ zend_function_entry amqp_basic_properties_class_functions[] = {
PHP_ME(AMQPBasicProperties, getAppId, arginfo_amqp_basic_properties_class_getAppId, ZEND_ACC_PUBLIC)
PHP_ME(AMQPBasicProperties, getClusterId, arginfo_amqp_basic_properties_class_getClusterId, ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
+ {NULL, NULL, NULL}
};
+#define PHP_AMQP_ZVAL_AMQP_DELIVERY_NONPERSISTENT(v) ZVAL_LONG(v, AMQP_DELIVERY_NONPERSISTENT)
-PHP_MINIT_FUNCTION (amqp_basic_properties) {
+PHP_MINIT_FUNCTION(amqp_basic_properties)
+{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "AMQPBasicProperties", amqp_basic_properties_class_functions);
- this_ce = zend_register_internal_class(&ce TSRMLS_CC);
+ this_ce = zend_register_internal_class(&ce);
- zend_declare_property_stringl(this_ce, ZEND_STRL("content_type"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_stringl(this_ce, ZEND_STRL("content_encoding"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "contentType", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "contentEncoding", ZEND_ACC_PRIVATE, IS_STRING, 1);
- zend_declare_property_null(this_ce, ZEND_STRL("headers"), ZEND_ACC_PRIVATE TSRMLS_CC);
+#if PHP_VERSION_ID >= 80000
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "headers", ZEND_ACC_PRIVATE, IS_ARRAY, 0, ZVAL_EMPTY_ARRAY);
+#else
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "headers", ZEND_ACC_PRIVATE, IS_ARRAY, 0, ZVAL_NULL);
+#endif
- zend_declare_property_long(this_ce, ZEND_STRL("delivery_mode"), AMQP_DELIVERY_NONPERSISTENT, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_long(this_ce, ZEND_STRL("priority"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(
+ this_ce,
+ "deliveryMode",
+ ZEND_ACC_PRIVATE,
+ IS_LONG,
+ 0,
+ PHP_AMQP_ZVAL_AMQP_DELIVERY_NONPERSISTENT
+ );
+ zval default_priority;
+ ZVAL_LONG(&default_priority, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_ZVAL(
+ this_ce,
+ "priority",
+ ZEND_ACC_PRIVATE,
+ PHP_AMQP_DECLARE_PROPERTY_TYPE(IS_LONG, 0),
+ default_priority
+ );
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "correlationId", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "replyTo", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "expiration", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "messageId", ZEND_ACC_PRIVATE, IS_STRING, 1);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "timestamp", ZEND_ACC_PRIVATE, IS_LONG, 1);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "type", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "userId", ZEND_ACC_PRIVATE, IS_STRING, 1);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "appId", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "clusterId", ZEND_ACC_PRIVATE, IS_STRING, 1);
- zend_declare_property_stringl(this_ce, ZEND_STRL("correlation_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_stringl(this_ce, ZEND_STRL("reply_to"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_stringl(this_ce, ZEND_STRL("expiration"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_stringl(this_ce, ZEND_STRL("message_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
+ return SUCCESS;
+}
- zend_declare_property_long(this_ce, ZEND_STRL("timestamp"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
+bool php_amqp_basic_properties_value_to_zval_internal(amqp_field_value_t *value, zval *result, zend_ulong depth)
+{
+ if (depth > PHP_AMQP_G(deserialization_depth)) {
+ zend_throw_exception_ex(
+ amqp_exception_class_entry,
+ 0,
+ "Maximum deserialization depth limit of " ZEND_LONG_FMT " reached while deserializing value",
+ PHP_AMQP_G(deserialization_depth)
+ );
+ return 0;
+ }
- zend_declare_property_stringl(this_ce, ZEND_STRL("type"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_stringl(this_ce, ZEND_STRL("user_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_stringl(this_ce, ZEND_STRL("app_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_stringl(this_ce, ZEND_STRL("cluster_id"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
+ switch (value->kind) {
+ case AMQP_FIELD_KIND_BOOLEAN:
+ ZVAL_BOOL(result, value->value.boolean);
+ break;
- return SUCCESS;
-}
+ case AMQP_FIELD_KIND_I8:
+ ZVAL_LONG(result, value->value.i8);
+ break;
+ case AMQP_FIELD_KIND_U8:
+ ZVAL_LONG(result, value->value.u8);
+ break;
-void parse_amqp_table(amqp_table_t *table, zval *result TSRMLS_DC) {
- int i;
- zend_bool has_value = 0;
+ case AMQP_FIELD_KIND_I16:
+ ZVAL_LONG(result, value->value.i16);
+ break;
- PHP5to7_zval_t value PHP5to7_MAYBE_SET_TO_NULL;
+ case AMQP_FIELD_KIND_U16:
+ ZVAL_LONG(result, value->value.u16);
+ break;
- assert(Z_TYPE_P(result) == IS_ARRAY);
+ case AMQP_FIELD_KIND_I32:
+ ZVAL_LONG(result, value->value.i32);
+ break;
- for (i = 0; i < table->num_entries; i++) {
- PHP5to7_MAYBE_INIT(value);
- has_value = 1;
+ case AMQP_FIELD_KIND_U32:
+ ZVAL_LONG(result, value->value.u32);
+ break;
- amqp_table_entry_t *entry = &(table->entries[i]);
- switch (entry->value.kind) {
- case AMQP_FIELD_KIND_BOOLEAN:
- ZVAL_BOOL(PHP5to7_MAYBE_PTR(value), entry->value.value.boolean);
- break;
- case AMQP_FIELD_KIND_I8:
- ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i8);
- break;
- case AMQP_FIELD_KIND_U8:
- ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u8);
- break;
- case AMQP_FIELD_KIND_I16:
- ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i16);
- break;
- case AMQP_FIELD_KIND_U16:
- ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u16);
- break;
- case AMQP_FIELD_KIND_I32:
- ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i32);
- break;
- case AMQP_FIELD_KIND_U32:
- ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u32);
- break;
- case AMQP_FIELD_KIND_I64:
- ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.i64);
- break;
- case AMQP_FIELD_KIND_U64:
- if (entry->value.value.u64 > LONG_MAX) {
- ZVAL_DOUBLE(PHP5to7_MAYBE_PTR(value), entry->value.value.u64);
- } else {
- ZVAL_LONG(PHP5to7_MAYBE_PTR(value), entry->value.value.u64);
- }
- break;
- case AMQP_FIELD_KIND_F32:
- ZVAL_DOUBLE(PHP5to7_MAYBE_PTR(value), entry->value.value.f32);
- break;
- case AMQP_FIELD_KIND_F64:
- ZVAL_DOUBLE(PHP5to7_MAYBE_PTR(value), entry->value.value.f64);
- break;
- case AMQP_FIELD_KIND_UTF8:
- case AMQP_FIELD_KIND_BYTES:
- PHP5to7_ZVAL_STRINGL_DUP(PHP5to7_MAYBE_PTR(value), entry->value.value.bytes.bytes, entry->value.value.bytes.len);
- break;
- case AMQP_FIELD_KIND_ARRAY: {
- int j;
- array_init(PHP5to7_MAYBE_PTR(value));
- for (j = 0; j < entry->value.value.array.num_entries; ++j) {
- switch (entry->value.value.array.entries[j].kind) {
- case AMQP_FIELD_KIND_UTF8:
- PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(
- PHP5to7_MAYBE_PTR(value),
- entry->value.value.array.entries[j].value.bytes.bytes,
- (unsigned) entry->value.value.array.entries[j].value.bytes.len
- );
- break;
- case AMQP_FIELD_KIND_TABLE: {
- PHP5to7_zval_t subtable PHP5to7_MAYBE_SET_TO_NULL;
- PHP5to7_MAYBE_INIT(subtable);
- PHP5to7_ARRAY_INIT(subtable);
-
- parse_amqp_table(
- &(entry->value.value.array.entries[j].value.table),
- PHP5to7_MAYBE_PTR(subtable) TSRMLS_CC
- );
- add_next_index_zval(PHP5to7_MAYBE_PTR(value), PHP5to7_MAYBE_PTR(subtable));
- }
- break;
- default:
- break;
- }
- }
- }
- break;
- case AMQP_FIELD_KIND_TABLE:
- PHP5to7_ARRAY_INIT(value);
- parse_amqp_table(&(entry->value.value.table), PHP5to7_MAYBE_PTR(value) TSRMLS_CC);
- break;
-
- case AMQP_FIELD_KIND_TIMESTAMP: {
- char timestamp_str[20];
- PHP5to7_zval_t timestamp PHP5to7_MAYBE_SET_TO_NULL;
- PHP5to7_MAYBE_INIT(timestamp);
-
- int length = snprintf(timestamp_str, sizeof(timestamp_str), ZEND_ULONG_FMT, entry->value.value.u64);
- PHP5to7_ZVAL_STRINGL_DUP(PHP5to7_MAYBE_PTR(timestamp), (char *)timestamp_str, length);
- object_init_ex(PHP5to7_MAYBE_PTR(value), amqp_timestamp_class_entry);
-
- zend_call_method_with_1_params(
- PHP5to8_OBJ_PROP(&value),
- amqp_timestamp_class_entry,
- NULL,
- "__construct",
- NULL,
- PHP5to7_MAYBE_PTR(timestamp)
- );
-
- PHP5to7_MAYBE_DESTROY(timestamp);
- break;
- }
-
- case AMQP_FIELD_KIND_VOID:
- ZVAL_NULL(PHP5to7_MAYBE_PTR(value));
- break;
- case AMQP_FIELD_KIND_DECIMAL: {
-
- PHP5to7_zval_t e PHP5to7_MAYBE_SET_TO_NULL;
- PHP5to7_zval_t n PHP5to7_MAYBE_SET_TO_NULL;
- PHP5to7_MAYBE_INIT(e);
- PHP5to7_MAYBE_INIT(n);
-
- ZVAL_LONG(PHP5to7_MAYBE_PTR(e), entry->value.value.decimal.decimals);
- ZVAL_LONG(PHP5to7_MAYBE_PTR(n), entry->value.value.decimal.value);
-
- object_init_ex(PHP5to7_MAYBE_PTR(value), amqp_decimal_class_entry);
-
- zend_call_method_with_2_params(
- PHP5to8_OBJ_PROP(&value),
- amqp_decimal_class_entry,
- NULL,
- "__construct",
- NULL,
- PHP5to7_MAYBE_PTR(e),
- PHP5to7_MAYBE_PTR(n)
- );
-
- PHP5to7_MAYBE_DESTROY(e);
- PHP5to7_MAYBE_DESTROY(n);
- break;
+ case AMQP_FIELD_KIND_I64:
+ ZVAL_LONG(result, value->value.i64);
+ break;
+
+ case AMQP_FIELD_KIND_U64:
+ if (value->value.u64 > LONG_MAX) {
+ ZVAL_DOUBLE(result, value->value.u64);
+ } else {
+ ZVAL_LONG(result, value->value.u64);
}
- default:
- has_value = 0;
- break;
+ break;
+
+ case AMQP_FIELD_KIND_F32:
+ ZVAL_DOUBLE(result, value->value.f32);
+ break;
+
+ case AMQP_FIELD_KIND_F64:
+ ZVAL_DOUBLE(result, value->value.f64);
+ break;
+
+ case AMQP_FIELD_KIND_UTF8:
+ case AMQP_FIELD_KIND_BYTES:
+ ZVAL_STRINGL(result, value->value.bytes.bytes, value->value.bytes.len);
+ break;
+
+ case AMQP_FIELD_KIND_VOID:
+ ZVAL_NULL(result);
+ break;
+
+ case AMQP_FIELD_KIND_ARRAY:
+ array_init(result);
+ php_amqp_basic_properties_array_to_zval_internal(&(value->value.array), result, depth);
+ break;
+
+ case AMQP_FIELD_KIND_TABLE:
+ array_init(result);
+ php_amqp_basic_properties_table_to_zval_internal(&(value->value.table), result, depth);
+ break;
+
+ case AMQP_FIELD_KIND_TIMESTAMP: {
+ zval timestamp;
+ ZVAL_UNDEF(×tamp);
+
+ ZVAL_DOUBLE(×tamp, value->value.u64);
+ object_init_ex(result, amqp_timestamp_class_entry);
+
+ zend_call_method_with_1_params(
+ PHP_AMQP_COMPAT_OBJ_P(result),
+ amqp_timestamp_class_entry,
+ NULL,
+ "__construct",
+ NULL,
+ ×tamp
+ );
+ break;
}
- if (has_value) {
- char *key = estrndup(entry->key.bytes, (unsigned) entry->key.len);
- add_assoc_zval(result, key, PHP5to7_MAYBE_PTR(value));
- efree(key);
- } else {
- PHP5to7_MAYBE_DESTROY(value);
+ case AMQP_FIELD_KIND_DECIMAL: {
+ zval e;
+ zval n;
+ ZVAL_UNDEF(&e);
+ ZVAL_UNDEF(&n);
+
+ ZVAL_LONG(&e, value->value.decimal.decimals);
+ ZVAL_LONG(&n, value->value.decimal.value);
+
+ object_init_ex(result, amqp_decimal_class_entry);
+
+ zend_call_method_with_2_params(
+ PHP_AMQP_COMPAT_OBJ_P(result),
+ amqp_decimal_class_entry,
+ NULL,
+ "__construct",
+ NULL,
+ &e,
+ &n
+ );
+
+ zval_ptr_dtor(&e);
+ zval_ptr_dtor(&n);
+ break;
+ }
+
+ default:
+ return 0;
+ }
+
+ return 1;
+}
+
+void php_amqp_basic_properties_array_to_zval_internal(amqp_array_t *array, zval *result, zend_ulong depth)
+{
+ assert(Z_TYPE_P(result) == IS_ARRAY);
+
+ int i;
+ for (i = 0; i < array->num_entries; ++i) {
+ zval result_nested;
+ ZVAL_UNDEF(&result_nested);
+ if (php_amqp_basic_properties_value_to_zval_internal(&(array->entries[i]), &result_nested, depth + 1)) {
+ add_next_index_zval(result, &result_nested);
+ } else if (!Z_ISUNDEF(result_nested)) {
+ zval_ptr_dtor(&result_nested);
}
}
- return;
}
-void php_amqp_basic_properties_extract(amqp_basic_properties_t *p, zval *obj TSRMLS_DC)
+void php_amqp_basic_properties_table_to_zval_internal(amqp_table_t *table, zval *result, zend_ulong depth)
{
- PHP5to7_zval_t headers PHP5to7_MAYBE_SET_TO_NULL;
+ int i;
+ zval result_nested;
- PHP5to7_MAYBE_INIT(headers);
- PHP5to7_ARRAY_INIT(headers);
+ assert(Z_TYPE_P(result) == IS_ARRAY);
+
+ for (i = 0; i < table->num_entries; ++i) {
+ amqp_table_entry_t *entry = &(table->entries[i]);
+ ZVAL_UNDEF(&result_nested);
+ if (php_amqp_basic_properties_value_to_zval_internal(&(entry->value), &result_nested, depth + 1)) {
+ char *key = estrndup(entry->key.bytes, (unsigned) entry->key.len);
+ add_assoc_zval(result, key, &result_nested);
+ efree(key);
+ } else if (!Z_ISUNDEF(result_nested)) {
+ zval_ptr_dtor(&result_nested);
+ }
+ }
+}
- if (p->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("content_type"), (const char *) p->content_type.bytes, (PHP5to7_param_str_len_type_t) p->content_type.len TSRMLS_CC);
+void php_amqp_basic_properties_extract(amqp_basic_properties_t *props, zval *obj)
+{
+ zval headers;
+
+ ZVAL_UNDEF(&headers);
+ array_init(&headers);
+
+ if (props->_flags & AMQP_BASIC_CONTENT_TYPE_FLAG) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("contentType"),
+ (const char *) props->content_type.bytes,
+ (size_t) props->content_type.len
+ );
} else {
/* BC */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("content_type"), "", 0 TSRMLS_CC);
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("contentType"));
}
- if (p->_flags & AMQP_BASIC_CONTENT_ENCODING_FLAG) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("content_encoding"), (const char *) p->content_encoding.bytes, (PHP5to7_param_str_len_type_t) p->content_encoding.len TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_CONTENT_ENCODING_FLAG) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("contentEncoding"),
+ (const char *) props->content_encoding.bytes,
+ (size_t) props->content_encoding.len
+ );
} else {
/* BC */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("content_encoding"), "", 0 TSRMLS_CC);
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("contentEncoding"));
}
- if (p->_flags & AMQP_BASIC_HEADERS_FLAG) {
- parse_amqp_table(&(p->headers), PHP5to7_MAYBE_PTR(headers) TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_HEADERS_FLAG) {
+ php_amqp_basic_properties_table_to_zval_internal(&(props->headers), &headers, 0);
}
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("headers"), PHP5to7_MAYBE_PTR(headers) TSRMLS_CC);
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("headers"), &headers);
- if (p->_flags & AMQP_BASIC_DELIVERY_MODE_FLAG) {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("delivery_mode"), (PHP5to7_param_long_type_t) p->delivery_mode TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_DELIVERY_MODE_FLAG) {
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("deliveryMode"),
+ (zend_long) props->delivery_mode
+ );
} else {
/* BC */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("delivery_mode"), AMQP_DELIVERY_NONPERSISTENT TSRMLS_CC);
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("deliveryMode"),
+ AMQP_DELIVERY_NONPERSISTENT
+ );
}
- if (p->_flags & AMQP_BASIC_PRIORITY_FLAG) {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("priority"), (PHP5to7_param_long_type_t) p->priority TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_PRIORITY_FLAG) {
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("priority"),
+ (zend_long) props->priority
+ );
} else {
/* BC */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("priority"), 0 TSRMLS_CC);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("priority"), 0);
}
- if (p->_flags & AMQP_BASIC_CORRELATION_ID_FLAG) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("correlation_id"), (const char *) p->correlation_id.bytes, (PHP5to7_param_str_len_type_t) p->correlation_id.len TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_CORRELATION_ID_FLAG) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("correlationId"),
+ (const char *) props->correlation_id.bytes,
+ (size_t) props->correlation_id.len
+ );
} else {
/* BC */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("correlation_id"), "", 0 TSRMLS_CC);
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("correlationId"));
}
- if (p->_flags & AMQP_BASIC_REPLY_TO_FLAG) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("reply_to"), (const char *) p->reply_to.bytes, (PHP5to7_param_str_len_type_t) p->reply_to.len TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_REPLY_TO_FLAG) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("replyTo"),
+ (const char *) props->reply_to.bytes,
+ (size_t) props->reply_to.len
+ );
} else {
/* BC */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("reply_to"), "", 0 TSRMLS_CC);
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("replyTo"));
}
- if (p->_flags & AMQP_BASIC_EXPIRATION_FLAG) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("expiration"), (const char *) p->expiration.bytes, (PHP5to7_param_str_len_type_t) p->expiration.len TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_EXPIRATION_FLAG) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("expiration"),
+ (const char *) props->expiration.bytes,
+ (size_t) props->expiration.len
+ );
} else {
/* BC */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("expiration"), "", 0 TSRMLS_CC);
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("expiration"));
}
- if (p->_flags & AMQP_BASIC_MESSAGE_ID_FLAG) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("message_id"), (const char *) p->message_id.bytes, (PHP5to7_param_str_len_type_t) p->message_id.len TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_MESSAGE_ID_FLAG) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("messageId"),
+ (const char *) props->message_id.bytes,
+ (size_t) props->message_id.len
+ );
} else {
/* BC */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("message_id"), "", 0 TSRMLS_CC);
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("messageId"));
}
- if (p->_flags & AMQP_BASIC_TIMESTAMP_FLAG) {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("timestamp"), (PHP5to7_param_long_type_t) p->timestamp TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_TIMESTAMP_FLAG) {
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("timestamp"),
+ (zend_long) props->timestamp
+ );
} else {
/* BC */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("timestamp"), 0 TSRMLS_CC);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("timestamp"), 0);
}
- if (p->_flags & AMQP_BASIC_TYPE_FLAG) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("type"), (const char *) p->type.bytes, (PHP5to7_param_str_len_type_t) p->type.len TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_TYPE_FLAG) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("type"),
+ (const char *) props->type.bytes,
+ (size_t) props->type.len
+ );
} else {
/* BC */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("type"), "", 0 TSRMLS_CC);
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("type"));
}
- if (p->_flags & AMQP_BASIC_USER_ID_FLAG) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("user_id"), (const char *) p->user_id.bytes, (PHP5to7_param_str_len_type_t) p->user_id.len TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_USER_ID_FLAG) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("userId"),
+ (const char *) props->user_id.bytes,
+ (size_t) props->user_id.len
+ );
} else {
/* BC */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("user_id"), "", 0 TSRMLS_CC);
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("userId"));
}
- if (p->_flags & AMQP_BASIC_APP_ID_FLAG) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("app_id"), (const char *) p->app_id.bytes, (PHP5to7_param_str_len_type_t) p->app_id.len TSRMLS_CC);
+ if (props->_flags & AMQP_BASIC_APP_ID_FLAG) {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(obj),
+ ZEND_STRL("appId"),
+ (const char *) props->app_id.bytes,
+ (size_t) props->app_id.len
+ );
} else {
/* BC */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(obj), ZEND_STRL("app_id"), "", 0 TSRMLS_CC);
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL("appId"));
}
- PHP5to7_MAYBE_DESTROY(headers);
+ zval_ptr_dtor(&headers);
}
-
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_basic_properties.h b/amqp_basic_properties.h
index a1233627..e8a5cf92 100644
--- a/amqp_basic_properties.h
+++ b/amqp_basic_properties.h
@@ -26,22 +26,8 @@
extern zend_class_entry *amqp_basic_properties_class_entry;
-void parse_amqp_table(amqp_table_t *table, zval *result TSRMLS_DC);
-void php_amqp_basic_properties_extract(amqp_basic_properties_t *p, zval *obj TSRMLS_DC);
-
-
-void php_amqp_basic_properties_convert_to_zval(amqp_basic_properties_t *props, zval *obj TSRMLS_DC);
-void php_amqp_basic_properties_set_empty_headers(zval *obj TSRMLS_DC);
-
+void php_amqp_basic_properties_extract(amqp_basic_properties_t *props, zval *obj);
+void php_amqp_basic_properties_to_zval(amqp_basic_properties_t *props, zval *obj);
+void php_amqp_basic_properties_set_empty_headers(zval *obj);
PHP_MINIT_FUNCTION(amqp_basic_properties);
-
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_channel.c b/amqp_channel.c
index cac84ab1..4b62d0fc 100644
--- a/amqp_channel.c
+++ b/amqp_channel.c
@@ -21,33 +21,37 @@
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
-#include "ext/standard/info.h"
#include "zend_exceptions.h"
#ifdef PHP_WIN32
-# if PHP_VERSION_ID >= 80000
-# include "main/php_stdint.h"
-# else
-# include "win32/php_stdint.h"
-# endif
-# include "win32/signal.h"
+ #if PHP_VERSION_ID >= 80000
+ #include
+ #else
+ #include "win32/php_stdint.h"
+ #endif
+ #include "win32/signal.h"
#else
-# include
-# include
+ #include
+ #include
#endif
-#include
-#include
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+ #include
+#else
+ #include
+ #include
+#endif
#ifdef PHP_WIN32
-# include "win32/unistd.h"
+ #include "win32/unistd.h"
#else
-# include
+ #include
#endif
#include "php_amqp.h"
@@ -61,79 +65,96 @@ zend_class_entry *amqp_channel_class_entry;
zend_object_handlers amqp_channel_object_handlers;
-void php_amqp_close_channel(amqp_channel_resource *channel_resource, zend_bool check_errors TSRMLS_DC)
+void php_amqp_close_channel(amqp_channel_resource *channel_resource, bool throw_exception)
{
- assert(channel_resource != NULL);
+ assert(channel_resource != NULL);
- amqp_connection_resource *connection_resource = channel_resource->connection_resource;
+ amqp_connection_resource *connection_resource = channel_resource->connection_resource;
- if (connection_resource != NULL) {
- /* First, remove it from active channels table to prevent recursion in case of connection error */
+ if (connection_resource != NULL) {
+ /* First, remove it from active channels table to prevent recursion in case of connection error */
php_amqp_connection_resource_unregister_channel(connection_resource, channel_resource->channel_id);
- } else {
- channel_resource->is_connected = '\0';
- }
+ } else {
+ channel_resource->is_connected = '\0';
+ }
- assert(channel_resource->connection_resource == NULL);
+ assert(channel_resource->connection_resource == NULL);
- if (!channel_resource->is_connected) {
- /* Nothing to do more - channel was previously marked as closed, possibly, due to channel-level error */
- return;
- }
+ if (!channel_resource->is_connected) {
+ /* Nothing to do more - channel was previously marked as closed, possibly, due to channel-level error */
+ return;
+ }
- channel_resource->is_connected = '\0';
+ channel_resource->is_connected = '\0';
- if (connection_resource && connection_resource->is_connected && channel_resource->channel_id > 0) {
- assert(connection_resource != NULL);
+ if (connection_resource && connection_resource->is_connected && channel_resource->channel_id > 0) {
+ assert(connection_resource != NULL);
- amqp_channel_close(connection_resource->connection_state, channel_resource->channel_id, AMQP_REPLY_SUCCESS);
+ // assume below methods will fail and mark slot as used
+ // If PHP_AMQP_MAYBE_ERROR fails it may free the connection_resource by calling php_amqp_disconnect_force
+ // So we cannot increment the used slots after the error as some code paths result in `use after free` on
+ // the connection_resource.
+ // In other code paths (error but not free) the connection_resource object is still valid and only the channels
+ // slot should be marked as used.
+ connection_resource->used_slots++;
- amqp_rpc_reply_t res = amqp_get_rpc_reply(connection_resource->connection_state);
+ amqp_rpc_reply_t close_res =
+ amqp_channel_close(connection_resource->connection_state, channel_resource->channel_id, AMQP_REPLY_SUCCESS);
- if (check_errors && PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- return;
- }
+ if (throw_exception && PHP_AMQP_MAYBE_ERROR(close_res, channel_resource, connection_resource)) {
+ php_amqp_zend_throw_exception_short(close_res, amqp_channel_exception_class_entry);
+ return;
+ }
- php_amqp_maybe_release_buffers_on_channel(connection_resource, channel_resource);
- }
-}
+ if (close_res.reply_type != AMQP_RESPONSE_NORMAL) {
+ return;
+ }
-#if PHP_MAJOR_VERSION >= 7
+ amqp_rpc_reply_t reply_res = amqp_get_rpc_reply(connection_resource->connection_state);
+ if (throw_exception && PHP_AMQP_MAYBE_ERROR(reply_res, channel_resource, connection_resource)) {
+ php_amqp_zend_throw_exception_short(reply_res, amqp_channel_exception_class_entry);
+ return;
+ }
+
+ if (reply_res.reply_type != AMQP_RESPONSE_NORMAL) {
+ return;
+ }
-static void php_amqp_destroy_fci(zend_fcall_info *fci) {
+ php_amqp_maybe_release_buffers_on_channel(connection_resource, channel_resource);
+ // was successful, let the slot be used again
+ // we know connection_resource is still valid at this point
+ connection_resource->used_slots--;
+ }
+}
+
+static void php_amqp_destroy_fci(zend_fcall_info *fci)
+{
if (fci->size > 0) {
zval_ptr_dtor(&fci->function_name);
if (fci->object != NULL) {
-#if PHP_VERSION_ID >= 70300
GC_DELREF(fci->object);
-#else
- GC_REFCOUNT(fci->object)--;
-#endif
}
fci->size = 0;
}
}
-static void php_amqp_duplicate_fci(zend_fcall_info *source) {
+static void php_amqp_duplicate_fci(zend_fcall_info *source)
+{
if (source->size > 0) {
zval_add_ref(&source->function_name);
if (source->object != NULL) {
-#if PHP_VERSION_ID >= 70300
GC_ADDREF(source->object);
-#else
- GC_REFCOUNT(source->object)++;
-#endif
}
}
}
-static int php_amqp_get_fci_gc_data_count(zend_fcall_info *fci) {
+static int php_amqp_get_fci_gc_data_count(zend_fcall_info *fci)
+{
int cnt = 0;
if (fci->size > 0) {
- cnt ++;
+ cnt++;
if (fci->object != NULL) {
cnt++;
@@ -143,17 +164,18 @@ static int php_amqp_get_fci_gc_data_count(zend_fcall_info *fci) {
return cnt;
}
-static zval * php_amqp_get_fci_gc_data(zend_fcall_info *fci, zval *gc_data) {
+static zval *php_amqp_get_fci_gc_data(zend_fcall_info *fci, zval *gc_data)
+{
if (ZEND_FCI_INITIALIZED(*fci)) {
- ZVAL_COPY_VALUE(gc_data++, &fci->function_name);
+ ZVAL_COPY_VALUE(gc_data++, &fci->function_name);
if (fci->object != NULL) {
ZVAL_OBJ(gc_data++, fci->object);
}
}
- return gc_data;
+ return gc_data;
}
#if PHP_MAJOR_VERSION < 8
@@ -163,166 +185,81 @@ static HashTable *amqp_channel_gc(zval *object, zval **table, int *n) /* {{{ */
#else
static HashTable *amqp_channel_gc(zend_object *object, zval **table, int *n) /* {{{ */
{
- amqp_channel_object *channel = php_amqp_channel_object_fetch(object);
+ amqp_channel_object *channel = php_amqp_channel_object_fetch(object);
#endif
- int basic_return_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_return.fci);
- int basic_ack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_ack.fci);
- int basic_nack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_nack.fci);
+ int basic_return_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_return.fci);
+ int basic_ack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_ack.fci);
+ int basic_nack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_nack.fci);
- int cnt = basic_return_cnt + basic_ack_cnt + basic_nack_cnt;
+ int cnt = basic_return_cnt + basic_ack_cnt + basic_nack_cnt;
- if (cnt > channel->gc_data_count) {
- channel->gc_data_count = cnt;
- channel->gc_data = (zval *) erealloc(channel->gc_data, sizeof(zval) * cnt);
- }
+ if (cnt > channel->gc_data_count) {
+ channel->gc_data_count = cnt;
+ channel->gc_data = (zval *) erealloc(channel->gc_data, sizeof(zval) * cnt);
+ }
- zval *gc_data = channel->gc_data;
+ zval *gc_data = channel->gc_data;
- gc_data = php_amqp_get_fci_gc_data(&channel->callbacks.basic_return.fci, gc_data);
- gc_data = php_amqp_get_fci_gc_data(&channel->callbacks.basic_ack.fci, gc_data);
- php_amqp_get_fci_gc_data(&channel->callbacks.basic_nack.fci, gc_data);
+ gc_data = php_amqp_get_fci_gc_data(&channel->callbacks.basic_return.fci, gc_data);
+ gc_data = php_amqp_get_fci_gc_data(&channel->callbacks.basic_ack.fci, gc_data);
+ php_amqp_get_fci_gc_data(&channel->callbacks.basic_nack.fci, gc_data);
- *table = channel->gc_data;
- *n = cnt;
+ *table = channel->gc_data;
+ *n = cnt;
- return zend_std_get_properties(object TSRMLS_CC);
+ return zend_std_get_properties(object);
} /* }}} */
-#else
-static void php_amqp_destroy_fci(zend_fcall_info *fci) {
- if (fci->size > 0) {
- zval_ptr_dtor(&fci->function_name);
- if (fci->object_ptr != NULL) {
- zval_ptr_dtor(&fci->object_ptr);
- }
- fci->size = 0;
- }
-}
-
-static void php_amqp_duplicate_fci(zend_fcall_info *source) {
- if (source->size > 0) {
-
- zval_add_ref(&source->function_name);
- if (source->object_ptr != NULL) {
- zval_add_ref(&source->object_ptr);
- }
- }
-}
-
-static int php_amqp_get_fci_gc_data_count(zend_fcall_info *fci) {
- int cnt = 0;
-
- if (fci->size > 0) {
- cnt ++;
-
- if (fci->object_ptr != NULL) {
- cnt++;
- }
- }
-
- return cnt;
-}
-
-static int php_amqp_get_fci_gc_data(zend_fcall_info *fci, zval **gc_data, int offset) {
-
- if (ZEND_FCI_INITIALIZED(*fci)) {
- gc_data[offset++] = fci->function_name;
-
- if (fci->object_ptr != NULL) {
- gc_data[offset++] = fci->object_ptr;
- }
- }
-
- return offset;
-}
-
-static HashTable *amqp_channel_gc(zval *object, zval ***table, int *n TSRMLS_DC) /* {{{ */
+static void php_amqp_clean_callbacks(amqp_channel_callbacks *callbacks)
{
- amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(object);
-
- int basic_return_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_return.fci);
- int basic_ack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_ack.fci);
- int basic_nack_cnt = php_amqp_get_fci_gc_data_count(&channel->callbacks.basic_nack.fci);
-
- int cnt = basic_return_cnt + basic_ack_cnt + basic_nack_cnt;
-
- if (cnt > channel->gc_data_count) {
- channel->gc_data_count = cnt;
- channel->gc_data = (zval **) erealloc(channel->gc_data, sizeof(zval *) * channel->gc_data_count);
- }
-
- php_amqp_get_fci_gc_data(&channel->callbacks.basic_return.fci, channel->gc_data, 0);
- php_amqp_get_fci_gc_data(&channel->callbacks.basic_ack.fci, channel->gc_data, basic_return_cnt);
- php_amqp_get_fci_gc_data(&channel->callbacks.basic_nack.fci, channel->gc_data, basic_return_cnt + basic_ack_cnt);
-
- *table = channel->gc_data;
- *n = cnt;
-
- return zend_std_get_properties(PHP5to8_OBJ_PROP(object) TSRMLS_CC);
-} /* }}} */
-
-#endif
-
-static void php_amqp_clean_callbacks(amqp_channel_callbacks *callbacks) {
- php_amqp_destroy_fci(&callbacks->basic_return.fci);
- php_amqp_destroy_fci(&callbacks->basic_ack.fci);
- php_amqp_destroy_fci(&callbacks->basic_nack.fci);
+ php_amqp_destroy_fci(&callbacks->basic_return.fci);
+ php_amqp_destroy_fci(&callbacks->basic_ack.fci);
+ php_amqp_destroy_fci(&callbacks->basic_nack.fci);
}
-void amqp_channel_free(PHP5to7_obj_free_zend_object *object TSRMLS_DC)
+void amqp_channel_free(zend_object *object)
{
- amqp_channel_object *channel = PHP_AMQP_FETCH_CHANNEL(object);
-
- if (channel->channel_resource != NULL) {
- php_amqp_close_channel(channel->channel_resource, 0 TSRMLS_CC);
-
- efree(channel->channel_resource);
- channel->channel_resource = NULL;
- }
-
- if (channel->gc_data) {
- efree(channel->gc_data);
- }
+ amqp_channel_object *channel = PHP_AMQP_FETCH_CHANNEL(object);
- php_amqp_clean_callbacks(&channel->callbacks);
+ if (channel->channel_resource != NULL) {
+ php_amqp_close_channel(channel->channel_resource, 0);
- zend_object_std_dtor(&channel->zo TSRMLS_CC);
+ efree(channel->channel_resource);
+ channel->channel_resource = NULL;
+ }
-#if PHP_MAJOR_VERSION < 7
- if (channel->this_ptr) {
- channel->this_ptr = NULL;
+ if (channel->gc_data) {
+ efree(channel->gc_data);
}
- efree(object);
-#endif
+ php_amqp_clean_callbacks(&channel->callbacks);
+
+ zend_object_std_dtor(&channel->zo);
}
-PHP5to7_zend_object_value amqp_channel_ctor(zend_class_entry *ce TSRMLS_DC)
+zend_object *amqp_channel_ctor(zend_class_entry *ce)
{
- amqp_channel_object *channel = PHP5to7_ECALLOC_CHANNEL_OBJECT(ce);
+ amqp_channel_object *channel =
+ (amqp_channel_object *) ecalloc(1, sizeof(amqp_channel_object) + zend_object_properties_size(ce));
- zend_object_std_init(&channel->zo, ce TSRMLS_CC);
- AMQP_OBJECT_PROPERTIES_INIT(channel->zo, ce);
+ zend_object_std_init(&channel->zo, ce);
+ AMQP_OBJECT_PROPERTIES_INIT(channel->zo, ce);
-#if PHP_MAJOR_VERSION >=7
- channel->zo.handlers = &amqp_channel_object_handlers;
+#if PHP_MAJOR_VERSION >= 7
+ channel->zo.handlers = &amqp_channel_object_handlers;
- return &channel->zo;
+ return &channel->zo;
#else
- PHP5to7_zend_object_value new_value;
+ zend_object *new_value;
- new_value.handle = zend_objects_store_put(
- channel,
- NULL,
- (zend_objects_free_object_storage_t) amqp_channel_free,
- NULL TSRMLS_CC
- );
+ new_value.handle =
+ zend_objects_store_put(channel, NULL, (zend_objects_free_object_storage_t) amqp_channel_free, NULL);
- new_value.handlers = zend_get_std_object_handlers();
+ new_value.handlers = zend_get_std_object_handlers();
- return new_value;
+ return new_value;
#endif
}
@@ -331,149 +268,196 @@ PHP5to7_zend_object_value amqp_channel_ctor(zend_class_entry *ce TSRMLS_DC)
*/
static PHP_METHOD(amqp_channel_class, __construct)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- zval *connection_object = NULL;
-
- amqp_channel_resource *channel_resource;
- amqp_channel_object *channel;
- amqp_connection_object *connection;
-
- /* Parse out the method parameters */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &connection_object, amqp_connection_class_entry) == FAILURE) {
- zend_throw_exception(amqp_channel_exception_class_entry, "Parameter must be an instance of AMQPConnection.", 0 TSRMLS_CC);
- RETURN_NULL();
- }
+ zval rv;
- PHP5to7_zval_t consumers PHP5to7_MAYBE_SET_TO_NULL;
+ zval *connection_object = NULL;
- PHP5to7_MAYBE_INIT(consumers);
- PHP5to7_ARRAY_INIT(consumers);
-
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("consumers"), PHP5to7_MAYBE_PTR(consumers) TSRMLS_CC);
-
- PHP5to7_MAYBE_DESTROY(consumers);
-
- channel = PHP_AMQP_GET_CHANNEL(getThis());
-#if PHP_MAJOR_VERSION < 7
- channel->this_ptr = getThis();
-#endif
-
- /* Set the prefetch count */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("prefetch_count"), INI_INT("amqp.prefetch_count") TSRMLS_CC);
-
- /* Set the prefetch size */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("prefetch_size"), INI_INT("amqp.prefetch_size") TSRMLS_CC);
-
- /* Set the global prefetch count */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("global_prefetch_count"), INI_INT("amqp.global_prefetch_count") TSRMLS_CC);
-
- /* Set the global prefetch size */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("global_prefetch_size"), INI_INT("amqp.global_prefetch_size") TSRMLS_CC);
+ amqp_channel_resource *channel_resource;
+ amqp_channel_object *channel;
+ amqp_connection_object *connection;
- /* Pull out and verify the connection */
- connection = PHP_AMQP_GET_CONNECTION(connection_object);
- PHP_AMQP_VERIFY_CONNECTION(connection, "Could not create channel.");
+ /* Parse out the method parameters */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &connection_object, amqp_connection_class_entry) == FAILURE) {
+ zend_throw_exception(amqp_channel_exception_class_entry, "Parameter must be an instance of AMQPConnection.", 0);
+ RETURN_NULL();
+ }
- if (!connection->connection_resource) {
- zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. No connection resource.", 0 TSRMLS_CC);
- return;
- }
+ zval consumers;
+
+ ZVAL_UNDEF(&consumers);
+ array_init(&consumers);
+
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("consumers"), &consumers);
+
+ zval_ptr_dtor(&consumers);
+
+ channel = PHP_AMQP_GET_CHANNEL(getThis());
+
+ /* Set the prefetch count */
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("prefetchCount"),
+ INI_INT("amqp.prefetch_count")
+ );
+
+ /* Set the prefetch size */
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("prefetchSize"),
+ INI_INT("amqp.prefetch_size")
+ );
+
+ /* Set the global prefetch count */
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("globalPrefetchCount"),
+ INI_INT("amqp.global_prefetch_count")
+ );
+
+ /* Set the global prefetch size */
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("globalPrefetchSize"),
+ INI_INT("amqp.global_prefetch_size")
+ );
+
+ /* Pull out and verify the connection */
+ connection = PHP_AMQP_GET_CONNECTION(connection_object);
+ PHP_AMQP_VERIFY_CONNECTION(connection, "Could not create channel.");
+
+ if (!connection->connection_resource) {
+ zend_throw_exception(
+ amqp_channel_exception_class_entry,
+ "Could not create channel. No connection resource.",
+ 0
+ );
+ RETURN_THROWS();
+ }
- if (!connection->connection_resource->is_connected) {
- zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Connection resource is not connected.", 0 TSRMLS_CC);
- return;
- }
+ if (!connection->connection_resource->is_connected) {
+ zend_throw_exception(
+ amqp_channel_exception_class_entry,
+ "Could not create channel. Connection resource is not connected.",
+ 0
+ );
+ return;
+ }
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connection"), connection_object TSRMLS_CC);
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("connection"), connection_object);
- channel_resource = (amqp_channel_resource*)ecalloc(1, sizeof(amqp_channel_resource));
- channel->channel_resource = channel_resource;
+ channel_resource = (amqp_channel_resource *) ecalloc(1, sizeof(amqp_channel_resource));
+ channel->channel_resource = channel_resource;
channel_resource->parent = channel;
- /* Figure out what the next available channel is on this connection */
- channel_resource->channel_id = php_amqp_connection_resource_get_available_channel_id(connection->connection_resource);
-
- /* Check that we got a valid channel */
- if (!channel_resource->channel_id) {
- zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Connection has no open channel slots remaining.", 0 TSRMLS_CC);
- return;
- }
+ /* Figure out what the next available channel is on this connection */
+ channel_resource->channel_id =
+ php_amqp_connection_resource_get_available_channel_id(connection->connection_resource);
+
+ /* Check that we got a valid channel */
+ if (!channel_resource->channel_id) {
+ zend_throw_exception(
+ amqp_channel_exception_class_entry,
+ "Could not create channel. Connection has no open channel slots remaining.",
+ 0
+ );
+ return;
+ }
- if (php_amqp_connection_resource_register_channel(connection->connection_resource, channel_resource, channel_resource->channel_id) == FAILURE) {
- zend_throw_exception(amqp_channel_exception_class_entry, "Could not create channel. Failed to add channel to connection slot.", 0 TSRMLS_CC);
- }
+ if (php_amqp_connection_resource_register_channel(
+ connection->connection_resource,
+ channel_resource,
+ channel_resource->channel_id
+ ) == FAILURE) {
+ zend_throw_exception(
+ amqp_channel_exception_class_entry,
+ "Could not create channel. Failed to add channel to connection slot.",
+ 0
+ );
+ }
- /* Open up the channel for use */
- amqp_channel_open_ok_t *r = amqp_channel_open(channel_resource->connection_resource->connection_state, channel_resource->channel_id);
+ /* Open up the channel for use */
+ amqp_channel_open_ok_t *r =
+ amqp_channel_open(channel_resource->connection_resource->connection_state, channel_resource->channel_id);
- if (!r) {
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
- php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_channel_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- /* Prevent double free, it may happens in case case channel resource was already freed due to some hard error. */
- if (channel_resource->connection_resource) {
- php_amqp_connection_resource_unregister_channel(channel_resource->connection_resource, channel_resource->channel_id);
- channel_resource->channel_id = 0;
- }
+ /* Prevent double free, it may happen in case the channel resource was already freed due to some hard error. */
+ if (channel_resource->connection_resource) {
+ php_amqp_connection_resource_unregister_channel(
+ channel_resource->connection_resource,
+ channel_resource->channel_id
+ );
+ channel_resource->channel_id = 0;
+ }
- return;
- }
+ return;
+ }
- /* r->channel_id is a 16-bit channel number insibe amqp_bytes_t, assertion below will without converting to uint16_t*/
- /* assert (r->channel_id == channel_resource->channel_id);*/
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ /* r->channel_id is a 16-bit channel number inside amqp_bytes_t, assertion below will without converting to uint16_t*/
+ /* assert (r->channel_id == channel_resource->channel_id);*/
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- channel_resource->is_connected = '\1';
+ channel_resource->is_connected = '\1';
- /* Set the prefetch count: */
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- 0, /* prefetch window size */
- (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("prefetch_count"), /* prefetch message count */
- /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */
- 0 /* global flag */
- );
+ /* Set the prefetch count: */
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ 0, /* prefetch window size */
+ (uint16_t) PHP_AMQP_READ_THIS_PROP_LONG("prefetchCount"), /* prefetch message count */
+ /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */
+ 0 /* global flag */
+ );
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- uint16_t global_prefetch_size = (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("global_prefetch_size");
- uint16_t global_prefetch_count = (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("global_prefetch_count");
+ uint32_t global_prefetch_size = (uint32_t) PHP_AMQP_READ_THIS_PROP_LONG("globalPrefetchSize");
+ uint16_t global_prefetch_count = (uint16_t) PHP_AMQP_READ_THIS_PROP_LONG("globalPrefetchCount");
- /* Set the global prefetch settings (ignoring if 0 for backwards compatibility) */
- if (global_prefetch_size != 0 || global_prefetch_count != 0) {
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- global_prefetch_size,
- global_prefetch_count,
- 1
- );
+ /* Set the global prefetch settings (ignoring if 0 for backwards compatibility) */
+ if (global_prefetch_size != 0 || global_prefetch_count != 0) {
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ global_prefetch_size,
+ global_prefetch_count,
+ 1
+ );
- res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- }
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ }
}
/* }}} */
@@ -482,13 +466,13 @@ static PHP_METHOD(amqp_channel_class, __construct)
check amqp channel */
static PHP_METHOD(amqp_channel_class, isConnected)
{
- amqp_channel_resource *channel_resource;
+ amqp_channel_resource *channel_resource;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- RETURN_BOOL(channel_resource && channel_resource->is_connected);
+ RETURN_BOOL(channel_resource && channel_resource->is_connected);
}
/* }}} */
@@ -498,12 +482,12 @@ static PHP_METHOD(amqp_channel_class, close)
{
amqp_channel_resource *channel_resource;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- if(channel_resource && channel_resource->is_connected) {
- php_amqp_close_channel(channel_resource, 1 TSRMLS_CC);
+ if (channel_resource && channel_resource->is_connected) {
+ php_amqp_close_channel(channel_resource, 1);
}
}
/* }}} */
@@ -512,17 +496,17 @@ static PHP_METHOD(amqp_channel_class, close)
get amqp channel ID */
static PHP_METHOD(amqp_channel_class, getChannelId)
{
- amqp_channel_resource *channel_resource;
+ amqp_channel_resource *channel_resource;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- if (!channel_resource) {
- RETURN_NULL();
- }
+ if (!channel_resource) {
+ RETURN_NULL();
+ }
- RETURN_LONG(channel_resource->channel_id);
+ RETURN_LONG(channel_resource->channel_id);
}
/* }}} */
@@ -530,69 +514,77 @@ static PHP_METHOD(amqp_channel_class, getChannelId)
set the number of prefetches */
static PHP_METHOD(amqp_channel_class, setPrefetchCount)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
- PHP5to7_param_long_type_t prefetch_count;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &prefetch_count) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch count.");
- // TODO: verify that connection is active and resource exists. that is enough
-
- /* If we are already connected, set the new prefetch count */
- if (channel_resource->is_connected) {
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- 0,
- (uint16_t)prefetch_count,
- 0
- );
-
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- uint16_t global_prefetch_size = (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("global_prefetch_size");
- uint16_t global_prefetch_count = (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("global_prefetch_count");
-
- /* Re-apply current global prefetch settings if set (writing consumer prefetch settings will clear global prefetch settings) */
- if (global_prefetch_size != 0 || global_prefetch_count != 0) {
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- global_prefetch_size,
- global_prefetch_count,
- 1
- );
-
- res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- }
- }
-
- /* Set the prefetch count - the implication is to disable the size */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("prefetch_count"), prefetch_count TSRMLS_CC);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("prefetch_size"), 0 TSRMLS_CC);
-
- RETURN_TRUE;
+ zval rv;
+
+ amqp_channel_resource *channel_resource;
+ zend_long prefetch_count;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &prefetch_count) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ if (!php_amqp_is_valid_prefetch_count(prefetch_count)) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'prefetchCount' must be between 0 and %u.",
+ PHP_AMQP_MAX_PREFETCH_COUNT
+ );
+ return;
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch count.");
+ // TODO: verify that connection is active and resource exists. that is enough
+
+ /* If we are already connected, set the new prefetch count */
+ if (channel_resource->is_connected) {
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ 0,
+ (uint16_t) prefetch_count,
+ 0
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+
+ uint32_t global_prefetch_size = (uint32_t) PHP_AMQP_READ_THIS_PROP_LONG("globalPrefetchSize");
+ uint16_t global_prefetch_count = (uint16_t) PHP_AMQP_READ_THIS_PROP_LONG("globalPrefetchCount");
+
+ /* Re-apply current global prefetch settings if set (writing consumer prefetch settings will clear global prefetch settings) */
+ if (global_prefetch_size != 0 || global_prefetch_count != 0) {
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ global_prefetch_size,
+ global_prefetch_count,
+ 1
+ );
+
+ res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ }
+ }
+
+ /* Set the prefetch count - the implication is to disable the size */
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("prefetchCount"), prefetch_count);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("prefetchSize"), 0);
}
/* }}} */
@@ -600,9 +592,9 @@ static PHP_METHOD(amqp_channel_class, setPrefetchCount)
get the number of prefetches */
static PHP_METHOD(amqp_channel_class, getPrefetchCount)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("prefetch_count")
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("prefetchCount")
}
/* }}} */
@@ -610,68 +602,76 @@ static PHP_METHOD(amqp_channel_class, getPrefetchCount)
set the number of prefetches */
static PHP_METHOD(amqp_channel_class, setPrefetchSize)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
- PHP5to7_param_long_type_t prefetch_size;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &prefetch_size) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch size.");
-
- /* If we are already connected, set the new prefetch count */
- if (channel_resource->is_connected) {
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- (uint16_t)prefetch_size,
- 0,
- 0
- );
-
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- uint16_t global_prefetch_size = (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("global_prefetch_size");
- uint16_t global_prefetch_count = (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("global_prefetch_count");
-
- /* Re-apply current global prefetch settings if set (writing consumer prefetch settings will clear global prefetch settings) */
- if (global_prefetch_size != 0 || global_prefetch_count != 0) {
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- global_prefetch_size,
- global_prefetch_count,
- 1
- );
-
- res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- }
- }
-
- /* Set the prefetch size - the implication is to disable the count */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("prefetch_count"), 0 TSRMLS_CC);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("prefetch_size"), prefetch_size TSRMLS_CC);
-
- RETURN_TRUE;
+ zval rv;
+
+ amqp_channel_resource *channel_resource;
+ zend_long prefetch_size;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &prefetch_size) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ if (!php_amqp_is_valid_prefetch_size(prefetch_size)) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'prefetchSize' must be between 0 and %u.",
+ PHP_AMQP_MAX_PREFETCH_SIZE
+ );
+ return;
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch size.");
+
+ /* If we are already connected, set the new prefetch count */
+ if (channel_resource->is_connected) {
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ (uint32_t) prefetch_size,
+ 0,
+ 0
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+
+ uint32_t global_prefetch_size = (uint32_t) PHP_AMQP_READ_THIS_PROP_LONG("globalPrefetchSize");
+ uint16_t global_prefetch_count = (uint16_t) PHP_AMQP_READ_THIS_PROP_LONG("globalPrefetchCount");
+
+ /* Re-apply current global prefetch settings if set (writing consumer prefetch settings will clear global prefetch settings) */
+ if (global_prefetch_size != 0 || global_prefetch_count != 0) {
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ global_prefetch_size,
+ global_prefetch_count,
+ 1
+ );
+
+ res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ }
+ }
+
+ /* Set the prefetch size - the implication is to disable the count */
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("prefetchCount"), 0);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("prefetchSize"), prefetch_size);
}
/* }}} */
@@ -679,9 +679,9 @@ static PHP_METHOD(amqp_channel_class, setPrefetchSize)
get the number of prefetches */
static PHP_METHOD(amqp_channel_class, getPrefetchSize)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("prefetch_size")
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("prefetchSize")
}
/* }}} */
@@ -689,45 +689,56 @@ static PHP_METHOD(amqp_channel_class, getPrefetchSize)
set the number of prefetches */
static PHP_METHOD(amqp_channel_class, setGlobalPrefetchCount)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
- PHP5to7_param_long_type_t global_prefetch_count;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &global_prefetch_count) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set global prefetch count.");
-
- /* If we are already connected, set the new prefetch count */
- if (channel_resource->is_connected) {
- /* Applying global prefetch settings retains existing consumer prefetch settings */
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- 0,
- (uint16_t)global_prefetch_count,
- 1
- );
+ amqp_channel_resource *channel_resource;
+ zend_long global_prefetch_count;
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &global_prefetch_count) == FAILURE) {
+ RETURN_THROWS();
+ }
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (!php_amqp_is_valid_prefetch_count(global_prefetch_count)) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'globalPrefetchCount' must be between 0 and %u.",
+ PHP_AMQP_MAX_PREFETCH_COUNT
+ );
+ return;
+ }
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- }
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set global prefetch count.");
+
+ /* If we are already connected, set the new prefetch count */
+ if (channel_resource->is_connected) {
+ /* Applying global prefetch settings retains existing consumer prefetch settings */
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ 0,
+ (uint16_t) global_prefetch_count,
+ 1
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- /* Set the global prefetch count - the implication is to disable the size */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("global_prefetch_count"), global_prefetch_count TSRMLS_CC);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("global_prefetch_size"), 0 TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ }
- RETURN_TRUE;
+ /* Set the global prefetch count - the implication is to disable the size */
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("globalPrefetchCount"),
+ global_prefetch_count
+ );
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("globalPrefetchSize"), 0);
}
/* }}} */
@@ -735,9 +746,9 @@ static PHP_METHOD(amqp_channel_class, setGlobalPrefetchCount)
get the number of prefetches */
static PHP_METHOD(amqp_channel_class, getGlobalPrefetchCount)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("global_prefetch_count")
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("globalPrefetchCount")
}
/* }}} */
@@ -745,45 +756,56 @@ static PHP_METHOD(amqp_channel_class, getGlobalPrefetchCount)
set the number of prefetches */
static PHP_METHOD(amqp_channel_class, setGlobalPrefetchSize)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
- PHP5to7_param_long_type_t global_prefetch_size;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &global_prefetch_size) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch size.");
-
- /* If we are already connected, set the new prefetch count */
- if (channel_resource->is_connected) {
- /* Applying global prefetch settings retains existing consumer prefetch settings */
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- (uint16_t)global_prefetch_size,
- 0,
- 1
- );
+ amqp_channel_resource *channel_resource;
+ zend_long global_prefetch_size;
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &global_prefetch_size) == FAILURE) {
+ RETURN_THROWS();
+ }
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (!php_amqp_is_valid_prefetch_size(global_prefetch_size)) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'globalPrefetchSize' must be between 0 and %u.",
+ PHP_AMQP_MAX_PREFETCH_SIZE
+ );
+ return;
+ }
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- }
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set prefetch size.");
+
+ /* If we are already connected, set the new prefetch count */
+ if (channel_resource->is_connected) {
+ /* Applying global prefetch settings retains existing consumer prefetch settings */
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ (uint32_t) global_prefetch_size,
+ 0,
+ 1
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- /* Set the global prefetch size - the implication is to disable the count */
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("global_prefetch_count"), 0 TSRMLS_CC);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("global_prefetch_size"), global_prefetch_size TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ }
- RETURN_TRUE;
+ /* Set the global prefetch size - the implication is to disable the count */
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("globalPrefetchCount"), 0);
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("globalPrefetchSize"),
+ global_prefetch_size
+ );
}
/* }}} */
@@ -791,9 +813,9 @@ static PHP_METHOD(amqp_channel_class, setGlobalPrefetchSize)
get the number of prefetches */
static PHP_METHOD(amqp_channel_class, getGlobalPrefetchSize)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("global_prefetch_size")
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("globalPrefetchSize")
}
/* }}} */
@@ -801,76 +823,89 @@ static PHP_METHOD(amqp_channel_class, getGlobalPrefetchSize)
set the number of prefetches */
static PHP_METHOD(amqp_channel_class, qos)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
- PHP5to7_param_long_type_t prefetch_size;
- PHP5to7_param_long_type_t prefetch_count;
- zend_bool global = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll|b", &prefetch_size, &prefetch_count, &global) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set qos parameters.");
-
- /* Set the prefetch size and prefetch count */
- if (global) {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("global_prefetch_size"), prefetch_size TSRMLS_CC);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("global_prefetch_count"), prefetch_count TSRMLS_CC);
- } else {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("prefetch_size"), prefetch_size TSRMLS_CC);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("prefetch_count"), prefetch_count TSRMLS_CC);
- }
-
- /* If we are already connected, set the new prefetch count */
- if (channel_resource->is_connected) {
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("prefetch_size"),
- (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("prefetch_count"),
- /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */
- 0 /* Global flag - whether this change should affect every channel_resource */
- );
-
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- uint16_t global_prefetch_size = (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("global_prefetch_size");
- uint16_t global_prefetch_count = (uint16_t)PHP_AMQP_READ_THIS_PROP_LONG("global_prefetch_count");
-
- /* Re-apply current global prefetch settings if set (writing consumer prefetch settings will clear global prefetch settings) */
- if (global_prefetch_size != 0 || global_prefetch_count != 0) {
- amqp_basic_qos(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- global_prefetch_size,
- global_prefetch_count,
- 1
- );
-
- res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- }
- }
-
- RETURN_TRUE;
+ zval rv;
+
+ amqp_channel_resource *channel_resource;
+ zend_long prefetch_size;
+ zend_long prefetch_count;
+ bool global = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll|b", &prefetch_size, &prefetch_count, &global) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(channel_resource, "Could not set qos parameters.");
+
+ /* Set the prefetch size and prefetch count */
+ if (global) {
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("globalPrefetchSize"),
+ prefetch_size
+ );
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("globalPrefetchCount"),
+ prefetch_count
+ );
+ } else {
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("prefetchSize"), prefetch_size);
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("prefetchCount"),
+ prefetch_count
+ );
+ }
+
+ /* If we are already connected, set the new prefetch count */
+ if (channel_resource->is_connected) {
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ (uint32_t) PHP_AMQP_READ_THIS_PROP_LONG("prefetchSize"),
+ (uint16_t) PHP_AMQP_READ_THIS_PROP_LONG("prefetchCount"),
+ /* NOTE that RabbitMQ has reinterpreted global flag field. See https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.qos.global for details */
+ 0 /* Global flag - whether this change should affect every channel_resource */
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+
+ uint32_t global_prefetch_size = (uint32_t) PHP_AMQP_READ_THIS_PROP_LONG("globalPrefetchSize");
+ uint16_t global_prefetch_count = (uint16_t) PHP_AMQP_READ_THIS_PROP_LONG("globalPrefetchCount");
+
+ /* Re-apply current global prefetch settings if set (writing consumer prefetch settings will clear global prefetch settings) */
+ if (global_prefetch_size != 0 || global_prefetch_count != 0) {
+ amqp_basic_qos(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ global_prefetch_size,
+ global_prefetch_count,
+ 1
+ );
+
+ res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ }
+ }
}
/* }}} */
@@ -879,33 +914,26 @@ static PHP_METHOD(amqp_channel_class, qos)
start a transaction on the given channel */
static PHP_METHOD(amqp_channel_class, startTransaction)
{
- amqp_channel_resource *channel_resource;
-
- amqp_rpc_reply_t res;
+ amqp_channel_resource *channel_resource;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
- return;
- }
+ amqp_rpc_reply_t res;
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start the transaction.");
+ PHP_AMQP_NOPARAMS()
- amqp_tx_select(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id
- );
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start the transaction.");
- res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ amqp_tx_select(channel_resource->connection_resource->connection_state, channel_resource->channel_id);
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- RETURN_TRUE;
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -914,33 +942,26 @@ static PHP_METHOD(amqp_channel_class, startTransaction)
start a transaction on the given channel */
static PHP_METHOD(amqp_channel_class, commitTransaction)
{
- amqp_channel_resource *channel_resource;
-
- amqp_rpc_reply_t res;
+ amqp_channel_resource *channel_resource;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
- return;
- }
+ amqp_rpc_reply_t res;
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start the transaction.");
+ PHP_AMQP_NOPARAMS()
- amqp_tx_commit(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id
- );
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start the transaction.");
- res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ amqp_tx_commit(channel_resource->connection_resource->connection_state, channel_resource->channel_id);
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- RETURN_TRUE;
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -948,34 +969,26 @@ static PHP_METHOD(amqp_channel_class, commitTransaction)
start a transaction on the given channel */
static PHP_METHOD(amqp_channel_class, rollbackTransaction)
{
- amqp_channel_resource *channel_resource;
-
- amqp_rpc_reply_t res;
+ amqp_channel_resource *channel_resource;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
- return;
- }
+ amqp_rpc_reply_t res;
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not rollback the transaction.");
+ PHP_AMQP_NOPARAMS()
- amqp_tx_rollback(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id
- );
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not rollback the transaction.");
- res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ amqp_tx_rollback(channel_resource->connection_resource->connection_state, channel_resource->channel_id);
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- RETURN_TRUE;
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -983,9 +996,9 @@ static PHP_METHOD(amqp_channel_class, rollbackTransaction)
Get the AMQPConnection object in use */
static PHP_METHOD(amqp_channel_class, getConnection)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("connection")
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("connection")
}
/* }}} */
@@ -993,36 +1006,34 @@ static PHP_METHOD(amqp_channel_class, getConnection)
Redeliver unacknowledged messages */
static PHP_METHOD(amqp_channel_class, basicRecover)
{
- amqp_channel_resource *channel_resource;
-
- amqp_rpc_reply_t res;
+ amqp_channel_resource *channel_resource;
- zend_bool requeue = 1;
+ amqp_rpc_reply_t res;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|b", &requeue) == FAILURE) {
- return;
- }
+ bool requeue = 1;
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not redeliver unacknowledged messages.");
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &requeue) == FAILURE) {
+ RETURN_THROWS();
+ }
- amqp_basic_recover(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- (amqp_boolean_t) requeue
- );
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not redeliver unacknowledged messages.");
- res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ amqp_basic_recover(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ (amqp_boolean_t) requeue
+ );
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- RETURN_TRUE;
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -1030,32 +1041,26 @@ static PHP_METHOD(amqp_channel_class, basicRecover)
Redeliver unacknowledged messages */
PHP_METHOD(amqp_channel_class, confirmSelect)
{
- amqp_channel_resource *channel_resource;
- amqp_rpc_reply_t res;
+ amqp_channel_resource *channel_resource;
+ amqp_rpc_reply_t res;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
- return;
- }
+ PHP_AMQP_NOPARAMS()
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not enable confirms mode.");
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(getThis());
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not enable confirms mode.");
- amqp_confirm_select(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id
- );
+ amqp_confirm_select(channel_resource->connection_resource->connection_state, channel_resource->channel_id);
- res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_channel_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- RETURN_TRUE;
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -1063,22 +1068,22 @@ PHP_METHOD(amqp_channel_class, confirmSelect)
Set callback for basic.return server method handling */
PHP_METHOD(amqp_channel_class, setReturnCallback)
{
- zend_fcall_info fci = empty_fcall_info;
- zend_fcall_info_cache fcc = empty_fcall_info_cache;
+ zend_fcall_info fci = empty_fcall_info;
+ zend_fcall_info_cache fcc = empty_fcall_info_cache;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f!", &fci, &fcc) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f!", &fci, &fcc) == FAILURE) {
+ RETURN_THROWS();
+ }
- amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(getThis());
+ amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(getThis());
- php_amqp_destroy_fci(&channel->callbacks.basic_return.fci);
+ php_amqp_destroy_fci(&channel->callbacks.basic_return.fci);
- if (ZEND_FCI_INITIALIZED(fci)) {
- php_amqp_duplicate_fci(&fci);
- channel->callbacks.basic_return.fci = fci;
- channel->callbacks.basic_return.fcc = fcc;
- }
+ if (ZEND_FCI_INITIALIZED(fci)) {
+ php_amqp_duplicate_fci(&fci);
+ channel->callbacks.basic_return.fci = fci;
+ channel->callbacks.basic_return.fcc = fcc;
+ }
}
/* }}} */
@@ -1086,91 +1091,107 @@ PHP_METHOD(amqp_channel_class, setReturnCallback)
Wait for basic.return method from server */
PHP_METHOD(amqp_channel_class, waitForBasicReturn)
{
- amqp_channel_object *channel;
- amqp_channel_resource *channel_resource;
- amqp_method_t method;
-
- int status;
-
- double timeout = 0;
-
- struct timeval tv = {0};
- struct timeval *tv_ptr = &tv;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|d", &timeout) == FAILURE) {
- return;
- }
-
- if (timeout < 0) {
- zend_throw_exception(amqp_channel_exception_class_entry, "Timeout must be greater than or equal to zero.", 0 TSRMLS_CC);
- return;
- }
+ amqp_channel_object *channel;
+ amqp_channel_resource *channel_resource;
+ amqp_method_t method;
- channel = PHP_AMQP_GET_CHANNEL(getThis());
+ int status;
- channel_resource = channel->channel_resource;
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start wait loop for basic.return method.");
+ double timeout = 0;
- if (timeout > 0) {
- tv.tv_sec = (long int) timeout;
- tv.tv_usec = (long int) ((timeout - tv.tv_sec) * 1000000);
- } else {
- tv_ptr = NULL;
- }
+ struct timeval tv = {0};
+ struct timeval *tv_ptr = &tv;
- assert(channel_resource->channel_id > 0);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|d", &timeout) == FAILURE) {
+ RETURN_THROWS();
+ }
- while(1) {
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ if (timeout < 0) {
+ zend_throw_exception(amqp_channel_exception_class_entry, "Timeout must be greater than or equal to zero.", 0);
+ return;
+ }
- status = amqp_simple_wait_method_noblock(channel_resource->connection_resource->connection_state, channel_resource->channel_id, AMQP_BASIC_RETURN_METHOD, &method, tv_ptr);
+ channel = PHP_AMQP_GET_CHANNEL(getThis());
- if (AMQP_STATUS_TIMEOUT == status) {
- zend_throw_exception(amqp_queue_exception_class_entry, "Wait timeout exceed", 0 TSRMLS_CC);
+ channel_resource = channel->channel_resource;
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start wait loop for basic.return method.");
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (timeout > 0) {
+ tv.tv_sec = (long int) timeout;
+ tv.tv_usec = (long int) ((timeout - tv.tv_sec) * 1000000);
+ } else {
+ tv_ptr = NULL;
+ }
- if (status != AMQP_STATUS_OK) {
- /* Emulate library error */
- amqp_rpc_reply_t res;
+ assert(channel_resource->channel_id > 0);
- if (AMQP_RESPONSE_SERVER_EXCEPTION == status) {
- res.reply_type = AMQP_RESPONSE_SERVER_EXCEPTION;
- res.reply = method;
- } else {
- res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- res.library_error = status;
- }
+ while (1) {
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
+ status = amqp_simple_wait_method_noblock(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ AMQP_BASIC_RETURN_METHOD,
+ &method,
+ tv_ptr
+ );
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (AMQP_STATUS_TIMEOUT == status) {
+ zend_throw_exception(amqp_queue_exception_class_entry, "Wait timeout exceed", 0);
- status = php_amqp_handle_basic_return(&PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource->channel_id, channel, &method TSRMLS_CC);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- if (PHP_AMQP_RESOURCE_RESPONSE_BREAK == status) {
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- break;
- }
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+
+ if (AMQP_RESPONSE_SERVER_EXCEPTION == status) {
+ res.reply_type = AMQP_RESPONSE_SERVER_EXCEPTION;
+ res.reply = method;
+ } else {
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+ }
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- if (PHP_AMQP_RESOURCE_RESPONSE_OK != status) {
- /* Emulate library error */
- amqp_rpc_reply_t res;
- res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- res.library_error = status;
+ status = php_amqp_handle_basic_return(&PHP_AMQP_G(error_message), channel, &method);
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
+ if (PHP_AMQP_RESOURCE_RESPONSE_BREAK == status) {
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ break;
+ }
- php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
- }
+ if (PHP_AMQP_RESOURCE_RESPONSE_OK != status) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_channel_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+ }
}
/* }}} */
@@ -1178,33 +1199,33 @@ PHP_METHOD(amqp_channel_class, waitForBasicReturn)
Set callback for basic.ack and, optionally, basic.nac server methods handling */
PHP_METHOD(amqp_channel_class, setConfirmCallback)
{
- zend_fcall_info ack_fci = empty_fcall_info;
- zend_fcall_info_cache ack_fcc = empty_fcall_info_cache;
+ zend_fcall_info ack_fci = empty_fcall_info;
+ zend_fcall_info_cache ack_fcc = empty_fcall_info_cache;
- zend_fcall_info nack_fci = empty_fcall_info;
- zend_fcall_info_cache nack_fcc = empty_fcall_info_cache;
+ zend_fcall_info nack_fci = empty_fcall_info;
+ zend_fcall_info_cache nack_fcc = empty_fcall_info_cache;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f!|f!", &ack_fci, &ack_fcc, &nack_fci, &nack_fcc) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f!|f!", &ack_fci, &ack_fcc, &nack_fci, &nack_fcc) == FAILURE) {
+ RETURN_THROWS();
+ }
- amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(getThis());
+ amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(getThis());
- php_amqp_destroy_fci(&channel->callbacks.basic_ack.fci);
+ php_amqp_destroy_fci(&channel->callbacks.basic_ack.fci);
- if (ZEND_FCI_INITIALIZED(ack_fci)) {
- php_amqp_duplicate_fci(&ack_fci);
- channel->callbacks.basic_ack.fci = ack_fci;
- channel->callbacks.basic_ack.fcc = ack_fcc;
- }
+ if (ZEND_FCI_INITIALIZED(ack_fci)) {
+ php_amqp_duplicate_fci(&ack_fci);
+ channel->callbacks.basic_ack.fci = ack_fci;
+ channel->callbacks.basic_ack.fcc = ack_fcc;
+ }
- php_amqp_destroy_fci(&channel->callbacks.basic_nack.fci);
+ php_amqp_destroy_fci(&channel->callbacks.basic_nack.fci);
- if (ZEND_FCI_INITIALIZED(nack_fci)) {
- php_amqp_duplicate_fci(&nack_fci);
- channel->callbacks.basic_nack.fci = nack_fci;
- channel->callbacks.basic_nack.fcc = nack_fcc;
- }
+ if (ZEND_FCI_INITIALIZED(nack_fci)) {
+ php_amqp_duplicate_fci(&nack_fci);
+ channel->callbacks.basic_nack.fci = nack_fci;
+ channel->callbacks.basic_nack.fcc = nack_fcc;
+ }
}
/* }}} */
@@ -1213,280 +1234,315 @@ PHP_METHOD(amqp_channel_class, setConfirmCallback)
Redeliver unacknowledged messages */
PHP_METHOD(amqp_channel_class, waitForConfirm)
{
- amqp_channel_object *channel;
- amqp_channel_resource *channel_resource;
- amqp_method_t method;
-
- int status;
-
- double timeout = 0;
-
- struct timeval tv = {0};
- struct timeval *tv_ptr = &tv;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|d", &timeout) == FAILURE) {
- return;
- }
-
- if (timeout < 0) {
- zend_throw_exception(amqp_channel_exception_class_entry, "Timeout must be greater than or equal to zero.", 0 TSRMLS_CC);
- return;
- }
-
- channel = PHP_AMQP_GET_CHANNEL(getThis());
-
- channel_resource = channel->channel_resource;
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start wait loop for basic.return method.");
-
- if (timeout > 0) {
- tv.tv_sec = (long int) timeout;
- tv.tv_usec = (long int) ((timeout - tv.tv_sec) * 1000000);
- } else {
- tv_ptr = NULL;
- }
-
- assert(channel_resource->channel_id > 0);
-
-
- amqp_method_number_t expected_methods[] = { AMQP_BASIC_ACK_METHOD, AMQP_BASIC_NACK_METHOD, AMQP_BASIC_RETURN_METHOD, 0 };
-
- while(1) {
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- status = amqp_simple_wait_method_list_noblock(channel_resource->connection_resource->connection_state, channel_resource->channel_id, expected_methods, &method, tv_ptr);
-
- if (AMQP_STATUS_TIMEOUT == status) {
- zend_throw_exception(amqp_queue_exception_class_entry, "Wait timeout exceed", 0 TSRMLS_CC);
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- if (status != AMQP_STATUS_OK) {
- /* Emulate library error */
- amqp_rpc_reply_t res;
-
- if (AMQP_RESPONSE_SERVER_EXCEPTION == status) {
- res.reply_type = AMQP_RESPONSE_SERVER_EXCEPTION;
- res.reply = method;
- } else {
- res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- res.library_error = status;
- }
-
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
-
- php_amqp_zend_throw_exception(res, amqp_channel_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- switch(method.id) {
- case AMQP_BASIC_ACK_METHOD:
- status = php_amqp_handle_basic_ack(&PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource->channel_id, channel, &method TSRMLS_CC);
- break;
- case AMQP_BASIC_NACK_METHOD:
- status = php_amqp_handle_basic_nack(&PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource->channel_id, channel, &method TSRMLS_CC);
- break;
- case AMQP_BASIC_RETURN_METHOD:
- status = php_amqp_handle_basic_return(&PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource->channel_id, channel, &method TSRMLS_CC);
- break;
- default:
- status = AMQP_STATUS_WRONG_METHOD;
- }
-
- if (PHP_AMQP_RESOURCE_RESPONSE_BREAK == status) {
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- break;
- }
-
- if (PHP_AMQP_RESOURCE_RESPONSE_OK != status) {
- /* Emulate library error */
- amqp_rpc_reply_t res;
- res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- res.library_error = status;
-
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
-
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
- }
+ amqp_channel_object *channel;
+ amqp_channel_resource *channel_resource;
+ amqp_method_t method;
+
+ int status;
+
+ double timeout = 0;
+
+ struct timeval tv = {0};
+ struct timeval *tv_ptr = &tv;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|d", &timeout) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ if (timeout < 0) {
+ zend_throw_exception(amqp_channel_exception_class_entry, "Timeout must be greater than or equal to zero.", 0);
+ return;
+ }
+
+ channel = PHP_AMQP_GET_CHANNEL(getThis());
+
+ channel_resource = channel->channel_resource;
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not start wait loop for basic.return method.");
+
+ if (timeout > 0) {
+ tv.tv_sec = (long int) timeout;
+ tv.tv_usec = (long int) ((timeout - tv.tv_sec) * 1000000);
+ } else {
+ tv_ptr = NULL;
+ }
+
+ assert(channel_resource->channel_id > 0);
+
+
+ amqp_method_number_t expected_methods[] =
+ {AMQP_BASIC_ACK_METHOD, AMQP_BASIC_NACK_METHOD, AMQP_BASIC_RETURN_METHOD, 0};
+
+ while (1) {
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+
+ status = amqp_simple_wait_method_list_noblock(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ expected_methods,
+ &method,
+ tv_ptr
+ );
+
+ if (AMQP_STATUS_TIMEOUT == status) {
+ zend_throw_exception(amqp_queue_exception_class_entry, "Wait timeout exceed", 0);
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+
+ if (AMQP_RESPONSE_SERVER_EXCEPTION == status) {
+ res.reply_type = AMQP_RESPONSE_SERVER_EXCEPTION;
+ res.reply = method;
+ } else {
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+ }
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_channel_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ switch (method.id) {
+ case AMQP_BASIC_ACK_METHOD:
+ status = php_amqp_handle_basic_ack(&PHP_AMQP_G(error_message), channel, &method);
+ break;
+ case AMQP_BASIC_NACK_METHOD:
+ status = php_amqp_handle_basic_nack(&PHP_AMQP_G(error_message), channel, &method);
+ break;
+ case AMQP_BASIC_RETURN_METHOD:
+ status = php_amqp_handle_basic_return(&PHP_AMQP_G(error_message), channel, &method);
+ break;
+ default:
+ status = AMQP_STATUS_WRONG_METHOD;
+ }
+
+ if (PHP_AMQP_RESOURCE_RESPONSE_BREAK == status) {
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ break;
+ }
+
+ if (PHP_AMQP_RESOURCE_RESPONSE_OK != status) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+ }
}
/* }}} */
-/* {{{ proto amqp::getConsumers() */
+/* {{{ proto AMQPChannel::getConsumers() */
static PHP_METHOD(amqp_channel_class, getConsumers)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("consumers");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ zval *tmp = zend_read_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("consumers"), 0, &rv);
+ // Return a proper copy, so that the internal consumer map can be safely modified
+ ZVAL_DUP(return_value, tmp);
}
/* }}} */
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_OBJ_INFO(0, amqp_connection, AMQPConnection, 0)
+ ZEND_ARG_OBJ_INFO(0, connection, AMQPConnection, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_isConnected, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_isConnected, ZEND_SEND_BY_VAL, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_close, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_close, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getChannelId, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_getChannelId, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, size)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_setPrefetchSize, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_getPrefetchSize, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, count)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_setPrefetchCount, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_getPrefetchCount, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setGlobalPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, size)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_channel_class_setGlobalPrefetchSize,
+ ZEND_SEND_BY_VAL,
+ 1,
+ IS_VOID,
+ 0
+)
+ ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getGlobalPrefetchSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_channel_class_getGlobalPrefetchSize,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_LONG,
+ 0
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setGlobalPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, count)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_channel_class_setGlobalPrefetchCount,
+ ZEND_SEND_BY_VAL,
+ 1,
+ IS_VOID,
+ 0
+)
+ ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getGlobalPrefetchCount, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_channel_class_getGlobalPrefetchCount,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_LONG,
+ 0
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_qos, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
- ZEND_ARG_INFO(0, size)
- ZEND_ARG_INFO(0, count)
- ZEND_ARG_INFO(0, global)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_qos, ZEND_SEND_BY_VAL, 2, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, size, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO(0, count, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, global, _IS_BOOL, 0, "false")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_startTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_startTransaction, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_commitTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_commitTransaction, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_rollbackTransaction, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_rollbackTransaction, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(arginfo_amqp_channel_class_getConnection, AMQPConnection, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_basicRecover, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
- ZEND_ARG_INFO(0, requeue)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_basicRecover, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, requeue, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_confirmSelect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_confirmSelect, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setConfirmCallback, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, ack_callback)
- ZEND_ARG_INFO(0, nack_callback)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_setConfirmCallback, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_CALLABLE_INFO(0, ackCallback, 1)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, nackCallback, IS_CALLABLE, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_waitForConfirm, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
- ZEND_ARG_INFO(0, timeout)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_waitForConfirm, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_DOUBLE, 0, "0.0")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_setReturnCallback, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, return_callback)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_setReturnCallback, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_CALLABLE_INFO(0, returnCallback, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_waitForBasicReturn, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
- ZEND_ARG_INFO(0, timeout)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_waitForBasicReturn, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, timeout, IS_DOUBLE, 0, "0.0")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_channel_class_getConsumers, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_channel_class_getConsumers, ZEND_SEND_BY_VAL, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
-//setConfirmsCallback
-
zend_function_entry amqp_channel_class_functions[] = {
- PHP_ME(amqp_channel_class, __construct, arginfo_amqp_channel_class__construct, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, isConnected, arginfo_amqp_channel_class_isConnected, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, close, arginfo_amqp_channel_class_close, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, __construct, arginfo_amqp_channel_class__construct, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, isConnected, arginfo_amqp_channel_class_isConnected, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, close, arginfo_amqp_channel_class_close, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, getChannelId, arginfo_amqp_channel_class_getChannelId, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, getChannelId, arginfo_amqp_channel_class_getChannelId, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, setPrefetchSize, arginfo_amqp_channel_class_setPrefetchSize, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, getPrefetchSize, arginfo_amqp_channel_class_getPrefetchSize, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, setPrefetchCount, arginfo_amqp_channel_class_setPrefetchCount, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, getPrefetchCount, arginfo_amqp_channel_class_getPrefetchCount, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, setGlobalPrefetchSize, arginfo_amqp_channel_class_setGlobalPrefetchSize, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, getGlobalPrefetchSize, arginfo_amqp_channel_class_getGlobalPrefetchSize, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, setGlobalPrefetchCount, arginfo_amqp_channel_class_setGlobalPrefetchCount, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, getGlobalPrefetchCount, arginfo_amqp_channel_class_getGlobalPrefetchCount, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, qos, arginfo_amqp_channel_class_qos, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, setPrefetchSize, arginfo_amqp_channel_class_setPrefetchSize, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, getPrefetchSize, arginfo_amqp_channel_class_getPrefetchSize, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, setPrefetchCount, arginfo_amqp_channel_class_setPrefetchCount, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, getPrefetchCount, arginfo_amqp_channel_class_getPrefetchCount, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, setGlobalPrefetchSize, arginfo_amqp_channel_class_setGlobalPrefetchSize, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, getGlobalPrefetchSize, arginfo_amqp_channel_class_getGlobalPrefetchSize, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, setGlobalPrefetchCount, arginfo_amqp_channel_class_setGlobalPrefetchCount, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, getGlobalPrefetchCount, arginfo_amqp_channel_class_getGlobalPrefetchCount, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, qos, arginfo_amqp_channel_class_qos, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, startTransaction, arginfo_amqp_channel_class_startTransaction, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, commitTransaction, arginfo_amqp_channel_class_commitTransaction, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, rollbackTransaction, arginfo_amqp_channel_class_rollbackTransaction, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, startTransaction, arginfo_amqp_channel_class_startTransaction, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, commitTransaction, arginfo_amqp_channel_class_commitTransaction, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, rollbackTransaction, arginfo_amqp_channel_class_rollbackTransaction, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, getConnection, arginfo_amqp_channel_class_getConnection, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, getConnection, arginfo_amqp_channel_class_getConnection, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, basicRecover, arginfo_amqp_channel_class_basicRecover, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, basicRecover, arginfo_amqp_channel_class_basicRecover, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, confirmSelect, arginfo_amqp_channel_class_confirmSelect, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, waitForConfirm, arginfo_amqp_channel_class_waitForConfirm, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, setConfirmCallback, arginfo_amqp_channel_class_setConfirmCallback, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, confirmSelect, arginfo_amqp_channel_class_confirmSelect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, waitForConfirm, arginfo_amqp_channel_class_waitForConfirm, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, setConfirmCallback, arginfo_amqp_channel_class_setConfirmCallback, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, setReturnCallback, arginfo_amqp_channel_class_setReturnCallback, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, waitForBasicReturn, arginfo_amqp_channel_class_waitForBasicReturn, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, setReturnCallback, arginfo_amqp_channel_class_setReturnCallback, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, waitForBasicReturn, arginfo_amqp_channel_class_waitForBasicReturn, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_channel_class, getConsumers, arginfo_amqp_channel_class_getConsumers, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_channel_class, getConsumers, arginfo_amqp_channel_class_getConsumers, ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
+ {NULL, NULL, NULL}
};
PHP_MINIT_FUNCTION(amqp_channel)
{
- zend_class_entry ce;
-
- INIT_CLASS_ENTRY(ce, "AMQPChannel", amqp_channel_class_functions);
- ce.create_object = amqp_channel_ctor;
- amqp_channel_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("connection"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("prefetch_count"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_long(this_ce, ZEND_STRL("prefetch_size"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("global_prefetch_count"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("global_prefetch_size"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("consumers"), ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "AMQPChannel", amqp_channel_class_functions);
+ ce.create_object = amqp_channel_ctor;
+ amqp_channel_class_entry = zend_register_internal_class(&ce);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_OBJ(this_ce, "connection", ZEND_ACC_PRIVATE, AMQPConnection, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "prefetchCount", ZEND_ACC_PRIVATE, IS_LONG, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "prefetchSize", ZEND_ACC_PRIVATE, IS_LONG, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "globalPrefetchCount", ZEND_ACC_PRIVATE, IS_LONG, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "globalPrefetchSize", ZEND_ACC_PRIVATE, IS_LONG, 1);
+#if PHP_VERSION_ID >= 80000
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "consumers", ZEND_ACC_PRIVATE, IS_ARRAY, 0, ZVAL_EMPTY_ARRAY);
+#else
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "consumers", ZEND_ACC_PRIVATE, IS_ARRAY, 0, ZVAL_NULL);
+#endif
-#if PHP_MAJOR_VERSION >=7
- memcpy(&amqp_channel_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+#if PHP_MAJOR_VERSION >= 7
+ memcpy(&amqp_channel_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
- amqp_channel_object_handlers.offset = XtOffsetOf(amqp_channel_object, zo);
- amqp_channel_object_handlers.free_obj = amqp_channel_free;
+ amqp_channel_object_handlers.offset = XtOffsetOf(amqp_channel_object, zo);
+ amqp_channel_object_handlers.free_obj = amqp_channel_free;
#endif
#if ZEND_MODULE_API_NO >= 20100000
- amqp_channel_object_handlers.get_gc = amqp_channel_gc;
+ amqp_channel_object_handlers.get_gc = amqp_channel_gc;
#endif
- return SUCCESS;
+ return SUCCESS;
}
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_channel.h b/amqp_channel.h
index 41691864..76c72609 100644
--- a/amqp_channel.h
+++ b/amqp_channel.h
@@ -20,17 +20,10 @@
| - Jonathan Tansavatdi |
+----------------------------------------------------------------------+
*/
+#include "php.h"
+
extern zend_class_entry *amqp_channel_class_entry;
-void php_amqp_close_channel(amqp_channel_resource *channel_resource, zend_bool check_errors TSRMLS_DC);
+void php_amqp_close_channel(amqp_channel_resource *channel_resource, bool throw);
PHP_MINIT_FUNCTION(amqp_channel);
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_connection.c b/amqp_connection.c
index 5689b81a..c45b21f3 100644
--- a/amqp_connection.c
+++ b/amqp_connection.c
@@ -23,7 +23,7 @@
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
@@ -31,24 +31,27 @@
#include "zend_exceptions.h"
#ifdef PHP_WIN32
-# if PHP_VERSION_ID >= 80000
-# include "main/php_stdint.h"
-# else
-# include "win32/php_stdint.h"
-# endif
-# include "win32/signal.h"
+ #if PHP_VERSION_ID >= 80000
+ #include
+ #else
+ #include "win32/php_stdint.h"
+ #endif
+ #include "win32/signal.h"
#else
-# include
-# include
+ #include
+ #include
+#endif
+
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+#else
+ #include
#endif
-#include
-#include
-#include
#ifdef PHP_WIN32
-# include "win32/unistd.h"
+ #include "win32/unistd.h"
#else
-# include
+ #include
#endif
#include "php_amqp.h"
@@ -56,109 +59,117 @@
#include "amqp_connection_resource.h"
#include "amqp_connection.h"
-#ifndef E_DEPRECATED
-#define E_DEPRECATED E_WARNING
-#endif
-
zend_class_entry *amqp_connection_class_entry;
#define this_ce amqp_connection_class_entry
zend_object_handlers amqp_connection_object_handlers;
-#define PHP_AMQP_EXTRACT_CONNECTION_STR(name) \
- zdata = NULL; \
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), (name), sizeof(name), zdata)) { \
- SEPARATE_ZVAL(zdata); \
- convert_to_string(PHP5to7_MAYBE_DEREF(zdata)); \
- } \
- if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) { \
- zend_update_property_string(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); \
- } else { \
- zend_update_property_string(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), INI_STR("amqp." name) TSRMLS_CC); \
- }
+#define PHP_AMQP_EXTRACT_CONNECTION_STR(name) \
+ zdata = NULL; \
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL(name))) != NULL) { \
+ SEPARATE_ZVAL(zdata); \
+ convert_to_string(zdata); \
+ } \
+ if (zdata && Z_STRLEN_P(zdata) > 0) { \
+ zend_update_property_string(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL(name), Z_STRVAL_P(zdata)); \
+ } else if (strlen(INI_STR("amqp." name)) > 0) { \
+ zend_update_property_string( \
+ this_ce, \
+ PHP_AMQP_COMPAT_OBJ_P(getThis()), \
+ ZEND_STRL(name), \
+ INI_STR("amqp." name) \
+ ); \
+ }
-#define PHP_AMQP_EXTRACT_CONNECTION_BOOL(name) \
- zdata = NULL; \
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), (name), sizeof(name), zdata)) { \
- SEPARATE_ZVAL(zdata); \
- convert_to_long(PHP5to7_MAYBE_DEREF(zdata)); \
- } \
- if (zdata) { \
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC); \
- } else { \
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), INI_INT("amqp." name) TSRMLS_CC); \
- }
+#define PHP_AMQP_EXTRACT_CONNECTION_BOOL(name) \
+ zdata = NULL; \
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL(name))) != NULL) { \
+ SEPARATE_ZVAL(zdata); \
+ convert_to_long(zdata); \
+ } \
+ if (zdata) { \
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL(name), Z_LVAL_P(zdata)); \
+ } else { \
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL(name), INI_INT("amqp." name)); \
+ }
-static int php_amqp_connection_resource_deleter(PHP5to7_zend_resource_le_t *el, amqp_connection_resource *connection_resource TSRMLS_DC)
+static int php_amqp_connection_resource_deleter(zval *el, amqp_connection_resource *connection_resource)
{
- if (Z_RES_P(el)->ptr == connection_resource) {
- return ZEND_HASH_APPLY_REMOVE | ZEND_HASH_APPLY_STOP;
- }
+ if (Z_RES_P(el)->ptr == connection_resource) {
+ return ZEND_HASH_APPLY_REMOVE | ZEND_HASH_APPLY_STOP;
+ }
- return ZEND_HASH_APPLY_KEEP;
+ return ZEND_HASH_APPLY_KEEP;
}
-static PHP5to7_param_str_len_type_t php_amqp_get_connection_hash(amqp_connection_params *params, char **hash) {
- return spprintf(hash,
- 0,
- "amqp_conn_res_h:%s_p:%d_v:%s_l:%s_p:%s_f:%d_c:%d_h:%d_cacert:%s_capath:%s_cert:%s_key:%s_sasl_method:%d_connection_name:%s",
- params->host,
- params->port,
- params->vhost,
- params->login,
- params->password,
- params->frame_max,
- params->channel_max,
- params->heartbeat,
- params->cacert,
- params->capath,
- params->cert,
- params->key,
- params->sasl_method,
- params->connection_name
- );
+static size_t php_amqp_get_connection_hash(amqp_connection_params *params, char **hash)
+{
+ return spprintf(
+ hash,
+ 0,
+ "amqp_conn_res_h:%s_p:%d_v:%s_l:%s_p:%s_f:%d_c:%d_h:%d_cacert:%s_capath:%s_cert:%s_key:%s_sasl_method:%d_connection_name:"
+ "%s",
+ params->host,
+ params->port,
+ params->vhost,
+ params->login,
+ params->password,
+ params->frame_max,
+ params->channel_max,
+ params->heartbeat,
+ params->cacert,
+ params->capath,
+ params->cert,
+ params->key,
+ params->sasl_method,
+ params->connection_name
+ );
}
-static void php_amqp_cleanup_connection_resource(amqp_connection_resource *connection_resource TSRMLS_DC)
+static void php_amqp_cleanup_connection_resource(amqp_connection_resource *connection_resource)
{
- if (!connection_resource) {
- return;
- }
+ if (!connection_resource) {
+ return;
+ }
- PHP5to7_zend_resource_t resource = connection_resource->resource;
+ zend_resource *resource = connection_resource->resource;
- connection_resource->parent->connection_resource = NULL;
- connection_resource->parent = NULL;
+ connection_resource->parent->connection_resource = NULL;
+ connection_resource->parent = NULL;
- if (connection_resource->is_dirty) {
- if (connection_resource->is_persistent) {
- zend_hash_apply_with_argument(&EG(persistent_list), (apply_func_arg_t)php_amqp_connection_resource_deleter, (void*)connection_resource TSRMLS_CC);
- }
+ if (connection_resource->is_dirty) {
+ if (connection_resource->is_persistent) {
+ zend_hash_apply_with_argument(
+ &EG(persistent_list),
+ (apply_func_arg_t) php_amqp_connection_resource_deleter,
+ (void *) connection_resource
+ );
+ }
- zend_list_delete(resource);
- } else {
- if (connection_resource->is_persistent) {
- connection_resource->resource = PHP5to7_ZEND_RESOURCE_EMPTY;
- }
+ zend_list_delete(resource);
+ } else {
+ if (connection_resource->is_persistent) {
+ connection_resource->resource = NULL;
+ }
- if (connection_resource->resource != PHP5to7_ZEND_RESOURCE_EMPTY) {
- zend_list_delete(resource);
- }
- }
+ if (connection_resource->resource != NULL) {
+ zend_list_delete(resource);
+ }
+ }
}
-static void php_amqp_disconnect(amqp_connection_resource *resource TSRMLS_DC)
+static void php_amqp_disconnect(amqp_connection_resource *resource)
{
- php_amqp_prepare_for_disconnect(resource TSRMLS_CC);
- php_amqp_cleanup_connection_resource(resource TSRMLS_CC);
+ php_amqp_prepare_for_disconnect(resource);
+ php_amqp_cleanup_connection_resource(resource);
}
-void php_amqp_disconnect_force(amqp_connection_resource *resource TSRMLS_DC)
+void php_amqp_disconnect_force(amqp_connection_resource *resource)
{
- php_amqp_prepare_for_disconnect(resource TSRMLS_CC);
- resource->is_dirty = '\1';
- php_amqp_cleanup_connection_resource(resource TSRMLS_CC);
+ php_amqp_prepare_for_disconnect(resource);
+ resource->is_dirty = '\1';
+ php_amqp_cleanup_connection_resource(resource);
}
/**
@@ -166,166 +177,180 @@ void php_amqp_disconnect_force(amqp_connection_resource *resource TSRMLS_DC)
* handles connecting to amqp
* called by connect(), pconnect(), reconnect(), preconnect()
*/
-int php_amqp_connect(amqp_connection_object *connection, zend_bool persistent, INTERNAL_FUNCTION_PARAMETERS)
+int php_amqp_connect(amqp_connection_object *connection, bool persistent, INTERNAL_FUNCTION_PARAMETERS)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- char *key = NULL;
- PHP5to7_param_str_len_type_t key_len = 0;
+ zval rv;
- if (connection->connection_resource) {
- /* Clean up old memory allocations which are now invalid (new connection) */
- php_amqp_cleanup_connection_resource(connection->connection_resource TSRMLS_CC);
- }
+ char *key = NULL;
+ size_t key_len = 0;
- assert(connection->connection_resource == NULL);
-
- amqp_connection_params connection_params;
-
- connection_params.host = PHP_AMQP_READ_THIS_PROP_STR("host");
- connection_params.port = (int)PHP_AMQP_READ_THIS_PROP_LONG("port");
- connection_params.vhost = PHP_AMQP_READ_THIS_PROP_STR("vhost");
- connection_params.login = PHP_AMQP_READ_THIS_PROP_STR("login");
- connection_params.password = PHP_AMQP_READ_THIS_PROP_STR("password");
- connection_params.frame_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("frame_max");
- connection_params.channel_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("channel_max");
- connection_params.heartbeat = (int) PHP_AMQP_READ_THIS_PROP_LONG("heartbeat");
- connection_params.read_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("read_timeout");
- connection_params.write_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("write_timeout");
- connection_params.connect_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("connect_timeout");
- connection_params.rpc_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("rpc_timeout");
- connection_params.cacert = PHP_AMQP_READ_THIS_PROP_STRLEN("cacert") ? PHP_AMQP_READ_THIS_PROP_STR("cacert") : NULL;
- connection_params.capath = PHP_AMQP_READ_THIS_PROP_STRLEN("capath") ? PHP_AMQP_READ_THIS_PROP_STR("capath") : NULL;
- connection_params.use_default_cacert = (int) PHP_AMQP_READ_THIS_PROP_BOOL("use_default_cacert");
- connection_params.use_default_capath = (int) PHP_AMQP_READ_THIS_PROP_BOOL("use_default_capath");
- connection_params.cert = PHP_AMQP_READ_THIS_PROP_STRLEN("cert") ? PHP_AMQP_READ_THIS_PROP_STR("cert") : NULL;
- connection_params.key = PHP_AMQP_READ_THIS_PROP_STRLEN("key") ? PHP_AMQP_READ_THIS_PROP_STR("key") : NULL;
- connection_params.verify = (int) PHP_AMQP_READ_THIS_PROP_BOOL("verify");
- connection_params.sasl_method = (int) PHP_AMQP_READ_THIS_PROP_LONG("sasl_method");
- connection_params.connection_name = PHP_AMQP_READ_THIS_PROP_STRLEN("connection_name") ? PHP_AMQP_READ_THIS_PROP_STR("connection_name") : NULL;
-
- if (persistent) {
- PHP5to7_zend_resource_store_t *le = PHP5to7_ZEND_RESOURCE_EMPTY;
-
- /* Look for an established resource */
- key_len = php_amqp_get_connection_hash(&connection_params, &key);
-
- if (PHP5to7_ZEND_HASH_STR_FIND_PTR(&EG(persistent_list), key, key_len, le)) {
- efree(key);
-
- if (le->type != le_amqp_connection_resource_persistent) {
- /* hash conflict, given name associate with non-amqp persistent connection resource */
- return 0;
- }
-
- /* An entry for this connection resource already exists */
- /* Stash the connection resource in the connection */
- connection->connection_resource = le->ptr;
-
- if (connection->connection_resource->resource != PHP5to7_ZEND_RESOURCE_EMPTY) {
- /* resource in use! */
- connection->connection_resource = NULL;
-
- zend_throw_exception(amqp_connection_exception_class_entry, "There are already established persistent connection to the same resource.", 0 TSRMLS_CC);
- return 0;
- }
-
- connection->connection_resource->resource = PHP5to7_ZEND_REGISTER_RESOURCE(connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource);
- connection->connection_resource->parent = connection;
-
- /* Set desired timeouts */
- if (php_amqp_set_resource_read_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("read_timeout") TSRMLS_CC) == 0
- || php_amqp_set_resource_write_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("write_timeout") TSRMLS_CC) == 0
- || php_amqp_set_resource_rpc_timeout(connection->connection_resource, PHP_AMQP_READ_THIS_PROP_DOUBLE("rpc_timeout") TSRMLS_CC) == 0) {
-
- php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
- return 0;
- }
-
- /* Set connection status to connected */
- connection->connection_resource->is_connected = '\1';
- connection->connection_resource->is_persistent = persistent;
-
- return 1;
- }
-
- efree(key);
- }
+ if (connection->connection_resource) {
+ /* Clean up old memory allocations which are now invalid (new connection) */
+ php_amqp_cleanup_connection_resource(connection->connection_resource);
+ }
- connection->connection_resource = connection_resource_constructor(&connection_params, persistent TSRMLS_CC);
+ assert(connection->connection_resource == NULL);
+
+ amqp_connection_params connection_params;
+
+ connection_params.host = PHP_AMQP_READ_THIS_PROP_STR("host");
+ connection_params.port = (int) PHP_AMQP_READ_THIS_PROP_LONG("port");
+ connection_params.vhost = PHP_AMQP_READ_THIS_PROP_STR("vhost");
+ connection_params.login = PHP_AMQP_READ_THIS_PROP_STR("login");
+ connection_params.password = PHP_AMQP_READ_THIS_PROP_STR("password");
+ connection_params.frame_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("frameMax");
+ connection_params.channel_max = (int) PHP_AMQP_READ_THIS_PROP_LONG("channelMax");
+ connection_params.heartbeat = (int) PHP_AMQP_READ_THIS_PROP_LONG("heartbeat");
+ connection_params.read_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("readTimeout");
+ connection_params.write_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("writeTimeout");
+ connection_params.connect_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("connectTimeout");
+ connection_params.rpc_timeout = PHP_AMQP_READ_THIS_PROP_DOUBLE("rpcTimeout");
+ connection_params.cacert = PHP_AMQP_READ_THIS_PROP_STRLEN("cacert") ? PHP_AMQP_READ_THIS_PROP_STR("cacert") : NULL;
+ connection_params.capath = PHP_AMQP_READ_THIS_PROP_STRLEN("capath") ? PHP_AMQP_READ_THIS_PROP_STR("capath") : NULL;
+ connection_params.use_default_cacert = (int) PHP_AMQP_READ_THIS_PROP_BOOL("use_default_cacert");
+ connection_params.use_default_capath = (int) PHP_AMQP_READ_THIS_PROP_BOOL("use_default_capath");
+ connection_params.cert = PHP_AMQP_READ_THIS_PROP_STRLEN("cert") ? PHP_AMQP_READ_THIS_PROP_STR("cert") : NULL;
+ connection_params.key = PHP_AMQP_READ_THIS_PROP_STRLEN("key") ? PHP_AMQP_READ_THIS_PROP_STR("key") : NULL;
+ connection_params.verify = (int) PHP_AMQP_READ_THIS_PROP_BOOL("verify");
+ connection_params.sasl_method = (int) PHP_AMQP_READ_THIS_PROP_LONG("saslMethod");
+ connection_params.connection_name =
+ PHP_AMQP_READ_THIS_PROP_STRLEN("connectionName") ? PHP_AMQP_READ_THIS_PROP_STR("connectionName") : NULL;
+
+ if (persistent) {
+ zend_resource *le = NULL;
+
+ /* Look for an established resource */
+ key_len = php_amqp_get_connection_hash(&connection_params, &key);
+
+ if ((le = zend_hash_str_find_ptr(&EG(persistent_list), key, key_len)) != NULL) {
+ efree(key);
+
+ if (le->type != le_amqp_connection_resource_persistent) {
+ /* hash conflict, given name associate with non-amqp persistent connection resource */
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Connection hash conflict detected. Persistent connection found that does not belong to AMQP.",
+ 0
+ );
+ return 0;
+ }
+
+ /* An entry for this connection resource already exists */
+ /* Stash the connection resource in the connection */
+ connection->connection_resource = le->ptr;
+
+ if (connection->connection_resource->resource != NULL) {
+ /* resource in use! */
+ connection->connection_resource = NULL;
+
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "There are already established persistent connection to the same resource.",
+ 0
+ );
+ return 0;
+ }
+
+ connection->connection_resource->resource = zend_register_resource(
+ connection->connection_resource,
+ persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource
+ );
+ connection->connection_resource->parent = connection;
+
+ /* Set desired timeouts */
+ if (php_amqp_set_resource_read_timeout(
+ connection->connection_resource,
+ PHP_AMQP_READ_THIS_PROP_DOUBLE("readTimeout")
+ ) == 0 ||
+ php_amqp_set_resource_write_timeout(
+ connection->connection_resource,
+ PHP_AMQP_READ_THIS_PROP_DOUBLE("writeTimeout")
+ ) == 0 ||
+ php_amqp_set_resource_rpc_timeout(
+ connection->connection_resource,
+ PHP_AMQP_READ_THIS_PROP_DOUBLE("rpcTimeout")
+ ) == 0) {
+
+ php_amqp_disconnect_force(connection->connection_resource);
+ return 0;
+ }
+
+ /* Set connection status to connected */
+ connection->connection_resource->is_connected = '\1';
+ connection->connection_resource->is_persistent = persistent;
+
+ return 1;
+ }
- if (connection->connection_resource == NULL) {
- return 0;
- }
+ efree(key);
+ }
- connection->connection_resource->resource = PHP5to7_ZEND_REGISTER_RESOURCE(connection->connection_resource, persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource);
- connection->connection_resource->parent = connection;
+ connection->connection_resource = connection_resource_constructor(&connection_params, persistent);
- /* Set connection status to connected */
- connection->connection_resource->is_connected = '\1';
+ if (connection->connection_resource == NULL) {
+ return 0;
+ }
- if (persistent) {
- connection->connection_resource->is_persistent = persistent;
+ connection->connection_resource->resource = zend_register_resource(
+ connection->connection_resource,
+ persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource
+ );
+ connection->connection_resource->parent = connection;
- key_len = php_amqp_get_connection_hash(&connection_params, &key);
+ /* Set connection status to connected */
+ connection->connection_resource->is_connected = '\1';
- PHP5to7_zend_resource_store_t new_le;
+ if (persistent) {
+ connection->connection_resource->is_persistent = persistent;
- /* Store a reference in the persistence list */
- new_le.ptr = connection->connection_resource;
- new_le.type = persistent ? le_amqp_connection_resource_persistent : le_amqp_connection_resource;
+ key_len = php_amqp_get_connection_hash(&connection_params, &key);
- if (!PHP5to7_ZEND_HASH_STR_UPD_MEM(&EG(persistent_list), key, key_len, new_le, sizeof(PHP5to7_zend_resource_store_t))) {
- efree(key);
- php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
- return 0;
- }
- efree(key);
- }
+ zend_resource new_le;
- return 1;
-}
+ /* Store a reference in the persistence list */
+ new_le.ptr = connection->connection_resource;
+ new_le.type = le_amqp_connection_resource_persistent;
-void amqp_connection_free(PHP5to7_obj_free_zend_object *object TSRMLS_DC)
-{
- amqp_connection_object *connection = PHP_AMQP_FETCH_CONNECTION(object);
+ if (!zend_hash_str_update_mem(&EG(persistent_list), key, key_len, &new_le, sizeof(zend_resource))) {
+ efree(key);
+ php_amqp_disconnect_force(connection->connection_resource);
- if (connection->connection_resource) {
- php_amqp_disconnect(connection->connection_resource TSRMLS_CC);
- }
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Could not store persistent connection in pool.",
+ 0
+ );
- zend_object_std_dtor(&connection->zo TSRMLS_CC);
+ return 0;
+ }
+ efree(key);
+ }
-#if PHP_MAJOR_VERSION < 7
- efree(object);
-#endif
+ return 1;
}
-PHP5to7_zend_object_value amqp_connection_ctor(zend_class_entry *ce TSRMLS_DC)
+void amqp_connection_free(zend_object *object)
{
- amqp_connection_object* connection = PHP5to7_ECALLOC_CONNECTION_OBJECT(ce);
+ amqp_connection_object *connection = PHP_AMQP_FETCH_CONNECTION(object);
- zend_object_std_init(&connection->zo, ce TSRMLS_CC);
- AMQP_OBJECT_PROPERTIES_INIT(connection->zo, ce);
+ if (connection->connection_resource) {
+ php_amqp_disconnect(connection->connection_resource);
+ }
-#if PHP_MAJOR_VERSION >=7
- connection->zo.handlers = &amqp_connection_object_handlers;
+ zend_object_std_dtor(&connection->zo);
+}
- return &connection->zo;
-#else
- PHP5to7_zend_object_value new_value;
+zend_object *amqp_connection_ctor(zend_class_entry *ce)
+{
+ amqp_connection_object *connection =
+ (amqp_connection_object *) ecalloc(1, sizeof(amqp_connection_object) + zend_object_properties_size(ce));
- new_value.handle = zend_objects_store_put(
- connection,
- NULL,
- (zend_objects_free_object_storage_t) amqp_connection_free,
- NULL TSRMLS_CC
- );
+ zend_object_std_init(&connection->zo, ce);
+ AMQP_OBJECT_PROPERTIES_INIT(connection->zo, ce);
- new_value.handlers = zend_get_std_object_handlers();
+ connection->zo.handlers = &amqp_connection_object_handlers;
- return new_value;
-#endif
+ return &connection->zo;
}
@@ -334,248 +359,458 @@ PHP5to7_zend_object_value amqp_connection_ctor(zend_class_entry *ce TSRMLS_DC)
*/
static PHP_METHOD(amqp_connection_class, __construct)
{
- zval* ini_arr = NULL;
+ zval *ini_arr = NULL;
- PHP5to7_zval_t *zdata = NULL;
+ zval *zdata = NULL;
- /* Parse out the method parameters */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|a/", &ini_arr) == FAILURE) {
- return;
- }
+ /* Parse out the method parameters */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|a/", &ini_arr) == FAILURE) {
+ RETURN_THROWS();
+ }
- /* Pull the login out of the $params array */
- zdata = NULL;
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "login", sizeof("login"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
- }
- /* Validate the given login */
- if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) {
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("login"), PHP5to7_MAYBE_DEREF(zdata)TSRMLS_CC);
- } else {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'login' exceeds 128 character limit.", 0 TSRMLS_CC);
- return;
- }
- } else {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("login"), INI_STR("amqp.login"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.login")) > 128 ? 128 : strlen(INI_STR("amqp.login"))) TSRMLS_CC);
- }
+ /* Pull the login out of the $params array */
+ zdata = NULL;
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("login"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_string(zdata);
+ }
+ /* Validate the given login */
+ if (zdata && Z_STRLEN_P(zdata) > 0) {
+ if (!php_amqp_is_valid_credential(Z_STR_P(zdata))) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'login' exceeds %d character limit.",
+ PHP_AMQP_MAX_CREDENTIALS_LENGTH
+ );
+ return;
+ }
- /* Pull the password out of the $params array */
- zdata = NULL;
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "password", sizeof("password"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
- }
- /* Validate the given password */
- if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("password"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- } else {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'password' exceeds 128 character limit.", 0 TSRMLS_CC);
- return;
- }
- } else {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("password"), INI_STR("amqp.password"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.password")) > 128 ? 128 : strlen(INI_STR("amqp.password"))) TSRMLS_CC);
- }
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("login"), zdata);
+ } else {
+ zend_update_property_string(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("login"),
+ INI_STR("amqp.login")
+ );
+ }
- /* Pull the host out of the $params array */
- zdata = NULL;
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "host", sizeof("host"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
- }
- /* Validate the given host */
- if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("host"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- } else {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'host' exceeds 128 character limit.", 0 TSRMLS_CC);
- return;
- }
- } else {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("host"), INI_STR("amqp.host"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.host")) > 128 ? 128 : strlen(INI_STR("amqp.host"))) TSRMLS_CC);
- }
+ /* Pull the password out of the $params array */
+ zdata = NULL;
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("password"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_string(zdata);
+ }
+ /* Validate the given password */
+ if (zdata && Z_STRLEN_P(zdata) > 0) {
+ if (!php_amqp_is_valid_credential(Z_STR_P(zdata))) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'password' exceeds %d character limit.",
+ PHP_AMQP_MAX_CREDENTIALS_LENGTH
+ );
+ return;
+ }
- /* Pull the vhost out of the $params array */
- zdata = NULL;
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "vhost", sizeof("vhost"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
- }
- /* Validate the given vhost */
- if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) < 128) {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("vhost"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)), Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- } else {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 character limit.", 0 TSRMLS_CC);
- return;
- }
- } else {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("vhost"), INI_STR("amqp.vhost"), (PHP5to7_param_str_len_type_t) (strlen(INI_STR("amqp.vhost")) > 128 ? 128 : strlen(INI_STR("amqp.vhost"))) TSRMLS_CC);
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("password"),
+ Z_STRVAL_P(zdata),
+ Z_STRLEN_P(zdata)
+ );
+ } else {
+ zend_update_property_string(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("password"),
+ INI_STR("amqp.password")
+ );
+ }
- }
+ /* Pull the host out of the $params array */
+ zdata = NULL;
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("host"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_string(zdata);
+ }
+ /* Validate the given host */
+ if (zdata && Z_STRLEN_P(zdata) > 0) {
+ if (!php_amqp_is_valid_identifier(Z_STR_P(zdata))) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'host' exceeds %d character limit.",
+ PHP_AMQP_MAX_IDENTIFIER_LENGTH
+ );
+ return;
+ }
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("port"), INI_INT("amqp.port") TSRMLS_CC);
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("host"),
+ Z_STRVAL_P(zdata),
+ Z_STRLEN_P(zdata)
+ );
+ } else {
+ zend_update_property_string(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("host"), INI_STR("amqp.host"));
+ }
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "port", sizeof("port"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("port"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
+ /* Pull the vhost out of the $params array */
+ zdata = NULL;
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("vhost"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_string(zdata);
+ }
+ /* Validate the given vhost */
+ if (zdata && Z_STRLEN_P(zdata) > 0) {
+ if (!php_amqp_is_valid_identifier(Z_STR_P(zdata))) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'vhost' exceeds %d character limit.",
+ PHP_AMQP_MAX_IDENTIFIER_LENGTH
+ );
+ return;
+ }
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC);
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "read_timeout", sizeof("read_timeout"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
- if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
- } else {
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "timeout", sizeof("timeout"), zdata)) {
- /* 'read_timeout' takes precedence on 'timeout' but users have to know this */
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Parameter 'timeout' is deprecated, 'read_timeout' used instead");
- }
-
- } else if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "timeout", sizeof("timeout"), zdata)) {
-
- php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "Parameter 'timeout' is deprecated; use 'read_timeout' instead");
-
- SEPARATE_ZVAL(zdata);
- convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
- if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
- } else {
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
- } else {
-
- assert(DEFAULT_TIMEOUT != NULL);
- if (strcmp(DEFAULT_TIMEOUT, INI_STR("amqp.timeout")) != 0) {
- php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead");
-
- if (strcmp(DEFAULT_READ_TIMEOUT, INI_STR("amqp.read_timeout")) == 0) {
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), INI_FLT("amqp.timeout") TSRMLS_CC);
- } else {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "INI setting 'amqp.read_timeout' will be used instead of 'amqp.timeout'");
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC);
- }
- } else {
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), INI_FLT("amqp.read_timeout") TSRMLS_CC);
- }
- }
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("vhost"),
+ Z_STRVAL_P(zdata),
+ Z_STRLEN_P(zdata)
+ );
+ } else {
+ zend_update_property_string(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("vhost"),
+ INI_STR("amqp.vhost")
+ );
+ }
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("write_timeout"), INI_FLT("amqp.write_timeout") TSRMLS_CC);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("port"), INI_INT("amqp.port"));
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "write_timeout", sizeof("write_timeout"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
- if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
- } else {
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("write_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
- }
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("port"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_long(zdata);
+
+ if (!php_amqp_is_valid_port(Z_LVAL_P(zdata))) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'port' must be a valid port number between %d and %d.",
+ PHP_AMQP_MIN_PORT,
+ PHP_AMQP_MAX_PORT
+ );
+ return;
+ }
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("rpc_timeout"), INI_FLT("amqp.rpc_timeout") TSRMLS_CC);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("port"), Z_LVAL_P(zdata));
+ }
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "rpc_timeout", sizeof("rpc_timeout"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
- if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'rpc_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
- } else {
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("rpc_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
- }
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("readTimeout"),
+ INI_FLT("amqp.read_timeout")
+ );
+
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("read_timeout"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_double(zdata);
+
+ if (!php_amqp_is_valid_timeout(Z_DVAL_P(zdata))) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Parameter 'read_timeout' must be greater than or equal to zero.",
+ 0
+ );
+ return;
+ }
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connect_timeout"), INI_FLT("amqp.connect_timeout") TSRMLS_CC);
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("readTimeout"),
+ Z_DVAL_P(zdata)
+ );
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "connect_timeout", sizeof("connect_timeout"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_double(PHP5to7_MAYBE_DEREF(zdata));
- if (Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'connect_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
- } else {
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connect_timeout"), Z_DVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("timeout"))) != NULL) {
+ /* 'read_timeout' takes precedence on 'timeout' but users have to know this */
+ php_error_docref(NULL, E_NOTICE, "Parameter 'timeout' is deprecated, 'read_timeout' used instead");
+ }
- }
- }
+ } else if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("timeout"))) != NULL) {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("channel_max"), INI_INT("amqp.channel_max") TSRMLS_CC);
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "channel_max", sizeof("channel_max"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
- if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_CHANNELS) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'channel_max' is out of range.", 0 TSRMLS_CC);
- } else {
- if(Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) == 0) {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("channel_max"), PHP_AMQP_DEFAULT_CHANNEL_MAX TSRMLS_CC);
- } else {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("channel_max"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
- }
- }
+ php_error_docref(NULL, E_DEPRECATED, "Parameter 'timeout' is deprecated; use 'read_timeout' instead");
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("frame_max"), INI_INT("amqp.frame_max") TSRMLS_CC);
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "frame_max", sizeof("frame_max"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
- if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_FRAME) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'frame_max' is out of range.", 0 TSRMLS_CC);
- } else {
- if(Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) == 0) {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("frame_max"), PHP_AMQP_DEFAULT_FRAME_MAX TSRMLS_CC);
- } else {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("frame_max"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
- }
- }
+ SEPARATE_ZVAL(zdata);
+ convert_to_double(zdata);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("heartbeat"), INI_INT("amqp.heartbeat") TSRMLS_CC);
+ if (!php_amqp_is_valid_timeout(Z_DVAL_P(zdata))) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Parameter 'timeout' must be greater than or equal to zero.",
+ 0
+ );
+ return;
+ }
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "heartbeat", sizeof("heartbeat"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
- if (Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) < 0 || Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) > PHP_AMQP_MAX_HEARTBEAT) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'heartbeat' is out of range.", 0 TSRMLS_CC);
- } else {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("heartbeat"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
- }
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("readTimeout"),
+ Z_DVAL_P(zdata)
+ );
+ } else {
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("sasl_method"), INI_INT("amqp.sasl_method") TSRMLS_CC);
+ assert(DEFAULT_TIMEOUT != NULL);
+ if (strcmp(DEFAULT_TIMEOUT, INI_STR("amqp.timeout")) != 0) {
+ php_error_docref(
+ NULL,
+ E_DEPRECATED,
+ "INI setting 'amqp.timeout' is deprecated; use 'amqp.read_timeout' instead"
+ );
+
+ if (strcmp(DEFAULT_READ_TIMEOUT, INI_STR("amqp.read_timeout")) == 0) {
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("readTimeout"),
+ INI_FLT("amqp.timeout")
+ );
+ } else {
+ php_error_docref(
+ NULL,
+ E_NOTICE,
+ "INI setting 'amqp.read_timeout' will be used instead of 'amqp.timeout'"
+ );
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("readTimeout"),
+ INI_FLT("amqp.read_timeout")
+ );
+ }
+ } else {
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("readTimeout"),
+ INI_FLT("amqp.read_timeout")
+ );
+ }
+ }
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "sasl_method", sizeof("sasl_method"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_long(PHP5to7_MAYBE_DEREF(zdata));
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("sasl_method"), Z_LVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("writeTimeout"),
+ INI_FLT("amqp.write_timeout")
+ );
+
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("write_timeout"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_double(zdata);
+
+ if (!php_amqp_is_valid_timeout(Z_DVAL_P(zdata))) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Parameter 'write_timeout' must be greater than or equal to zero.",
+ 0
+ );
+ return;
+ }
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("writeTimeout"),
+ Z_DVAL_P(zdata)
+ );
+ }
- PHP_AMQP_EXTRACT_CONNECTION_STR("cacert");
- PHP_AMQP_EXTRACT_CONNECTION_STR("capath");
- PHP_AMQP_EXTRACT_CONNECTION_BOOL("use_default_cacert");
- PHP_AMQP_EXTRACT_CONNECTION_BOOL("use_default_capath");
- PHP_AMQP_EXTRACT_CONNECTION_STR("key");
- PHP_AMQP_EXTRACT_CONNECTION_STR("cert");
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("rpcTimeout"),
+ INI_FLT("amqp.rpc_timeout")
+ );
+
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("rpc_timeout"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_double(zdata);
+
+ if (!php_amqp_is_valid_timeout(Z_DVAL_P(zdata))) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Parameter 'rpc_timeout' must be greater than or equal to zero.",
+ 0
+ );
+ RETURN_THROWS();
+ }
- PHP_AMQP_EXTRACT_CONNECTION_BOOL("verify");
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("rpcTimeout"),
+ Z_DVAL_P(zdata)
+ );
+ }
- /* Pull the connection_name out of the $params array */
- zdata = NULL;
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "connection_name", sizeof("connection_name"), zdata)) {
- SEPARATE_ZVAL(zdata);
- convert_to_string(PHP5to7_MAYBE_DEREF(zdata));
- }
- if (zdata && Z_STRLEN_P(PHP5to7_MAYBE_DEREF(zdata)) > 0) {
- zend_update_property_string(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connection_name"), Z_STRVAL_P(PHP5to7_MAYBE_DEREF(zdata)) TSRMLS_CC);
- }
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("connectTimeout"),
+ INI_FLT("amqp.connect_timeout")
+ );
+
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("connect_timeout"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_double(zdata);
+
+ if (!php_amqp_is_valid_timeout(Z_DVAL_P(zdata))) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Parameter 'connect_timeout' must be greater than or equal to zero.",
+ 0
+ );
+ RETURN_THROWS();
+ }
+
+ zend_update_property_double(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("connectTimeout"),
+ Z_DVAL_P(zdata)
+ );
+ }
+
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("channelMax"),
+ INI_INT("amqp.channel_max")
+ );
+
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("channel_max"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_long(zdata);
+
+ if (!php_amqp_is_valid_channel_max(Z_LVAL_P(zdata))) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'channel_max' is out of range.", 0);
+ RETURN_THROWS();
+ }
+
+ if (Z_LVAL_P(zdata) == 0) {
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("channelMax"),
+ PHP_AMQP_DEFAULT_CHANNEL_MAX
+ );
+ } else {
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("channelMax"),
+ Z_LVAL_P(zdata)
+ );
+ }
+ }
+
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("frameMax"),
+ INI_INT("amqp.frame_max")
+ );
+
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("frame_max"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_long(zdata);
+ if (!php_amqp_is_valid_frame_size_max(Z_LVAL_P(zdata))) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'frame_max' is out of range.", 0);
+ RETURN_THROWS();
+ }
+
+ if (Z_LVAL_P(zdata) == 0) {
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("frameMax"),
+ PHP_AMQP_DEFAULT_FRAME_MAX
+ );
+ } else {
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("frameMax"),
+ Z_LVAL_P(zdata)
+ );
+ }
+ }
+
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("heartbeat"),
+ INI_INT("amqp.heartbeat")
+ );
+
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("heartbeat"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_long(zdata);
+ if (!php_amqp_is_valid_heartbeat(Z_LVAL_P(zdata))) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'heartbeat' is out of range.", 0);
+ RETURN_THROWS();
+ }
+
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("heartbeat"), Z_LVAL_P(zdata));
+ }
+
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("saslMethod"),
+ INI_INT("amqp.sasl_method")
+ );
+
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("sasl_method"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_long(zdata);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("saslMethod"), Z_LVAL_P(zdata));
+ }
+
+
+ PHP_AMQP_EXTRACT_CONNECTION_STR("cacert");
+ PHP_AMQP_EXTRACT_CONNECTION_STR("capath");
+ PHP_AMQP_EXTRACT_CONNECTION_BOOL("use_default_cacert");
+ PHP_AMQP_EXTRACT_CONNECTION_BOOL("use_default_capath");
+ PHP_AMQP_EXTRACT_CONNECTION_STR("key");
+ PHP_AMQP_EXTRACT_CONNECTION_STR("cert");
+
+ PHP_AMQP_EXTRACT_CONNECTION_BOOL("verify");
+
+ /* Pull the connection_name out of the $params array */
+ zdata = NULL;
+ if (ini_arr && (zdata = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("connection_name"))) != NULL) {
+ SEPARATE_ZVAL(zdata);
+ convert_to_string(zdata);
+ }
+ if (zdata && Z_STRLEN_P(zdata) > 0) {
+ zend_update_property_string(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("connectionName"),
+ Z_STRVAL_P(zdata)
+ );
+ }
}
/* }}} */
@@ -584,20 +819,14 @@ static PHP_METHOD(amqp_connection_class, __construct)
check amqp connection */
static PHP_METHOD(amqp_connection_class, isConnected)
{
- amqp_connection_object *connection;
-
- PHP_AMQP_NOPARAMS();
+ amqp_connection_object *connection;
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ PHP_AMQP_NOPARAMS()
- /* If the channel_connect is 1, we have a connection */
- if (connection->connection_resource != NULL && connection->connection_resource->is_connected) {
- RETURN_TRUE;
- }
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- /* We have no connection */
- RETURN_FALSE;
+ RETURN_BOOL(connection->connection_resource != NULL && connection->connection_resource->is_connected);
}
/* }}} */
@@ -606,23 +835,27 @@ static PHP_METHOD(amqp_connection_class, isConnected)
create amqp connection */
static PHP_METHOD(amqp_connection_class, connect)
{
- amqp_connection_object *connection;
+ amqp_connection_object *connection;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (connection->connection_resource && connection->connection_resource->is_connected) {
- if (connection->connection_resource->is_persistent) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start transient connection while persistent transient one already established. Continue.");
- }
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
+ if (connection->connection_resource->is_persistent) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Attempt to start transient connection while persistent one already established. Continue.",
+ 0
+ );
+ }
- RETURN_TRUE;
- }
+ return;
+ }
- /* Actually connect this resource to the broker */
- RETURN_BOOL(php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU));
+ /* Actually connect this resource to the broker */
+ php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
@@ -631,55 +864,66 @@ static PHP_METHOD(amqp_connection_class, connect)
create amqp connection */
static PHP_METHOD(amqp_connection_class, pconnect)
{
- amqp_connection_object *connection;
+ amqp_connection_object *connection;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (connection->connection_resource && connection->connection_resource->is_connected) {
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
- assert(connection->connection_resource != NULL);
- if (!connection->connection_resource->is_persistent) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to start persistent connection while transient one already established. Continue.");
- }
+ assert(connection->connection_resource != NULL);
+ if (!connection->connection_resource->is_persistent) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Attempt to start persistent connection while transient one already established. Continue.",
+ 0
+ );
+ }
- RETURN_TRUE;
- }
+ return;
+ }
- /* Actually connect this resource to the broker or use stored connection */
- RETURN_BOOL(php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU));
+ /* Actually connect this resource to the broker or use stored connection */
+ php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
+#define PERSISTENT_TRANSIENT_EXCEPTION_MESSAGE \
+ "Attempted to %s a %s connection while a %s connection is established. Call '%s' instead"
/* {{{ proto amqp:pdisconnect()
destroy amqp persistent connection */
static PHP_METHOD(amqp_connection_class, pdisconnect)
{
- amqp_connection_object *connection;
-
- PHP_AMQP_NOPARAMS();
-
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
-
- if (!connection->connection_resource || !connection->connection_resource->is_connected) {
- RETURN_TRUE;
- }
+ amqp_connection_object *connection;
- assert(connection->connection_resource != NULL);
+ PHP_AMQP_NOPARAMS()
- if (!connection->connection_resource->is_persistent) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close persistent connection while transient one already established. Abort.");
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- RETURN_FALSE;
- }
+ if (!connection->connection_resource || !connection->connection_resource->is_connected) {
+ return;
+ }
- php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
+ assert(connection->connection_resource != NULL);
+
+ if (!connection->connection_resource->is_persistent) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ PERSISTENT_TRANSIENT_EXCEPTION_MESSAGE,
+ "close",
+ "persistent",
+ "transient",
+ "disconnect"
+ );
+ return;
+ }
- RETURN_TRUE;
+ php_amqp_disconnect_force(connection->connection_resource);
}
/* }}} */
@@ -688,28 +932,33 @@ static PHP_METHOD(amqp_connection_class, pdisconnect)
destroy amqp connection */
static PHP_METHOD(amqp_connection_class, disconnect)
{
- amqp_connection_object *connection;
-
- PHP_AMQP_NOPARAMS();
+ amqp_connection_object *connection;
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ PHP_AMQP_NOPARAMS()
- if (!connection->connection_resource || !connection->connection_resource->is_connected) {
- RETURN_TRUE;
- }
-
- if (connection->connection_resource->is_persistent) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to close transient connection while persistent one already established. Abort.");
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- RETURN_FALSE;
- }
+ if (!connection->connection_resource || !connection->connection_resource->is_connected) {
+ return;
+ }
- assert(connection->connection_resource != NULL);
+ if (connection->connection_resource->is_persistent) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ PERSISTENT_TRANSIENT_EXCEPTION_MESSAGE,
+ "close",
+ "transient",
+ "persistent",
+ "pdisconnect"
+ );
+ return;
+ }
- php_amqp_disconnect(connection->connection_resource TSRMLS_CC);
+ assert(connection->connection_resource != NULL);
- RETURN_TRUE;
+ php_amqp_disconnect(connection->connection_resource);
}
/* }}} */
@@ -718,27 +967,34 @@ static PHP_METHOD(amqp_connection_class, disconnect)
recreate amqp connection */
static PHP_METHOD(amqp_connection_class, reconnect)
{
- amqp_connection_object *connection;
-
- PHP_AMQP_NOPARAMS();
-
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ amqp_connection_object *connection;
- if (connection->connection_resource && connection->connection_resource->is_connected) {
+ PHP_AMQP_NOPARAMS()
- assert(connection->connection_resource != NULL);
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (connection->connection_resource->is_persistent) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect persistent connection while transient one already established. Abort.");
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
- RETURN_FALSE;
- }
+ assert(connection->connection_resource != NULL);
+
+ if (connection->connection_resource->is_persistent) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ PERSISTENT_TRANSIENT_EXCEPTION_MESSAGE,
+ "reconnect",
+ "transient",
+ "persistent",
+ "preconnect"
+ );
+ return;
+ }
- php_amqp_disconnect(connection->connection_resource TSRMLS_CC);
- }
+ php_amqp_disconnect(connection->connection_resource);
+ }
- RETURN_BOOL(php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU));
+ php_amqp_connect(connection, 0, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
@@ -746,28 +1002,35 @@ static PHP_METHOD(amqp_connection_class, reconnect)
recreate amqp connection */
static PHP_METHOD(amqp_connection_class, preconnect)
{
- amqp_connection_object *connection;
-
- PHP_AMQP_NOPARAMS();
-
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ amqp_connection_object *connection;
+ PHP_AMQP_NOPARAMS()
- if (connection->connection_resource && connection->connection_resource->is_connected) {
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- assert(connection->connection_resource != NULL);
- if (!connection->connection_resource->is_persistent) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Attempt to reconnect transient connection while persistent one already established. Abort.");
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
- RETURN_FALSE;
- }
+ assert(connection->connection_resource != NULL);
+
+ if (!connection->connection_resource->is_persistent) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ PERSISTENT_TRANSIENT_EXCEPTION_MESSAGE,
+ "reconnect",
+ "persistent",
+ "transient",
+ "reconnect"
+ );
+ return;
+ }
- php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
- }
+ php_amqp_disconnect_force(connection->connection_resource);
+ }
- RETURN_BOOL(php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU));
+ php_amqp_connect(connection, 1, INTERNAL_FUNCTION_PARAM_PASSTHRU);
}
/* }}} */
@@ -785,11 +1048,11 @@ static PHP_METHOD(amqp_connection_class, sendHeartbeat)
if (connection->connection_resource && connection->connection_resource->is_connected) {
if (AMQP_STATUS_OK != amqp_send_heartbeat(connection->connection_resource->connection_state)) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Library error: error while send heartbeat", 0 TSRMLS_CC);
+ zend_throw_exception(amqp_connection_exception_class_entry, "Library error: error while send heartbeat", 0);
return;
}
} else {
- zend_throw_exception(amqp_connection_exception_class_entry, "Error while try send heartbeat: not connected", 0 TSRMLS_CC);
+ zend_throw_exception(amqp_connection_exception_class_entry, "Error while try send heartbeat: not connected", 0);
}
RETURN_TRUE;
@@ -801,9 +1064,9 @@ static PHP_METHOD(amqp_connection_class, sendHeartbeat)
get the login */
static PHP_METHOD(amqp_connection_class, getLogin)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("login");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("login");
}
/* }}} */
@@ -812,22 +1075,26 @@ static PHP_METHOD(amqp_connection_class, getLogin)
set the login */
static PHP_METHOD(amqp_connection_class, setLogin)
{
- char *login = NULL; PHP5to7_param_str_len_type_t login_len = 0;
-
- /* Get the login from the method params */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &login, &login_len) == FAILURE) {
- return;
- }
+ char *login = NULL;
+ size_t login_len = 0;
- /* Validate login length */
- if (login_len > 128) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'login' given, exceeds 128 characters limit.", 0 TSRMLS_CC);
- return;
- }
+ /* Get the login from the method params */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &login, &login_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("login"), login, login_len TSRMLS_CC);
+ /* Validate login length */
+ if (login_len > PHP_AMQP_MAX_CREDENTIALS_LENGTH) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'login' exceeds %d character limit.",
+ PHP_AMQP_MAX_CREDENTIALS_LENGTH
+ );
+ return;
+ }
- RETURN_TRUE;
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("login"), login, login_len);
}
/* }}} */
@@ -835,9 +1102,9 @@ static PHP_METHOD(amqp_connection_class, setLogin)
get the password */
static PHP_METHOD(amqp_connection_class, getPassword)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("password");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("password");
}
/* }}} */
@@ -846,22 +1113,32 @@ static PHP_METHOD(amqp_connection_class, getPassword)
set the password */
static PHP_METHOD(amqp_connection_class, setPassword)
{
- char *password = NULL; PHP5to7_param_str_len_type_t password_len = 0;
-
- /* Get the password from the method params */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &password, &password_len) == FAILURE) {
- return;
- }
+ char *password = NULL;
+ size_t password_len = 0;
- /* Validate password length */
- if (password_len > 128) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'password' given, exceeds 128 characters limit.", 0 TSRMLS_CC);
- return;
- }
+ /* Get the password from the method params */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &password, &password_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("password"), password, password_len TSRMLS_CC);
+ /* Validate password length */
+ if (password_len > PHP_AMQP_MAX_CREDENTIALS_LENGTH) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'password' exceeds %d character limit.",
+ PHP_AMQP_MAX_CREDENTIALS_LENGTH
+ );
+ return;
+ }
- RETURN_TRUE;
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("password"),
+ password,
+ password_len
+ );
}
/* }}} */
@@ -870,9 +1147,9 @@ static PHP_METHOD(amqp_connection_class, setPassword)
get the host */
static PHP_METHOD(amqp_connection_class, getHost)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("host");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("host");
}
/* }}} */
@@ -881,22 +1158,26 @@ static PHP_METHOD(amqp_connection_class, getHost)
set the host */
static PHP_METHOD(amqp_connection_class, setHost)
{
- char *host = NULL; PHP5to7_param_str_len_type_t host_len = 0;
-
- /* Get the host from the method params */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &host, &host_len) == FAILURE) {
- return;
- }
+ char *host = NULL;
+ size_t host_len = 0;
- /* Validate host length */
- if (host_len > 1024) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Invalid 'host' given, exceeds 1024 character limit.", 0 TSRMLS_CC);
- return;
- }
+ /* Get the host from the method params */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &host, &host_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("host"), host, host_len TSRMLS_CC);
+ /* Validate host length */
+ if (host_len > PHP_AMQP_MAX_IDENTIFIER_LENGTH) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'host' exceeds %d character limit.",
+ PHP_AMQP_MAX_IDENTIFIER_LENGTH
+ );
+ return;
+ }
- RETURN_TRUE;
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("host"), host, host_len);
}
/* }}} */
@@ -905,9 +1186,9 @@ static PHP_METHOD(amqp_connection_class, setHost)
get the port */
static PHP_METHOD(amqp_connection_class, getPort)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("port");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("port");
}
/* }}} */
@@ -916,39 +1197,26 @@ static PHP_METHOD(amqp_connection_class, getPort)
set the port */
static PHP_METHOD(amqp_connection_class, setPort)
{
- zval *zvalPort;
- int port;
-
- /* Get the port from the method params */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z/", &zvalPort) == FAILURE) {
- return;
- }
+ zend_long port;
- /* Parse out the port*/
- switch (Z_TYPE_P(zvalPort)) {
- case IS_DOUBLE:
- port = (int)Z_DVAL_P(zvalPort);
- break;
- case IS_LONG:
- port = (int)Z_LVAL_P(zvalPort);
- break;
- case IS_STRING:
- convert_to_long(zvalPort);
- port = (int)Z_LVAL_P(zvalPort);
- break;
- default:
- port = 0;
- }
-
- /* Check the port value */
- if (port <= 0 || port > 65535) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Invalid port given. Value must be between 1 and 65535.", 0 TSRMLS_CC);
- return;
- }
+ /* Get the port from the method params */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &port) == FAILURE) {
+ RETURN_THROWS();
+ }
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("port"), port TSRMLS_CC);
+ /* Check the port value */
+ if (!php_amqp_is_valid_port(port)) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'port' must be a valid port number between %d and %d.",
+ PHP_AMQP_MIN_PORT,
+ PHP_AMQP_MAX_PORT
+ );
+ return;
+ }
- RETURN_TRUE;
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("port"), port);
}
/* }}} */
@@ -956,9 +1224,9 @@ static PHP_METHOD(amqp_connection_class, setPort)
get the vhost */
static PHP_METHOD(amqp_connection_class, getVhost)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("vhost");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("vhost");
}
/* }}} */
@@ -967,21 +1235,25 @@ static PHP_METHOD(amqp_connection_class, getVhost)
set the vhost */
static PHP_METHOD(amqp_connection_class, setVhost)
{
- char *vhost = NULL; PHP5to7_param_str_len_type_t vhost_len = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &vhost, &vhost_len) == FAILURE) {
- return;
- }
+ char *vhost = NULL;
+ size_t vhost_len = 0;
- /* Validate vhost length */
- if (vhost_len > 128) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'vhost' exceeds 128 characters limit.", 0 TSRMLS_CC);
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &vhost, &vhost_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("vhost"), vhost, vhost_len TSRMLS_CC);
+ /* Validate vhost length */
+ if (vhost_len > PHP_AMQP_MAX_IDENTIFIER_LENGTH) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Parameter 'vhost' exceeds %d characters limit.",
+ PHP_AMQP_MAX_IDENTIFIER_LENGTH
+ );
+ return;
+ }
- RETURN_TRUE;
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("vhost"), vhost, vhost_len);
}
/* }}} */
@@ -990,11 +1262,15 @@ static PHP_METHOD(amqp_connection_class, setVhost)
get the timeout */
static PHP_METHOD(amqp_connection_class, getTimeout)
{
- php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead");
-
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("read_timeout");
+ php_error_docref(
+ NULL,
+ E_DEPRECATED,
+ "AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead"
+ );
+
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("readTimeout");
}
/* }}} */
@@ -1003,37 +1279,44 @@ static PHP_METHOD(amqp_connection_class, getTimeout)
set the timeout */
static PHP_METHOD(amqp_connection_class, setTimeout)
{
- amqp_connection_object *connection;
- double read_timeout;
-
- php_error_docref(NULL TSRMLS_CC, E_DEPRECATED, "AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead");
-
- /* Get the timeout from the method params */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &read_timeout) == FAILURE) {
- return;
- }
-
- /* Validate timeout */
- if (read_timeout < 0) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
- return;
- }
+ amqp_connection_object *connection;
+ double read_timeout;
+
+ php_error_docref(
+ NULL,
+ E_DEPRECATED,
+ "AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) "
+ "instead"
+ );
+
+ /* Get the timeout from the method params */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "d", &read_timeout) == FAILURE) {
+ RETURN_THROWS();
+ }
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Validate timeout */
+ if (!php_amqp_is_valid_timeout(read_timeout)) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Parameter 'timeout' must be greater than or equal to zero.",
+ 0
+ );
+ return;
+ }
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), read_timeout TSRMLS_CC);
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (connection->connection_resource && connection->connection_resource->is_connected) {
- if (php_amqp_set_resource_read_timeout(connection->connection_resource, read_timeout TSRMLS_CC) == 0) {
+ zend_update_property_double(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("readTimeout"), read_timeout);
- php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
+ if (php_amqp_set_resource_read_timeout(connection->connection_resource, read_timeout) == 0) {
- RETURN_FALSE;
- }
- }
+ php_amqp_disconnect_force(connection->connection_resource);
- RETURN_TRUE;
+ zend_throw_exception(amqp_connection_exception_class_entry, "Could not set read timeout", 0);
+ }
+ }
}
/* }}} */
@@ -1041,9 +1324,9 @@ static PHP_METHOD(amqp_connection_class, setTimeout)
get the read timeout */
static PHP_METHOD(amqp_connection_class, getReadTimeout)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("read_timeout");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("readTimeout");
}
/* }}} */
@@ -1051,35 +1334,37 @@ static PHP_METHOD(amqp_connection_class, getReadTimeout)
set read timeout */
static PHP_METHOD(amqp_connection_class, setReadTimeout)
{
- amqp_connection_object *connection;
- double read_timeout;
-
- /* Get the timeout from the method params */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &read_timeout) == FAILURE) {
- return;
- }
+ amqp_connection_object *connection;
+ double read_timeout;
- /* Validate timeout */
- if (read_timeout < 0) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'read_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
- return;
- }
+ /* Get the timeout from the method params */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "d", &read_timeout) == FAILURE) {
+ RETURN_THROWS();
+ }
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Validate timeout */
+ if (!php_amqp_is_valid_timeout(read_timeout)) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Parameter 'readTimeout' must be greater than or equal to zero.",
+ 0
+ );
+ return;
+ }
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("read_timeout"), read_timeout TSRMLS_CC);
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (connection->connection_resource && connection->connection_resource->is_connected) {
- if (php_amqp_set_resource_read_timeout(connection->connection_resource, read_timeout TSRMLS_CC) == 0) {
+ zend_update_property_double(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("readTimeout"), read_timeout);
- php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
+ if (php_amqp_set_resource_read_timeout(connection->connection_resource, read_timeout) == 0) {
- RETURN_FALSE;
- }
- }
+ php_amqp_disconnect_force(connection->connection_resource);
- RETURN_TRUE;
+ zend_throw_exception(amqp_connection_exception_class_entry, "Could not set read timeout", 0);
+ }
+ }
}
/* }}} */
@@ -1087,9 +1372,9 @@ static PHP_METHOD(amqp_connection_class, setReadTimeout)
get write timeout */
static PHP_METHOD(amqp_connection_class, getWriteTimeout)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("write_timeout");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("writeTimeout");
}
/* }}} */
@@ -1097,35 +1382,47 @@ static PHP_METHOD(amqp_connection_class, getWriteTimeout)
set write timeout */
static PHP_METHOD(amqp_connection_class, setWriteTimeout)
{
- amqp_connection_object *connection;
- double write_timeout;
+ amqp_connection_object *connection;
+ double write_timeout;
- /* Get the timeout from the method params */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &write_timeout) == FAILURE) {
- return;
- }
+ /* Get the timeout from the method params */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "d", &write_timeout) == FAILURE) {
+ RETURN_THROWS();
+ }
- /* Validate timeout */
- if (write_timeout < 0) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'write_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
- return;
- }
+ /* Validate timeout */
+ if (!php_amqp_is_valid_timeout(write_timeout)) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Parameter 'writeTimeout' must be greater than or equal to zero.",
+ 0
+ );
+ return;
+ }
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("write_timeout"), write_timeout TSRMLS_CC);
+ zend_update_property_double(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("writeTimeout"), write_timeout);
- if (connection->connection_resource && connection->connection_resource->is_connected) {
- if (php_amqp_set_resource_write_timeout(connection->connection_resource, write_timeout TSRMLS_CC) == 0) {
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
+ if (php_amqp_set_resource_write_timeout(connection->connection_resource, write_timeout) == 0) {
- php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
+ php_amqp_disconnect_force(connection->connection_resource);
- RETURN_FALSE;
- }
- }
+ zend_throw_exception(amqp_connection_exception_class_entry, "Could not set write timeout", 0);
+ }
+ }
+}
+/* }}} */
- RETURN_TRUE;
+/* {{{ proto amqp::getRpcTimeout()
+get rpc timeout */
+static PHP_METHOD(amqp_connection_class, getConnectTimeout)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("connectTimeout");
}
/* }}} */
@@ -1133,9 +1430,9 @@ static PHP_METHOD(amqp_connection_class, setWriteTimeout)
get rpc timeout */
static PHP_METHOD(amqp_connection_class, getRpcTimeout)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("rpc_timeout");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("rpcTimeout");
}
/* }}} */
@@ -1143,35 +1440,37 @@ static PHP_METHOD(amqp_connection_class, getRpcTimeout)
set rpc timeout */
static PHP_METHOD(amqp_connection_class, setRpcTimeout)
{
- amqp_connection_object *connection;
- double rpc_timeout;
-
- /* Get the timeout from the method params */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", &rpc_timeout) == FAILURE) {
- return;
- }
+ amqp_connection_object *connection;
+ double rpc_timeout;
- /* Validate timeout */
- if (rpc_timeout < 0) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Parameter 'rpc_timeout' must be greater than or equal to zero.", 0 TSRMLS_CC);
- return;
- }
+ /* Get the timeout from the method params */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "d", &rpc_timeout) == FAILURE) {
+ RETURN_THROWS();
+ }
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Validate timeout */
+ if (!php_amqp_is_valid_timeout(rpc_timeout)) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Parameter 'rpcTimeout' must be greater than or equal to zero.",
+ 0
+ );
+ return;
+ }
- zend_update_property_double(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("rpc_timeout"), rpc_timeout TSRMLS_CC);
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (connection->connection_resource && connection->connection_resource->is_connected) {
- if (php_amqp_set_resource_rpc_timeout(connection->connection_resource, rpc_timeout TSRMLS_CC) == 0) {
+ zend_update_property_double(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("rpcTimeout"), rpc_timeout);
- php_amqp_disconnect_force(connection->connection_resource TSRMLS_CC);
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
+ if (php_amqp_set_resource_rpc_timeout(connection->connection_resource, rpc_timeout) == 0) {
- RETURN_FALSE;
- }
- }
+ php_amqp_disconnect_force(connection->connection_resource);
- RETURN_TRUE;
+ zend_throw_exception(amqp_connection_exception_class_entry, "Could not set connect timeout", 0);
+ }
+ }
}
/* }}} */
@@ -1179,21 +1478,21 @@ static PHP_METHOD(amqp_connection_class, setRpcTimeout)
Get max used channels number */
static PHP_METHOD(amqp_connection_class, getUsedChannels)
{
- amqp_connection_object *connection;
+ amqp_connection_object *connection;
- /* Get the timeout from the method params */
- PHP_AMQP_NOPARAMS();
+ /* Get the timeout from the method params */
+ PHP_AMQP_NOPARAMS()
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (!connection->connection_resource || !connection->connection_resource->is_connected) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Connection is not connected.");
+ if (!connection->connection_resource || !connection->connection_resource->is_connected) {
+ php_error_docref(NULL, E_WARNING, "Connection is not connected.");
- RETURN_LONG(0);
- }
+ RETURN_LONG(0);
+ }
- RETURN_LONG(connection->connection_resource->used_slots);
+ RETURN_LONG(connection->connection_resource->used_slots);
}
/* }}} */
@@ -1201,19 +1500,19 @@ static PHP_METHOD(amqp_connection_class, getUsedChannels)
Get max supported channels number per connection */
PHP_METHOD(amqp_connection_class, getMaxChannels)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- amqp_connection_object *connection;
+ zval rv;
+ amqp_connection_object *connection;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (connection->connection_resource && connection->connection_resource->is_connected) {
- RETURN_LONG(connection->connection_resource->max_slots);
- }
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
+ RETURN_LONG(connection->connection_resource->max_slots);
+ }
- PHP_AMQP_RETURN_THIS_PROP("channel_max");
+ PHP_AMQP_RETURN_THIS_PROP("channelMax");
}
/* }}} */
@@ -1221,19 +1520,19 @@ PHP_METHOD(amqp_connection_class, getMaxChannels)
Get max supported frame size per connection in bytes */
static PHP_METHOD(amqp_connection_class, getMaxFrameSize)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- amqp_connection_object *connection;
+ zval rv;
+ amqp_connection_object *connection;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (connection->connection_resource && connection->connection_resource->is_connected) {
- RETURN_LONG(amqp_get_frame_max(connection->connection_resource->connection_state));
- }
+ if (connection->connection_resource && connection->connection_resource->is_connected) {
+ RETURN_LONG(amqp_get_frame_max(connection->connection_resource->connection_state));
+ }
- PHP_AMQP_RETURN_THIS_PROP("frame_max");
+ PHP_AMQP_RETURN_THIS_PROP("frameMax");
}
/* }}} */
@@ -1241,20 +1540,19 @@ static PHP_METHOD(amqp_connection_class, getMaxFrameSize)
Get number of seconds between heartbeats of the connection in seconds */
static PHP_METHOD(amqp_connection_class, getHeartbeatInterval)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- amqp_connection_object *connection;
+ zval rv;
+ amqp_connection_object *connection;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- /* Get the connection object out of the store */
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ /* Get the connection object out of the store */
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- if (connection->connection_resource != NULL
- && connection->connection_resource->is_connected != '\0') {
- RETURN_LONG(amqp_get_heartbeat(connection->connection_resource->connection_state));
- }
+ if (connection->connection_resource != NULL && connection->connection_resource->is_connected != '\0') {
+ RETURN_LONG(amqp_get_heartbeat(connection->connection_resource->connection_state));
+ }
- PHP_AMQP_RETURN_THIS_PROP("heartbeat");
+ PHP_AMQP_RETURN_THIS_PROP("heartbeat");
}
/* }}} */
@@ -1262,13 +1560,13 @@ static PHP_METHOD(amqp_connection_class, getHeartbeatInterval)
check whether amqp connection is persistent */
static PHP_METHOD(amqp_connection_class, isPersistent)
{
- amqp_connection_object *connection;
+ amqp_connection_object *connection;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- connection = PHP_AMQP_GET_CONNECTION(getThis());
+ connection = PHP_AMQP_GET_CONNECTION(getThis());
- RETURN_BOOL(connection->connection_resource && connection->connection_resource->is_persistent);
+ RETURN_BOOL(connection->connection_resource && connection->connection_resource->is_persistent);
}
/* }}} */
@@ -1276,24 +1574,27 @@ static PHP_METHOD(amqp_connection_class, isPersistent)
/* {{{ proto amqp::getCACert() */
static PHP_METHOD(amqp_connection_class, getCACert)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("cacert");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("cacert");
}
/* }}} */
/* {{{ proto amqp::setCACert(string cacert) */
static PHP_METHOD(amqp_connection_class, setCACert)
{
- char *str = NULL; PHP5to7_param_str_len_type_t str_len = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
- return;
- }
+ char *str = NULL;
+ size_t str_len = 0;
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("cacert"), str, str_len TSRMLS_CC);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!", &str, &str_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- RETURN_TRUE;
+ if (str == NULL) {
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("cacert"));
+ } else {
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("cacert"), str, str_len);
+ }
}
/* }}} */
@@ -1311,11 +1612,11 @@ static PHP_METHOD(amqp_connection_class, setCAPath)
{
char *str = NULL; PHP5to7_param_str_len_type_t str_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &str, &str_len) == FAILURE) {
return;
}
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("capath"), str, str_len TSRMLS_CC);
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("capath"), str, str_len);
RETURN_TRUE;
}
@@ -1336,11 +1637,11 @@ static PHP_METHOD(amqp_connection_class, setUseDefaultCACert)
{
zend_bool use_default_cacert = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &use_default_cacert) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &use_default_cacert) == FAILURE) {
return;
}
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("use_default_cacert"), use_default_cacert TSRMLS_CC);
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("use_default_cacert"), use_default_cacert);
RETURN_TRUE;
}
@@ -1361,11 +1662,11 @@ static PHP_METHOD(amqp_connection_class, setUseDefaultCAPath)
{
zend_bool use_default_capath = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &use_default_capath) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &use_default_capath) == FAILURE) {
return;
}
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("use_default_capath"), use_default_capath TSRMLS_CC);
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("use_default_capath"), use_default_capath);
RETURN_TRUE;
}
@@ -1374,48 +1675,54 @@ static PHP_METHOD(amqp_connection_class, setUseDefaultCAPath)
/* {{{ proto amqp::getCert() */
static PHP_METHOD(amqp_connection_class, getCert)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("cert");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("cert");
}
/* }}} */
/* {{{ proto amqp::setCert(string cert) */
static PHP_METHOD(amqp_connection_class, setCert)
{
- char *str = NULL; PHP5to7_param_str_len_type_t str_len = 0;
+ char *str = NULL;
+ size_t str_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
- return;
- }
-
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("cert"), str, str_len TSRMLS_CC);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!", &str, &str_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- RETURN_TRUE;
+ if (str == NULL) {
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("cert"));
+ } else {
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("cert"), str, str_len);
+ }
}
/* }}} */
/* {{{ proto amqp::getKey() */
static PHP_METHOD(amqp_connection_class, getKey)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("key");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("key");
}
/* }}} */
/* {{{ proto amqp::setKey(string key) */
static PHP_METHOD(amqp_connection_class, setKey)
{
- char *str = NULL; PHP5to7_param_str_len_type_t str_len = 0;
+ char *str = NULL;
+ size_t str_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
- return;
- }
-
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("key"), str, str_len TSRMLS_CC);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!", &str, &str_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- RETURN_TRUE;
+ if (str == NULL) {
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("key"));
+ } else {
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("key"), str, str_len);
+ }
}
/* }}} */
@@ -1423,24 +1730,22 @@ static PHP_METHOD(amqp_connection_class, setKey)
/* {{{ proto amqp::getVerify() */
static PHP_METHOD(amqp_connection_class, getVerify)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("verify");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("verify");
}
/* }}} */
/* {{{ proto amqp::setVerify(bool verify) */
static PHP_METHOD(amqp_connection_class, setVerify)
{
- zend_bool verify = 1;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "b", &verify) == FAILURE) {
- return;
- }
+ bool verify = 1;
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("verify"), verify TSRMLS_CC);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "b", &verify) == FAILURE) {
+ RETURN_THROWS();
+ }
- RETURN_TRUE;
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("verify"), verify);
}
/* }}} */
@@ -1448,9 +1753,9 @@ static PHP_METHOD(amqp_connection_class, setVerify)
get sasl method */
static PHP_METHOD(amqp_connection_class, getSaslMethod)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("sasl_method");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("saslMethod");
}
/* }}} */
@@ -1458,165 +1763,192 @@ static PHP_METHOD(amqp_connection_class, getSaslMethod)
set sasl method */
static PHP_METHOD(amqp_connection_class, setSaslMethod)
{
- long method;
-
- /* Get the port from the method params */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &method) == FAILURE) {
- return;
- }
+ long method;
- /* Check the method value */
- if (method != AMQP_SASL_METHOD_PLAIN && method != AMQP_SASL_METHOD_EXTERNAL) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Invalid SASL method given. Method must be AMQP_SASL_METHOD_PLAIN or AMQP_SASL_METHOD_EXTERNAL.", 0 TSRMLS_CC);
- return;
- }
+ /* Get the port from the method params */
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &method) == FAILURE) {
+ RETURN_THROWS();
+ }
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("sasl_method"), method TSRMLS_CC);
+ /* Check the method value */
+ if (method != AMQP_SASL_METHOD_PLAIN && method != AMQP_SASL_METHOD_EXTERNAL) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Invalid SASL method given. Method must be AMQP_SASL_METHOD_PLAIN or AMQP_SASL_METHOD_EXTERNAL.",
+ 0
+ );
+ return;
+ }
- RETURN_TRUE;
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("saslMethod"), method);
}
/* }}} */
/* {{{ proto amqp::getConnectionName() */
static PHP_METHOD(amqp_connection_class, getConnectionName)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("connection_name");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("connectionName");
}
/* }}} */
/* {{{ proto amqp::setConnectionName(string connectionName) */
static PHP_METHOD(amqp_connection_class, setConnectionName)
{
- char *str = NULL; PHP5to7_param_str_len_type_t str_len = 0;
+ char *str = NULL;
+ size_t str_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!", &str, &str_len) == FAILURE) {
- return;
- }
- if (str == NULL) {
- zend_update_property_null(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connection_name") TSRMLS_CC);
- } else {
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connection_name"), str, str_len TSRMLS_CC);
- }
-
-
- RETURN_TRUE;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!", &str, &str_len) == FAILURE) {
+ RETURN_THROWS();
+ }
+ if (str == NULL) {
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("connectionName"));
+ } else {
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("connectionName"),
+ str,
+ str_len
+ );
+ }
}
/* }}} */
/* amqp_connection_class ARG_INFO definition */
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
- ZEND_ARG_ARRAY_INFO(0, credentials, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, credentials, IS_ARRAY, 0, "[]")
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_isConnected, ZEND_SEND_BY_VAL, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_isConnected, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_connect, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_connect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_pconnect, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_pconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_pdisconnect, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_pdisconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_disconnect, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_disconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_reconnect, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_reconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_preconnect, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_preconnect, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getLogin, ZEND_SEND_BY_VAL, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_sendHeartbeat, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getLogin, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setLogin, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, login, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setLogin, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, login)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getPassword, ZEND_SEND_BY_VAL, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getPassword, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setPassword, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, password, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setPassword, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, password)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getHost, ZEND_SEND_BY_VAL, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getHost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setHost, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, host, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setHost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, host)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getPort, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getPort, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setPort, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, port, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setPort, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, port)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getVhost, ZEND_SEND_BY_VAL, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getVhost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setVhost, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, vhost, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setVhost, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, vhost)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getTimeout, ZEND_SEND_BY_VAL, 0, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setTimeout, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, timeout)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getReadTimeout, ZEND_SEND_BY_VAL, 0, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getReadTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setReadTimeout, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setReadTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, timeout)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_connection_class_getWriteTimeout,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_DOUBLE,
+ 0
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getWriteTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setWriteTimeout, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setWriteTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, timeout)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_connection_class_getConnectTimeout,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_DOUBLE,
+ 0
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getRpcTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getRpcTimeout, ZEND_SEND_BY_VAL, 0, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setRpcTimeout, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, timeout)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setRpcTimeout, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, timeout, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getUsedChannels, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getUsedChannels, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getMaxChannels, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getMaxChannels, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getMaxFrameSize, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getMaxFrameSize, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getHeartbeatInterval, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_connection_class_getHeartbeatInterval,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_LONG,
+ 0
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_isPersistent, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_isPersistent, ZEND_SEND_BY_VAL, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getCACert, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getCACert, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setCACert, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, cacert)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setCACert, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, cacert, IS_STRING, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getCAPath, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
@@ -1640,159 +1972,170 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setUseDefaultCAPath, ZEND_S
ZEND_ARG_INFO(0, use_default_capath)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getCert, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getCert, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setCert, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, cert)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setCert, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, cert, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getKey, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getKey, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setKey, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, key)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setKey, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, key, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getVerify, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getVerify, ZEND_SEND_BY_VAL, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setVerify, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, verify)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setVerify, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, verify, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getSaslMethod, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_getSaslMethod, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setSaslMethod, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, sasl_method)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_connection_class_setSaslMethod, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, saslMethod, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_getConnectionName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_connection_class_getConnectionName,
+ ZEND_SEND_BY_VAL,
+ 0,
+ IS_STRING,
+ 1
+)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_connection_class_setConnectionName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, connection_name)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(
+ arginfo_amqp_connection_class_setConnectionName,
+ ZEND_SEND_BY_VAL,
+ 1,
+ IS_VOID,
+ 0
+)
+ ZEND_ARG_TYPE_INFO(0, connectionName, IS_STRING, 1)
ZEND_END_ARG_INFO()
zend_function_entry amqp_connection_class_functions[] = {
- PHP_ME(amqp_connection_class, __construct, arginfo_amqp_connection_class__construct, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, isConnected, arginfo_amqp_connection_class_isConnected, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, connect, arginfo_amqp_connection_class_connect, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, pconnect, arginfo_amqp_connection_class_pconnect, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, pdisconnect, arginfo_amqp_connection_class_pdisconnect, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, disconnect, arginfo_amqp_connection_class_disconnect, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, reconnect, arginfo_amqp_connection_class_reconnect, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, preconnect, arginfo_amqp_connection_class_preconnect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, __construct, arginfo_amqp_connection_class__construct, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, isConnected, arginfo_amqp_connection_class_isConnected, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, connect, arginfo_amqp_connection_class_connect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, pconnect, arginfo_amqp_connection_class_pconnect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, pdisconnect, arginfo_amqp_connection_class_pdisconnect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, disconnect, arginfo_amqp_connection_class_disconnect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, reconnect, arginfo_amqp_connection_class_reconnect, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, preconnect, arginfo_amqp_connection_class_preconnect, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, sendHeartbeat, arginfo_amqp_connection_class_sendHeartbeat, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, sendHeartbeat, arginfo_amqp_connection_class_sendHeartbeat, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getLogin, arginfo_amqp_connection_class_getLogin, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setLogin, arginfo_amqp_connection_class_setLogin, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getLogin, arginfo_amqp_connection_class_getLogin, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setLogin, arginfo_amqp_connection_class_setLogin, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getPassword, arginfo_amqp_connection_class_getPassword, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setPassword, arginfo_amqp_connection_class_setPassword, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getPassword, arginfo_amqp_connection_class_getPassword, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setPassword, arginfo_amqp_connection_class_setPassword, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getHost, arginfo_amqp_connection_class_getHost, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setHost, arginfo_amqp_connection_class_setHost, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getHost, arginfo_amqp_connection_class_getHost, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setHost, arginfo_amqp_connection_class_setHost, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getPort, arginfo_amqp_connection_class_getPort, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setPort, arginfo_amqp_connection_class_setPort, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getPort, arginfo_amqp_connection_class_getPort, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setPort, arginfo_amqp_connection_class_setPort, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getVhost, arginfo_amqp_connection_class_getVhost, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setVhost, arginfo_amqp_connection_class_setVhost, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getVhost, arginfo_amqp_connection_class_getVhost, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setVhost, arginfo_amqp_connection_class_setVhost, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getTimeout, arginfo_amqp_connection_class_getTimeout, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setTimeout, arginfo_amqp_connection_class_setTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getTimeout, arginfo_amqp_connection_class_getTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setTimeout, arginfo_amqp_connection_class_setTimeout, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getReadTimeout, arginfo_amqp_connection_class_getReadTimeout, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setReadTimeout, arginfo_amqp_connection_class_setReadTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getReadTimeout, arginfo_amqp_connection_class_getReadTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setReadTimeout, arginfo_amqp_connection_class_setReadTimeout, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getWriteTimeout, arginfo_amqp_connection_class_getWriteTimeout, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setWriteTimeout, arginfo_amqp_connection_class_setWriteTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getWriteTimeout, arginfo_amqp_connection_class_getWriteTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setWriteTimeout, arginfo_amqp_connection_class_setWriteTimeout, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getRpcTimeout, arginfo_amqp_connection_class_getRpcTimeout, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setRpcTimeout, arginfo_amqp_connection_class_setRpcTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getConnectTimeout, arginfo_amqp_connection_class_getConnectTimeout, ZEND_ACC_PUBLIC)
+ /** setConnectTimeout intentionally left out */
- PHP_ME(amqp_connection_class, getUsedChannels, arginfo_amqp_connection_class_getUsedChannels, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getMaxChannels, arginfo_amqp_connection_class_getMaxChannels, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, isPersistent, arginfo_amqp_connection_class_isPersistent, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getHeartbeatInterval, arginfo_amqp_connection_class_getHeartbeatInterval, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getMaxFrameSize, arginfo_amqp_connection_class_getMaxFrameSize, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getRpcTimeout, arginfo_amqp_connection_class_getRpcTimeout, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setRpcTimeout, arginfo_amqp_connection_class_setRpcTimeout, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getCACert, arginfo_amqp_connection_class_getCACert, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setCACert, arginfo_amqp_connection_class_setCACert, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getUsedChannels, arginfo_amqp_connection_class_getUsedChannels, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getMaxChannels, arginfo_amqp_connection_class_getMaxChannels, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, isPersistent, arginfo_amqp_connection_class_isPersistent, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getHeartbeatInterval, arginfo_amqp_connection_class_getHeartbeatInterval, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getMaxFrameSize, arginfo_amqp_connection_class_getMaxFrameSize, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getCert, arginfo_amqp_connection_class_getCert, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setCert, arginfo_amqp_connection_class_setCert, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getCACert, arginfo_amqp_connection_class_getCACert, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setCACert, arginfo_amqp_connection_class_setCACert, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getKey, arginfo_amqp_connection_class_getKey, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setKey, arginfo_amqp_connection_class_setKey, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getCert, arginfo_amqp_connection_class_getCert, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setCert, arginfo_amqp_connection_class_setCert, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getVerify, arginfo_amqp_connection_class_getVerify, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setVerify, arginfo_amqp_connection_class_setVerify, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getKey, arginfo_amqp_connection_class_getKey, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setKey, arginfo_amqp_connection_class_setKey, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getSaslMethod, arginfo_amqp_connection_class_getSaslMethod, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setSaslMethod, arginfo_amqp_connection_class_setSaslMethod, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getVerify, arginfo_amqp_connection_class_getVerify, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setVerify, arginfo_amqp_connection_class_setVerify, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, getConnectionName, arginfo_amqp_connection_class_getConnectionName, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_connection_class, setConnectionName, arginfo_amqp_connection_class_setConnectionName, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, getSaslMethod, arginfo_amqp_connection_class_getSaslMethod, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setSaslMethod, arginfo_amqp_connection_class_setSaslMethod, ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
-};
+ PHP_ME(amqp_connection_class, getConnectionName, arginfo_amqp_connection_class_getConnectionName, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_connection_class, setConnectionName, arginfo_amqp_connection_class_setConnectionName, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
PHP_MINIT_FUNCTION(amqp_connection)
{
- zend_class_entry ce;
-
- INIT_CLASS_ENTRY(ce, "AMQPConnection", amqp_connection_class_functions);
- ce.create_object = amqp_connection_ctor;
- this_ce = zend_register_internal_class(&ce TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("login"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("password"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("host"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("vhost"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("port"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("read_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("write_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("connect_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("rpc_timeout"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("channel_max"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("frame_max"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("heartbeat"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("cacert"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("capath"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("use_default_cacert"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("use_default_capath"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("key"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("cert"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("verify"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("sasl_method"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("connection_name"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
-#if PHP_MAJOR_VERSION >=7
- memcpy(&amqp_connection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
-
- amqp_connection_object_handlers.offset = XtOffsetOf(amqp_connection_object, zo);
- amqp_connection_object_handlers.free_obj = amqp_connection_free;
-#endif
-
- return SUCCESS;
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "AMQPConnection", amqp_connection_class_functions);
+ ce.create_object = amqp_connection_ctor;
+ this_ce = zend_register_internal_class(&ce);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "login", ZEND_ACC_PRIVATE, IS_STRING, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "password", ZEND_ACC_PRIVATE, IS_STRING, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "host", ZEND_ACC_PRIVATE, IS_STRING, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "vhost", ZEND_ACC_PRIVATE, IS_STRING, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "port", ZEND_ACC_PRIVATE, IS_LONG, 0);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "readTimeout", ZEND_ACC_PRIVATE, IS_DOUBLE, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "writeTimeout", ZEND_ACC_PRIVATE, IS_DOUBLE, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "connectTimeout", ZEND_ACC_PRIVATE, IS_DOUBLE, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "rpcTimeout", ZEND_ACC_PRIVATE, IS_DOUBLE, 0);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "frameMax", ZEND_ACC_PRIVATE, IS_LONG, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "channelMax", ZEND_ACC_PRIVATE, IS_LONG, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "heartbeat", ZEND_ACC_PRIVATE, IS_LONG, 0);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "cacert", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "capath", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "use_default_cacert", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "use_default_capath", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "key", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "cert", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "verify", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_TRUE);
+
+ zval default_sasl_method;
+ ZVAL_LONG(&default_sasl_method, DEFAULT_SASL_METHOD);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_ZVAL(
+ this_ce,
+ "saslMethod",
+ ZEND_ACC_PRIVATE,
+ PHP_AMQP_DECLARE_PROPERTY_TYPE(IS_LONG, 0),
+ default_sasl_method
+ );
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "connectionName", ZEND_ACC_PRIVATE, IS_STRING, 1);
+
+ memcpy(&amqp_connection_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
+
+ amqp_connection_object_handlers.offset = XtOffsetOf(amqp_connection_object, zo);
+ amqp_connection_object_handlers.free_obj = amqp_connection_free;
+
+ return SUCCESS;
}
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<6
-*/
diff --git a/amqp_connection.h b/amqp_connection.h
index 0b8b5559..fbdca86f 100644
--- a/amqp_connection.h
+++ b/amqp_connection.h
@@ -24,17 +24,8 @@
extern zend_class_entry *amqp_connection_class_entry;
-int php_amqp_connect(amqp_connection_object *amqp_connection, zend_bool persistent, INTERNAL_FUNCTION_PARAMETERS);
-void php_amqp_disconnect_force(amqp_connection_resource *resource TSRMLS_DC);
+int php_amqp_connect(amqp_connection_object *amqp_connection, bool persistent, INTERNAL_FUNCTION_PARAMETERS);
+void php_amqp_disconnect_force(amqp_connection_resource *resource);
PHP_MINIT_FUNCTION(amqp_connection);
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_connection_resource.c b/amqp_connection_resource.c
index c48938cd..126df257 100644
--- a/amqp_connection_resource.c
+++ b/amqp_connection_resource.c
@@ -22,158 +22,199 @@
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
-#include "ext/standard/datetime.h"
+#include "ext/date/php_date.h"
#include "zend_exceptions.h"
#ifdef PHP_WIN32
-# if PHP_VERSION_ID >= 80000
-# include "main/php_stdint.h"
-# else
-# include "win32/php_stdint.h"
-# endif
-# include "win32/signal.h"
+ #if PHP_VERSION_ID >= 80000
+ #include
+ #else
+ #include "win32/php_stdint.h"
+ #endif
+ #include "win32/signal.h"
#else
-# include
-# include
+ #include
+ #include
+ #include
#endif
-#include
-#include
-#include
-#include
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+ #include
+ #include
+ #include
+#else
+ #include
+ #include
+ #include
+ #include
+#endif
#ifdef PHP_WIN32
-# include "win32/unistd.h"
+ #include "win32/unistd.h"
#else
-# include
+ #include
#endif
-//#include "amqp_basic_properties.h"
#include "amqp_methods_handling.h"
#include "amqp_connection_resource.h"
#include "amqp_channel.h"
#include "php_amqp.h"
#ifndef E_DEPRECATED
-#define E_DEPRECATED E_WARNING
+ #define E_DEPRECATED E_WARNING
#endif
int le_amqp_connection_resource;
int le_amqp_connection_resource_persistent;
-static void connection_resource_destructor(amqp_connection_resource *resource, int persistent TSRMLS_DC);
-static void php_amqp_close_connection_from_server(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource TSRMLS_DC);
-static void php_amqp_close_channel_from_server(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC);
+static void connection_resource_destructor(amqp_connection_resource *resource, int persistent);
+static void php_amqp_close_connection_from_server(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *resource
+);
+static void php_amqp_close_channel_from_server(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *resource,
+ amqp_channel_t channel_id
+);
/* Figure out what's going on connection and handle protocol exceptions, if any */
-int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC)
+int php_amqp_connection_resource_error(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *resource,
+ amqp_channel_t channel_id
+)
{
- assert (resource != NULL);
-
- switch (reply.reply_type) {
- case AMQP_RESPONSE_NORMAL:
- return PHP_AMQP_RESOURCE_RESPONSE_OK;
-
- case AMQP_RESPONSE_NONE:
- spprintf(message, 0, "Missing RPC reply type.");
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
-
- case AMQP_RESPONSE_LIBRARY_EXCEPTION:
-
- spprintf(message, 0, "Library error: %s", amqp_error_string2(reply.library_error));
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
-
- case AMQP_RESPONSE_SERVER_EXCEPTION:
- switch (reply.reply.id) {
- case AMQP_CONNECTION_CLOSE_METHOD: {
- php_amqp_close_connection_from_server(reply, message, resource TSRMLS_CC);
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED;
- }
- case AMQP_CHANNEL_CLOSE_METHOD: {
- php_amqp_close_channel_from_server(reply, message, resource, channel_id TSRMLS_CC);
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED;
- }
- }
- /* Default for the above switch should be handled by the below default. */
- default:
- spprintf(message, 0, "Unknown server error, method id 0x%08X", reply.reply.id);
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
- }
-
- /* Should not never get here*/
+ assert(resource != NULL);
+
+ switch (reply.reply_type) {
+ case AMQP_RESPONSE_NORMAL:
+ return PHP_AMQP_RESOURCE_RESPONSE_OK;
+
+ case AMQP_RESPONSE_NONE:
+ spprintf(message, 0, "Missing RPC reply type.");
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+
+ case AMQP_RESPONSE_LIBRARY_EXCEPTION:
+ spprintf(message, 0, "%s", amqp_error_string2(reply.library_error));
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+
+ case AMQP_RESPONSE_SERVER_EXCEPTION:
+ switch (reply.reply.id) {
+ case AMQP_CONNECTION_CLOSE_METHOD: {
+ php_amqp_close_connection_from_server(reply, message, resource);
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED;
+ }
+ case AMQP_CHANNEL_CLOSE_METHOD: {
+ php_amqp_close_channel_from_server(reply, message, resource, channel_id);
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED;
+ }
+ }
+ /* Default for the above switch should be handled by the below default. */
+ default:
+ spprintf(message, 0, "Unknown server error, method id 0x%08X", reply.reply.id);
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+ }
+
+ /* Should not never get here*/
}
-static void php_amqp_close_connection_from_server(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource TSRMLS_DC) {
- amqp_connection_close_t *m = (amqp_connection_close_t *)reply.reply.decoded;
- int result;
-
- if (!reply.reply.id) {
- PHP_AMQP_G(error_code) = -1;
- spprintf(message, 0, "Server connection error: %ld, message: %s",
- (long)PHP_AMQP_G(error_code),
- "unexpected response"
- );
- } else {
- PHP_AMQP_G(error_code) = m->reply_code;
- spprintf(message, 0, "Server connection error: %d, message: %.*s",
- m->reply_code,
- (int) m->reply_text.len,
- (char *) m->reply_text.bytes
- );
- }
-
- /*
+static void php_amqp_close_connection_from_server(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *resource
+)
+{
+ amqp_connection_close_t *m = (amqp_connection_close_t *) reply.reply.decoded;
+ int result;
+
+ if (!reply.reply.id) {
+ PHP_AMQP_G(error_code) = -1;
+ spprintf(
+ message,
+ 0,
+ "Server connection error: " ZEND_LONG_FMT ", message: %s",
+ PHP_AMQP_G(error_code),
+ "unexpected response"
+ );
+ } else {
+ PHP_AMQP_G(error_code) = m->reply_code;
+ spprintf(
+ message,
+ 0,
+ "Server connection error: %d, message: %.*s",
+ m->reply_code,
+ (int) m->reply_text.len,
+ (char *) m->reply_text.bytes
+ );
+ }
+
+ /*
* - If r.reply.id == AMQP_CONNECTION_CLOSE_METHOD a connection exception
* occurred, cast r.reply.decoded to amqp_connection_close_t* to see
* details of the exception. The client amqp_send_method() a
* amqp_connection_close_ok_t and disconnect from the broker.
*/
- amqp_connection_close_ok_t *decoded = (amqp_connection_close_ok_t *) NULL;
+ amqp_connection_close_ok_t *decoded = (amqp_connection_close_ok_t *) NULL;
- result = amqp_send_method(
- resource->connection_state,
- 0, /* NOTE: 0-channel is reserved for things like this */
- AMQP_CONNECTION_CLOSE_OK_METHOD,
- &decoded
- );
+ result = amqp_send_method(
+ resource->connection_state,
+ 0, /* NOTE: 0-channel is reserved for things like this */
+ AMQP_CONNECTION_CLOSE_OK_METHOD,
+ &decoded
+ );
- if (result != AMQP_STATUS_OK) {
- zend_throw_exception(amqp_channel_exception_class_entry, "An error occurred while closing the connection.", 0 TSRMLS_CC);
- }
+ if (result != AMQP_STATUS_OK) {
+ zend_throw_exception(amqp_channel_exception_class_entry, "An error occurred while closing the connection.", 0);
+ }
- /* Prevent finishing AMQP connection in connection resource destructor */
- resource->is_connected = '\0';
+ /* Prevent finishing AMQP connection in connection resource destructor */
+ resource->is_connected = '\0';
}
-static void php_amqp_close_channel_from_server(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC) {
- assert(channel_id > 0 && channel_id <= resource->max_slots);
-
- amqp_channel_close_t *m = (amqp_channel_close_t *) reply.reply.decoded;
-
- if (!reply.reply.id) {
- PHP_AMQP_G(error_code) = -1;
- spprintf(message, 0, "Server channel error: %ld, message: %s",
- (long)PHP_AMQP_G(error_code),
- "unexpected response"
- );
- } else {
- PHP_AMQP_G(error_code) = m->reply_code;
- spprintf(message, 0, "Server channel error: %d, message: %.*s",
- m->reply_code,
- (int) m->reply_text.len,
- (char *)m->reply_text.bytes
- );
- }
-
- /*
+static void php_amqp_close_channel_from_server(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *resource,
+ amqp_channel_t channel_id
+)
+{
+ assert(channel_id > 0 && channel_id <= resource->max_slots);
+
+ amqp_channel_close_t *m = (amqp_channel_close_t *) reply.reply.decoded;
+
+ if (!reply.reply.id) {
+ PHP_AMQP_G(error_code) = -1;
+ spprintf(
+ message,
+ 0,
+ "Server channel error: " ZEND_LONG_FMT ", message: %s",
+ PHP_AMQP_G(error_code),
+ "unexpected response"
+ );
+ } else {
+ PHP_AMQP_G(error_code) = m->reply_code;
+ spprintf(
+ message,
+ 0,
+ "Server channel error: %d, message: %.*s",
+ m->reply_code,
+ (int) m->reply_text.len,
+ (char *) m->reply_text.bytes
+ );
+ }
+
+ /*
* - If r.reply.id == AMQP_CHANNEL_CLOSE_METHOD a channel exception
* occurred, cast r.reply.decoded to amqp_channel_close_t* to see details
* of the exception. The client should amqp_send_method() a
@@ -182,171 +223,183 @@ static void php_amqp_close_channel_from_server(amqp_rpc_reply_t reply, char **me
* (auto-delete exchanges, auto-delete queues, consumers) are invalid
* and must be recreated before attempting to use them again.
*/
-
- if (resource) {
- int result;
- amqp_channel_close_ok_t *decoded = (amqp_channel_close_ok_t *) NULL;
-
- result = amqp_send_method(
- resource->connection_state,
- channel_id,
- AMQP_CHANNEL_CLOSE_OK_METHOD,
- &decoded
- );
- if (result != AMQP_STATUS_OK) {
- zend_throw_exception(amqp_channel_exception_class_entry, "An error occurred while closing channel.", 0 TSRMLS_CC);
- }
- }
+ if (resource) {
+ int result;
+ amqp_channel_close_ok_t *decoded = (amqp_channel_close_ok_t *) NULL;
+
+ result = amqp_send_method(resource->connection_state, channel_id, AMQP_CHANNEL_CLOSE_OK_METHOD, &decoded);
+ if (result != AMQP_STATUS_OK) {
+ zend_throw_exception(amqp_channel_exception_class_entry, "An error occurred while closing channel.", 0);
+ }
+ }
}
-int php_amqp_connection_resource_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel TSRMLS_DC)
+int php_amqp_connection_resource_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_channel_object *channel)
{
- assert(resource != NULL);
-
- amqp_frame_t frame;
-
- assert(AMQP_RESPONSE_LIBRARY_EXCEPTION == reply.reply_type);
- assert(AMQP_STATUS_UNEXPECTED_STATE == reply.library_error);
-
- if (channel_id < 0 || AMQP_STATUS_OK != amqp_simple_wait_frame(resource->connection_state, &frame)) {
- if (*message != NULL) {
- efree(*message);
- }
-
- spprintf(message, 0, "Library error: %s", amqp_error_string2(reply.library_error));
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
- }
-
- if (channel_id != frame.channel) {
- spprintf(message, 0, "Library error: channel mismatch");
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
- }
-
- if (AMQP_FRAME_METHOD == frame.frame_type) {
- switch (frame.payload.method.id) {
- case AMQP_CONNECTION_CLOSE_METHOD: {
- php_amqp_close_connection_from_server(reply, message, resource TSRMLS_CC);
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED;
- }
- case AMQP_CHANNEL_CLOSE_METHOD: {
- php_amqp_close_channel_from_server(reply, message, resource, channel_id TSRMLS_CC);
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED;
- }
-
- case AMQP_BASIC_ACK_METHOD:
- /* if we've turned publisher confirms on, and we've published a message
+ amqp_frame_t frame;
+
+ assert(AMQP_RESPONSE_LIBRARY_EXCEPTION == reply.reply_type);
+ assert(AMQP_STATUS_UNEXPECTED_STATE == reply.library_error);
+
+ if (channel->channel_resource->channel_id < 0 ||
+ AMQP_STATUS_OK !=
+ amqp_simple_wait_frame(channel->channel_resource->connection_resource->connection_state, &frame)) {
+ if (*message != NULL) {
+ efree(*message);
+ }
+
+ spprintf(message, 0, "%s", amqp_error_string2(reply.library_error));
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+ }
+
+ if (channel->channel_resource->channel_id != frame.channel) {
+ spprintf(message, 0, "Channel mismatch");
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+ }
+
+ if (AMQP_FRAME_METHOD == frame.frame_type) {
+ switch (frame.payload.method.id) {
+ case AMQP_CONNECTION_CLOSE_METHOD: {
+ php_amqp_close_connection_from_server(reply, message, channel->channel_resource->connection_resource);
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED;
+ }
+ case AMQP_CHANNEL_CLOSE_METHOD: {
+ php_amqp_close_channel_from_server(
+ reply,
+ message,
+ channel->channel_resource->connection_resource,
+ channel->channel_resource->channel_id
+ );
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED;
+ }
+
+ case AMQP_BASIC_ACK_METHOD:
+ /* if we've turned publisher confirms on, and we've published a message
* here is a message being confirmed
*/
- return php_amqp_handle_basic_ack(message, resource, channel_id, channel, &frame.payload.method TSRMLS_CC);
- case AMQP_BASIC_NACK_METHOD:
- /* if we've turned publisher confirms on, and we've published a message
+ return php_amqp_handle_basic_ack(message, channel, &frame.payload.method);
+ case AMQP_BASIC_NACK_METHOD:
+ /* if we've turned publisher confirms on, and we've published a message
* here is a message being confirmed
*/
- return php_amqp_handle_basic_nack(message, resource, channel_id, channel, &frame.payload.method TSRMLS_CC);
- case AMQP_BASIC_RETURN_METHOD:
- /* if a published message couldn't be routed and the mandatory flag was set
+ return php_amqp_handle_basic_nack(message, channel, &frame.payload.method);
+ case AMQP_BASIC_RETURN_METHOD:
+ /* if a published message couldn't be routed and the mandatory flag was set
* this is what would be returned. The message then needs to be read.
*/
- return php_amqp_handle_basic_return(message, resource, channel_id, channel, &frame.payload.method TSRMLS_CC);
- default:
- if (*message != NULL) {
- efree(*message);
- }
+ return php_amqp_handle_basic_return(message, channel, &frame.payload.method);
+ default:
+ if (*message != NULL) {
+ efree(*message);
+ }
- spprintf(message, 0, "Library error: An unexpected method was received 0x%08X\n", frame.payload.method.id);
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
- }
- }
+ spprintf(message, 0, "An unexpected method was received 0x%08X\n", frame.payload.method.id);
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+ }
+ }
- if (*message != NULL) {
- efree(*message);
- }
+ if (*message != NULL) {
+ efree(*message);
+ }
- spprintf(message, 0, "Library error: %s", amqp_error_string2(reply.library_error));
- return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
+ spprintf(message, 0, "%s", amqp_error_string2(reply.library_error));
+ return PHP_AMQP_RESOURCE_RESPONSE_ERROR;
}
/* Socket-related functions */
-int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double timeout TSRMLS_DC)
+int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double timeout)
{
- assert(timeout >= 0.0);
+ assert(timeout >= 0.0);
#ifdef PHP_WIN32
- DWORD read_timeout;
- /*
+ DWORD read_timeout;
+ /*
In Windows, setsockopt with SO_RCVTIMEO sets actual timeout
to a value that's 500ms greater than specified value.
Also, it's not possible to set timeout to any value below 500ms.
Zero timeout works like it should, however.
*/
- if (timeout == 0.) {
- read_timeout = 0;
- } else {
- read_timeout = (int) (max(timeout * 1.e+3 - .5e+3, 1.));
- }
+ if (timeout == 0.) {
+ read_timeout = 0;
+ } else {
+ read_timeout = (int) (max(timeout * 1.e+3 - .5e+3, 1.));
+ }
#else
- struct timeval read_timeout;
- read_timeout.tv_sec = (int) floor(timeout);
- read_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6);
+ struct timeval read_timeout;
+ read_timeout.tv_sec = (int) floor(timeout);
+ read_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6);
#endif
- if (0 != setsockopt(amqp_get_sockfd(resource->connection_state), SOL_SOCKET, SO_RCVTIMEO, (char *)&read_timeout, sizeof(read_timeout))) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_RCVTIMEO", 0 TSRMLS_CC);
- return 0;
- }
+ if (0 != setsockopt(
+ amqp_get_sockfd(resource->connection_state),
+ SOL_SOCKET,
+ SO_RCVTIMEO,
+ (char *) &read_timeout,
+ sizeof(read_timeout)
+ )) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_RCVTIMEO", 0);
+ return 0;
+ }
- return 1;
+ return 1;
}
-int php_amqp_set_resource_rpc_timeout(amqp_connection_resource *resource, double timeout TSRMLS_DC)
+int php_amqp_set_resource_rpc_timeout(amqp_connection_resource *resource, double timeout)
{
- assert(timeout >= 0.0);
+ assert(timeout >= 0.0);
#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH >= 90
- struct timeval rpc_timeout;
+ struct timeval rpc_timeout;
- if (timeout == 0.) return 1;
+ if (timeout == 0.)
+ return 1;
- rpc_timeout.tv_sec = (int) floor(timeout);
- rpc_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6);
+ rpc_timeout.tv_sec = (int) floor(timeout);
+ rpc_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6);
- if (AMQP_STATUS_OK != amqp_set_rpc_timeout(resource->connection_state, &rpc_timeout)) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Library error: cannot set rpc_timeout", 0 TSRMLS_CC);
- return 0;
- }
+ if (AMQP_STATUS_OK != amqp_set_rpc_timeout(resource->connection_state, &rpc_timeout)) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Cannot set rpc_timeout", 0);
+ return 0;
+ }
#endif
- return 1;
+ return 1;
}
-int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double timeout TSRMLS_DC)
+int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double timeout)
{
- assert(timeout >= 0.0);
+ assert(timeout >= 0.0);
#ifdef PHP_WIN32
- DWORD write_timeout;
+ DWORD write_timeout;
- if (timeout == 0.) {
- write_timeout = 0;
- } else {
- write_timeout = (int) (max(timeout * 1.e+3 - .5e+3, 1.));
- }
+ if (timeout == 0.) {
+ write_timeout = 0;
+ } else {
+ write_timeout = (int) (max(timeout * 1.e+3 - .5e+3, 1.));
+ }
#else
- struct timeval write_timeout;
- write_timeout.tv_sec = (int) floor(timeout);
- write_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6);
+ struct timeval write_timeout;
+ write_timeout.tv_sec = (int) floor(timeout);
+ write_timeout.tv_usec = (int) ((timeout - floor(timeout)) * 1.e+6);
#endif
- if (0 != setsockopt(amqp_get_sockfd(resource->connection_state), SOL_SOCKET, SO_SNDTIMEO, (char *)&write_timeout, sizeof(write_timeout))) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_SNDTIMEO", 0 TSRMLS_CC);
- return 0;
- }
+ if (0 != setsockopt(
+ amqp_get_sockfd(resource->connection_state),
+ SOL_SOCKET,
+ SO_SNDTIMEO,
+ (char *) &write_timeout,
+ sizeof(write_timeout)
+ )) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: cannot setsockopt SO_SNDTIMEO", 0);
+ return 0;
+ }
- return 1;
+ return 1;
}
@@ -354,80 +407,84 @@ int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, doub
amqp_channel_t php_amqp_connection_resource_get_available_channel_id(amqp_connection_resource *resource)
{
- assert(resource != NULL);
- assert(resource->slots != NULL);
+ assert(resource != NULL);
+ assert(resource->slots != NULL);
- /* Check if there are any open slots */
- if (resource->used_slots >= resource->max_slots) {
- return 0;
- }
+ /* Check if there are any open slots */
+ if (resource->used_slots >= resource->max_slots) {
+ return 0;
+ }
- amqp_channel_t slot;
+ amqp_channel_t slot;
- for (slot = 0; slot < resource->max_slots; slot++) {
- if (resource->slots[slot] == 0) {
- return (amqp_channel_t) (slot + 1);
- }
- }
+ for (slot = resource->used_slots; slot < resource->max_slots; slot++) {
+ if (resource->slots[slot] == 0) {
+ return (amqp_channel_t) (slot + 1);
+ }
+ }
- return 0;
+ return 0;
}
-int php_amqp_connection_resource_register_channel(amqp_connection_resource *resource, amqp_channel_resource *channel_resource, amqp_channel_t channel_id)
+int php_amqp_connection_resource_register_channel(
+ amqp_connection_resource *resource,
+ amqp_channel_resource *channel_resource,
+ amqp_channel_t channel_id
+)
{
- assert(resource != NULL);
- assert(resource->slots != NULL);
- assert(channel_id > 0 && channel_id <= resource->max_slots);
+ assert(resource != NULL);
+ assert(resource->slots != NULL);
+ assert(channel_id > 0 && channel_id <= resource->max_slots);
- if (resource->slots[channel_id - 1] != 0) {
- return FAILURE;
- }
+ if (resource->slots[channel_id - 1] != 0) {
+ return FAILURE;
+ }
- resource->slots[channel_id - 1] = channel_resource;
- channel_resource->connection_resource = resource;
- resource->used_slots++;
+ resource->slots[channel_id - 1] = channel_resource;
+ channel_resource->connection_resource = resource;
+ resource->used_slots++;
- return SUCCESS;
+ return SUCCESS;
}
int php_amqp_connection_resource_unregister_channel(amqp_connection_resource *resource, amqp_channel_t channel_id)
{
- assert(resource != NULL);
- assert(resource->slots != NULL);
- assert(channel_id > 0 && channel_id <= resource->max_slots);
+ assert(resource != NULL);
+ assert(resource->slots != NULL);
+ assert(channel_id > 0 && channel_id <= resource->max_slots);
- if (resource->slots[channel_id - 1] != 0) {
- resource->slots[channel_id - 1]->connection_resource = NULL;
+ if (resource->slots[channel_id - 1] != 0) {
+ resource->slots[channel_id - 1]->connection_resource = NULL;
- resource->slots[channel_id - 1] = 0;
- resource->used_slots--;
- }
+ resource->slots[channel_id - 1] = 0;
+ resource->used_slots--;
+ }
- return SUCCESS;
+ return SUCCESS;
}
/* Creating and destroying resource */
-amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, zend_bool persistent TSRMLS_DC)
+amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, bool persistent)
{
- struct timeval tv = {0};
- struct timeval *tv_ptr = &tv;
+ struct timeval tv = {0};
+ struct timeval *tv_ptr = &tv;
+ zend_string *std_datetime;
- char *std_datetime;
- amqp_table_entry_t client_properties_entries[5];
- amqp_table_t client_properties_table;
+ amqp_table_entry_t client_properties_entries[4];
+ amqp_table_t client_properties_table;
- amqp_table_entry_t custom_properties_entries[2];
- amqp_table_t custom_properties_table;
+ amqp_table_entry_t custom_properties_entries[2];
+ amqp_table_t custom_properties_table;
- amqp_connection_resource *resource;
+ amqp_connection_resource *resource;
- /* Allocate space for the connection resource */
- resource = (amqp_connection_resource *)pecalloc(1, sizeof(amqp_connection_resource), persistent);
+ /* Allocate space for the connection resource */
+ resource = (amqp_connection_resource *) pecalloc(1, sizeof(amqp_connection_resource), persistent);
- /* Create the connection */
- resource->connection_state = amqp_new_connection();
+ /* Create the connection */
+ resource->connection_state = amqp_new_connection();
int use_ssl = params->cacert || params->capath || params->use_default_cacert || params->use_default_capath;
@@ -435,155 +492,174 @@ amqp_connection_resource *connection_resource_constructor(amqp_connection_params
if (use_ssl) {
resource->socket = amqp_ssl_socket_new(resource->connection_state);
- if (!resource->socket) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not create SSL socket.", 0 TSRMLS_CC);
-
- return NULL;
- }
- } else {
- resource->socket = amqp_tcp_socket_new(resource->connection_state);
+ if (!resource->socket) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Socket error: could not create SSL socket.",
+ 0
+ );
- if (!resource->socket) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not create socket.", 0 TSRMLS_CC);
+ return NULL;
+ }
- return NULL;
- }
- }
- if (params->cacert && amqp_ssl_socket_set_cacert(resource->socket, params->cacert)) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not set CA certificate.", 0 TSRMLS_CC);
+ if (amqp_ssl_socket_set_cacert(resource->socket, params->cacert) != AMQP_STATUS_OK) {
+ zend_throw_exception(
+ amqp_connection_exception_class_entry,
+ "Socket error: could not set CA certificate.",
+ 0
+ );
+ connection_resource_destructor(resource, persistent);
return NULL;
} else if (params->capath && amqp_ssl_socket_set_capath(resource->socket, params->capath)) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not set CA path.", 0 TSRMLS_CC);
+ zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not set CA path.", 0);
return NULL;
} else if (params->use_default_cacert && amqp_ssl_socket_set_default_cacert(resource->socket)) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not set default CA certificate.", 0 TSRMLS_CC);
+ zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not set default CA certificate.", 0);
return NULL;
} else if (params->use_default_capath && amqp_ssl_socket_set_default_capath(resource->socket)) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not set default CA path.", 0 TSRMLS_CC);
+ zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not set default CA path.", 0);
return NULL;
}
if (use_ssl) {
#if AMQP_VERSION_MAJOR * 100 + AMQP_VERSION_MINOR * 10 + AMQP_VERSION_PATCH >= 80
- amqp_ssl_socket_set_verify_peer(resource->socket, params->verify);
- amqp_ssl_socket_set_verify_hostname(resource->socket, params->verify);
+ amqp_ssl_socket_set_verify_peer(resource->socket, params->verify);
+ amqp_ssl_socket_set_verify_hostname(resource->socket, params->verify);
#else
- amqp_ssl_socket_set_verify(resource->socket, params->verify);
+ amqp_ssl_socket_set_verify(resource->socket, params->verify);
#endif
- }
-
- if (params->cert && params->key && amqp_ssl_socket_set_key(resource->socket, params->cert, params->key)) {
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not setting client cert.", 0 TSRMLS_CC);
-
- return NULL;
- }
-
- if (params->connect_timeout > 0) {
- tv.tv_sec = (long int) params->connect_timeout;
- tv.tv_usec = (long int) ((params->connect_timeout - tv.tv_sec) * 1000000);
- } else {
- tv_ptr = NULL;
- }
- /* Try to connect and verify that no error occurred */
- if (amqp_socket_open_noblock(resource->socket, params->host, params->port, tv_ptr)) {
+ if (params->cert && params->key) {
+ int client_cert_result = amqp_ssl_socket_set_key(resource->socket, params->cert, params->key);
+ if (client_cert_result != AMQP_STATUS_OK) {
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Socket error: could not set client cert, %s",
+ amqp_error_string2(client_cert_result)
+ );
+ connection_resource_destructor(resource, persistent);
+
+ return NULL;
+ }
+ }
+
+ } else {
+ resource->socket = amqp_tcp_socket_new(resource->connection_state);
+
+ if (!resource->socket) {
+ zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not create socket.", 0);
+
+ return NULL;
+ }
+ }
- zend_throw_exception(amqp_connection_exception_class_entry, "Socket error: could not connect to host.", 0 TSRMLS_CC);
+ if (params->connect_timeout > 0) {
+ tv.tv_sec = (long int) params->connect_timeout;
+ tv.tv_usec = (long int) ((params->connect_timeout - tv.tv_sec) * 1000000);
+ } else {
+ tv_ptr = NULL;
+ }
- connection_resource_destructor(resource, persistent TSRMLS_CC);
+ /* Try to connect and verify that no error occurred */
+ int connection_result = amqp_socket_open_noblock(resource->socket, params->host, params->port, tv_ptr);
+ if (connection_result != AMQP_STATUS_OK) {
- return NULL;
- }
+ zend_throw_exception_ex(
+ amqp_connection_exception_class_entry,
+ 0,
+ "Socket error: could not connect to host, %s",
+ amqp_error_string2(connection_result)
+ );
+ connection_resource_destructor(resource, persistent);
- if (!php_amqp_set_resource_read_timeout(resource, params->read_timeout TSRMLS_CC)) {
- connection_resource_destructor(resource, persistent TSRMLS_CC);
- return NULL;
- }
-
- if (!php_amqp_set_resource_write_timeout(resource, params->write_timeout TSRMLS_CC)) {
- connection_resource_destructor(resource, persistent TSRMLS_CC);
- return NULL;
- }
+ return NULL;
+ }
- if (!php_amqp_set_resource_rpc_timeout(resource, params->rpc_timeout TSRMLS_CC)) {
- connection_resource_destructor(resource, persistent TSRMLS_CC);
- return NULL;
- }
+ if (!php_amqp_set_resource_read_timeout(resource, params->read_timeout)) {
+ connection_resource_destructor(resource, persistent);
+ return NULL;
+ }
- std_datetime = php_std_date(time(NULL) TSRMLS_CC);
+ if (!php_amqp_set_resource_write_timeout(resource, params->write_timeout)) {
+ connection_resource_destructor(resource, persistent);
+ return NULL;
+ }
- client_properties_entries[0].key = amqp_cstring_bytes("type");
- client_properties_entries[0].value.kind = AMQP_FIELD_KIND_UTF8;
- client_properties_entries[0].value.value.bytes = amqp_cstring_bytes("php-amqp extension");
+ if (!php_amqp_set_resource_rpc_timeout(resource, params->rpc_timeout)) {
+ connection_resource_destructor(resource, persistent);
+ return NULL;
+ }
- client_properties_entries[1].key = amqp_cstring_bytes("version");
- client_properties_entries[1].value.kind = AMQP_FIELD_KIND_UTF8;
- client_properties_entries[1].value.value.bytes = amqp_cstring_bytes(PHP_AMQP_VERSION);
+ client_properties_entries[0].key = amqp_cstring_bytes("type");
+ client_properties_entries[0].value.kind = AMQP_FIELD_KIND_UTF8;
+ client_properties_entries[0].value.value.bytes = amqp_cstring_bytes("php-amqp extension");
- client_properties_entries[2].key = amqp_cstring_bytes("revision");
- client_properties_entries[2].value.kind = AMQP_FIELD_KIND_UTF8;
- client_properties_entries[2].value.value.bytes = amqp_cstring_bytes(PHP_AMQP_REVISION);
+ client_properties_entries[1].key = amqp_cstring_bytes("version");
+ client_properties_entries[1].value.kind = AMQP_FIELD_KIND_UTF8;
+ client_properties_entries[1].value.value.bytes = amqp_cstring_bytes(PHP_AMQP_VERSION);
- client_properties_entries[3].key = amqp_cstring_bytes("connection type");
- client_properties_entries[3].value.kind = AMQP_FIELD_KIND_UTF8;
- client_properties_entries[3].value.value.bytes = amqp_cstring_bytes(persistent ? "persistent" : "transient");
+ client_properties_entries[2].key = amqp_cstring_bytes("connection type");
+ client_properties_entries[2].value.kind = AMQP_FIELD_KIND_UTF8;
+ client_properties_entries[2].value.value.bytes = amqp_cstring_bytes(persistent ? "persistent" : "transient");
- client_properties_entries[4].key = amqp_cstring_bytes("connection started");
- client_properties_entries[4].value.kind = AMQP_FIELD_KIND_UTF8;
- client_properties_entries[4].value.value.bytes = amqp_cstring_bytes(std_datetime);
+ client_properties_entries[3].key = amqp_cstring_bytes("connection started");
+ client_properties_entries[3].value.kind = AMQP_FIELD_KIND_UTF8;
+ std_datetime = php_format_date("D, d M Y H:i:s \\G\\M\\T", sizeof("D, d M Y H:i:s \\G\\M\\T") - 1, time(NULL), 0);
+ client_properties_entries[3].value.value.bytes = amqp_cstring_bytes(ZSTR_VAL(std_datetime));
- client_properties_table.entries = client_properties_entries;
- client_properties_table.num_entries = sizeof(client_properties_entries) / sizeof(amqp_table_entry_t);
+ client_properties_table.entries = client_properties_entries;
+ client_properties_table.num_entries = sizeof(client_properties_entries) / sizeof(amqp_table_entry_t);
- custom_properties_entries[0].key = amqp_cstring_bytes("client");
- custom_properties_entries[0].value.kind = AMQP_FIELD_KIND_TABLE;
- custom_properties_entries[0].value.value.table = client_properties_table;
+ custom_properties_entries[0].key = amqp_cstring_bytes("client");
+ custom_properties_entries[0].value.kind = AMQP_FIELD_KIND_TABLE;
+ custom_properties_entries[0].value.value.table = client_properties_table;
- if (params->connection_name) {
- custom_properties_entries[1].key = amqp_cstring_bytes("connection_name");
- custom_properties_entries[1].value.kind = AMQP_FIELD_KIND_UTF8;
- custom_properties_entries[1].value.value.bytes = amqp_cstring_bytes(params->connection_name);
- }
+ if (params->connection_name) {
+ custom_properties_entries[1].key = amqp_cstring_bytes("connection_name");
+ custom_properties_entries[1].value.kind = AMQP_FIELD_KIND_UTF8;
+ custom_properties_entries[1].value.value.bytes = amqp_cstring_bytes(params->connection_name);
+ }
- custom_properties_table.entries = custom_properties_entries;
- custom_properties_table.num_entries = params->connection_name ? 2 : 1;
+ custom_properties_table.entries = custom_properties_entries;
+ custom_properties_table.num_entries = params->connection_name ? 2 : 1;
- /* We can assume that connection established here but it is not true, real handshake goes during login */
+ /* We can assume that connection established here but it is not true, real handshake goes during login */
- assert(params->frame_max > 0);
+ assert(params->frame_max > 0);
- amqp_rpc_reply_t res = amqp_login_with_properties(
- resource->connection_state,
- params->vhost,
- params->channel_max,
- params->frame_max,
- params->heartbeat,
- &custom_properties_table,
- params->sasl_method,
- params->login,
- params->password
- );
+ amqp_rpc_reply_t res = amqp_login_with_properties(
+ resource->connection_state,
+ params->vhost,
+ params->channel_max,
+ params->frame_max,
+ params->heartbeat,
+ &custom_properties_table,
+ params->sasl_method,
+ params->login,
+ params->password
+ );
- efree(std_datetime);
+ zend_string_release(std_datetime);
- if (AMQP_RESPONSE_NORMAL != res.reply_type) {
- char *message = NULL, *long_message = NULL;
+ if (AMQP_RESPONSE_NORMAL != res.reply_type) {
+ char *message = NULL, *long_message = NULL;
- php_amqp_connection_resource_error(res, &message, resource, 0 TSRMLS_CC);
+ php_amqp_connection_resource_error(res, &message, resource, 0);
- spprintf(&long_message, 0, "%s - Potential login failure.", message);
- zend_throw_exception(amqp_connection_exception_class_entry, long_message, PHP_AMQP_G(error_code) TSRMLS_CC);
+ spprintf(&long_message, 0, "%s", message);
+ zend_throw_exception(amqp_connection_exception_class_entry, long_message, PHP_AMQP_G(error_code));
- efree(message);
- efree(long_message);
+ efree(message);
+ efree(long_message);
- /* https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf
+ /* https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf
*
* 2.2.4 The Connection Class:
* ... a peer that detects an error MUST close the socket without sending any further data.
@@ -593,105 +669,115 @@ amqp_connection_resource *connection_resource_constructor(amqp_connection_params
* (presumably a thread) for a period of several seconds and then to close the network connection. This
* includes syntax errors, over-sized data, and failed attempts to authenticate.
*/
- connection_resource_destructor(resource, persistent TSRMLS_CC);
- return NULL;
- }
+ connection_resource_destructor(resource, persistent);
+ return NULL;
+ }
- /* Allocate space for the channel slots in the ring buffer */
- resource->max_slots = (amqp_channel_t) amqp_get_channel_max(resource->connection_state);
- assert(resource->max_slots > 0);
+ /* Allocate space for the channel slots in the ring buffer */
+ resource->max_slots = (amqp_channel_t) amqp_get_channel_max(resource->connection_state);
+ assert(resource->max_slots > 0);
- resource->slots = (amqp_channel_resource **)pecalloc(resource->max_slots + 1, sizeof(amqp_channel_object*), persistent);
+ resource->slots =
+ (amqp_channel_resource **) pecalloc(resource->max_slots + 1, sizeof(amqp_channel_object *), persistent);
- resource->is_connected = '\1';
+ resource->is_connected = '\1';
- return resource;
+ return resource;
}
ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor_persistent)
{
- amqp_connection_resource *resource = (amqp_connection_resource *)PHP5to7_ZEND_RESOURCE_DTOR_ARG->ptr;
+ amqp_connection_resource *resource = (amqp_connection_resource *) res->ptr;
- connection_resource_destructor(resource, 1 TSRMLS_CC);
+ connection_resource_destructor(resource, 1);
}
ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor)
{
- amqp_connection_resource *resource = (amqp_connection_resource *)PHP5to7_ZEND_RESOURCE_DTOR_ARG->ptr;
+ amqp_connection_resource *resource = (amqp_connection_resource *) res->ptr;
- connection_resource_destructor(resource, 0 TSRMLS_CC);
+ connection_resource_destructor(resource, 0);
}
-static void connection_resource_destructor(amqp_connection_resource *resource, int persistent TSRMLS_DC)
+static void connection_resource_destructor(amqp_connection_resource *resource, int persistent)
{
- assert(resource != NULL);
+ assert(resource != NULL);
#ifndef PHP_WIN32
- void * old_handler;
-
- /*
+ /*
If we are trying to close the connection and the connection already closed, it will throw
SIGPIPE, which is fine, so ignore all SIGPIPES
*/
- /* Start ignoring SIGPIPE */
- old_handler = signal(SIGPIPE, SIG_IGN);
+ struct sigaction oldact;
+ struct sigaction act = {0};
+
+ act.sa_flags = SA_ONSTACK;
+ act.sa_handler = SIG_IGN;
+
+ /* Start ignoring SIGPIPE */
+ if (sigaction(SIGPIPE, &act, &oldact) == -1) {
+ perror("sigaction");
+ }
#endif
- if (resource->parent) {
- resource->parent->connection_resource = NULL;
- }
+ if (resource->parent) {
+ resource->parent->connection_resource = NULL;
+ }
- if (resource->slots) {
- php_amqp_prepare_for_disconnect(resource TSRMLS_CC);
+ if (resource->slots) {
+ php_amqp_prepare_for_disconnect(resource);
- pefree(resource->slots, persistent);
- resource->slots = NULL;
- }
+ pefree(resource->slots, persistent);
+ resource->slots = NULL;
+ }
- /* connection may be closed in case of previous failure */
- if (resource->is_connected) {
- amqp_connection_close(resource->connection_state, AMQP_REPLY_SUCCESS);
- }
+ /* connection may be closed in case of previous failure */
+ if (resource->is_connected) {
+ amqp_connection_close(resource->connection_state, AMQP_REPLY_SUCCESS);
+ }
- amqp_destroy_connection(resource->connection_state);
+ amqp_destroy_connection(resource->connection_state);
#ifndef PHP_WIN32
- /* End ignoring of SIGPIPEs */
- signal(SIGPIPE, old_handler);
+ /* End ignoring of SIGPIPEs */
+ oldact.sa_flags |= SA_ONSTACK;
+
+ if (sigaction(SIGPIPE, &oldact, NULL) == -1) {
+ perror("sigaction");
+ }
#endif
- pefree(resource, persistent);
+ pefree(resource, persistent);
}
-void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource TSRMLS_DC)
+void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource)
{
- if (resource == NULL) {
- return;
- }
+ if (resource == NULL) {
+ return;
+ }
- if(resource->slots != NULL) {
- /* NOTE: when we have persistent connection we do not move channels between php requests
+ if (resource->slots != NULL) {
+ /* NOTE: when we have persistent connection we do not move channels between php requests
* due to current php-amqp extension limitation in AMQPChannel where __construct == channel.open AMQP method call
* and __destruct = channel.close AMQP method call
*/
- /* Clean up old memory allocations which are now invalid (new connection) */
- amqp_channel_t slot;
+ /* Clean up old memory allocations which are now invalid (new connection) */
+ amqp_channel_t slot;
- for (slot = 0; slot < resource->max_slots; slot++) {
- if (resource->slots[slot] != 0) {
- php_amqp_close_channel(resource->slots[slot], 0 TSRMLS_CC);
- }
- }
- }
+ for (slot = 0; slot < resource->max_slots; slot++) {
+ if (resource->slots[slot] != 0) {
+ php_amqp_close_channel(resource->slots[slot], 0);
+ }
+ }
+ }
- /* If it's persistent connection do not destroy connection resource (this keep connection alive) */
- if (resource->is_persistent) {
- /* Cleanup buffers to reduce memory usage in idle mode */
- amqp_maybe_release_buffers(resource->connection_state);
- }
+ /* If it's persistent connection do not destroy connection resource (this keep connection alive) */
+ if (resource->is_persistent) {
+ /* Cleanup buffers to reduce memory usage in idle mode */
+ amqp_maybe_release_buffers(resource->connection_state);
+ }
- return;
+ return;
}
-
diff --git a/amqp_connection_resource.h b/amqp_connection_resource.h
index d046b4e3..c43ca785 100644
--- a/amqp_connection_resource.h
+++ b/amqp_connection_resource.h
@@ -23,19 +23,23 @@
#ifndef PHP_AMQP_CONNECTION_RESOURCE_H
#define PHP_AMQP_CONNECTION_RESOURCE_H
-#define PHP_AMQP_RESOURCE_RESPONSE_BREAK 1
-#define PHP_AMQP_RESOURCE_RESPONSE_OK 0
-#define PHP_AMQP_RESOURCE_RESPONSE_ERROR -1
-#define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED -2
+#define PHP_AMQP_RESOURCE_RESPONSE_BREAK 1
+#define PHP_AMQP_RESOURCE_RESPONSE_OK 0
+#define PHP_AMQP_RESOURCE_RESPONSE_ERROR -1
+#define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CHANNEL_CLOSED -2
#define PHP_AMQP_RESOURCE_RESPONSE_ERROR_CONNECTION_CLOSED -3
extern int le_amqp_connection_resource;
extern int le_amqp_connection_resource_persistent;
#include "php_amqp.h"
-#include "amqp.h"
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+#else
+ #include
+#endif
-void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource TSRMLS_DC);
+void php_amqp_prepare_for_disconnect(amqp_connection_resource *resource);
typedef struct _amqp_connection_params {
char *login;
@@ -62,32 +66,33 @@ typedef struct _amqp_connection_params {
} amqp_connection_params;
/* Figure out what's going on connection and handle protocol exceptions, if any */
-int php_amqp_connection_resource_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id TSRMLS_DC);
-int php_amqp_connection_resource_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel TSRMLS_DC);
+int php_amqp_connection_resource_error(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *resource,
+ amqp_channel_t channel_id
+);
+int php_amqp_connection_resource_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_channel_object *channel);
/* Socket-related functions */
-int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double read_timeout TSRMLS_DC);
-int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double write_timeout TSRMLS_DC);
+int php_amqp_set_resource_read_timeout(amqp_connection_resource *resource, double read_timeout);
+int php_amqp_set_resource_write_timeout(amqp_connection_resource *resource, double write_timeout);
/*Not socket-related rpc timeout function */
-int php_amqp_set_resource_rpc_timeout(amqp_connection_resource *resource, double rpc_timeout TSRMLS_DC);
+int php_amqp_set_resource_rpc_timeout(amqp_connection_resource *resource, double rpc_timeout);
/* Channel-related functions */
amqp_channel_t php_amqp_connection_resource_get_available_channel_id(amqp_connection_resource *resource);
int php_amqp_connection_resource_unregister_channel(amqp_connection_resource *resource, amqp_channel_t channel_id);
-int php_amqp_connection_resource_register_channel(amqp_connection_resource *resource, amqp_channel_resource *channel_resource, amqp_channel_t channel_id);
+int php_amqp_connection_resource_register_channel(
+ amqp_connection_resource *resource,
+ amqp_channel_resource *channel_resource,
+ amqp_channel_t channel_id
+);
/* Creating and destroying resource */
-amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, zend_bool persistent TSRMLS_DC);
+amqp_connection_resource *connection_resource_constructor(amqp_connection_params *params, bool persistent);
ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor_persistent);
ZEND_RSRC_DTOR_FUNC(amqp_connection_resource_dtor);
#endif
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_decimal.c b/amqp_decimal.c
index 8fd92c13..ee0dbe9b 100644
--- a/amqp_decimal.c
+++ b/amqp_decimal.c
@@ -21,53 +21,64 @@
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
#include "zend_exceptions.h"
#include "php_amqp.h"
+#include "amqp_value.h"
zend_class_entry *amqp_decimal_class_entry;
#define this_ce amqp_decimal_class_entry
-static const PHP5to7_param_long_type_t AMQP_DECIMAL_EXPONENT_MIN = 0;
-static const PHP5to7_param_long_type_t AMQP_DECIMAL_EXPONENT_MAX = UINT8_MAX;
-static const PHP5to7_param_long_type_t AMQP_DECIMAL_SIGNIFICAND_MIN = 0;
-static const PHP5to7_param_long_type_t AMQP_DECIMAL_SIGNIFICAND_MAX = UINT32_MAX;
+static const zend_long AMQP_DECIMAL_EXPONENT_MIN = 0;
+static const zend_long AMQP_DECIMAL_EXPONENT_MAX = UINT8_MAX;
+static const zend_long AMQP_DECIMAL_SIGNIFICAND_MIN = 0;
+static const zend_long AMQP_DECIMAL_SIGNIFICAND_MAX = UINT32_MAX;
/* {{{ proto AMQPDecimal::__construct(int $e, int $n)
*/
static PHP_METHOD(amqp_decimal_class, __construct)
{
- PHP5to7_param_long_type_t exponent, significand;
+ zend_long exponent, significand;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &exponent, &significand) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &exponent, &significand) == FAILURE) {
+ RETURN_THROWS();
+ }
- if (exponent < AMQP_DECIMAL_EXPONENT_MIN) {
- zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "Decimal exponent value must be unsigned.");
- return;
- }
+ if (exponent < AMQP_DECIMAL_EXPONENT_MIN) {
+ zend_throw_exception_ex(amqp_value_exception_class_entry, 0, "Decimal exponent value must be unsigned.");
+ return;
+ }
- if (exponent > AMQP_DECIMAL_EXPONENT_MAX) {
- zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "Decimal exponent value must be less than %u.", (unsigned)AMQP_DECIMAL_EXPONENT_MAX);
- return;
- }
+ if (exponent > AMQP_DECIMAL_EXPONENT_MAX) {
+ zend_throw_exception_ex(
+ amqp_value_exception_class_entry,
+ 0,
+ "Decimal exponent value must be less than %u.",
+ (unsigned) AMQP_DECIMAL_EXPONENT_MAX
+ );
+ return;
+ }
if (significand < AMQP_DECIMAL_SIGNIFICAND_MIN) {
- zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "Decimal significand value must be unsigned.");
+ zend_throw_exception_ex(amqp_value_exception_class_entry, 0, "Decimal significand value must be unsigned.");
return;
}
if (significand > AMQP_DECIMAL_SIGNIFICAND_MAX) {
- zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "Decimal significand value must be less than %u.", (unsigned)AMQP_DECIMAL_SIGNIFICAND_MAX);
+ zend_throw_exception_ex(
+ amqp_value_exception_class_entry,
+ 0,
+ "Decimal significand value must be less than %u.",
+ (unsigned) AMQP_DECIMAL_SIGNIFICAND_MAX
+ );
return;
}
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("exponent"), exponent TSRMLS_CC);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("significand"), significand TSRMLS_CC);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("exponent"), exponent);
+ zend_update_property_long(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("significand"), significand);
}
/* }}} */
@@ -75,70 +86,78 @@ static PHP_METHOD(amqp_decimal_class, __construct)
Get exponent */
static PHP_METHOD(amqp_decimal_class, getExponent)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
+ zval rv;
+ PHP_AMQP_NOPARAMS()
- PHP_AMQP_RETURN_THIS_PROP("exponent");
+ PHP_AMQP_RETURN_THIS_PROP("exponent");
}
/* }}} */
/* {{{ proto int AMQPDecimal::getSignificand()
-Get E */
+Get significand */
static PHP_METHOD(amqp_decimal_class, getSignificand)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
+ zval rv;
+ PHP_AMQP_NOPARAMS()
PHP_AMQP_RETURN_THIS_PROP("significand");
}
/* }}} */
+/* {{{ proto int AMQPDecimal::toAmqpValue()
+Get AMQPDecimal as AMQPValue */
+static PHP_METHOD(amqp_decimal_class, toAmqpValue)
+{
+ PHP_AMQP_NOPARAMS()
+
+ RETURN_ZVAL(getThis(), 1, 0);
+}
+/* }}} */
+
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_decimal_class_construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
- ZEND_ARG_INFO(0, exponent)
- ZEND_ARG_INFO(0, significand)
+ ZEND_ARG_TYPE_INFO(0, exponent, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO(0, significand, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_decimal_class_getExponent, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_decimal_class_getExponent, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_decimal_class_getSignificand, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_decimal_class_getSignificand, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_decimal_class_toAmqpValue, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
zend_function_entry amqp_decimal_class_functions[] = {
PHP_ME(amqp_decimal_class, __construct, arginfo_amqp_decimal_class_construct, ZEND_ACC_PUBLIC)
PHP_ME(amqp_decimal_class, getExponent, arginfo_amqp_decimal_class_getExponent, ZEND_ACC_PUBLIC)
PHP_ME(amqp_decimal_class, getSignificand, arginfo_amqp_decimal_class_getSignificand, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_decimal_class, toAmqpValue, arginfo_amqp_decimal_class_toAmqpValue, ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
+ {NULL, NULL, NULL}
};
PHP_MINIT_FUNCTION(amqp_decimal)
{
- zend_class_entry ce;
-
- INIT_CLASS_ENTRY(ce, "AMQPDecimal", amqp_decimal_class_functions);
- this_ce = zend_register_internal_class(&ce TSRMLS_CC);
- this_ce->ce_flags = this_ce->ce_flags | PHP5to7_ZEND_ACC_FINAL_CLASS;
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "AMQPDecimal", amqp_decimal_class_functions);
+ this_ce = zend_register_internal_class(&ce);
+ zend_class_implements(this_ce, 1, amqp_value_class_entry);
+ this_ce->ce_flags |= ZEND_ACC_FINAL;
+#if PHP_VERSION_ID >= 80200
+ this_ce->ce_flags |= ZEND_ACC_READONLY_CLASS;
+#endif
- zend_declare_class_constant_long(this_ce, ZEND_STRL("EXPONENT_MIN"), AMQP_DECIMAL_EXPONENT_MIN TSRMLS_CC);
- zend_declare_class_constant_long(this_ce, ZEND_STRL("EXPONENT_MAX"), AMQP_DECIMAL_EXPONENT_MAX TSRMLS_CC);
- zend_declare_class_constant_long(this_ce, ZEND_STRL("SIGNIFICAND_MIN"), AMQP_DECIMAL_SIGNIFICAND_MIN TSRMLS_CC);
- zend_declare_class_constant_long(this_ce, ZEND_STRL("SIGNIFICAND_MAX"), AMQP_DECIMAL_SIGNIFICAND_MAX TSRMLS_CC);
+ zend_declare_class_constant_long(this_ce, ZEND_STRL("EXPONENT_MIN"), AMQP_DECIMAL_EXPONENT_MIN);
+ zend_declare_class_constant_long(this_ce, ZEND_STRL("EXPONENT_MAX"), AMQP_DECIMAL_EXPONENT_MAX);
+ zend_declare_class_constant_long(this_ce, ZEND_STRL("SIGNIFICAND_MIN"), AMQP_DECIMAL_SIGNIFICAND_MIN);
+ zend_declare_class_constant_long(this_ce, ZEND_STRL("SIGNIFICAND_MAX"), AMQP_DECIMAL_SIGNIFICAND_MAX);
- zend_declare_property_long(this_ce, ZEND_STRL("exponent"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_long(this_ce, ZEND_STRL("significand"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "exponent", ZEND_ACC_PRIVATE, IS_LONG, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "significand", ZEND_ACC_PRIVATE, IS_LONG, 0);
- return SUCCESS;
+ return SUCCESS;
}
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<6
-*/
diff --git a/amqp_decimal.h b/amqp_decimal.h
index 6c41aa0d..c4c27e5e 100644
--- a/amqp_decimal.h
+++ b/amqp_decimal.h
@@ -25,12 +25,3 @@
extern zend_class_entry *amqp_decimal_class_entry;
PHP_MINIT_FUNCTION(amqp_decimal);
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_envelope.c b/amqp_envelope.c
index 7d7e4d4d..827887ce 100644
--- a/amqp_envelope.c
+++ b/amqp_envelope.c
@@ -21,37 +21,36 @@
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
#include "zend_exceptions.h"
#ifdef PHP_WIN32
-# if PHP_VERSION_ID >= 80000
-# include "main/php_stdint.h"
-# else
-# include "win32/php_stdint.h"
-# endif
-# include "win32/signal.h"
+ #if PHP_VERSION_ID >= 80000
+ #include
+ #else
+ #include "win32/php_stdint.h"
+ #endif
+ #include "win32/signal.h"
#else
-
-# include
-# include
-
+ #include
+ #include
#endif
-#include
-#include
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+ #include
+#else
+ #include
+ #include
+#endif
#ifdef PHP_WIN32
-# include "win32/unistd.h"
+ #include "win32/unistd.h"
#else
-
-# include
-
+ #include
#endif
#include "amqp_envelope.h"
@@ -62,7 +61,7 @@ zend_class_entry *amqp_envelope_class_entry;
#define this_ce amqp_envelope_class_entry
-void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelope TSRMLS_DC)
+void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelope)
{
/* Build the envelope */
object_init_ex(envelope, this_ce);
@@ -71,38 +70,73 @@ void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelop
amqp_basic_properties_t *p = &amqp_envelope->message.properties;
amqp_message_t *message = &amqp_envelope->message;
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(envelope), ZEND_STRL("body"), (const char *) message->body.bytes, (PHP5to7_param_str_len_type_t) message->body.len TSRMLS_CC);
-
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(envelope), ZEND_STRL("consumer_tag"), (const char *) amqp_envelope->consumer_tag.bytes, (PHP5to7_param_str_len_type_t) amqp_envelope->consumer_tag.len TSRMLS_CC);
- zend_update_property_long(this_ce, PHP5to8_OBJ_PROP(envelope), ZEND_STRL("delivery_tag"), (PHP5to7_param_long_type_t) amqp_envelope->delivery_tag TSRMLS_CC);
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(envelope), ZEND_STRL("is_redelivery"), (PHP5to7_param_long_type_t) amqp_envelope->redelivered TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(envelope), ZEND_STRL("exchange_name"), (const char *) amqp_envelope->exchange.bytes, (PHP5to7_param_str_len_type_t) amqp_envelope->exchange.len TSRMLS_CC);
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(envelope), ZEND_STRL("routing_key"), (const char *) amqp_envelope->routing_key.bytes, (PHP5to7_param_str_len_type_t) amqp_envelope->routing_key.len TSRMLS_CC);
-
- php_amqp_basic_properties_extract(p, envelope TSRMLS_CC);
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(envelope),
+ ZEND_STRL("body"),
+ (const char *) message->body.bytes,
+ (size_t) message->body.len
+ );
+
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(envelope),
+ ZEND_STRL("consumerTag"),
+ (const char *) amqp_envelope->consumer_tag.bytes,
+ (size_t) amqp_envelope->consumer_tag.len
+ );
+ zend_update_property_long(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(envelope),
+ ZEND_STRL("deliveryTag"),
+ (zend_long) amqp_envelope->delivery_tag
+ );
+ zend_update_property_bool(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(envelope),
+ ZEND_STRL("isRedelivery"),
+ (zend_long) amqp_envelope->redelivered
+ );
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(envelope),
+ ZEND_STRL("exchangeName"),
+ (const char *) amqp_envelope->exchange.bytes,
+ (size_t) amqp_envelope->exchange.len
+ );
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(envelope),
+ ZEND_STRL("routingKey"),
+ (const char *) amqp_envelope->routing_key.bytes,
+ (size_t) amqp_envelope->routing_key.len
+ );
+
+ php_amqp_basic_properties_extract(p, envelope);
}
/* {{{ proto AMQPEnvelope::__construct() */
-static PHP_METHOD(amqp_envelope_class, __construct) {
- PHP_AMQP_NOPARAMS();
+static PHP_METHOD(amqp_envelope_class, __construct)
+{
+ PHP_AMQP_NOPARAMS()
/* BC */
- php_amqp_basic_properties_set_empty_headers(getThis() TSRMLS_CC);
+ php_amqp_basic_properties_set_empty_headers(getThis());
}
/* }}} */
/* {{{ proto AMQPEnvelope::getBody()*/
-static PHP_METHOD(amqp_envelope_class, getBody) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+static PHP_METHOD(amqp_envelope_class, getBody)
+{
+ zval rv;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- zval* zv = PHP_AMQP_READ_THIS_PROP("body");
+ zval *zv = PHP_AMQP_READ_THIS_PROP("body");
if (Z_STRLEN_P(zv) == 0) {
- /* BC */
- RETURN_FALSE;
+ RETURN_STRING("");
}
RETURN_ZVAL(zv, 1, 0);
@@ -110,90 +144,92 @@ static PHP_METHOD(amqp_envelope_class, getBody) {
/* }}} */
/* {{{ proto AMQPEnvelope::getRoutingKey() */
-static PHP_METHOD(amqp_envelope_class, getRoutingKey) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("routing_key");
+static PHP_METHOD(amqp_envelope_class, getRoutingKey)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("routingKey");
}
/* }}} */
/* {{{ proto AMQPEnvelope::getDeliveryTag() */
-static PHP_METHOD(amqp_envelope_class, getDeliveryTag) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("delivery_tag");
+static PHP_METHOD(amqp_envelope_class, getDeliveryTag)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("deliveryTag");
}
/* }}} */
/* {{{ proto AMQPEnvelope::getConsumerTag() */
-static PHP_METHOD(amqp_envelope_class, getConsumerTag) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("consumer_tag");
+static PHP_METHOD(amqp_envelope_class, getConsumerTag)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("consumerTag");
}
/* }}} */
/* {{{ proto AMQPEnvelope::getExchangeName() */
-static PHP_METHOD(amqp_envelope_class, getExchangeName) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("exchange_name");
+static PHP_METHOD(amqp_envelope_class, getExchangeName)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("exchangeName");
}
/* }}} */
/* {{{ proto AMQPEnvelope::isRedelivery() */
-static PHP_METHOD(amqp_envelope_class, isRedelivery) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("is_redelivery");
+static PHP_METHOD(amqp_envelope_class, isRedelivery)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("isRedelivery");
}
/* }}} */
/* {{{ proto AMQPEnvelope::getHeader(string name) */
-static PHP_METHOD(amqp_envelope_class, getHeader) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+static PHP_METHOD(amqp_envelope_class, getHeader)
+{
+ zval rv;
- char *key; PHP5to7_param_str_len_type_t key_len;
- PHP5to7_zval_t *tmp = NULL;
+ char *key;
+ size_t key_len;
+ zval *tmp = NULL;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &key_len) == FAILURE) {
+ RETURN_THROWS();
}
- zval* zv = PHP_AMQP_READ_THIS_PROP_CE("headers", amqp_basic_properties_class_entry);
- //zval* zv = PHP_AMQP_READ_THIS_PROP("headers");
+ zval *zv = PHP_AMQP_READ_THIS_PROP_CE("headers", amqp_basic_properties_class_entry);
/* Look for the hash key */
- if (!PHP5to7_ZEND_HASH_FIND(HASH_OF(zv), key, key_len + 1, tmp)) {
- RETURN_FALSE;
+ if ((tmp = zend_hash_str_find(HASH_OF(zv), key, key_len)) == NULL) {
+ RETURN_NULL();
}
- RETURN_ZVAL(PHP5to7_MAYBE_DEREF(tmp), 1, 0);
+ RETURN_ZVAL(tmp, 1, 0);
}
/* }}} */
/* {{{ proto AMQPEnvelope::hasHeader(string name) */
-static PHP_METHOD(amqp_envelope_class, hasHeader) {
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+static PHP_METHOD(amqp_envelope_class, hasHeader)
+{
+ zval rv;
- char *key; PHP5to7_param_str_len_type_t key_len;
- PHP5to7_zval_t *tmp = NULL;
+ char *key;
+ size_t key_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &key_len) == FAILURE) {
+ RETURN_THROWS();
}
- zval* zv = PHP_AMQP_READ_THIS_PROP_CE("headers", amqp_basic_properties_class_entry);
- //zval* zv = PHP_AMQP_READ_THIS_PROP("headers");
+ zval *zv = PHP_AMQP_READ_THIS_PROP_CE("headers", amqp_basic_properties_class_entry);
/* Look for the hash key */
- if (!PHP5to7_ZEND_HASH_FIND(HASH_OF(zv), key, key_len + 1, tmp)) {
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
+ RETURN_BOOL(zend_hash_str_find(HASH_OF(zv), key, key_len) != NULL);
}
/* }}} */
@@ -202,74 +238,76 @@ static PHP_METHOD(amqp_envelope_class, hasHeader) {
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getBody, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_envelope_class_getBody, ZEND_SEND_BY_VAL, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getRoutingKey, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_envelope_class_getRoutingKey, ZEND_SEND_BY_VAL, 0, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getConsumerTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_envelope_class_getConsumerTag, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getDeliveryTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_envelope_class_getDeliveryTag, ZEND_SEND_BY_VAL, 0, IS_LONG, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getExchangeName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_envelope_class_getExchangeName, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_isRedelivery, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_envelope_class_isRedelivery, ZEND_SEND_BY_VAL, 0, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getHeader, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, name)
+#ifdef IS_MIXED
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_envelope_class_getHeader, ZEND_SEND_BY_VAL, 1, IS_MIXED, 1)
+#else
+/* PHP < 8.0 */
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_getHeader, 0, 0, 1)
+#endif
+ ZEND_ARG_TYPE_INFO(0, headerName, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_envelope_class_hasHeader, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, name)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_envelope_class_hasHeader, ZEND_SEND_BY_VAL, 1, _IS_BOOL, 0)
+ ZEND_ARG_TYPE_INFO(0, headerName, IS_STRING, 0)
ZEND_END_ARG_INFO()
zend_function_entry amqp_envelope_class_functions[] = {
- PHP_ME(amqp_envelope_class, __construct, arginfo_amqp_envelope_class__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
+ PHP_ME(amqp_envelope_class, __construct, arginfo_amqp_envelope_class__construct, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
- PHP_ME(amqp_envelope_class, getBody, arginfo_amqp_envelope_class_getBody, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getBody, arginfo_amqp_envelope_class_getBody, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_envelope_class, getRoutingKey, arginfo_amqp_envelope_class_getRoutingKey, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_envelope_class, getConsumerTag, arginfo_amqp_envelope_class_getConsumerTag, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_envelope_class, getDeliveryTag, arginfo_amqp_envelope_class_getDeliveryTag, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_envelope_class, getExchangeName, arginfo_amqp_envelope_class_getExchangeName, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_envelope_class, isRedelivery, arginfo_amqp_envelope_class_isRedelivery, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getRoutingKey, arginfo_amqp_envelope_class_getRoutingKey, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getConsumerTag, arginfo_amqp_envelope_class_getConsumerTag, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getDeliveryTag, arginfo_amqp_envelope_class_getDeliveryTag, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getExchangeName, arginfo_amqp_envelope_class_getExchangeName, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, isRedelivery, arginfo_amqp_envelope_class_isRedelivery, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_envelope_class, getHeader, arginfo_amqp_envelope_class_getHeader, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_envelope_class, hasHeader, arginfo_amqp_envelope_class_hasHeader, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, getHeader, arginfo_amqp_envelope_class_getHeader, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_envelope_class, hasHeader, arginfo_amqp_envelope_class_hasHeader, ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
+ {NULL, NULL, NULL}
};
-PHP_MINIT_FUNCTION (amqp_envelope) {
+PHP_MINIT_FUNCTION(amqp_envelope)
+{
zend_class_entry ce;
INIT_CLASS_ENTRY(ce, "AMQPEnvelope", amqp_envelope_class_functions);
- this_ce = zend_register_internal_class_ex(&ce, amqp_basic_properties_class_entry PHP5to7_PARENT_CLASS_NAME_C(NULL) TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("body"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("consumer_tag"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("delivery_tag"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("is_redelivery"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("exchange_name"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("routing_key"), ZEND_ACC_PRIVATE TSRMLS_CC);
+ this_ce = zend_register_internal_class_ex(&ce, amqp_basic_properties_class_entry);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "body", ZEND_ACC_PRIVATE, IS_STRING, 0, ZVAL_EMPTY_STRING);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "consumerTag", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "deliveryTag", ZEND_ACC_PRIVATE, IS_LONG, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "isRedelivery", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_FALSE);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "exchangeName", ZEND_ACC_PRIVATE, IS_STRING, 1, ZVAL_NULL);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(
+ this_ce,
+ "routingKey",
+ ZEND_ACC_PRIVATE,
+ IS_STRING,
+ 0,
+ ZVAL_EMPTY_STRING
+ );
return SUCCESS;
}
-
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_envelope.h b/amqp_envelope.h
index e315682b..ac42a8df 100644
--- a/amqp_envelope.h
+++ b/amqp_envelope.h
@@ -20,25 +20,10 @@
| - Jonathan Tansavatdi |
+----------------------------------------------------------------------+
*/
-
-#if PHP_MAJOR_VERSION >= 7
- #include "php7_support.h"
-#else
- #include "php5_support.h"
-#endif
+#include "php_amqp.h"
extern zend_class_entry *amqp_envelope_class_entry;
-void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelope TSRMLS_DC);
+void convert_amqp_envelope_to_zval(amqp_envelope_t *amqp_envelope, zval *envelope);
PHP_MINIT_FUNCTION(amqp_envelope);
-
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_envelope_exception.c b/amqp_envelope_exception.c
new file mode 100644
index 00000000..debd5b07
--- /dev/null
+++ b/amqp_envelope_exception.c
@@ -0,0 +1,78 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include "php.h"
+#include "zend_exceptions.h"
+#include "php_amqp.h"
+
+zend_class_entry *amqp_envelope_exception_class_entry;
+#define this_ce amqp_envelope_exception_class_entry
+
+/* {{{ proto float AMQPEnvelopeException::getEnvelope()
+Get AMQPEnvelope object */
+static PHP_METHOD(amqp_envelope_exception_class, getEnvelope)
+{
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+
+ PHP_AMQP_RETURN_THIS_PROP("envelope");
+}
+/* }}} */
+
+
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(
+ arginfo_amqp_envelope_exception_class_getEnvelope,
+ ZEND_SEND_BY_VAL,
+ 0,
+ AMQPEnvelope,
+ 0
+)
+ZEND_END_ARG_INFO()
+
+zend_function_entry amqp_envelope_exception_class_functions[] = {
+ PHP_ME(amqp_envelope_exception_class, getEnvelope, arginfo_amqp_envelope_exception_class_getEnvelope, ZEND_ACC_PUBLIC)
+
+ {NULL, NULL, NULL}
+};
+
+
+PHP_MINIT_FUNCTION(amqp_envelope_exception)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "AMQPEnvelopeException", amqp_envelope_exception_class_functions);
+ amqp_envelope_exception_class_entry = zend_register_internal_class_ex(&ce, amqp_exception_class_entry);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_OBJ(
+ amqp_envelope_exception_class_entry,
+ "envelope",
+ ZEND_ACC_PRIVATE,
+ AMQPEnvelope,
+ 0
+ );
+
+ return SUCCESS;
+}
diff --git a/amqp_envelope_exception.h b/amqp_envelope_exception.h
new file mode 100644
index 00000000..49509579
--- /dev/null
+++ b/amqp_envelope_exception.h
@@ -0,0 +1,27 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+#include "php.h"
+
+extern zend_class_entry *amqp_envelope_exception_class_entry;
+
+PHP_MINIT_FUNCTION(amqp_envelope_exception);
diff --git a/amqp_exchange.c b/amqp_exchange.c
index e4cd6b1c..138759c3 100644
--- a/amqp_exchange.c
+++ b/amqp_exchange.c
@@ -21,32 +21,36 @@
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
-#include "php_ini.h"
-#include "ext/standard/info.h"
#include "zend_exceptions.h"
#ifdef PHP_WIN32
-# if PHP_VERSION_ID >= 80000
-# include "main/php_stdint.h"
-# else
-# include "win32/php_stdint.h"
-# endif
-# include "win32/signal.h"
+ #if PHP_VERSION_ID >= 80000
+ #include
+ #else
+ #include "win32/php_stdint.h"
+ #endif
+ #include "win32/signal.h"
#else
-# include
-# include
+ #include
+ #include
+ #include
+#endif
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+ #include
+#else
+ #include
+ #include
#endif
-#include
-#include
#ifdef PHP_WIN32
-# include "win32/unistd.h"
+ #include "win32/unistd.h"
#else
-# include
+ #include
#endif
#include "php_amqp.h"
@@ -62,27 +66,32 @@ zend_class_entry *amqp_exchange_class_entry;
create Exchange */
static PHP_METHOD(amqp_exchange_class, __construct)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- PHP5to7_zval_t arguments PHP5to7_MAYBE_SET_TO_NULL;
+ zval arguments;
- zval *channelObj;
- amqp_channel_resource *channel_resource;
+ zval *channelObj;
+ amqp_channel_resource *channel_resource;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &channelObj, amqp_channel_class_entry) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &channelObj, amqp_channel_class_entry) == FAILURE) {
+ RETURN_THROWS();
+ }
- PHP5to7_MAYBE_INIT(arguments);
- PHP5to7_ARRAY_INIT(arguments);
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("arguments"), PHP5to7_MAYBE_PTR(arguments) TSRMLS_CC);
- PHP5to7_MAYBE_DESTROY(arguments);
+ ZVAL_UNDEF(&arguments);
+ array_init(&arguments);
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("arguments"), &arguments);
+ zval_ptr_dtor(&arguments);
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channelObj);
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not create exchange.");
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channelObj);
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not create exchange.");
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("channel"), channelObj TSRMLS_CC);
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connection"), PHP_AMQP_READ_OBJ_PROP(amqp_channel_class_entry, channelObj, "connection") TSRMLS_CC);
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("channel"), channelObj);
+ zend_update_property(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("connection"),
+ PHP_AMQP_READ_OBJ_PROP(amqp_channel_class_entry, channelObj, "connection")
+ );
}
/* }}} */
@@ -91,16 +100,15 @@ static PHP_METHOD(amqp_exchange_class, __construct)
Get the exchange name */
static PHP_METHOD(amqp_exchange_class, getName)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") > 0) {
- PHP_AMQP_RETURN_THIS_PROP("name");
- } else {
- /* BC */
- RETURN_FALSE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") > 0) {
+ PHP_AMQP_RETURN_THIS_PROP("name");
+ } else {
+ RETURN_NULL();
+ }
}
/* }}} */
@@ -109,21 +117,25 @@ static PHP_METHOD(amqp_exchange_class, getName)
Set the exchange name */
static PHP_METHOD(amqp_exchange_class, setName)
{
- char *name = NULL;
- PHP5to7_param_str_len_type_t name_len = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
- return;
- }
-
- /* Verify that the name is not null and not an empty string */
- if (name_len > 255) {
- zend_throw_exception(amqp_exchange_exception_class_entry, "Invalid exchange name given, must be less than 255 characters long.", 0 TSRMLS_CC);
- return;
- }
-
- /* Set the exchange name */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("name"), name, name_len TSRMLS_CC);
+ char *name = NULL;
+ size_t name_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!", &name, &name_len) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ /* Verify that the name is not null and not an empty string */
+ if (name_len > 255) {
+ zend_throw_exception(
+ amqp_exchange_exception_class_entry,
+ "Invalid exchange name given, must be less than 255 characters long.",
+ 0
+ );
+ return;
+ }
+
+ /* Set the exchange name */
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("name"), name, name_len);
}
/* }}} */
@@ -132,29 +144,29 @@ static PHP_METHOD(amqp_exchange_class, setName)
Get the exchange parameters */
static PHP_METHOD(amqp_exchange_class, getFlags)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- PHP5to7_param_long_type_t flags = AMQP_NOPARAM;
+ zend_long flags = AMQP_NOPARAM;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- if (PHP_AMQP_READ_THIS_PROP_BOOL("passive")) {
- flags |= AMQP_PASSIVE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_BOOL("passive")) {
+ flags |= AMQP_PASSIVE;
+ }
- if (PHP_AMQP_READ_THIS_PROP_BOOL("durable")) {
- flags |= AMQP_DURABLE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_BOOL("durable")) {
+ flags |= AMQP_DURABLE;
+ }
- if (PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete")) {
- flags |= AMQP_AUTODELETE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_BOOL("autoDelete")) {
+ flags |= AMQP_AUTODELETE;
+ }
- if (PHP_AMQP_READ_THIS_PROP_BOOL("internal")) {
- flags |= AMQP_INTERNAL;
- }
+ if (PHP_AMQP_READ_THIS_PROP_BOOL("internal")) {
+ flags |= AMQP_INTERNAL;
+ }
- RETURN_LONG(flags);
+ RETURN_LONG(flags);
}
/* }}} */
@@ -163,20 +175,19 @@ static PHP_METHOD(amqp_exchange_class, getFlags)
Set the exchange parameters */
static PHP_METHOD(amqp_exchange_class, setFlags)
{
- PHP5to7_param_long_type_t flags = AMQP_NOPARAM;
- zend_bool flags_is_null = 1;
+ zend_long flags = AMQP_NOPARAM;
+ bool flags_is_null = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l!", &flags, &flags_is_null) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l!", &flags, &flags_is_null) == FAILURE) {
+ RETURN_THROWS();
+ }
- /* Set the flags based on the bitmask we were given */
- flags = flags ? flags & PHP_AMQP_EXCHANGE_FLAGS : flags;
+ flags = flags & PHP_AMQP_EXCHANGE_FLAGS;
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("passive"), IS_PASSIVE(flags) TSRMLS_CC);
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("durable"), IS_DURABLE(flags) TSRMLS_CC);
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("auto_delete"), IS_AUTODELETE(flags) TSRMLS_CC);
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("internal"), IS_INTERNAL(flags) TSRMLS_CC);
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("passive"), IS_PASSIVE(flags));
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("durable"), IS_DURABLE(flags));
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("autoDelete"), IS_AUTODELETE(flags));
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("internal"), IS_INTERNAL(flags));
}
/* }}} */
@@ -185,16 +196,15 @@ static PHP_METHOD(amqp_exchange_class, setFlags)
Get the exchange type */
static PHP_METHOD(amqp_exchange_class, getType)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- if (PHP_AMQP_READ_THIS_PROP_STRLEN("type") > 0) {
- PHP_AMQP_RETURN_THIS_PROP("type");
- } else {
- /* BC */
- RETURN_FALSE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_STRLEN("type") > 0) {
+ PHP_AMQP_RETURN_THIS_PROP("type");
+ } else {
+ RETURN_NULL();
+ }
}
/* }}} */
@@ -203,13 +213,14 @@ static PHP_METHOD(amqp_exchange_class, getType)
Set the exchange type */
static PHP_METHOD(amqp_exchange_class, setType)
{
- char *type = NULL; PHP5to7_param_str_len_type_t type_len = 0;
+ char *type = NULL;
+ size_t type_len = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &type, &type_len) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s!", &type, &type_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("type"), type, type_len TSRMLS_CC);
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("type"), type, type_len);
}
/* }}} */
@@ -218,42 +229,38 @@ static PHP_METHOD(amqp_exchange_class, setType)
Get the exchange argument referenced by key */
static PHP_METHOD(amqp_exchange_class, getArgument)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- PHP5to7_zval_t *tmp = NULL;
+ zval *tmp = NULL;
- char *key; PHP5to7_param_str_len_type_t key_len;
+ char *key;
+ size_t key_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &key_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len + 1, tmp)) {
- RETURN_FALSE;
- }
+ if ((tmp = zend_hash_str_find(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len)) == NULL) {
+ zend_throw_exception_ex(amqp_exchange_exception_class_entry, 0, "The argument \"%s\" does not exist", key);
+ return;
+ }
- RETURN_ZVAL(PHP5to7_MAYBE_DEREF(tmp), 1, 0);
+ RETURN_ZVAL(tmp, 1, 0);
}
/* }}} */
/* {{{ proto AMQPExchange::hasArgument(string key) */
static PHP_METHOD(amqp_exchange_class, hasArgument)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
+ char *key;
+ size_t key_len;
- PHP5to7_zval_t *tmp = NULL;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &key_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- char *key; PHP5to7_param_str_len_type_t key_len;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) {
- return;
- }
-
- if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (unsigned)(key_len + 1), tmp)) {
- RETURN_FALSE;
- }
-
- RETURN_TRUE;
+ RETURN_BOOL(zend_hash_str_find(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len) != NULL);
}
/* }}} */
@@ -261,9 +268,9 @@ static PHP_METHOD(amqp_exchange_class, hasArgument)
Get the exchange arguments */
static PHP_METHOD(amqp_exchange_class, getArguments)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("arguments");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("arguments");
}
/* }}} */
@@ -272,15 +279,13 @@ static PHP_METHOD(amqp_exchange_class, getArguments)
Overwrite all exchange arguments with given args */
static PHP_METHOD(amqp_exchange_class, setArguments)
{
- zval *zvalArguments;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &zvalArguments) == FAILURE) {
- return;
- }
+ zval *zvalArguments;
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("arguments"), zvalArguments TSRMLS_CC);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "a/", &zvalArguments) == FAILURE) {
+ RETURN_THROWS();
+ }
- RETURN_TRUE;
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("arguments"), zvalArguments);
}
/* }}} */
@@ -288,92 +293,112 @@ static PHP_METHOD(amqp_exchange_class, setArguments)
/* {{{ proto AMQPExchange::setArgument(key, value) */
static PHP_METHOD(amqp_exchange_class, setArgument)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- char *key= NULL; PHP5to7_param_str_len_type_t key_len = 0;
- zval *value = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
- &key, &key_len,
- &value) == FAILURE) {
- return;
- }
-
- switch (Z_TYPE_P(value)) {
- case IS_NULL:
- PHP5to7_ZEND_HASH_DEL(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (unsigned) (key_len + 1));
- break;
- PHP5to7_CASE_IS_BOOL:
- case IS_LONG:
- case IS_DOUBLE:
- case IS_STRING:
- PHP5to7_ZEND_HASH_ADD(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (unsigned) (key_len + 1), value, sizeof(zval *));
- Z_TRY_ADDREF_P(value);
- break;
- default:
- zend_throw_exception(amqp_exchange_exception_class_entry, "The value parameter must be of type NULL, int, double or string.", 0 TSRMLS_CC);
- return;
- }
-
- RETURN_TRUE;
+ zval rv;
+
+ char *key = NULL;
+ size_t key_len = 0;
+ zval *value = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz", &key, &key_len, &value) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ switch (Z_TYPE_P(value)) {
+ case IS_NULL:
+ case IS_TRUE:
+ case IS_FALSE:
+ case IS_LONG:
+ case IS_DOUBLE:
+ case IS_STRING:
+ zend_hash_str_add(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len, value);
+ Z_TRY_ADDREF_P(value);
+ break;
+ default:
+ zend_throw_exception(
+ amqp_exchange_exception_class_entry,
+ "The value parameter must be of type NULL, int, double or string.",
+ 0
+ );
+ return;
+ }
}
/* }}} */
+/* {{{ proto AMQPExchange::removeArgument(key) */
+static PHP_METHOD(amqp_exchange_class, removeArgument)
+{
+ zval rv;
+
+ char *key = NULL;
+ size_t key_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &key_len) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ zend_hash_str_del(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len);
+}
+/* }}} */
+
/* {{{ proto AMQPExchange::declareExchange();
declare Exchange
*/
static PHP_METHOD(amqp_exchange_class, declareExchange)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
- amqp_table_t *arguments;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not declare exchange.");
-
- /* Check that the exchange has a name */
- if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") < 1) {
- zend_throw_exception(amqp_exchange_exception_class_entry, "Could not declare exchange. Exchanges must have a name.", 0 TSRMLS_CC);
- return;
- }
-
- /* Check that the exchange has a name */
- if (PHP_AMQP_READ_THIS_PROP_STRLEN("type") < 1) {
- zend_throw_exception(amqp_exchange_exception_class_entry, "Could not declare exchange. Exchanges must have a type.", 0 TSRMLS_CC);
- return;
- }
-
- arguments = php_amqp_type_convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments") TSRMLS_CC);
-
- amqp_exchange_declare(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("type")),
- PHP_AMQP_READ_THIS_PROP_BOOL("passive"),
- PHP_AMQP_READ_THIS_PROP_BOOL("durable"),
- PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete"),
- PHP_AMQP_READ_THIS_PROP_BOOL("internal"),
- *arguments
- );
-
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- php_amqp_type_free_amqp_table(arguments);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry TSRMLS_CC);
- return;
- }
-
- RETURN_TRUE;
+ zval rv;
+
+ amqp_channel_resource *channel_resource;
+ amqp_table_t *arguments;
+
+ PHP_AMQP_NOPARAMS()
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not declare exchange.");
+
+ /* Check that the exchange has a name */
+ if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") < 1) {
+ zend_throw_exception(
+ amqp_exchange_exception_class_entry,
+ "Could not declare exchange. Exchanges must have a name.",
+ 0
+ );
+ return;
+ }
+
+ /* Check that the exchange has a name */
+ if (PHP_AMQP_READ_THIS_PROP_STRLEN("type") < 1) {
+ zend_throw_exception(
+ amqp_exchange_exception_class_entry,
+ "Could not declare exchange. Exchanges must have a type.",
+ 0
+ );
+ return;
+ }
+
+ arguments = php_amqp_type_convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments"));
+
+ amqp_exchange_declare(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("type")),
+ PHP_AMQP_READ_THIS_PROP_BOOL("passive"),
+ PHP_AMQP_READ_THIS_PROP_BOOL("durable"),
+ PHP_AMQP_READ_THIS_PROP_BOOL("autoDelete"),
+ PHP_AMQP_READ_THIS_PROP_BOOL("internal"),
+ *arguments
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ php_amqp_type_free_amqp_table(arguments);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry);
+ return;
+ }
}
/* }}} */
@@ -383,41 +408,42 @@ delete Exchange
*/
static PHP_METHOD(amqp_exchange_class, delete)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
-
- char *name = NULL;
- PHP5to7_param_str_len_type_t name_len = 0;
- PHP5to7_param_long_type_t flags = AMQP_NOPARAM;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sl",
- &name, &name_len,
- &flags) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not delete exchange.");
-
- amqp_exchange_delete(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(name_len ? name : PHP_AMQP_READ_THIS_PROP_STR("name")),
- (AMQP_IFUNUSED & flags) ? 1 : 0
- );
-
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- RETURN_TRUE;
+ zval rv;
+
+ amqp_channel_resource *channel_resource;
+
+ char *name = NULL;
+ size_t name_len = 0;
+ zend_long flags = AMQP_NOPARAM;
+ bool flags_is_null = 1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s!l!", &name, &name_len, &flags, &flags_is_null) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not delete exchange.");
+
+ amqp_exchange_delete(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(
+ name_len ? name
+ : PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name")
+ : ""
+ ),
+ (AMQP_IFUNUSED & flags) ? 1 : 0
+ );
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -427,213 +453,232 @@ publish into Exchange
*/
static PHP_METHOD(amqp_exchange_class, publish)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- zval *ini_arr = NULL;
- PHP5to7_zval_t *tmp = NULL;
-
- amqp_channel_resource *channel_resource;
-
- char *key_name = NULL;
- PHP5to7_param_str_len_type_t key_len = 0;
- char *msg = NULL;
- PHP5to7_param_str_len_type_t msg_len = 0;
- PHP5to7_param_long_type_t flags = AMQP_NOPARAM;
+ zval rv;
+
+ zval *ini_arr = NULL;
+ zval *tmp = NULL;
+
+ amqp_channel_resource *channel_resource;
+
+ char *key_name = NULL;
+ size_t key_len = 0;
+ char *msg = NULL;
+ size_t msg_len = 0;
+ zend_long flags = AMQP_NOPARAM;
+ bool flags_is_null = 1;
+
+ amqp_basic_properties_t props;
+
+ if (zend_parse_parameters(
+ ZEND_NUM_ARGS(),
+ "s|s!l!a/",
+ &msg,
+ &msg_len,
+ &key_name,
+ &key_len,
+ &flags,
+ &flags_is_null,
+ &ini_arr
+ ) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ /* By default (and for BC) content type is text/plain (may be skipped at all, then set props._flags to 0) */
+ props.content_type = amqp_cstring_bytes("text/plain");
+ props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG;
+
+ props.headers.entries = 0;
+
+ {
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("content_type"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(tmp);
+
+ if (Z_STRLEN_P(tmp) > 0) {
+ props.content_type = amqp_cstring_bytes(Z_STRVAL_P(tmp));
+ props._flags |= AMQP_BASIC_CONTENT_TYPE_FLAG;
+ }
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("content_encoding"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(tmp);
+
+ if (Z_STRLEN_P(tmp) > 0) {
+ props.content_encoding = amqp_cstring_bytes(Z_STRVAL_P(tmp));
+ props._flags |= AMQP_BASIC_CONTENT_ENCODING_FLAG;
+ }
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("message_id"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(tmp);
+
+ if (Z_STRLEN_P(tmp) > 0) {
+ props.message_id = amqp_cstring_bytes(Z_STRVAL_P(tmp));
+ props._flags |= AMQP_BASIC_MESSAGE_ID_FLAG;
+ }
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("user_id"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(tmp);
+
+ if (Z_STRLEN_P(tmp) > 0) {
+ props.user_id = amqp_cstring_bytes(Z_STRVAL_P(tmp));
+ props._flags |= AMQP_BASIC_USER_ID_FLAG;
+ }
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("app_id"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(tmp);
+
+ if (Z_STRLEN_P(tmp) > 0) {
+ props.app_id = amqp_cstring_bytes(Z_STRVAL_P(tmp));
+ props._flags |= AMQP_BASIC_APP_ID_FLAG;
+ }
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("delivery_mode"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_long(tmp);
+
+ props.delivery_mode = (uint8_t) Z_LVAL_P(tmp);
+ props._flags |= AMQP_BASIC_DELIVERY_MODE_FLAG;
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("priority"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_long(tmp);
+
+ props.priority = (uint8_t) Z_LVAL_P(tmp);
+ props._flags |= AMQP_BASIC_PRIORITY_FLAG;
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("timestamp"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_long(tmp);
+
+ props.timestamp = (uint64_t) Z_LVAL_P(tmp);
+ props._flags |= AMQP_BASIC_TIMESTAMP_FLAG;
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("expiration"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(tmp);
+
+ if (Z_STRLEN_P(tmp) > 0) {
+ props.expiration = amqp_cstring_bytes(Z_STRVAL_P(tmp));
+ props._flags |= AMQP_BASIC_EXPIRATION_FLAG;
+ }
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("type"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(tmp);
+
+ if (Z_STRLEN_P(tmp) > 0) {
+ props.type = amqp_cstring_bytes(Z_STRVAL_P(tmp));
+ props._flags |= AMQP_BASIC_TYPE_FLAG;
+ }
+ }
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("reply_to"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(tmp);
+
+ if (Z_STRLEN_P(tmp) > 0) {
+ props.reply_to = amqp_cstring_bytes(Z_STRVAL_P(tmp));
+ props._flags |= AMQP_BASIC_REPLY_TO_FLAG;
+ }
+ }
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("correlation_id"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_string(tmp);
+
+ if (Z_STRLEN_P(tmp) > 0) {
+ props.correlation_id = amqp_cstring_bytes(Z_STRVAL_P(tmp));
+ props._flags |= AMQP_BASIC_CORRELATION_ID_FLAG;
+ }
+ }
+ }
+
+ amqp_table_t *headers = NULL;
+
+ if (ini_arr && (tmp = zend_hash_str_find(HASH_OF(ini_arr), ZEND_STRL("headers"))) != NULL) {
+ SEPARATE_ZVAL(tmp);
+ convert_to_array(tmp);
+
+ headers = php_amqp_type_convert_zval_to_amqp_table(tmp);
+
+ props._flags |= AMQP_BASIC_HEADERS_FLAG;
+ props.headers = *headers;
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not publish to exchange.");
#ifndef PHP_WIN32
- /* Storage for previous signal handler during SIGPIPE override */
- void * old_handler;
-#endif
+ /* Start ignoring SIGPIPE */
+ struct sigaction oldact;
+ struct sigaction act = {0};
- amqp_basic_properties_t props;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!la/",
- &msg, &msg_len,
- &key_name, &key_len,
- &flags,
- &ini_arr) == FAILURE) {
- return;
- }
-
- /* By default (and for BC) content type is text/plain (may be skipped at all, then set props._flags to 0) */
- props.content_type = amqp_cstring_bytes("text/plain");
- props._flags = AMQP_BASIC_CONTENT_TYPE_FLAG;
-
- props.headers.entries = 0;
-
- {
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "content_type", sizeof("content_type"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(PHP5to7_MAYBE_DEREF(tmp));
-
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) {
- props.content_type = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp)));
- props._flags |= AMQP_BASIC_CONTENT_TYPE_FLAG;
- }
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "content_encoding", sizeof("content_encoding"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(PHP5to7_MAYBE_DEREF(tmp));
-
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) {
- props.content_encoding = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp)));
- props._flags |= AMQP_BASIC_CONTENT_ENCODING_FLAG;
- }
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "message_id", sizeof("message_id"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(PHP5to7_MAYBE_DEREF(tmp));
-
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) {
- props.message_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp)));
- props._flags |= AMQP_BASIC_MESSAGE_ID_FLAG;
- }
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "user_id", sizeof("user_id"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(PHP5to7_MAYBE_DEREF(tmp));
-
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) {
- props.user_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp)));
- props._flags |= AMQP_BASIC_USER_ID_FLAG;
- }
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "app_id", sizeof("app_id"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(PHP5to7_MAYBE_DEREF(tmp));
-
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) {
- props.app_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp)));
- props._flags |= AMQP_BASIC_APP_ID_FLAG;
- }
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "delivery_mode", sizeof("delivery_mode"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_long(PHP5to7_MAYBE_DEREF(tmp));
-
- props.delivery_mode = (uint8_t)Z_LVAL_P(PHP5to7_MAYBE_DEREF(tmp));
- props._flags |= AMQP_BASIC_DELIVERY_MODE_FLAG;
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "priority", sizeof("priority"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_long(PHP5to7_MAYBE_DEREF(tmp));
-
- props.priority = (uint8_t)Z_LVAL_P(PHP5to7_MAYBE_DEREF(tmp));
- props._flags |= AMQP_BASIC_PRIORITY_FLAG;
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "timestamp", sizeof("timestamp"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_long(PHP5to7_MAYBE_DEREF(tmp));
-
- props.timestamp = (uint64_t)Z_LVAL_P(PHP5to7_MAYBE_DEREF(tmp));
- props._flags |= AMQP_BASIC_TIMESTAMP_FLAG;
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "expiration", sizeof("expiration"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(PHP5to7_MAYBE_DEREF(tmp));
-
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) {
- props.expiration = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp)));
- props._flags |= AMQP_BASIC_EXPIRATION_FLAG;
- }
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "type", sizeof("type"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(PHP5to7_MAYBE_DEREF(tmp));
-
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) {
- props.type = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp)));
- props._flags |= AMQP_BASIC_TYPE_FLAG;
- }
- }
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "reply_to", sizeof("reply_to"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(PHP5to7_MAYBE_DEREF(tmp));
-
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) {
- props.reply_to = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp)));
- props._flags |= AMQP_BASIC_REPLY_TO_FLAG;
- }
- }
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF (ini_arr), "correlation_id", sizeof("correlation_id"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_string(PHP5to7_MAYBE_DEREF(tmp));
-
- if (Z_STRLEN_P(PHP5to7_MAYBE_DEREF(tmp)) > 0) {
- props.correlation_id = amqp_cstring_bytes(Z_STRVAL_P(PHP5to7_MAYBE_DEREF(tmp)));
- props._flags |= AMQP_BASIC_CORRELATION_ID_FLAG;
- }
- }
-
- }
-
- amqp_table_t *headers = NULL;
-
- if (ini_arr && PHP5to7_ZEND_HASH_FIND(HASH_OF(ini_arr), "headers", sizeof("headers"), tmp)) {
- SEPARATE_ZVAL(tmp);
- convert_to_array(PHP5to7_MAYBE_DEREF(tmp));
-
- headers = php_amqp_type_convert_zval_to_amqp_table(PHP5to7_MAYBE_DEREF(tmp) TSRMLS_CC);
-
- props._flags |= AMQP_BASIC_HEADERS_FLAG;
- props.headers = *headers;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not publish to exchange.");
+ act.sa_flags = SA_ONSTACK;
+ act.sa_handler = SIG_IGN;
-#ifndef PHP_WIN32
- /* Start ignoring SIGPIPE */
- old_handler = signal(SIGPIPE, SIG_IGN);
+ /* Start ignoring SIGPIPE */
+ if (sigaction(SIGPIPE, &act, &oldact) == -1) {
+ perror("sigaction");
+ }
#endif
- zval *exchange_name = PHP_AMQP_READ_THIS_PROP("name");
-
- /* NOTE: basic.publish is asynchronous and thus will not indicate failure if something goes wrong on the broker */
- int status = amqp_basic_publish(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- (Z_TYPE_P(exchange_name) == IS_STRING && Z_STRLEN_P(exchange_name) > 0 ? amqp_cstring_bytes(Z_STRVAL_P(exchange_name)) : amqp_empty_bytes), /* exchange */
- (key_len > 0 ? amqp_cstring_bytes(key_name) : amqp_empty_bytes), /* routing key */
- (AMQP_MANDATORY & flags) ? 1 : 0, /* mandatory */
- (AMQP_IMMEDIATE & flags) ? 1 : 0, /* immediate */
- &props,
- php_amqp_type_char_to_amqp_long(msg, msg_len) /* message body */
- );
-
- if (headers) {
- php_amqp_type_free_amqp_table(headers);
- }
+ zval *exchange_name = PHP_AMQP_READ_THIS_PROP("name");
+
+ /* NOTE: basic.publish is asynchronous and thus will not indicate failure if something goes wrong on the broker */
+ int status = amqp_basic_publish(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ (Z_TYPE_P(exchange_name) == IS_STRING && Z_STRLEN_P(exchange_name) > 0
+ ? amqp_cstring_bytes(Z_STRVAL_P(exchange_name))
+ : amqp_empty_bytes), /* exchange */
+ (key_len > 0 ? amqp_cstring_bytes(key_name) : amqp_empty_bytes), /* routing key */
+ (AMQP_MANDATORY & flags) ? 1 : 0, /* mandatory */
+ (AMQP_IMMEDIATE & flags) ? 1 : 0, /* immediate */
+ &props,
+ php_amqp_type_char_to_amqp_long(msg, msg_len) /* message body */
+ );
+
+ if (headers) {
+ php_amqp_type_free_amqp_table(headers);
+ }
#ifndef PHP_WIN32
- /* End ignoring of SIGPIPEs */
- signal(SIGPIPE, old_handler);
-#endif
-
- if (status != AMQP_STATUS_OK) {
- /* Emulate library error */
- amqp_rpc_reply_t res;
- res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- res.library_error = status;
+ /* End ignoring of SIGPIPEs */
+ oldact.sa_flags |= SA_ONSTACK;
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
-
- php_amqp_zend_throw_exception(res, amqp_exchange_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (sigaction(SIGPIPE, &oldact, NULL) == -1) {
+ perror("sigaction");
+ }
+#endif
- RETURN_TRUE;
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_exchange_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
}
/* }}} */
@@ -643,57 +688,60 @@ bind exchange to exchange by routing key
*/
static PHP_METHOD(amqp_exchange_class, bind)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- zval *zvalArguments = NULL;
-
- amqp_channel_resource *channel_resource;
-
- char *src_name;
- PHP5to7_param_str_len_type_t src_name_len = 0;
- char *keyname = NULL;
- PHP5to7_param_str_len_type_t keyname_len = 0;
-
- amqp_table_t *arguments = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!a",
- &src_name, &src_name_len,
- &keyname, &keyname_len,
- &zvalArguments) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not bind to exchange.");
-
- if (zvalArguments) {
- arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments TSRMLS_CC);
- }
-
- amqp_exchange_bind(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
- (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes),
- (keyname != NULL && keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
- (arguments ? *arguments : amqp_empty_table)
- );
-
- if (arguments) {
- php_amqp_type_free_amqp_table(arguments);
- }
-
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- RETURN_TRUE;
+ zval rv;
+
+ zval *zvalArguments = NULL;
+
+ amqp_channel_resource *channel_resource;
+
+ char *src_name;
+ size_t src_name_len = 0;
+ char *keyname = NULL;
+ size_t keyname_len = 0;
+
+ amqp_table_t *arguments = NULL;
+
+ if (zend_parse_parameters(
+ ZEND_NUM_ARGS(),
+ "s|s!a",
+ &src_name,
+ &src_name_len,
+ &keyname,
+ &keyname_len,
+ &zvalArguments
+ ) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not bind to exchange.");
+
+ if (zvalArguments) {
+ arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments);
+ }
+
+ amqp_exchange_bind(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name") : ""),
+ (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes),
+ (keyname != NULL && keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
+ (arguments ? *arguments : amqp_empty_table)
+ );
+
+ if (arguments) {
+ php_amqp_type_free_amqp_table(arguments);
+ }
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -702,57 +750,60 @@ remove exchange to exchange binding by routing key
*/
static PHP_METHOD(amqp_exchange_class, unbind)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- zval *zvalArguments = NULL;
-
- amqp_channel_resource *channel_resource;
-
- char *src_name;
- PHP5to7_param_str_len_type_t src_name_len = 0;
- char *keyname = NULL;
- PHP5to7_param_str_len_type_t keyname_len = 0;
-
- amqp_table_t *arguments = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!a",
- &src_name, &src_name_len,
- &keyname, &keyname_len,
- &zvalArguments) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not unbind from exchange.");
-
- if (zvalArguments) {
- arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments TSRMLS_CC);
- }
-
- amqp_exchange_unbind(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
- (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes),
- (keyname != NULL && keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
- (arguments ? *arguments : amqp_empty_table)
- );
-
- if (arguments) {
- php_amqp_type_free_amqp_table(arguments);
- }
-
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- RETURN_TRUE;
+ zval rv;
+
+ zval *zvalArguments = NULL;
+
+ amqp_channel_resource *channel_resource;
+
+ char *src_name;
+ size_t src_name_len = 0;
+ char *keyname = NULL;
+ size_t keyname_len = 0;
+
+ amqp_table_t *arguments = NULL;
+
+ if (zend_parse_parameters(
+ ZEND_NUM_ARGS(),
+ "s|s!a",
+ &src_name,
+ &src_name_len,
+ &keyname,
+ &keyname_len,
+ &zvalArguments
+ ) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not unbind from exchange.");
+
+ if (zvalArguments) {
+ arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments);
+ }
+
+ amqp_exchange_unbind(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name") : ""),
+ (src_name_len > 0 ? amqp_cstring_bytes(src_name) : amqp_empty_bytes),
+ (keyname != NULL && keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
+ (arguments ? *arguments : amqp_empty_table)
+ );
+
+ if (arguments) {
+ php_amqp_type_free_amqp_table(arguments);
+ }
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_exchange_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -760,9 +811,9 @@ static PHP_METHOD(amqp_exchange_class, unbind)
Get the AMQPChannel object in use */
static PHP_METHOD(amqp_exchange_class, getChannel)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("channel");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("channel");
}
/* }}} */
@@ -770,148 +821,148 @@ static PHP_METHOD(amqp_exchange_class, getChannel)
Get the AMQPConnection object in use */
static PHP_METHOD(amqp_exchange_class, getConnection)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("connection");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("connection");
}
/* }}} */
/* amqp_exchange ARG_INFO definition */
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_OBJ_INFO(0, amqp_channel, AMQPChannel, 0)
+ ZEND_ARG_OBJ_INFO(0, channel, AMQPChannel, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_getName, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, exchange_name)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_setName, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, exchangeName, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_getFlags, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_setFlags, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_getType, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setType, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, exchange_type)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_setType, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, exchangeType, IS_STRING, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, argument)
+ ZEND_ARG_TYPE_INFO(0, argumentName, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_hasArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, argument)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_hasArgument, ZEND_SEND_BY_VAL, 1, _IS_BOOL, 0)
+ ZEND_ARG_TYPE_INFO(0, argumentName, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_getArguments, ZEND_SEND_BY_VAL, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
- ZEND_ARG_INFO(0, key)
- ZEND_ARG_INFO(0, value)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_setArgument, ZEND_SEND_BY_VAL, 2, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, argumentName, IS_STRING, 0)
+ ZEND_ARG_INFO(0, argumentValue)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_setArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_ARRAY_INFO(0, arguments, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_removeArgument, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, argumentName, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_declareExchange, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_setArguments, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_ARRAY_INFO(0, arguments, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_bind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
- ZEND_ARG_INFO(0, exchange_name)
- ZEND_ARG_INFO(0, routing_key)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_declareExchange, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_unbind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
- ZEND_ARG_INFO(0, exchange_name)
- ZEND_ARG_INFO(0, routing_key)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_bind, ZEND_RETURN_VALUE, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, exchangeName, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, routingKey, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arguments, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_delete, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
- ZEND_ARG_INFO(0, exchange_name)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_unbind, ZEND_RETURN_VALUE, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, exchangeName, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, routingKey, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arguments, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_publish, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, message)
- ZEND_ARG_INFO(0, routing_key)
- ZEND_ARG_INFO(0, flags)
- ZEND_ARG_ARRAY_INFO(0, headers, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_delete, ZEND_RETURN_VALUE, 0, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, exchangeName, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getChannel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_exchange_class_publish, ZEND_RETURN_VALUE, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, message, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, routingKey, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, headers, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_exchange_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(arginfo_amqp_exchange_class_getChannel, AMQPChannel, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(arginfo_amqp_exchange_class_getConnection, AMQPConnection, 0)
ZEND_END_ARG_INFO()
zend_function_entry amqp_exchange_class_functions[] = {
- PHP_ME(amqp_exchange_class, __construct, arginfo_amqp_exchange_class__construct, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, __construct, arginfo_amqp_exchange_class__construct, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, getName, arginfo_amqp_exchange_class_getName, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, setName, arginfo_amqp_exchange_class_setName, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, getName, arginfo_amqp_exchange_class_getName, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setName, arginfo_amqp_exchange_class_setName, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, getFlags, arginfo_amqp_exchange_class_getFlags, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, setFlags, arginfo_amqp_exchange_class_setFlags, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, getFlags, arginfo_amqp_exchange_class_getFlags, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setFlags, arginfo_amqp_exchange_class_setFlags, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, getType, arginfo_amqp_exchange_class_getType, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, setType, arginfo_amqp_exchange_class_setType, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, getType, arginfo_amqp_exchange_class_getType, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setType, arginfo_amqp_exchange_class_setType, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, getArgument, arginfo_amqp_exchange_class_getArgument, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, getArguments, arginfo_amqp_exchange_class_getArguments, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, setArgument, arginfo_amqp_exchange_class_setArgument, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, setArguments, arginfo_amqp_exchange_class_setArguments, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, hasArgument, arginfo_amqp_exchange_class_hasArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, getArgument, arginfo_amqp_exchange_class_getArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, getArguments, arginfo_amqp_exchange_class_getArguments, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setArgument, arginfo_amqp_exchange_class_setArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, removeArgument, arginfo_amqp_exchange_class_removeArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, setArguments, arginfo_amqp_exchange_class_setArguments, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, hasArgument, arginfo_amqp_exchange_class_hasArgument, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, declareExchange,arginfo_amqp_exchange_class_declareExchange,ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, bind, arginfo_amqp_exchange_class_bind, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, unbind, arginfo_amqp_exchange_class_unbind, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, delete, arginfo_amqp_exchange_class_delete, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, publish, arginfo_amqp_exchange_class_publish, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, declareExchange, arginfo_amqp_exchange_class_declareExchange, ZEND_ACC_PUBLIC)
+ PHP_MALIAS(amqp_exchange_class, declare, declareExchange, arginfo_amqp_exchange_class_declareExchange, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, getChannel, arginfo_amqp_exchange_class_getChannel, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_exchange_class, getConnection, arginfo_amqp_exchange_class_getConnection, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, bind, arginfo_amqp_exchange_class_bind, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, unbind, arginfo_amqp_exchange_class_unbind, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, delete, arginfo_amqp_exchange_class_delete, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, publish, arginfo_amqp_exchange_class_publish, ZEND_ACC_PUBLIC)
- PHP_MALIAS(amqp_exchange_class, declare, declareExchange, arginfo_amqp_exchange_class_declareExchange, ZEND_ACC_PUBLIC | ZEND_ACC_DEPRECATED)
+ PHP_ME(amqp_exchange_class, getChannel, arginfo_amqp_exchange_class_getChannel, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_exchange_class, getConnection, arginfo_amqp_exchange_class_getConnection, ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
+ {NULL, NULL, NULL}
};
PHP_MINIT_FUNCTION(amqp_exchange)
{
- zend_class_entry ce;
-
- INIT_CLASS_ENTRY(ce, "AMQPExchange", amqp_exchange_class_functions);
- this_ce = zend_register_internal_class(&ce TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("connection"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("channel"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_stringl(this_ce, ZEND_STRL("name"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("type"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_bool(this_ce, ZEND_STRL("passive"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_bool(this_ce, ZEND_STRL("durable"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_bool(this_ce, ZEND_STRL("auto_delete"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_bool(this_ce, ZEND_STRL("internal"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("arguments"), ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "AMQPExchange", amqp_exchange_class_functions);
+ this_ce = zend_register_internal_class(&ce);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_OBJ(this_ce, "connection", ZEND_ACC_PRIVATE, AMQPConnection, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_OBJ(this_ce, "channel", ZEND_ACC_PRIVATE, AMQPChannel, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "name", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "type", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "passive", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_FALSE);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "durable", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_FALSE);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "autoDelete", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_FALSE);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "internal", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_FALSE);
+#if PHP_VERSION_ID >= 80000
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "arguments", ZEND_ACC_PRIVATE, IS_ARRAY, 0, ZVAL_EMPTY_ARRAY);
+#else
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "arguments", ZEND_ACC_PRIVATE, IS_ARRAY, 0, ZVAL_NULL);
+#endif
- return SUCCESS;
+ return SUCCESS;
}
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_exchange.h b/amqp_exchange.h
index a1dbf05a..91235455 100644
--- a/amqp_exchange.h
+++ b/amqp_exchange.h
@@ -20,16 +20,8 @@
| - Jonathan Tansavatdi |
+----------------------------------------------------------------------+
*/
-extern zend_class_entry *amqp_exchange_class_entry;
+#include "php.h"
+extern zend_class_entry *amqp_exchange_class_entry;
PHP_MINIT_FUNCTION(amqp_exchange);
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_methods_handling.c b/amqp_methods_handling.c
index fa8bfcf6..8091c0a2 100644
--- a/amqp_methods_handling.c
+++ b/amqp_methods_handling.c
@@ -25,241 +25,235 @@
#include "amqp_methods_handling.h"
/* taken from rabbbitmq-c */
-static int amqp_id_in_reply_list(amqp_method_number_t expected, amqp_method_number_t *list) {
- while (*list != 0) {
- if (*list == expected) {
- return 1;
- }
- list++;
- }
-
- return 0;
-}
-
-/* taken from rabbbitmq-c */
-static int amqp_simple_wait_method_list(amqp_connection_state_t state,
- amqp_channel_t expected_channel,
- amqp_method_number_t *expected_methods,
- amqp_method_t *output) {
- amqp_frame_t frame;
- int res = amqp_simple_wait_frame_on_channel(state, expected_channel, &frame);
-
- if (AMQP_STATUS_OK != res) {
- return res;
- }
-
- if (AMQP_FRAME_METHOD != frame.frame_type ||
- expected_channel != frame.channel ||
- !amqp_id_in_reply_list(frame.payload.method.id, expected_methods)) {
- return AMQP_STATUS_WRONG_METHOD;
- }
-
- *output = frame.payload.method;
- return AMQP_STATUS_OK;
+static int amqp_id_in_reply_list(amqp_method_number_t expected, amqp_method_number_t *list)
+{
+ while (*list != 0) {
+ if (*list == expected) {
+ return 1;
+ }
+ list++;
+ }
+
+ return 0;
}
/* taken from rabbbitmq-c */
-int amqp_simple_wait_method_list_noblock(amqp_connection_state_t state,
- amqp_channel_t expected_channel,
- amqp_method_number_t *expected_methods,
- amqp_method_t *output,
- struct timeval *timeout) {
- amqp_frame_t frame;
- int res = amqp_simple_wait_frame_on_channel_noblock(state, expected_channel, &frame, timeout);
+int amqp_simple_wait_method_list_noblock(
+ amqp_connection_state_t state,
+ amqp_channel_t expected_channel,
+ amqp_method_number_t *expected_methods,
+ amqp_method_t *output,
+ struct timeval *timeout
+)
+{
+ amqp_frame_t frame;
+ int res = amqp_simple_wait_frame_noblock(state, &frame, timeout);
- if (AMQP_STATUS_OK != res) {
- return res;
- }
+ if (AMQP_STATUS_OK != res) {
+ return res;
+ }
- if (AMQP_FRAME_METHOD != frame.frame_type ||
- expected_channel != frame.channel ||
- !amqp_id_in_reply_list(frame.payload.method.id, expected_methods)) {
+ if (AMQP_FRAME_METHOD != frame.frame_type || expected_channel != frame.channel ||
+ !amqp_id_in_reply_list(frame.payload.method.id, expected_methods)) {
- if (AMQP_CHANNEL_CLOSE_METHOD == frame.payload.method.id || AMQP_CONNECTION_CLOSE_METHOD == frame.payload.method.id) {
+ if (AMQP_CHANNEL_CLOSE_METHOD == frame.payload.method.id ||
+ AMQP_CONNECTION_CLOSE_METHOD == frame.payload.method.id) {
- *output = frame.payload.method;
+ *output = frame.payload.method;
- return AMQP_RESPONSE_SERVER_EXCEPTION;
- }
+ return AMQP_RESPONSE_SERVER_EXCEPTION;
+ }
- return AMQP_STATUS_WRONG_METHOD;
- }
+ return AMQP_STATUS_WRONG_METHOD;
+ }
- *output = frame.payload.method;
- return AMQP_STATUS_OK;
+ *output = frame.payload.method;
+ return AMQP_STATUS_OK;
}
/* taken from rabbbitmq-c */
-int amqp_simple_wait_method_noblock(amqp_connection_state_t state,
- amqp_channel_t expected_channel,
- amqp_method_number_t expected_method,
- amqp_method_t *output,
- struct timeval *timeout)
+int amqp_simple_wait_method_noblock(
+ amqp_connection_state_t state,
+ amqp_channel_t expected_channel,
+ amqp_method_number_t expected_method,
+ amqp_method_t *output,
+ struct timeval *timeout
+)
{
- amqp_method_number_t expected_methods[] = { 0, 0 };
- expected_methods[0] = expected_method;
+ amqp_method_number_t expected_methods[] = {0, 0};
+ expected_methods[0] = expected_method;
- return amqp_simple_wait_method_list_noblock(state, expected_channel, expected_methods, output, timeout);
+ return amqp_simple_wait_method_list_noblock(state, expected_channel, expected_methods, output, timeout);
}
-int php_amqp_handle_basic_return(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC) {
- amqp_rpc_reply_t ret;
- amqp_message_t msg;
- int status = PHP_AMQP_RESOURCE_RESPONSE_OK;
-
- assert(AMQP_BASIC_RETURN_METHOD == method->id);
-
- amqp_basic_return_t *m = (amqp_basic_return_t *) method->decoded;
-
- ret = amqp_read_message(resource->connection_state, channel_id, &msg, 0);
-
- if (AMQP_RESPONSE_NORMAL != ret.reply_type) {
- return php_amqp_connection_resource_error(ret, message, resource, channel_id TSRMLS_CC);
- }
-
- if (channel->callbacks.basic_return.fci.size > 0) {
- status = php_amqp_call_basic_return_callback(m, &msg, &channel->callbacks.basic_return TSRMLS_CC);
- } else {
- zend_error(E_NOTICE, "Unhandled basic.return method from server received. Use AMQPChannel::setReturnCallback() to process it.");
- status = PHP_AMQP_RESOURCE_RESPONSE_BREAK;
- }
-
- amqp_destroy_message(&msg);
-
- return status;
+int php_amqp_handle_basic_return(char **message, amqp_channel_object *channel, amqp_method_t *method)
+{
+ amqp_rpc_reply_t ret;
+ amqp_message_t msg;
+ int status = PHP_AMQP_RESOURCE_RESPONSE_OK;
+
+ assert(AMQP_BASIC_RETURN_METHOD == method->id);
+
+ amqp_basic_return_t *m = (amqp_basic_return_t *) method->decoded;
+
+ ret = amqp_read_message(
+ channel->channel_resource->connection_resource->connection_state,
+ channel->channel_resource->channel_id,
+ &msg,
+ 0
+ );
+
+ if (AMQP_RESPONSE_NORMAL != ret.reply_type) {
+ return php_amqp_connection_resource_error(
+ ret,
+ message,
+ channel->channel_resource->connection_resource,
+ channel->channel_resource->channel_id
+ );
+ }
+
+ if (channel->callbacks.basic_return.fci.size > 0) {
+ status = php_amqp_call_basic_return_callback(m, &msg, &channel->callbacks.basic_return);
+ } else {
+ zend_error(
+ E_NOTICE,
+ "Unhandled basic.return method from server received. Use AMQPChannel::setReturnCallback() to process it."
+ );
+ status = PHP_AMQP_RESOURCE_RESPONSE_BREAK;
+ }
+
+ amqp_destroy_message(&msg);
+
+ return status;
}
-int php_amqp_call_basic_return_callback(amqp_basic_return_t *m, amqp_message_t *msg, amqp_callback_bucket *cb TSRMLS_DC) {
- PHP5to7_zval_t params PHP5to7_MAYBE_SET_TO_NULL;
- PHP5to7_zval_t basic_properties PHP5to7_MAYBE_SET_TO_NULL;
+int php_amqp_call_basic_return_callback(amqp_basic_return_t *m, amqp_message_t *msg, amqp_callback_bucket *cb)
+{
+ zval params;
+ zval basic_properties;
- int status = PHP_AMQP_RESOURCE_RESPONSE_OK;
+ int status = PHP_AMQP_RESOURCE_RESPONSE_OK;
- PHP5to7_MAYBE_INIT(params);
- PHP5to7_ARRAY_INIT(params);
+ ZVAL_UNDEF(¶ms);
+ array_init(¶ms);
- PHP5to7_MAYBE_INIT(basic_properties);
+ ZVAL_UNDEF(&basic_properties);
- /* callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body); */
+ /* callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body); */
- add_next_index_long(PHP5to7_MAYBE_PTR(params), (PHP5to7_param_long_type_t) m->reply_code);
- PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(PHP5to7_MAYBE_PTR(params), (const char *) m->reply_text.bytes, (PHP5to7_param_str_len_type_t) m->reply_text.len);
- PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(PHP5to7_MAYBE_PTR(params), (const char *) m->exchange.bytes, (PHP5to7_param_str_len_type_t) m->exchange.len);
- PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(PHP5to7_MAYBE_PTR(params), (const char *) m->routing_key.bytes, (PHP5to7_param_str_len_type_t) m->routing_key.len);
+ add_next_index_long(¶ms, (zend_long) m->reply_code);
+ add_next_index_stringl(¶ms, m->reply_text.bytes, m->reply_text.len);
+ add_next_index_stringl(¶ms, m->exchange.bytes, m->exchange.len);
+ add_next_index_stringl(¶ms, m->routing_key.bytes, m->routing_key.len);
- php_amqp_basic_properties_convert_to_zval(&msg->properties, PHP5to7_MAYBE_PTR(basic_properties) TSRMLS_CC);
- add_next_index_zval(PHP5to7_MAYBE_PTR(params), PHP5to7_MAYBE_PTR(basic_properties));
- Z_ADDREF_P(PHP5to7_MAYBE_PTR(basic_properties));
+ php_amqp_basic_properties_to_zval(&msg->properties, &basic_properties);
+ add_next_index_zval(¶ms, &basic_properties);
+ Z_ADDREF_P(&basic_properties);
- PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(PHP5to7_MAYBE_PTR(params), (const char *) msg->body.bytes, (PHP5to7_param_str_len_type_t) msg->body.len);
+ add_next_index_stringl(¶ms, msg->body.bytes, msg->body.len);
- status = php_amqp_call_callback_with_params(params, cb TSRMLS_CC);
+ status = php_amqp_call_callback_with_params(params, cb);
- PHP5to7_MAYBE_DESTROY(basic_properties);
+ zval_ptr_dtor(&basic_properties);
- return status;
+ return status;
}
-int php_amqp_handle_basic_ack(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC) {
- amqp_rpc_reply_t ret;
- int status = PHP_AMQP_RESOURCE_RESPONSE_OK;
+int php_amqp_handle_basic_ack(char **message, amqp_channel_object *channel, amqp_method_t *method)
+{
+ assert(AMQP_BASIC_ACK_METHOD == method->id);
- assert(AMQP_BASIC_ACK_METHOD == method->id);
+ amqp_basic_ack_t *m = (amqp_basic_ack_t *) method->decoded;
- amqp_basic_ack_t *m = (amqp_basic_ack_t *) method->decoded;
+ if (channel->callbacks.basic_ack.fci.size > 0) {
+ return php_amqp_call_basic_ack_callback(m, &channel->callbacks.basic_ack);
+ }
- if (channel->callbacks.basic_ack.fci.size > 0) {
- status = php_amqp_call_basic_ack_callback(m, &channel->callbacks.basic_ack TSRMLS_CC);
- } else {
- zend_error(E_NOTICE, "Unhandled basic.ack method from server received. Use AMQPChannel::setConfirmCallback() to process it.");
- status = PHP_AMQP_RESOURCE_RESPONSE_BREAK;
- }
+ zend_error(
+ E_NOTICE,
+ "Unhandled basic.ack method from server received. Use AMQPChannel::setConfirmCallback() to process it."
+ );
- return status;
+ return PHP_AMQP_RESOURCE_RESPONSE_BREAK;
}
-int php_amqp_call_basic_ack_callback(amqp_basic_ack_t *m, amqp_callback_bucket *cb TSRMLS_DC) {
- PHP5to7_zval_t params PHP5to7_MAYBE_SET_TO_NULL;
+int php_amqp_call_basic_ack_callback(amqp_basic_ack_t *m, amqp_callback_bucket *cb)
+{
+ zval params;
- PHP5to7_MAYBE_INIT(params);
- PHP5to7_ARRAY_INIT(params);
+ ZVAL_UNDEF(¶ms);
+ array_init(¶ms);
- /* callback(int $delivery_tag, bool $multiple); */
- add_next_index_long(PHP5to7_MAYBE_PTR(params), (PHP5to7_param_long_type_t) m->delivery_tag);
- add_next_index_bool(PHP5to7_MAYBE_PTR(params), m->multiple);
+ /* callback(int $delivery_tag, bool $multiple); */
+ add_next_index_long(¶ms, (zend_long) m->delivery_tag);
+ add_next_index_bool(¶ms, m->multiple);
- return php_amqp_call_callback_with_params(params, cb TSRMLS_CC);
+ return php_amqp_call_callback_with_params(params, cb);
}
-int php_amqp_handle_basic_nack(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC) {
- amqp_rpc_reply_t ret;
- int status = PHP_AMQP_RESOURCE_RESPONSE_OK;
+int php_amqp_handle_basic_nack(char **message, amqp_channel_object *channel, amqp_method_t *method)
+{
+ int status = PHP_AMQP_RESOURCE_RESPONSE_OK;
- assert(AMQP_BASIC_NACK_METHOD == method->id);
+ assert(AMQP_BASIC_NACK_METHOD == method->id);
- amqp_basic_nack_t *m = (amqp_basic_nack_t *) method->decoded;
+ amqp_basic_nack_t *m = (amqp_basic_nack_t *) method->decoded;
- if (channel->callbacks.basic_nack.fci.size > 0) {
- status = php_amqp_call_basic_nack_callback(m, &channel->callbacks.basic_nack TSRMLS_CC);
- } else {
- zend_error(E_NOTICE, "Unhandled basic.nack method from server received. Use AMQPChannel::setConfirmCallback() to process it.");
- status = PHP_AMQP_RESOURCE_RESPONSE_BREAK;
- }
+ if (channel->callbacks.basic_nack.fci.size > 0) {
+ status = php_amqp_call_basic_nack_callback(m, &channel->callbacks.basic_nack);
+ } else {
+ zend_error(
+ E_NOTICE,
+ "Unhandled basic.nack method from server received. Use AMQPChannel::setConfirmCallback() to process it."
+ );
+ status = PHP_AMQP_RESOURCE_RESPONSE_BREAK;
+ }
- return status;
+ return status;
}
-int php_amqp_call_basic_nack_callback(amqp_basic_nack_t *m, amqp_callback_bucket *cb TSRMLS_DC) {
- PHP5to7_zval_t params PHP5to7_MAYBE_SET_TO_NULL;
+int php_amqp_call_basic_nack_callback(amqp_basic_nack_t *m, amqp_callback_bucket *cb)
+{
+ zval params;
- PHP5to7_MAYBE_INIT(params);
- PHP5to7_ARRAY_INIT(params);
+ ZVAL_UNDEF(¶ms);
+ array_init(¶ms);
- /* callback(int $delivery_tag, bool $multiple, bool $requeue); */
- add_next_index_long(PHP5to7_MAYBE_PTR(params), (PHP5to7_param_long_type_t) m->delivery_tag);
- add_next_index_bool(PHP5to7_MAYBE_PTR(params), m->multiple);
- add_next_index_bool(PHP5to7_MAYBE_PTR(params), m->requeue);
+ /* callback(int $delivery_tag, bool $multiple, bool $requeue); */
+ add_next_index_long(¶ms, (zend_long) m->delivery_tag);
+ add_next_index_bool(¶ms, m->multiple);
+ add_next_index_bool(¶ms, m->requeue);
- return php_amqp_call_callback_with_params(params, cb TSRMLS_CC);
+ return php_amqp_call_callback_with_params(params, cb);
}
-int php_amqp_call_callback_with_params(PHP5to7_zval_t params, amqp_callback_bucket *cb TSRMLS_DC)
+int php_amqp_call_callback_with_params(zval params, amqp_callback_bucket *cb)
{
- zval retval;
- zval *retval_ptr = &retval;
+ zval retval;
+ zval *retval_ptr = &retval;
- int status = PHP_AMQP_RESOURCE_RESPONSE_OK;
+ int status = PHP_AMQP_RESOURCE_RESPONSE_OK;
- ZVAL_NULL(&retval);
+ ZVAL_NULL(&retval);
- /* Convert everything to be callable */
- zend_fcall_info_args(&cb->fci, PHP5to7_MAYBE_PTR(params) TSRMLS_CC);
+ /* Convert everything to be callable */
+ zend_fcall_info_args(&cb->fci, ¶ms);
- /* Initialize the return value pointer */
- PHP5to7_SET_FCI_RETVAL_PTR(cb->fci, retval_ptr);
+ /* Initialize the return value pointer */
+ cb->fci.retval = retval_ptr;
- zend_call_function(&cb->fci, &cb->fcc TSRMLS_CC);
+ zend_call_function(&cb->fci, &cb->fcc);
- /* Check if user land function wants to bail */
- if (EG(exception) || PHP5to7_IS_FALSE_P(retval_ptr)) {
- status = PHP_AMQP_RESOURCE_RESPONSE_BREAK;
- }
+ /* Check if user land function wants to bail */
+ if (EG(exception) || Z_TYPE_P(retval_ptr) == IS_FALSE) {
+ status = PHP_AMQP_RESOURCE_RESPONSE_BREAK;
+ }
- /* Clean up our mess */
- zend_fcall_info_args_clear(&cb->fci, 1);
- PHP5to7_MAYBE_DESTROY(params);
- PHP5to7_MAYBE_DESTROY2(retval, retval_ptr);
+ /* Clean up our mess */
+ zend_fcall_info_args_clear(&cb->fci, 1);
+ zval_ptr_dtor(¶ms);
+ zval_ptr_dtor(retval_ptr);
- return status;
+ return status;
}
-
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_methods_handling.h b/amqp_methods_handling.h
index 25d1e1a0..d081ffa6 100644
--- a/amqp_methods_handling.h
+++ b/amqp_methods_handling.h
@@ -24,39 +24,38 @@
#define PHP_AMQP_METHODS_HANDLING_H
#include "php_amqp.h"
-#include "amqp.h"
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+#else
+ #include
+#endif
#include "php.h"
-int amqp_simple_wait_method_list_noblock(amqp_connection_state_t state,
- amqp_channel_t expected_channel,
- amqp_method_number_t *expected_methods,
- amqp_method_t *output,
- struct timeval *timeout);
+int amqp_simple_wait_method_list_noblock(
+ amqp_connection_state_t state,
+ amqp_channel_t expected_channel,
+ amqp_method_number_t *expected_methods,
+ amqp_method_t *output,
+ struct timeval *timeout
+);
-int amqp_simple_wait_method_noblock(amqp_connection_state_t state,
- amqp_channel_t expected_channel,
- amqp_method_number_t expected_method,
- amqp_method_t *output,
- struct timeval *timeout);
+int amqp_simple_wait_method_noblock(
+ amqp_connection_state_t state,
+ amqp_channel_t expected_channel,
+ amqp_method_number_t expected_method,
+ amqp_method_t *output,
+ struct timeval *timeout
+);
-int php_amqp_call_callback_with_params(PHP5to7_zval_t params, amqp_callback_bucket *cb TSRMLS_DC);
+int php_amqp_call_callback_with_params(zval params, amqp_callback_bucket *cb);
-int php_amqp_call_basic_return_callback(amqp_basic_return_t *m, amqp_message_t *msg, amqp_callback_bucket *cb TSRMLS_DC);
-int php_amqp_handle_basic_return(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC);
+int php_amqp_call_basic_return_callback(amqp_basic_return_t *m, amqp_message_t *msg, amqp_callback_bucket *cb);
+int php_amqp_handle_basic_return(char **message, amqp_channel_object *channel, amqp_method_t *method);
-int php_amqp_call_basic_ack_callback(amqp_basic_ack_t *m, amqp_callback_bucket *cb TSRMLS_DC);
-int php_amqp_handle_basic_ack(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC);
+int php_amqp_call_basic_ack_callback(amqp_basic_ack_t *m, amqp_callback_bucket *cb);
+int php_amqp_handle_basic_ack(char **message, amqp_channel_object *channel, amqp_method_t *method);
-int php_amqp_call_basic_nack_callback(amqp_basic_nack_t *m, amqp_callback_bucket *cb TSRMLS_DC);
-int php_amqp_handle_basic_nack(char **message, amqp_connection_resource *resource, amqp_channel_t channel_id, amqp_channel_object *channel, amqp_method_t *method TSRMLS_DC);
+int php_amqp_call_basic_nack_callback(amqp_basic_nack_t *m, amqp_callback_bucket *cb);
+int php_amqp_handle_basic_nack(char **message, amqp_channel_object *channel, amqp_method_t *method);
#endif
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_queue.c b/amqp_queue.c
index 23a4cd0b..48287fa1 100644
--- a/amqp_queue.c
+++ b/amqp_queue.c
@@ -21,40 +21,50 @@
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
-#include "ext/standard/info.h"
#include "zend_exceptions.h"
#ifdef PHP_WIN32
-# if PHP_VERSION_ID >= 80000
-# include "main/php_stdint.h"
-# else
-# include "win32/php_stdint.h"
-# endif
-# include "win32/signal.h"
+ #if PHP_VERSION_ID >= 80000
+ #include
+ #else
+ #include "win32/php_stdint.h"
+ #endif
+ #include "win32/signal.h"
#else
-# include
-# include
+ #include
+ #include
+#endif
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+ #include
+#else
+ #include
+ #include
#endif
-#include
-#include
#ifdef PHP_WIN32
-# include "win32/unistd.h"
+ #include "win32/unistd.h"
#else
-# include
+ #include
#endif
#include "php_amqp.h"
#include "amqp_envelope.h"
+#include "amqp_envelope_exception.h"
#include "amqp_connection.h"
#include "amqp_channel.h"
+#include "amqp_connection.h"
+#include "amqp_envelope.h"
#include "amqp_queue.h"
#include "amqp_type.h"
+#include "amqp_value.h"
+#include "amqp_decimal.h"
+#include "amqp_timestamp.h"
zend_class_entry *amqp_queue_class_entry;
#define this_ce amqp_queue_class_entry
@@ -65,28 +75,32 @@ AMQPQueue constructor
*/
static PHP_METHOD(amqp_queue_class, __construct)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- PHP5to7_zval_t arguments PHP5to7_MAYBE_SET_TO_NULL;
+ zval rv;
- zval *channelObj;
- amqp_channel_resource *channel_resource;
+ zval arguments;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &channelObj, amqp_channel_class_entry) == FAILURE) {
- return;
- }
+ zval *channelObj;
+ amqp_channel_resource *channel_resource;
- PHP5to7_MAYBE_INIT(arguments);
- PHP5to7_ARRAY_INIT(arguments);
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("arguments"), PHP5to7_MAYBE_PTR(arguments) TSRMLS_CC);
- PHP5to7_MAYBE_DESTROY(arguments);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &channelObj, amqp_channel_class_entry) == FAILURE) {
+ RETURN_THROWS();
+ }
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channelObj);
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not create queue.");
+ ZVAL_UNDEF(&arguments);
+ array_init(&arguments);
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("arguments"), &arguments);
+ zval_ptr_dtor(&arguments);
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("channel"), channelObj TSRMLS_CC);
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("connection"), PHP_AMQP_READ_OBJ_PROP(amqp_channel_class_entry, channelObj, "connection") TSRMLS_CC);
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channelObj);
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not create queue.");
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("channel"), channelObj);
+ zend_update_property(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("connection"),
+ PHP_AMQP_READ_OBJ_PROP(amqp_channel_class_entry, channelObj, "connection")
+ );
}
/* }}} */
@@ -95,16 +109,15 @@ static PHP_METHOD(amqp_queue_class, __construct)
Get the queue name */
static PHP_METHOD(amqp_queue_class, getName)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") > 0) {
- PHP_AMQP_RETURN_THIS_PROP("name");
- } else {
- /* BC */
- RETURN_FALSE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_STRLEN("name") > 0) {
+ PHP_AMQP_RETURN_THIS_PROP("name");
+ } else {
+ RETURN_NULL();
+ }
}
/* }}} */
@@ -113,55 +126,56 @@ static PHP_METHOD(amqp_queue_class, getName)
Set the queue name */
static PHP_METHOD(amqp_queue_class, setName)
{
- char *name = NULL; PHP5to7_param_str_len_type_t name_len = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
- return;
- }
-
- if (name_len < 1 || name_len > 255) {
- /* Verify that the name is not null and not an empty string */
- zend_throw_exception(amqp_queue_exception_class_entry, "Invalid queue name given, must be between 1 and 255 characters long.", 0 TSRMLS_CC);
- return;
- }
-
- /* Set the queue name */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("name"), name, name_len TSRMLS_CC);
-
- /* BC */
- RETURN_TRUE;
+ char *name = NULL;
+ size_t name_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &name, &name_len) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ if (name_len < 1 || name_len > 255) {
+ /* Verify that the name is not null and not an empty string */
+ zend_throw_exception(
+ amqp_queue_exception_class_entry,
+ "Invalid queue name given, must be between 1 and 255 characters long.",
+ 0
+ );
+ return;
+ }
+
+ /* Set the queue name */
+ zend_update_property_stringl(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("name"), name, name_len);
}
/* }}} */
-
/* {{{ proto AMQPQueue::getFlags()
Get the queue parameters */
static PHP_METHOD(amqp_queue_class, getFlags)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- PHP5to7_param_long_type_t flags = 0;
+ zend_long flags = 0;
- PHP_AMQP_NOPARAMS();
+ PHP_AMQP_NOPARAMS()
- if (PHP_AMQP_READ_THIS_PROP_BOOL("passive")) {
- flags |= AMQP_PASSIVE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_BOOL("passive")) {
+ flags |= AMQP_PASSIVE;
+ }
- if (PHP_AMQP_READ_THIS_PROP_BOOL("durable")) {
- flags |= AMQP_DURABLE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_BOOL("durable")) {
+ flags |= AMQP_DURABLE;
+ }
- if (PHP_AMQP_READ_THIS_PROP_BOOL("exclusive")) {
- flags |= AMQP_EXCLUSIVE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_BOOL("exclusive")) {
+ flags |= AMQP_EXCLUSIVE;
+ }
- if (PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete")) {
- flags |= AMQP_AUTODELETE;
- }
+ if (PHP_AMQP_READ_THIS_PROP_BOOL("autoDelete")) {
+ flags |= AMQP_AUTODELETE;
+ }
- RETURN_LONG(flags);
+ RETURN_LONG(flags);
}
/* }}} */
@@ -170,23 +184,19 @@ static PHP_METHOD(amqp_queue_class, getFlags)
Set the queue parameters */
static PHP_METHOD(amqp_queue_class, setFlags)
{
- PHP5to7_param_long_type_t flags;
- zend_bool flags_is_null = 1;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l!", &flags, &flags_is_null) == FAILURE) {
- return;
- }
+ zend_long flags = AMQP_NOPARAM;
+ bool flags_is_null = 1;
- /* Set the flags based on the bitmask we were given */
- flags = flags ? flags & PHP_AMQP_QUEUE_FLAGS : flags;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l!", &flags, &flags_is_null) == FAILURE) {
+ RETURN_THROWS();
+ }
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("passive"), IS_PASSIVE(flags) TSRMLS_CC);
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("durable"), IS_DURABLE(flags) TSRMLS_CC);
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("exclusive"), IS_EXCLUSIVE(flags) TSRMLS_CC);
- zend_update_property_bool(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("auto_delete"), IS_AUTODELETE(flags) TSRMLS_CC);
+ flags = flags & PHP_AMQP_QUEUE_FLAGS;
- /* BC */
- RETURN_TRUE;
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("passive"), IS_PASSIVE(flags));
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("durable"), IS_DURABLE(flags));
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("exclusive"), IS_EXCLUSIVE(flags));
+ zend_update_property_bool(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("autoDelete"), IS_AUTODELETE(flags));
}
/* }}} */
@@ -195,42 +205,37 @@ static PHP_METHOD(amqp_queue_class, setFlags)
Get the queue argument referenced by key */
static PHP_METHOD(amqp_queue_class, getArgument)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- PHP5to7_zval_t *tmp = NULL;
-
- char *key; PHP5to7_param_str_len_type_t key_len;
+ zval rv;
+ zval *tmp = NULL;
+ char *key;
+ size_t key_len;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &key_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (unsigned)(key_len + 1), tmp)) {
- RETURN_FALSE;
- }
+ if ((tmp = zend_hash_str_find(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len)) == NULL) {
+ zend_throw_exception_ex(amqp_queue_exception_class_entry, 0, "The argument \"%s\" does not exist", key);
+ return;
+ }
- RETURN_ZVAL(PHP5to7_MAYBE_DEREF(tmp), 1, 0);
+ RETURN_ZVAL(tmp, 1, 0);
}
/* }}} */
/* {{{ proto AMQPQueue::hasArgument(string key) */
static PHP_METHOD(amqp_queue_class, hasArgument)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- PHP5to7_zval_t *tmp = NULL;
+ zval rv;
- char *key; PHP5to7_param_str_len_type_t key_len;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &key, &key_len) == FAILURE) {
- return;
- }
+ char *key;
+ size_t key_len;
- if (!PHP5to7_ZEND_HASH_FIND(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (unsigned)(key_len + 1), tmp)) {
- RETURN_FALSE;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &key_len) == FAILURE) {
+ RETURN_THROWS();
+ }
- RETURN_TRUE;
+ RETURN_BOOL(zend_hash_str_find(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len) != NULL);
}
/* }}} */
@@ -239,9 +244,9 @@ static PHP_METHOD(amqp_queue_class, hasArgument)
Get the queue arguments */
static PHP_METHOD(amqp_queue_class, getArguments)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("arguments");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("arguments");
}
/* }}} */
@@ -249,15 +254,13 @@ static PHP_METHOD(amqp_queue_class, getArguments)
Overwrite all queue arguments with given args */
static PHP_METHOD(amqp_queue_class, setArguments)
{
- zval *zvalArguments;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a/", &zvalArguments) == FAILURE) {
- return;
- }
+ zval *zvalArguments;
- zend_update_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("arguments"), zvalArguments TSRMLS_CC);
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "a/", &zvalArguments) == FAILURE) {
+ RETURN_THROWS();
+ }
- RETURN_TRUE;
+ zend_update_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("arguments"), zvalArguments);
}
/* }}} */
@@ -266,93 +269,125 @@ static PHP_METHOD(amqp_queue_class, setArguments)
Get the queue name */
static PHP_METHOD(amqp_queue_class, setArgument)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- char *key= NULL; PHP5to7_param_str_len_type_t key_len = 0;
- zval *value = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sz",
- &key, &key_len,
- &value) == FAILURE) {
- return;
- }
-
- switch (Z_TYPE_P(value)) {
- case IS_NULL:
- PHP5to7_ZEND_HASH_DEL(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (unsigned) (key_len + 1));
- break;
- PHP5to7_CASE_IS_BOOL:
- case IS_LONG:
- case IS_DOUBLE:
- case IS_STRING:
- PHP5to7_ZEND_HASH_ADD(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, (unsigned) (key_len + 1), value, sizeof(zval *));
- Z_TRY_ADDREF_P(value);
- break;
- default:
- zend_throw_exception(amqp_exchange_exception_class_entry, "The value parameter must be of type NULL, int, double or string.", 0 TSRMLS_CC);
- return;
- }
-
- RETURN_TRUE;
+ zval rv;
+
+ char *key = NULL;
+ size_t key_len = 0;
+ zval *value = NULL;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "sz", &key, &key_len, &value) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ switch (Z_TYPE_P(value)) {
+ case IS_OBJECT:
+ if (!instanceof_function(Z_OBJCE_P(value), amqp_timestamp_class_entry) &&
+ !instanceof_function(Z_OBJCE_P(value), amqp_decimal_class_entry) &&
+ !instanceof_function(Z_OBJCE_P(value), amqp_value_class_entry)) {
+ goto err;
+ }
+ // Intentional fall-through
+ case IS_NULL:
+ case IS_TRUE:
+ case IS_FALSE:
+ case IS_LONG:
+ case IS_DOUBLE:
+ case IS_STRING:
+ case IS_ARRAY:
+ zend_hash_str_add(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len, value);
+ Z_TRY_ADDREF_P(value);
+ break;
+ default:
+ err:
+ zend_throw_exception(
+ amqp_queue_exception_class_entry,
+ "The value parameter must be of type bool, int, double, string, null, array, AMQPTimestamp, "
+ "AMQPDecimal, or an implementation of AMQPValue.",
+ 0
+ );
+ return;
+ }
}
/* }}} */
+/* {{{ proto AMQPQueue::removeArgument(key)
+Get the queue name */
+static PHP_METHOD(amqp_queue_class, removeArgument)
+{
+ zval rv;
+
+ char *key = NULL;
+ size_t key_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &key, &key_len) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ if (zend_hash_str_exists_ind(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len)) {
+ zend_hash_str_del_ind(PHP_AMQP_READ_THIS_PROP_ARR("arguments"), key, key_len);
+ }
+}
+/* }}} */
+
/* {{{ proto int AMQPQueue::declareQueue();
declare queue
*/
static PHP_METHOD(amqp_queue_class, declareQueue)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- amqp_channel_resource *channel_resource;
+ amqp_channel_resource *channel_resource;
- char *name;
- amqp_table_t *arguments;
- PHP5to7_param_long_type_t message_count;
+ char *name;
+ amqp_table_t *arguments;
+ zend_long message_count;
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
+ PHP_AMQP_NOPARAMS()
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not declare queue.");
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not declare queue.");
- arguments = php_amqp_type_convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments") TSRMLS_CC);
+ arguments = php_amqp_type_convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments"));
- amqp_queue_declare_ok_t *r = amqp_queue_declare(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
- PHP_AMQP_READ_THIS_PROP_BOOL("passive"),
- PHP_AMQP_READ_THIS_PROP_BOOL("durable"),
- PHP_AMQP_READ_THIS_PROP_BOOL("exclusive"),
- PHP_AMQP_READ_THIS_PROP_BOOL("auto_delete"),
- *arguments
- );
+ amqp_queue_declare_ok_t *r = amqp_queue_declare(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name") : ""),
+ PHP_AMQP_READ_THIS_PROP_BOOL("passive"),
+ PHP_AMQP_READ_THIS_PROP_BOOL("durable"),
+ PHP_AMQP_READ_THIS_PROP_BOOL("exclusive"),
+ PHP_AMQP_READ_THIS_PROP_BOOL("autoDelete"),
+ *arguments
+ );
- php_amqp_type_free_amqp_table(arguments);
+ php_amqp_type_free_amqp_table(arguments);
- if (!r) {
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- message_count = r->message_count;
+ message_count = r->message_count;
- /* Set the queue name, in case it is an autogenerated queue name */
- name = php_amqp_type_amqp_bytes_to_char(r->queue);
- zend_update_property_string(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("name"), name TSRMLS_CC);
- efree(name);
+ /* Set the queue name, in case it is an autogenerated queue name */
+ name = php_amqp_type_amqp_bytes_to_char(r->queue);
+ zend_update_property_string(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("name"), name);
+ efree(name);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- RETURN_LONG(message_count);
+ RETURN_LONG(message_count);
}
/* }}} */
@@ -362,55 +397,60 @@ bind queue to exchange by routing key
*/
static PHP_METHOD(amqp_queue_class, bind)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- zval *zvalArguments = NULL;
-
- amqp_channel_resource *channel_resource;
-
- char *exchange_name; PHP5to7_param_str_len_type_t exchange_name_len;
- char *keyname = NULL; PHP5to7_param_str_len_type_t keyname_len = 0;
-
- amqp_table_t *arguments = NULL;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|s!a",
- &exchange_name, &exchange_name_len,
- &keyname, &keyname_len,
- &zvalArguments) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not bind queue.");
-
- if (zvalArguments) {
- arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments TSRMLS_CC);
- }
+ zval rv;
+
+ zval *zvalArguments = NULL;
+
+ amqp_channel_resource *channel_resource;
+
+ char *exchange_name;
+ size_t exchange_name_len;
+ char *keyname = NULL;
+ size_t keyname_len = 0;
+
+ amqp_table_t *arguments = NULL;
+
+ if (zend_parse_parameters(
+ ZEND_NUM_ARGS(),
+ "s|s!a",
+ &exchange_name,
+ &exchange_name_len,
+ &keyname,
+ &keyname_len,
+ &zvalArguments
+ ) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not bind queue.");
+
+ if (zvalArguments) {
+ arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments);
+ }
+
+ amqp_queue_bind(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name") : ""),
+ (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes),
+ (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
+ (arguments ? *arguments : amqp_empty_table)
+ );
+
+ if (arguments) {
+ php_amqp_type_free_amqp_table(arguments);
+ }
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ RETURN_THROWS();
+ }
- amqp_queue_bind(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
- (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes),
- (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
- (arguments ? *arguments : amqp_empty_table)
- );
-
- if (arguments) {
- php_amqp_type_free_amqp_table(arguments);
- }
-
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- RETURN_TRUE;
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -421,344 +461,360 @@ return array (messages)
*/
static PHP_METHOD(amqp_queue_class, get)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- amqp_channel_resource *channel_resource;
+ amqp_channel_resource *channel_resource;
- PHP5to7_zval_t message PHP5to7_MAYBE_SET_TO_NULL;
- PHP5to7_zval_t retval PHP5to7_MAYBE_SET_TO_NULL;
+ zval message;
- PHP5to7_param_long_type_t flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM;
+ zend_long flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM;
+ bool flags_is_null = 1;
- /* Parse out the method parameters */
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &flags, &flags_is_null) == FAILURE) {
+ RETURN_THROWS();
+ }
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not get messages from queue.");
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not get messages from queue.");
- amqp_rpc_reply_t res = amqp_basic_get(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
- (AMQP_AUTOACK & flags) ? 1 : 0
- );
+ amqp_rpc_reply_t res = amqp_basic_get(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name") : ""),
+ (AMQP_AUTOACK & flags) ? 1 : 0
+ );
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- if (AMQP_BASIC_GET_EMPTY_METHOD == res.reply.id) {
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- RETURN_FALSE;
- }
+ if (AMQP_BASIC_GET_EMPTY_METHOD == res.reply.id) {
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ RETURN_NULL();
+ }
- assert(AMQP_BASIC_GET_OK_METHOD == res.reply.id);
+ assert(AMQP_BASIC_GET_OK_METHOD == res.reply.id);
- /* Fill the envelope from response */
- amqp_basic_get_ok_t *get_ok_method = res.reply.decoded;
+ /* Fill the envelope from response */
+ amqp_basic_get_ok_t *get_ok_method = res.reply.decoded;
- amqp_envelope_t envelope;
+ amqp_envelope_t envelope;
- envelope.channel = channel_resource->channel_id;
- envelope.consumer_tag = amqp_empty_bytes;
- envelope.delivery_tag = get_ok_method->delivery_tag;
- envelope.redelivered = get_ok_method->redelivered;
- envelope.exchange = amqp_bytes_malloc_dup(get_ok_method->exchange);
- envelope.routing_key = amqp_bytes_malloc_dup(get_ok_method->routing_key);
+ envelope.channel = channel_resource->channel_id;
+ envelope.consumer_tag = amqp_empty_bytes;
+ envelope.delivery_tag = get_ok_method->delivery_tag;
+ envelope.redelivered = get_ok_method->redelivered;
+ envelope.exchange = amqp_bytes_malloc_dup(get_ok_method->exchange);
+ envelope.routing_key = amqp_bytes_malloc_dup(get_ok_method->routing_key);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- res = amqp_read_message(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- &envelope.message,
- 0
- );
+ res = amqp_read_message(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ &envelope.message,
+ 0
+ );
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- amqp_destroy_envelope(&envelope);
- return;
- }
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ amqp_destroy_envelope(&envelope);
+ return;
+ }
- PHP5to7_MAYBE_INIT(message);
+ ZVAL_UNDEF(&message);
- convert_amqp_envelope_to_zval(&envelope, PHP5to7_MAYBE_PTR(message) TSRMLS_CC);
+ convert_amqp_envelope_to_zval(&envelope, &message);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- amqp_destroy_envelope(&envelope);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ amqp_destroy_envelope(&envelope);
- RETVAL_ZVAL(PHP5to7_MAYBE_PTR(message), 1, 0);
- PHP5to7_MAYBE_DESTROY(message);
+ RETVAL_ZVAL(&message, 1, 0);
+ zval_ptr_dtor(&message);
}
/* }}} */
-/* {{{ proto array AMQPQueue::consume([callback, flags = , consumer_tag, bool no_block = 0]);
+/* {{{ proto array AMQPQueue::consume([callback, flags = , consumer_tag]);
consume the message
*/
static PHP_METHOD(amqp_queue_class, consume)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- PHP5to7_zval_t *consumer_tag_zv = NULL;
- PHP5to7_zval_t current_channel_zv PHP5to7_MAYBE_SET_TO_NULL;
-
- PHP5to7_zval_t *current_queue_zv = NULL;
-
- amqp_channel_resource *channel_resource;
- amqp_channel_resource *current_channel_resource;
-
- zend_fcall_info fci = empty_fcall_info;
- zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
-
- zend_bool no_block = 0;
-
- amqp_table_t *arguments;
-
- char *consumer_tag = NULL;
- PHP5to7_param_str_len_type_t consumer_tag_len = 0;
- PHP5to7_param_long_type_t flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|f!lsb",
- &fci, &fci_cache,
- &flags,
- &consumer_tag, &consumer_tag_len,
- &no_block) == FAILURE) {
- return;
- }
-
- zval *channel_zv = PHP_AMQP_READ_THIS_PROP("channel");
- zval *consumers = zend_read_property(amqp_channel_class_entry, PHP5to8_OBJ_PROP(channel_zv), ZEND_STRL("consumers"), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC);
-
- if (IS_ARRAY != Z_TYPE_P(consumers)) {
- zend_throw_exception(amqp_queue_exception_class_entry, "Invalid channel consumers, forgot to call channel constructor?", 0 TSRMLS_CC);
- return;
- }
-
- amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(channel_zv);
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channel_zv);
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not get channel.");
-
- if (!(AMQP_JUST_CONSUME & flags)) {
- /* Setup the consume */
- arguments = php_amqp_type_convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments") TSRMLS_CC);
-
- amqp_basic_consume_ok_t *r = amqp_basic_consume(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
- (consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag) : amqp_empty_bytes), /* Consumer tag */
- (AMQP_NOLOCAL & flags) ? 1 : 0, /* No local */
- (AMQP_AUTOACK & flags) ? 1 : 0, /* no_ack, aka AUTOACK */
- PHP_AMQP_READ_THIS_PROP_BOOL("exclusive"),
- *arguments
- );
-
- php_amqp_type_free_amqp_table(arguments);
-
- if (!r) {
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
-
- zend_throw_exception(amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- char *key;
- key = estrndup((char *) r->consumer_tag.bytes, (unsigned) r->consumer_tag.len);
-
- if (PHP5to7_ZEND_HASH_FIND(Z_ARRVAL_P(consumers), (const char *) key, PHP5to7_ZEND_HASH_STRLEN(r->consumer_tag.len), consumer_tag_zv)) {
- // This should never happen as AMQP server guarantees that consumer tag is unique within channel
- zend_throw_exception(amqp_exception_class_entry, "Duplicate consumer tag", 0 TSRMLS_CC);
- efree(key);
- return;
- }
-
- PHP5to7_zval_t tmp PHP5to7_MAYBE_SET_TO_NULL;
-
-#if PHP_MAJOR_VERSION >= 7
- PHP5to7_MAYBE_INIT(tmp);
- ZVAL_COPY(PHP5to7_MAYBE_PTR(tmp), getThis());
-#else
- tmp = getThis();
- Z_ADDREF_P(tmp);
-#endif
-
- PHP5to7_ZEND_HASH_ADD(Z_ARRVAL_P(consumers),
- (const char *) key,
- PHP5to7_ZEND_HASH_STRLEN(r->consumer_tag.len),
- PHP5to7_MAYBE_PTR(tmp),
- sizeof(PHP5to7_MAYBE_PTR_TYPE)
- );
-
- efree(key);
-
- /* Set the consumer tag name, in case it is an autogenerated consumer tag name */
- zend_update_property_stringl(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("consumer_tag"), (const char *) r->consumer_tag.bytes, (PHP5to7_param_str_len_type_t) r->consumer_tag.len TSRMLS_CC);
- }
-
- if (!ZEND_FCI_INITIALIZED(fci)) {
- /* Callback not set, we have nothing to do - real consuming may happens later */
- return;
- }
-
- struct timeval tv = {0};
- struct timeval *tv_ptr = &tv;
-
- double read_timeout = PHP_AMQP_READ_OBJ_PROP_DOUBLE(amqp_connection_class_entry, PHP_AMQP_READ_THIS_PROP("connection"), "read_timeout");
+ zval rv;
+
+ zval current_channel_zv;
+
+ zval *current_queue_zv = NULL;
+
+ amqp_channel_resource *channel_resource;
+ amqp_channel_resource *current_channel_resource;
+
+ zend_fcall_info fci = empty_fcall_info;
+ zend_fcall_info_cache fci_cache = empty_fcall_info_cache;
+
+ amqp_table_t *arguments;
+
+ char *consumer_tag = NULL;
+ size_t consumer_tag_len = 0;
+ zend_long flags = INI_INT("amqp.auto_ack") ? AMQP_AUTOACK : AMQP_NOPARAM;
+ bool flags_is_null = 1;
+
+ if (zend_parse_parameters(
+ ZEND_NUM_ARGS(),
+ "|f!l!s!",
+ &fci,
+ &fci_cache,
+ &flags,
+ &flags_is_null,
+ &consumer_tag,
+ &consumer_tag_len
+ ) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ zval *channel_zv = PHP_AMQP_READ_THIS_PROP("channel");
+ zval *consumers =
+ zend_read_property(amqp_channel_class_entry, PHP_AMQP_COMPAT_OBJ_P(channel_zv), ZEND_STRL("consumers"), 0, &rv);
+
+ if (IS_ARRAY != Z_TYPE_P(consumers)) {
+ zend_throw_exception(
+ amqp_queue_exception_class_entry,
+ "Invalid channel consumers, forgot to call channel constructor?",
+ 0
+ );
+ RETURN_THROWS();
+ }
+
+ amqp_channel_object *channel = PHP_AMQP_GET_CHANNEL(channel_zv);
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channel_zv);
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not get channel.");
+
+ if (!(AMQP_JUST_CONSUME & flags)) {
+ /* Set up the consume loop */
+ arguments = php_amqp_type_convert_zval_to_amqp_table(PHP_AMQP_READ_THIS_PROP("arguments"));
+
+ amqp_basic_consume_ok_t *r = amqp_basic_consume(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name") : ""),
+ (consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag) : amqp_empty_bytes), /* Consumer tag */
+ (AMQP_NOLOCAL & flags) ? 1 : 0, /* No local */
+ (AMQP_AUTOACK & flags) ? 1 : 0, /* no_ack, aka AUTOACK */
+ PHP_AMQP_READ_THIS_PROP_BOOL("exclusive"),
+ *arguments
+ );
+
+ php_amqp_type_free_amqp_table(arguments);
+
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ zend_throw_exception(amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code));
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ RETURN_THROWS();
+ }
+
+ char *key;
+ key = estrndup((char *) r->consumer_tag.bytes, (unsigned) r->consumer_tag.len);
+
+ if (zend_hash_str_find(Z_ARRVAL_P(consumers), key, r->consumer_tag.len) != NULL) {
+ // This should never happen as AMQP server guarantees that consumer tag is unique within channel
+ zend_throw_exception(amqp_exception_class_entry, "Duplicate consumer tag", 0);
+ efree(key);
+ RETURN_THROWS();
+ }
+
+ zval tmp;
+
+ ZVAL_UNDEF(&tmp);
+ ZVAL_COPY(&tmp, getThis());
+
+ zend_hash_str_add(Z_ARRVAL_P(consumers), key, r->consumer_tag.len, &tmp);
+ efree(key);
+
+ /* Set the consumer tag name, in case it is an autogenerated consumer tag name */
+ zend_update_property_stringl(
+ this_ce,
+ PHP_AMQP_COMPAT_OBJ_P(getThis()),
+ ZEND_STRL("consumerTag"),
+ (const char *) r->consumer_tag.bytes,
+ (size_t) r->consumer_tag.len
+ );
+ }
+
+ if (!ZEND_FCI_INITIALIZED(fci)) {
+ /* Callback not set, we have nothing to do - real consuming may happen later */
+ return;
+ }
+
+ struct timeval tv = {0};
+ struct timeval *tv_ptr = &tv;
+
+ double read_timeout = PHP_AMQP_READ_OBJ_PROP_DOUBLE(
+ amqp_connection_class_entry,
+ PHP_AMQP_READ_THIS_PROP("connection"),
+ "readTimeout"
+ );
if (read_timeout > 0) {
- tv.tv_sec = (long int) read_timeout;
- tv.tv_usec = (long int) ((read_timeout - tv.tv_sec) * 1000000);
- } else {
- tv_ptr = NULL;
- }
-
- while(1) {
- /* Initialize the message */
- PHP5to7_zval_t message PHP5to7_MAYBE_SET_TO_NULL;
-
- amqp_envelope_t envelope;
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- amqp_rpc_reply_t res = amqp_consume_message(channel_resource->connection_resource->connection_state, &envelope, tv_ptr, 0);
-
- if (AMQP_RESPONSE_LIBRARY_EXCEPTION == res.reply_type && AMQP_STATUS_TIMEOUT == res.library_error) {
- if (no_block) {
- amqp_destroy_envelope(&envelope);
- break;
- }
-
- zend_throw_exception(amqp_queue_exception_class_entry, "Consumer timeout exceed", 0 TSRMLS_CC);
+ tv.tv_sec = (long int) read_timeout;
+ tv.tv_usec = (long int) ((read_timeout - tv.tv_sec) * 1000000);
+ } else {
+ tv_ptr = NULL;
+ }
- amqp_destroy_envelope(&envelope);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ while (1) {
+ /* Initialize the message */
+ zval message;
- if (PHP_AMQP_MAYBE_ERROR_RECOVERABLE(res, channel_resource)) {
+ amqp_envelope_t envelope;
- if (PHP_AMQP_IS_ERROR_RECOVERABLE(res, channel_resource, channel)) {
- /* In case no message was received, continue the loop */
- amqp_destroy_envelope(&envelope);
-
- continue;
- } else {
- /* Mark connection resource as closed to prevent sending any further requests */
- channel_resource->connection_resource->is_connected = '\0';
-
- /* Close connection with all its channels */
- php_amqp_disconnect_force(channel_resource->connection_resource TSRMLS_CC);
- }
-
- php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC);
-
- amqp_destroy_envelope(&envelope);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- return;
- }
-
- PHP5to7_MAYBE_INIT(message);
- convert_amqp_envelope_to_zval(&envelope, PHP5to7_MAYBE_PTR(message) TSRMLS_CC);
-
- current_channel_resource = channel_resource->connection_resource->slots[envelope.channel - 1];
-
- if (!current_channel_resource) {
- // This should never happen, but just in case
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, "Orphaned channel. Please, report a bug.", 0 TSRMLS_CC);
- amqp_destroy_envelope(&envelope);
- break;
- }
-
-#if PHP_MAJOR_VERSION >= 7
- PHP5to7_MAYBE_INIT(current_channel_zv);
- ZVAL_OBJ(¤t_channel_zv, ¤t_channel_resource->parent->zo);
-#else
- current_channel_zv = current_channel_resource->parent->this_ptr;
-#endif
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- consumers = zend_read_property(amqp_channel_class_entry, PHP5to8_OBJ_PROP(PHP5to7_MAYBE_PTR(current_channel_zv)), ZEND_STRL("consumers"), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC);
+ amqp_rpc_reply_t res =
+ amqp_consume_message(channel_resource->connection_resource->connection_state, &envelope, tv_ptr, 0);
- if (IS_ARRAY != Z_TYPE_P(consumers)) {
- zend_throw_exception(amqp_queue_exception_class_entry, "Invalid channel consumers, forgot to call channel constructor?", 0 TSRMLS_CC);
- amqp_destroy_envelope(&envelope);
- break;
- }
+ if (AMQP_RESPONSE_NORMAL != res.reply_type) {
- char *key;
- key = estrndup((char *)envelope.consumer_tag.bytes, (unsigned) envelope.consumer_tag.len);
+ if (AMQP_RESPONSE_LIBRARY_EXCEPTION == res.reply_type) {
- if (!PHP5to7_ZEND_HASH_FIND(Z_ARRVAL_P(consumers), key, PHP5to7_ZEND_HASH_STRLEN(envelope.consumer_tag.len), current_queue_zv)) {
- PHP5to7_zval_t exception PHP5to7_MAYBE_SET_TO_NULL;
- PHP5to7_MAYBE_INIT(exception);
- object_init_ex(PHP5to7_MAYBE_PTR(exception), amqp_envelope_exception_class_entry);
- zend_update_property_string(zend_exception_get_default(TSRMLS_C), PHP5to8_OBJ_PROP(PHP5to7_MAYBE_PTR(exception)), ZEND_STRL("message"), "Orphaned envelope" TSRMLS_CC);
- zend_update_property(amqp_envelope_exception_class_entry, PHP5to8_OBJ_PROP(PHP5to7_MAYBE_PTR(exception)), ZEND_STRL("envelope"), PHP5to7_MAYBE_PTR(message) TSRMLS_CC);
+ // Special case consumer timeout: do not close connection but end consumption
+ if (AMQP_STATUS_TIMEOUT == res.library_error) {
+ zend_throw_exception(amqp_queue_exception_class_entry, "Consumer timeout exceed", 0);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- zend_throw_exception_object(PHP5to7_MAYBE_PTR(exception) TSRMLS_CC);
-
- PHP5to7_MAYBE_DESTROY(message);
-
- amqp_destroy_envelope(&envelope);
- efree(key);
- break;
- }
-
- efree(key);
- amqp_destroy_envelope(&envelope);
-
- /* Make the callback */
- PHP5to7_zval_t params PHP5to7_MAYBE_SET_TO_NULL;
- PHP5to7_zval_t retval PHP5to7_MAYBE_SET_TO_NULL;
-
- /* Build the parameter array */
- PHP5to7_MAYBE_INIT(params);
- PHP5to7_ARRAY_INIT(params);
-
- /* Dump it into the params array */
- add_index_zval(PHP5to7_MAYBE_PTR(params), 0, PHP5to7_MAYBE_PTR(message));
- Z_ADDREF_P( PHP5to7_MAYBE_PTR(message));
-
- /* Add a pointer to the queue: */
- add_index_zval(PHP5to7_MAYBE_PTR(params), 1, PHP5to7_MAYBE_DEREF(current_queue_zv));
- Z_ADDREF_P(PHP5to7_MAYBE_DEREF(current_queue_zv));
-
-
- /* Convert everything to be callable */
- zend_fcall_info_args(&fci, PHP5to7_MAYBE_PTR(params) TSRMLS_CC);
- /* Initialize the return value pointer */
-
- PHP5to7_SET_FCI_RETVAL_PTR(fci, PHP5to7_MAYBE_PTR(retval));
-
- /* Call the function, and track the return value */
- if (zend_call_function(&fci, &fci_cache TSRMLS_CC) == SUCCESS && PHP5to7_CHECK_FCI_RETVAL_PTR(fci)) {
- RETVAL_ZVAL(PHP5to7_MAYBE_PTR(retval), 1, 1);
- }
-
- /* Clean up our mess */
- zend_fcall_info_args_clear(&fci, 1);
- PHP5to7_MAYBE_DESTROY(params);
- PHP5to7_MAYBE_DESTROY(message);
+ // Handle a potentially recoverable error
+ if (AMQP_STATUS_UNEXPECTED_STATE == res.library_error &&
+ PHP_AMQP_RESOURCE_RESPONSE_OK <=
+ php_amqp_connection_resource_error_advanced(res, &PHP_AMQP_G(error_message), channel)) {
+ continue;
+ }
+ }
- /* Check if user land function wants to bail */
- if (EG(exception) || PHP5to7_IS_FALSE_P(return_value)) {
- break;
- }
- }
+ /* Mark connection resource as closed to prevent sending any further requests */
+ channel_resource->connection_resource->is_connected = '\0';
+ php_amqp_disconnect_force(channel_resource->connection_resource);
+ php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+
+ RETURN_THROWS();
+ }
+
+ ZVAL_UNDEF(&message);
+ convert_amqp_envelope_to_zval(&envelope, &message);
+
+ current_channel_resource = channel_resource->connection_resource->slots[envelope.channel - 1];
+
+ if (!current_channel_resource) {
+ // This should never happen, but just in case
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ "Orphaned channel. Please, report a bug.",
+ 0
+ );
+ amqp_destroy_envelope(&envelope);
+ break;
+ }
+
+ ZVAL_UNDEF(¤t_channel_zv);
+ ZVAL_OBJ(¤t_channel_zv, ¤t_channel_resource->parent->zo);
+
+ consumers = zend_read_property(
+ amqp_channel_class_entry,
+ PHP_AMQP_COMPAT_OBJ_P(¤t_channel_zv),
+ ZEND_STRL("consumers"),
+ 0,
+ &rv
+ );
+
+ if (IS_ARRAY != Z_TYPE_P(consumers)) {
+ zend_throw_exception(
+ amqp_queue_exception_class_entry,
+ "Invalid channel consumers, forgot to call channel constructor?",
+ 0
+ );
+ amqp_destroy_envelope(&envelope);
+ break;
+ }
+
+ char *key;
+ key = estrndup((char *) envelope.consumer_tag.bytes, (unsigned) envelope.consumer_tag.len);
+
+ if ((current_queue_zv = zend_hash_str_find(Z_ARRVAL_P(consumers), key, envelope.consumer_tag.len)) == NULL) {
+ zval exception;
+ ZVAL_UNDEF(&exception);
+ object_init_ex(&exception, amqp_envelope_exception_class_entry);
+ zend_update_property_string(
+ zend_ce_exception,
+ PHP_AMQP_COMPAT_OBJ_P(&exception),
+ ZEND_STRL("message"),
+ "Orphaned envelope"
+ );
+ zend_update_property(
+ amqp_envelope_exception_class_entry,
+ PHP_AMQP_COMPAT_OBJ_P(&exception),
+ ZEND_STRL("envelope"),
+ &message
+ );
+
+ zend_throw_exception_object(&exception);
+
+ zval_ptr_dtor(&message);
+
+ amqp_destroy_envelope(&envelope);
+ efree(key);
+ break;
+ }
+
+ efree(key);
+ amqp_destroy_envelope(&envelope);
+
+ /* Make the callback */
+ zval params;
+ zval retval;
+
+ /* Build the parameter array */
+ ZVAL_UNDEF(¶ms);
+ array_init(¶ms);
+
+ /* Dump it into the params array */
+ add_index_zval(¶ms, 0, &message);
+ Z_ADDREF_P(&message);
+
+ /* Add a pointer to the queue: */
+ add_index_zval(¶ms, 1, current_queue_zv);
+ Z_ADDREF_P(current_queue_zv);
+
+
+ /* Convert everything to be callable */
+ zend_fcall_info_args(&fci, ¶ms);
+ /* Initialize the return value pointer */
+
+ fci.retval = &retval;
+
+ zend_call_function(&fci, &fci_cache);
+
+ /* Clean up our mess */
+ zend_fcall_info_args_clear(&fci, 1);
+ zval_ptr_dtor(¶ms);
+ zval_ptr_dtor(&message);
+
+ /* Check if user land function wants to bail */
+ if (EG(exception) || Z_TYPE_P(&retval) == IS_FALSE) {
+ break;
+ }
+ }
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -768,42 +824,46 @@ static PHP_METHOD(amqp_queue_class, consume)
*/
static PHP_METHOD(amqp_queue_class, ack)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
-
- PHP5to7_param_long_type_t deliveryTag = 0;
- PHP5to7_param_long_type_t flags = AMQP_NOPARAM;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &deliveryTag, &flags ) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not ack message.");
-
- /* NOTE: basic.ack is asynchronous and thus will not indicate failure if something goes wrong on the broker */
- int status = amqp_basic_ack(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- (uint64_t) deliveryTag,
- (AMQP_MULTIPLE & flags) ? 1 : 0
- );
-
- if (status != AMQP_STATUS_OK) {
- /* Emulate library error */
- amqp_rpc_reply_t res;
- res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- res.library_error = status;
-
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
-
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- RETURN_TRUE;
+ zval rv;
+
+ amqp_channel_resource *channel_resource;
+
+ zend_long deliveryTag = 0;
+ zend_long flags = AMQP_NOPARAM;
+ bool flags_is_null = 1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l!", &deliveryTag, &flags, &flags_is_null) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not ack message.");
+
+ /* NOTE: basic.ack is asynchronous and thus will not indicate failure if something goes wrong on the broker */
+ int status = amqp_basic_ack(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ (uint64_t) deliveryTag,
+ (AMQP_MULTIPLE & flags) ? 1 : 0
+ );
+
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
}
/* }}} */
@@ -813,43 +873,47 @@ static PHP_METHOD(amqp_queue_class, ack)
*/
static PHP_METHOD(amqp_queue_class, nack)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
-
- PHP5to7_param_long_type_t deliveryTag = 0;
- PHP5to7_param_long_type_t flags = AMQP_NOPARAM;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &deliveryTag, &flags ) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not nack message.");
-
- /* NOTE: basic.nack is asynchronous and thus will not indicate failure if something goes wrong on the broker */
- int status = amqp_basic_nack(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- (uint64_t) deliveryTag,
- (AMQP_MULTIPLE & flags) ? 1 : 0,
- (AMQP_REQUEUE & flags) ? 1 : 0
- );
-
- if (status != AMQP_STATUS_OK) {
- /* Emulate library error */
- amqp_rpc_reply_t res;
- res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- res.library_error = status;
-
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
-
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- RETURN_TRUE;
+ zval rv;
+
+ amqp_channel_resource *channel_resource;
+
+ zend_long deliveryTag = 0;
+ zend_long flags = AMQP_NOPARAM;
+ bool flags_is_null = 1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l!", &deliveryTag, &flags, &flags_is_null) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not nack message.");
+
+ /* NOTE: basic.nack is asynchronous and thus will not indicate failure if something goes wrong on the broker */
+ int status = amqp_basic_nack(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ (uint64_t) deliveryTag,
+ (AMQP_MULTIPLE & flags) ? 1 : 0,
+ (AMQP_REQUEUE & flags) ? 1 : 0
+ );
+
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
}
/* }}} */
@@ -859,42 +923,46 @@ static PHP_METHOD(amqp_queue_class, nack)
*/
static PHP_METHOD(amqp_queue_class, reject)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
-
- PHP5to7_param_long_type_t deliveryTag = 0;
- PHP5to7_param_long_type_t flags = AMQP_NOPARAM;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &deliveryTag, &flags) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not reject message.");
-
- /* NOTE: basic.reject is asynchronous and thus will not indicate failure if something goes wrong on the broker */
- int status = amqp_basic_reject(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- (uint64_t) deliveryTag,
- (AMQP_REQUEUE & flags) ? 1 : 0
- );
-
- if (status != AMQP_STATUS_OK) {
- /* Emulate library error */
- amqp_rpc_reply_t res;
- res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
- res.library_error = status;
-
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
-
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- RETURN_TRUE;
+ zval rv;
+
+ amqp_channel_resource *channel_resource;
+
+ zend_long deliveryTag = 0;
+ zend_long flags = AMQP_NOPARAM;
+ bool flags_is_null = 1;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l!", &deliveryTag, &flags, &flags_is_null) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not reject message.");
+
+ /* NOTE: basic.reject is asynchronous and thus will not indicate failure if something goes wrong on the broker */
+ int status = amqp_basic_reject(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ (uint64_t) deliveryTag,
+ (AMQP_REQUEUE & flags) ? 1 : 0
+ );
+
+ if (status != AMQP_STATUS_OK) {
+ /* Emulate library error */
+ amqp_rpc_reply_t res;
+ res.reply_type = AMQP_RESPONSE_LIBRARY_EXCEPTION;
+ res.library_error = status;
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
}
/* }}} */
@@ -904,162 +972,216 @@ purge queue
*/
static PHP_METHOD(amqp_queue_class, purge)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
-
- if (zend_parse_parameters_none() == FAILURE) {
- return;
- }
+ zval rv;
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not purge queue.");
+ amqp_channel_resource *channel_resource;
- amqp_queue_purge_ok_t *r = amqp_queue_purge(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name"))
- );
+ PHP_AMQP_NOPARAMS()
- if (!r) {
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not purge queue.");
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
+ amqp_queue_purge_ok_t *r = amqp_queue_purge(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name") : "")
+ );
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- /* long message_count = r->message_count; */
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- /* RETURN_LONG(message_count) */;
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- /* BC */
- RETURN_TRUE;
+ RETURN_LONG(r->message_count);
}
/* }}} */
-/* {{{ proto int AMQPQueue::cancel([string consumer_tag]);
+/* {{{ proto int AMQPQueue::cancel([string consumerTag]);
cancel queue to consumer
*/
static PHP_METHOD(amqp_queue_class, cancel)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- amqp_channel_resource *channel_resource;
- PHP5to7_zval_t *tmp = NULL;
+ zval rv;
+
+ amqp_channel_resource *channel_resource;
+
+ char *consumer_tag = NULL;
+ size_t consumer_tag_len = 0;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|s", &consumer_tag, &consumer_tag_len) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ zval *channel_zv = PHP_AMQP_READ_THIS_PROP("channel");
+ zval *consumers =
+ zend_read_property(amqp_channel_class_entry, PHP_AMQP_COMPAT_OBJ_P(channel_zv), ZEND_STRL("consumers"), 0, &rv);
+ bool previous_consumer_tag_exists = (bool) (IS_STRING == Z_TYPE_P(PHP_AMQP_READ_THIS_PROP("consumerTag")));
+
+ if (IS_ARRAY != Z_TYPE_P(consumers)) {
+ zend_throw_exception(
+ amqp_queue_exception_class_entry,
+ "Invalid channel consumers, forgot to call channel constructor?",
+ 0
+ );
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channel_zv);
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not cancel queue.");
+
+ if (!consumer_tag_len && (!previous_consumer_tag_exists || !PHP_AMQP_READ_THIS_PROP_STRLEN("consumerTag"))) {
+ return;
+ }
+
+ amqp_basic_cancel_ok_t *r = amqp_basic_cancel(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag)
+ : amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("consumerTag"))
+ );
+
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
+
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
+
+ if (!consumer_tag_len ||
+ (previous_consumer_tag_exists && strcmp(consumer_tag, PHP_AMQP_READ_THIS_PROP_STR("consumerTag")) == 0)) {
+ zend_update_property_null(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("consumerTag"));
+ }
+
+ zend_hash_str_del_ind(Z_ARRVAL_P(consumers), r->consumer_tag.bytes, r->consumer_tag.len);
- char *consumer_tag = NULL; PHP5to7_param_str_len_type_t consumer_tag_len = 0;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &consumer_tag, &consumer_tag_len) == FAILURE) {
- return;
- }
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+}
+/* }}} */
- zval *channel_zv = PHP_AMQP_READ_THIS_PROP("channel");
- zval *consumers = zend_read_property(amqp_channel_class_entry, PHP5to8_OBJ_PROP(channel_zv), ZEND_STRL("consumers"), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC);
- zend_bool has_consumer_tag = (zend_bool) (IS_STRING == Z_TYPE_P(PHP_AMQP_READ_THIS_PROP("consumer_tag")));
+/* {{{ proto int AMQPQueue::recover([boolean requeue]);
+recover messages already delivered to the consumer
+*/
+static PHP_METHOD(amqp_queue_class, recover)
+{
+ zval rv;
- if (IS_ARRAY != Z_TYPE_P(consumers)) {
- zend_throw_exception(amqp_queue_exception_class_entry, "Invalid channel consumers, forgot to call channel constructor?", 0 TSRMLS_CC);
- return;
- }
+ amqp_channel_resource *channel_resource;
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channel_zv);
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not cancel queue.");
+ bool requeue = 1;
- if (!consumer_tag_len && (!has_consumer_tag || !PHP_AMQP_READ_THIS_PROP_STRLEN("consumer_tag"))) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &requeue) == FAILURE) {
+ RETURN_THROWS();
+ }
- amqp_basic_cancel_ok_t *r = amqp_basic_cancel(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- consumer_tag_len > 0 ? amqp_cstring_bytes(consumer_tag) : amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("consumer_tag"))
- );
+ zval *channel_zv = PHP_AMQP_READ_THIS_PROP("channel");
- if (!r) {
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(channel_zv);
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not recover messages.");
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
+ amqp_basic_recover_ok_t *r = amqp_basic_recover(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ requeue
+ );
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- if (!consumer_tag_len || (has_consumer_tag && strcmp(consumer_tag, PHP_AMQP_READ_THIS_PROP_STR("consumer_tag")) != 0)) {
- zend_update_property_null(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("consumer_tag") TSRMLS_CC);
- }
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
- char *key;
- key = estrndup((char *)r->consumer_tag.bytes, (unsigned) r->consumer_tag.len);
- PHP5to7_ZEND_HASH_DEL(Z_ARRVAL_P(consumers), (const char *) key, PHP5to7_ZEND_HASH_STRLEN(r->consumer_tag.len));
- efree(key);
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- RETURN_TRUE;
}
/* }}} */
-
/* {{{ proto int AMQPQueue::unbind(string exchangeName, [string routingKey, array arguments]);
unbind queue from exchange
*/
static PHP_METHOD(amqp_queue_class, unbind)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
-
- zval *zvalArguments = NULL;
- amqp_channel_resource *channel_resource;
-
- char *exchange_name; PHP5to7_param_str_len_type_t exchange_name_len;
- char *keyname = NULL; PHP5to7_param_str_len_type_t keyname_len = 0;
-
- amqp_table_t *arguments = NULL;
+ zval rv;
+
+ zval *zvalArguments = NULL;
+ amqp_channel_resource *channel_resource;
+
+ char *exchange_name;
+ size_t exchange_name_len;
+ char *keyname = NULL;
+ size_t keyname_len = 0;
+
+ amqp_table_t *arguments = NULL;
+
+ if (zend_parse_parameters(
+ ZEND_NUM_ARGS(),
+ "s|s!a",
+ &exchange_name,
+ &exchange_name_len,
+ &keyname,
+ &keyname_len,
+ &zvalArguments
+ ) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not unbind queue.");
+
+ if (zvalArguments) {
+ arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments);
+ }
+
+ amqp_queue_unbind(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name") : ""),
+ (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes),
+ (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
+ (arguments ? *arguments : amqp_empty_table)
+ );
+
+ if (arguments) {
+ php_amqp_type_free_amqp_table(arguments);
+ }
+
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+
+ if (PHP_AMQP_MAYBE_ERROR(res, channel_resource, channel_resource->connection_resource)) {
+ php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|sa",
- &exchange_name, &exchange_name_len,
- &keyname, &keyname_len,
- &zvalArguments) == FAILURE) {
- return;
- }
-
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not unbind queue.");
-
- if (zvalArguments) {
- arguments = php_amqp_type_convert_zval_to_amqp_table(zvalArguments TSRMLS_CC);
- }
-
- amqp_queue_unbind(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
- (exchange_name_len > 0 ? amqp_cstring_bytes(exchange_name) : amqp_empty_bytes),
- (keyname_len > 0 ? amqp_cstring_bytes(keyname) : amqp_empty_bytes),
- (arguments ? *arguments : amqp_empty_table)
- );
-
- if (arguments) {
- php_amqp_type_free_amqp_table(arguments);
- }
-
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
-
- if (PHP_AMQP_MAYBE_ERROR(res, channel_resource)) {
- php_amqp_zend_throw_exception_short(res, amqp_queue_exception_class_entry TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
-
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
-
- RETURN_TRUE;
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
}
/* }}} */
@@ -1069,44 +1191,50 @@ delete queue and return the number of messages deleted in it
*/
static PHP_METHOD(amqp_queue_class, delete)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
+ zval rv;
- amqp_channel_resource *channel_resource;
+ amqp_channel_resource *channel_resource;
- PHP5to7_param_long_type_t flags = AMQP_NOPARAM;
+ zend_long flags = AMQP_NOPARAM;
+ bool flags_is_null = 1;
- PHP5to7_param_long_type_t message_count;
+ zend_long message_count;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
- return;
- }
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l!", &flags, &flags_is_null) == FAILURE) {
+ RETURN_THROWS();
+ }
- channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
- PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not delete queue.");
+ channel_resource = PHP_AMQP_GET_CHANNEL_RESOURCE(PHP_AMQP_READ_THIS_PROP("channel"));
+ PHP_AMQP_VERIFY_CHANNEL_RESOURCE(channel_resource, "Could not delete queue.");
- amqp_queue_delete_ok_t * r = amqp_queue_delete(
- channel_resource->connection_resource->connection_state,
- channel_resource->channel_id,
- amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STR("name")),
- (AMQP_IFUNUSED & flags) ? 1 : 0,
- (AMQP_IFEMPTY & flags) ? 1 : 0
- );
+ amqp_queue_delete_ok_t *r = amqp_queue_delete(
+ channel_resource->connection_resource->connection_state,
+ channel_resource->channel_id,
+ amqp_cstring_bytes(PHP_AMQP_READ_THIS_PROP_STRLEN("name") ? PHP_AMQP_READ_THIS_PROP_STR("name") : ""),
+ (AMQP_IFUNUSED & flags) ? 1 : 0,
+ (AMQP_IFEMPTY & flags) ? 1 : 0
+ );
- if (!r) {
- amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
+ if (!r) {
+ amqp_rpc_reply_t res = amqp_get_rpc_reply(channel_resource->connection_resource->connection_state);
- php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource TSRMLS_CC);
+ php_amqp_error(res, &PHP_AMQP_G(error_message), channel_resource->connection_resource, channel_resource);
- php_amqp_zend_throw_exception(res, amqp_queue_exception_class_entry, PHP_AMQP_G(error_message), PHP_AMQP_G(error_code) TSRMLS_CC);
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- return;
- }
+ php_amqp_zend_throw_exception(
+ res,
+ amqp_queue_exception_class_entry,
+ PHP_AMQP_G(error_message),
+ PHP_AMQP_G(error_code)
+ );
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ return;
+ }
- message_count = r->message_count;
+ message_count = r->message_count;
- php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
+ php_amqp_maybe_release_buffers_on_channel(channel_resource->connection_resource, channel_resource);
- RETURN_LONG(message_count);
+ RETURN_LONG(message_count);
}
/* }}} */
@@ -1114,9 +1242,9 @@ static PHP_METHOD(amqp_queue_class, delete)
Get the AMQPChannel object in use */
static PHP_METHOD(amqp_queue_class, getChannel)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("channel");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("channel");
}
/* }}} */
@@ -1124,9 +1252,9 @@ static PHP_METHOD(amqp_queue_class, getChannel)
Get the AMQPConnection object in use */
static PHP_METHOD(amqp_queue_class, getConnection)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("connection");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("connection");
}
/* }}} */
@@ -1134,181 +1262,179 @@ static PHP_METHOD(amqp_queue_class, getConnection)
Get latest consumer tag*/
static PHP_METHOD(amqp_queue_class, getConsumerTag)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
- PHP_AMQP_RETURN_THIS_PROP("consumer_tag");
+ zval rv;
+ PHP_AMQP_NOPARAMS()
+ PHP_AMQP_RETURN_THIS_PROP("consumerTag");
}
/* }}} */
/* amqp_queue_class ARG_INFO definition */
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class__construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_OBJ_INFO(0, amqp_channel, AMQPChannel, 0)
+ ZEND_ARG_OBJ_INFO(0, channel, AMQPChannel, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_getName, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setName, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, queue_name)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_setName, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_getFlags, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setFlags, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_setFlags, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, flags, IS_LONG, 1)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, argument)
+ ZEND_ARG_TYPE_INFO(0, argumentName, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_getArguments, ZEND_SEND_BY_VAL, 0, IS_ARRAY, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 2)
- ZEND_ARG_INFO(0, key)
- ZEND_ARG_INFO(0, value)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_setArgument, ZEND_SEND_BY_VAL, 2, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, argumentName, IS_STRING, 0)
+ ZEND_ARG_INFO(0, argumentValue)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_hasArgument, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, key)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_removeArgument, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, argumentName, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_setArguments, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_ARRAY_INFO(0, arguments, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_hasArgument, ZEND_SEND_BY_VAL, 1, _IS_BOOL, 0)
+ ZEND_ARG_TYPE_INFO(0, argumentName, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_declareQueue, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_setArguments, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_ARRAY_INFO(0, arguments, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_bind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, exchange_name)
- ZEND_ARG_INFO(0, routing_key)
- ZEND_ARG_INFO(0, arguments)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_declareQueue, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_get, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_bind, ZEND_RETURN_VALUE, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, exchangeName, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, routingKey, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arguments, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_consume, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, callback)
- ZEND_ARG_INFO(0, flags)
- ZEND_ARG_INFO(0, consumer_tag)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_amqp_queue_class_get, ZEND_SEND_BY_VAL, 0, AMQPEnvelope, 1)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_ack, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, delivery_tag)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_consume, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, callback, IS_CALLABLE, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, consumerTag, IS_STRING, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_nack, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, delivery_tag)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_ack, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, deliveryTag, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_reject, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, delivery_tag)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_nack, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, deliveryTag, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_purge, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_reject, ZEND_SEND_BY_VAL, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, deliveryTag, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_cancel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
- ZEND_ARG_INFO(0, consumer_tag)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_recover, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, requeue, _IS_BOOL, 0, "true")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_unbind, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
- ZEND_ARG_INFO(0, exchange_name)
- ZEND_ARG_INFO(0, routing_key)
- ZEND_ARG_INFO(0, arguments)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_purge, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_delete, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
- ZEND_ARG_INFO(0, flags)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_cancel, ZEND_SEND_BY_VAL, 0, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, consumerTag, IS_STRING, 0, "\"\"")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getChannel, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_unbind, ZEND_RETURN_VALUE, 1, IS_VOID, 0)
+ ZEND_ARG_TYPE_INFO(0, exchangeName, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, routingKey, IS_STRING, 1, "null")
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, arguments, IS_ARRAY, 0, "[]")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getConnection, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_delete, ZEND_SEND_BY_VAL, 0, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flags, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_queue_class_getConsumerTag, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(arginfo_amqp_queue_class_getChannel, AMQPChannel, 0)
ZEND_END_ARG_INFO()
-zend_function_entry amqp_queue_class_functions[] = {
- PHP_ME(amqp_queue_class, __construct, arginfo_amqp_queue_class__construct, ZEND_ACC_PUBLIC)
-
- PHP_ME(amqp_queue_class, getName, arginfo_amqp_queue_class_getName, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, setName, arginfo_amqp_queue_class_setName, ZEND_ACC_PUBLIC)
-
- PHP_ME(amqp_queue_class, getFlags, arginfo_amqp_queue_class_getFlags, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, setFlags, arginfo_amqp_queue_class_setFlags, ZEND_ACC_PUBLIC)
-
- PHP_ME(amqp_queue_class, getArgument, arginfo_amqp_queue_class_getArgument, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, getArguments, arginfo_amqp_queue_class_getArguments, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, setArgument, arginfo_amqp_queue_class_setArgument, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, setArguments, arginfo_amqp_queue_class_setArguments, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, hasArgument, arginfo_amqp_queue_class_hasArgument, ZEND_ACC_PUBLIC)
-
- PHP_ME(amqp_queue_class, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, bind, arginfo_amqp_queue_class_bind, ZEND_ACC_PUBLIC)
-
- PHP_ME(amqp_queue_class, get, arginfo_amqp_queue_class_get, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, consume, arginfo_amqp_queue_class_consume, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, ack, arginfo_amqp_queue_class_ack, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, nack, arginfo_amqp_queue_class_nack, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, reject, arginfo_amqp_queue_class_reject, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, purge, arginfo_amqp_queue_class_purge, ZEND_ACC_PUBLIC)
-
- PHP_ME(amqp_queue_class, cancel, arginfo_amqp_queue_class_cancel, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, delete, arginfo_amqp_queue_class_delete, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, unbind, arginfo_amqp_queue_class_unbind, ZEND_ACC_PUBLIC)
-
- PHP_ME(amqp_queue_class, getChannel, arginfo_amqp_queue_class_getChannel, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, getConnection, arginfo_amqp_queue_class_getConnection, ZEND_ACC_PUBLIC)
- PHP_ME(amqp_queue_class, getConsumerTag, arginfo_amqp_queue_class_getConsumerTag, ZEND_ACC_PUBLIC)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO(arginfo_amqp_queue_class_getConnection, AMQPConnection, 0)
+ZEND_END_ARG_INFO()
- PHP_MALIAS(amqp_queue_class, declare, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC | ZEND_ACC_DEPRECATED)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_queue_class_getConsumerTag, ZEND_SEND_BY_VAL, 0, IS_STRING, 1)
+ZEND_END_ARG_INFO()
- {NULL, NULL, NULL}
+zend_function_entry amqp_queue_class_functions[] = {
+ PHP_ME(amqp_queue_class, __construct, arginfo_amqp_queue_class__construct, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, getName, arginfo_amqp_queue_class_getName, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, setName, arginfo_amqp_queue_class_setName, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, getFlags, arginfo_amqp_queue_class_getFlags, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, setFlags, arginfo_amqp_queue_class_setFlags, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, getArgument, arginfo_amqp_queue_class_getArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, getArguments, arginfo_amqp_queue_class_getArguments, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, setArgument, arginfo_amqp_queue_class_setArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, removeArgument, arginfo_amqp_queue_class_removeArgument, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, setArguments, arginfo_amqp_queue_class_setArguments, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, hasArgument, arginfo_amqp_queue_class_hasArgument, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC)
+ PHP_MALIAS(amqp_queue_class, declare, declareQueue, arginfo_amqp_queue_class_declareQueue, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, bind, arginfo_amqp_queue_class_bind, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, get, arginfo_amqp_queue_class_get, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, consume, arginfo_amqp_queue_class_consume, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, ack, arginfo_amqp_queue_class_ack, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, nack, arginfo_amqp_queue_class_nack, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, reject, arginfo_amqp_queue_class_reject, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, recover, arginfo_amqp_queue_class_recover, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, purge, arginfo_amqp_queue_class_purge, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, cancel, arginfo_amqp_queue_class_cancel, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, delete, arginfo_amqp_queue_class_delete, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, unbind, arginfo_amqp_queue_class_unbind, ZEND_ACC_PUBLIC)
+
+ PHP_ME(amqp_queue_class, getChannel, arginfo_amqp_queue_class_getChannel, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, getConnection, arginfo_amqp_queue_class_getConnection, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_queue_class, getConsumerTag, arginfo_amqp_queue_class_getConsumerTag, ZEND_ACC_PUBLIC)
+
+ {NULL, NULL, NULL}
};
PHP_MINIT_FUNCTION(amqp_queue)
{
- zend_class_entry ce;
-
- INIT_CLASS_ENTRY(ce, "AMQPQueue", amqp_queue_class_functions);
- this_ce = zend_register_internal_class(&ce TSRMLS_CC);
-
- zend_declare_property_null(this_ce, ZEND_STRL("connection"), ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("channel"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_stringl(this_ce, ZEND_STRL("name"), "", 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_null(this_ce, ZEND_STRL("consumer_tag"), ZEND_ACC_PRIVATE TSRMLS_CC);
-
- zend_declare_property_bool(this_ce, ZEND_STRL("passive"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_bool(this_ce, ZEND_STRL("durable"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- zend_declare_property_bool(this_ce, ZEND_STRL("exclusive"), 0, ZEND_ACC_PRIVATE TSRMLS_CC);
- /* By default, the auto_delete flag should be set */
- zend_declare_property_bool(this_ce, ZEND_STRL("auto_delete"), 1, ZEND_ACC_PRIVATE TSRMLS_CC);
-
-
-
- zend_declare_property_null(this_ce, ZEND_STRL("arguments"), ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "AMQPQueue", amqp_queue_class_functions);
+ this_ce = zend_register_internal_class(&ce);
+
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_OBJ(this_ce, "connection", ZEND_ACC_PRIVATE, AMQPConnection, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_OBJ(this_ce, "channel", ZEND_ACC_PRIVATE, AMQPChannel, 0);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "name", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "consumerTag", ZEND_ACC_PRIVATE, IS_STRING, 1);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "passive", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_FALSE);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "durable", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_FALSE);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "exclusive", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_FALSE);
+ /* By default, the auto_delete flag should be set */
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "autoDelete", ZEND_ACC_PRIVATE, _IS_BOOL, 0, ZVAL_TRUE);
+#if PHP_VERSION_ID >= 80000
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "arguments", ZEND_ACC_PRIVATE, IS_ARRAY, 0, ZVAL_EMPTY_ARRAY);
+#else
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(this_ce, "arguments", ZEND_ACC_PRIVATE, IS_ARRAY, 0, ZVAL_NULL);
+#endif
- return SUCCESS;
+ return SUCCESS;
}
-
-/*
-*Local variables:
-*tab-width: 4
-*tabstop: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_queue.h b/amqp_queue.h
index a8088d01..4a65dcf0 100644
--- a/amqp_queue.h
+++ b/amqp_queue.h
@@ -20,16 +20,8 @@
| - Jonathan Tansavatdi |
+----------------------------------------------------------------------+
*/
-extern zend_class_entry *amqp_queue_class_entry;
+#include "php.h"
+extern zend_class_entry *amqp_queue_class_entry;
PHP_MINIT_FUNCTION(amqp_queue);
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_timestamp.c b/amqp_timestamp.c
index ed07ab6f..2a426ed4 100644
--- a/amqp_timestamp.c
+++ b/amqp_timestamp.c
@@ -21,67 +21,64 @@
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
-#include "php_ini.h"
#include "zend_exceptions.h"
#include "php_amqp.h"
#include "ext/standard/php_math.h"
+#include "amqp_value.h"
zend_class_entry *amqp_timestamp_class_entry;
#define this_ce amqp_timestamp_class_entry
-static const double AMQP_TIMESTAMP_MAX = 0xFFFFFFFFFFFFFFFF;
+static const double AMQP_TIMESTAMP_MAX = 0xFFFFFFFFFFFFFFFFp0;
static const double AMQP_TIMESTAMP_MIN = 0;
-/* {{{ proto AMQPTimestamp::__construct(string $timestamp)
+/* {{{ proto AMQPTimestamp::__construct(float $timestamp)
*/
static PHP_METHOD(amqp_timestamp_class, __construct)
{
- double timestamp;
- zval *timestamp_value;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "d", ×tamp) == FAILURE) {
- return;
- }
-
- if (timestamp < AMQP_TIMESTAMP_MIN) {
- zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "The timestamp parameter must be greater than %0.f.", AMQP_TIMESTAMP_MIN);
- return;
- }
-
- if (timestamp > AMQP_TIMESTAMP_MAX) {
- zend_throw_exception_ex(amqp_value_exception_class_entry, 0 TSRMLS_CC, "The timestamp parameter must be less than %0.f.", AMQP_TIMESTAMP_MAX);
- return;
- }
-
- {
- #if PHP_MAJOR_VERSION >= 7
- zend_string *str;
- str = _php_math_number_format_ex(timestamp, 0, "", 0, "", 0);
- zend_update_property_str(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL("timestamp"), str);
- zend_string_delref(str);
- #else
- char *str;
- str = _php_math_number_format_ex(timestamp, 0, "", 0, "", 0);
- zend_update_property_string(this_ce, getThis(), ZEND_STRL("timestamp"), str TSRMLS_CC);
- efree(str);
- #endif
- }
+ double timestamp;
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "d", ×tamp) == FAILURE) {
+ RETURN_THROWS();
+ }
+
+ if (timestamp < AMQP_TIMESTAMP_MIN) {
+ zend_throw_exception_ex(
+ amqp_value_exception_class_entry,
+ 0,
+ "The timestamp parameter must be greater than %0.f.",
+ AMQP_TIMESTAMP_MIN
+ );
+ return;
+ }
+
+ if (timestamp > AMQP_TIMESTAMP_MAX) {
+ zend_throw_exception_ex(
+ amqp_value_exception_class_entry,
+ 0,
+ "The timestamp parameter must be less than %0.f.",
+ AMQP_TIMESTAMP_MAX
+ );
+ return;
+ }
+
+ zend_update_property_double(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("timestamp"), floor(timestamp));
}
/* }}} */
-/* {{{ proto int AMQPTimestamp::getTimestamp()
+/* {{{ proto float AMQPTimestamp::getTimestamp()
Get timestamp */
static PHP_METHOD(amqp_timestamp_class, getTimestamp)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
+ zval rv;
+ PHP_AMQP_NOPARAMS()
- PHP_AMQP_RETURN_THIS_PROP("timestamp");
+ PHP_AMQP_RETURN_THIS_PROP("timestamp");
}
/* }}} */
@@ -90,62 +87,65 @@ static PHP_METHOD(amqp_timestamp_class, getTimestamp)
Return timestamp as string */
static PHP_METHOD(amqp_timestamp_class, __toString)
{
- PHP5to7_READ_PROP_RV_PARAM_DECL;
- PHP_AMQP_NOPARAMS();
+ zval rv;
+ PHP_AMQP_NOPARAMS()
- PHP_AMQP_RETURN_THIS_PROP("timestamp");
+ zval *timestamp = zend_read_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL("timestamp"), 0, &rv);
+
+ RETURN_NEW_STR(_php_math_number_format_ex(Z_DVAL_P(timestamp), 0, "", 0, "", 0));
+}
+/* }}} */
+
+/* {{{ proto string AMQPTimestamp::toAmqpValue()
+Return timestamp as AMQPValue */
+static PHP_METHOD(amqp_timestamp_class, toAmqpValue)
+{
+ PHP_AMQP_NOPARAMS()
+
+ RETURN_ZVAL(getThis(), 1, 0);
}
/* }}} */
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_timestamp_class_construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
- ZEND_ARG_INFO(0, timestamp)
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_timestamp_class_construct, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 1)
+ ZEND_ARG_TYPE_INFO(0, timestamp, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_timestamp_class_getTimestamp, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_timestamp_class_getTimestamp, ZEND_SEND_BY_VAL, 0, IS_DOUBLE, 0)
ZEND_END_ARG_INFO()
-#if PHP_MAJOR_VERSION < 8
-ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_timestamp_class_toString, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
-#else
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_timestamp_class_toString, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, IS_STRING, 0)
-#endif
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_amqp_timestamp_class_toString, ZEND_SEND_BY_VAL, 0, IS_STRING, 0)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_timestamp_class_toAmqpValue, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
ZEND_END_ARG_INFO()
zend_function_entry amqp_timestamp_class_functions[] = {
PHP_ME(amqp_timestamp_class, __construct, arginfo_amqp_timestamp_class_construct, ZEND_ACC_PUBLIC)
PHP_ME(amqp_timestamp_class, getTimestamp, arginfo_amqp_timestamp_class_getTimestamp, ZEND_ACC_PUBLIC)
PHP_ME(amqp_timestamp_class, __toString, arginfo_amqp_timestamp_class_toString, ZEND_ACC_PUBLIC)
+ PHP_ME(amqp_timestamp_class, toAmqpValue, arginfo_amqp_timestamp_class_toAmqpValue, ZEND_ACC_PUBLIC)
- {NULL, NULL, NULL}
+ {NULL, NULL, NULL}
};
PHP_MINIT_FUNCTION(amqp_timestamp)
{
- zend_class_entry ce;
- char min[21], max[21];
- int min_len, max_len;
-
- INIT_CLASS_ENTRY(ce, "AMQPTimestamp", amqp_timestamp_class_functions);
- this_ce = zend_register_internal_class(&ce TSRMLS_CC);
- this_ce->ce_flags = this_ce->ce_flags | PHP5to7_ZEND_ACC_FINAL_CLASS;
-
- zend_declare_property_null(this_ce, ZEND_STRL("timestamp"), ZEND_ACC_PRIVATE TSRMLS_CC);
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "AMQPTimestamp", amqp_timestamp_class_functions);
+ this_ce = zend_register_internal_class(&ce);
+ zend_class_implements(this_ce, 1, amqp_value_class_entry);
+ this_ce->ce_flags |= ZEND_ACC_FINAL;
+#if PHP_VERSION_ID >= 80200
+ this_ce->ce_flags |= ZEND_ACC_READONLY_CLASS;
+#endif
- max_len = snprintf(max, sizeof(max), "%.0f", AMQP_TIMESTAMP_MAX);
- zend_declare_class_constant_stringl(this_ce, ZEND_STRL("MAX"), max, max_len TSRMLS_CC);
+ PHP_AMQP_DECLARE_TYPED_PROPERTY(this_ce, "timestamp", ZEND_ACC_PRIVATE, IS_DOUBLE, 0);
- min_len = snprintf(min, sizeof(min), "%.0f", AMQP_TIMESTAMP_MIN);
- zend_declare_class_constant_stringl(this_ce, ZEND_STRL("MIN"), min, min_len TSRMLS_CC);
+ zend_declare_class_constant_double(this_ce, ZEND_STRL("MAX"), AMQP_TIMESTAMP_MAX);
+ zend_declare_class_constant_double(this_ce, ZEND_STRL("MIN"), AMQP_TIMESTAMP_MIN);
- return SUCCESS;
+ return SUCCESS;
}
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<6
-*/
diff --git a/amqp_timestamp.h b/amqp_timestamp.h
index 5d94fc72..f854f5da 100644
--- a/amqp_timestamp.h
+++ b/amqp_timestamp.h
@@ -25,12 +25,3 @@
extern zend_class_entry *amqp_timestamp_class_entry;
PHP_MINIT_FUNCTION(amqp_timestamp);
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/amqp_type.c b/amqp_type.c
index 5f1ab914..08da4b90 100644
--- a/amqp_type.c
+++ b/amqp_type.c
@@ -20,363 +20,397 @@
| - Jonathan Tansavatdi |
+----------------------------------------------------------------------+
*/
-#include
-#include
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
+#else
+ #include
+#endif
#include "Zend/zend_interfaces.h"
-#include "amqp_type.h"
-#include "amqp_timestamp.h"
+#include "Zend/zend_exceptions.h"
+#include "amqp_value.h"
#include "amqp_decimal.h"
+#include "amqp_timestamp.h"
+#include "amqp_type.h"
#ifdef PHP_WIN32
-# define strtoimax _strtoi64
+ #define strtoimax _strtoi64
#endif
-static void php_amqp_type_internal_free_amqp_array(amqp_array_t *array);
-static void php_amqp_type_internal_free_amqp_table(amqp_table_t *object, zend_bool clear_root);
-
-amqp_bytes_t php_amqp_type_char_to_amqp_long(char const *cstr, PHP5to7_param_str_len_type_t len)
+static void php_amqp_type_free_amqp_array_internal(amqp_array_t *array);
+static void php_amqp_type_free_amqp_table_internal(amqp_table_t *object, bool clear_root);
+void php_amqp_type_zval_to_amqp_array_internal(zval *value, amqp_array_t *arguments, zend_ulong depth);
+void php_amqp_type_zval_to_amqp_container_internal(zval *array, amqp_field_value_t **field_ptr, zend_ulong depth);
+void php_amqp_type_zval_to_amqp_table_internal(zval *array, amqp_table_t *amqp_table, zend_ulong depth);
+bool php_amqp_type_zval_to_amqp_value_internal(
+ zval *value,
+ amqp_field_value_t **field_ptr,
+ char *key,
+ zend_ulong depth
+);
+
+amqp_bytes_t php_amqp_type_char_to_amqp_long(char const *cstr, size_t len)
{
- amqp_bytes_t result;
+ amqp_bytes_t result;
- if (len < 1) {
- return amqp_empty_bytes;
- }
+ if (len < 1) {
+ return amqp_empty_bytes;
+ }
- result.len = (size_t)len;
- result.bytes = (void *) cstr;
+ result.len = (size_t) len;
+ result.bytes = (void *) cstr;
- return result;
+ return result;
}
char *php_amqp_type_amqp_bytes_to_char(amqp_bytes_t bytes)
{
-/* We will need up to 4 chars per byte, plus the terminating 0 */
- char *res = emalloc(bytes.len * 4 + 1);
- uint8_t *data = bytes.bytes;
- char *p = res;
- size_t i;
-
- for (i = 0; i < bytes.len; i++) {
- if (data[i] >= 32 && data[i] != 127) {
- *p++ = data[i];
- } else {
- *p++ = '\\';
- *p++ = '0' + (data[i] >> 6);
- *p++ = '0' + (data[i] >> 3 & 0x7);
- *p++ = '0' + (data[i] & 0x7);
- }
- }
-
- *p = 0;
- return res;
+ /* We will need up to 4 chars per byte, plus the terminating 0 */
+ char *res = emalloc(bytes.len * 4 + 1);
+ uint8_t *data = bytes.bytes;
+ char *p = res;
+ size_t i;
+
+ for (i = 0; i < bytes.len; i++) {
+ if (data[i] >= 32 && data[i] != 127) {
+ *p++ = data[i];
+ } else {
+ *p++ = '\\';
+ *p++ = '0' + (data[i] >> 6);
+ *p++ = '0' + (data[i] >> 3 & 0x7);
+ *p++ = '0' + (data[i] & 0x7);
+ }
+ }
+
+ *p = 0;
+ return res;
}
-void php_amqp_type_internal_convert_zval_array(zval *php_array, amqp_field_value_t **field, zend_bool allow_int_keys TSRMLS_DC)
+void php_amqp_type_zval_to_amqp_container_internal(zval *array, amqp_field_value_t **field_ptr, zend_ulong depth)
{
- HashTable *ht;
- HashPosition pos;
-
- zval *value;
- zval **data;
-
- PHP5to7_ZEND_REAL_HASH_KEY_T *real_key;
-
- char *key;
- unsigned key_len;
-
- zend_ulong index;
- ht = Z_ARRVAL_P(php_array);
-
- zend_bool is_amqp_array = 1;
-
- PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) {
- if (PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, index, pos)) {
- is_amqp_array = 0;
- break;
- }
-
- } PHP5to7_ZEND_HASH_FOREACH_END();
-
- if (is_amqp_array) {
- (*field)->kind = AMQP_FIELD_KIND_ARRAY;
- php_amqp_type_internal_convert_zval_to_amqp_array(php_array, &(*field)->value.array TSRMLS_CC);
- } else {
- (*field)->kind = AMQP_FIELD_KIND_TABLE;
- php_amqp_type_internal_convert_zval_to_amqp_table(php_array, &(*field)->value.table, allow_int_keys TSRMLS_CC);
- }
+ HashTable *ht;
+ zend_string *key;
+ amqp_field_value_t *field;
+
+ ht = Z_ARRVAL_P(array);
+
+ bool is_amqp_array = 1;
+
+ ZEND_HASH_FOREACH_STR_KEY(ht, key)
+ if (key) {
+ is_amqp_array = 0;
+ break;
+ }
+ ZEND_HASH_FOREACH_END ();
+
+ field = *field_ptr;
+ if (is_amqp_array) {
+ field->kind = AMQP_FIELD_KIND_ARRAY;
+ php_amqp_type_zval_to_amqp_array_internal(array, &field->value.array, depth);
+ } else {
+ field->kind = AMQP_FIELD_KIND_TABLE;
+ php_amqp_type_zval_to_amqp_table_internal(array, &field->value.table, depth);
+ }
}
-void php_amqp_type_internal_convert_zval_to_amqp_table(zval *php_array, amqp_table_t *amqp_table, zend_bool allow_int_keys TSRMLS_DC)
+void php_amqp_type_zval_to_amqp_table_internal(zval *array, amqp_table_t *amqp_table, zend_ulong depth)
{
- HashTable *ht;
- HashPosition pos;
-
- zval *value;
- zval **data;
-
- PHP5to7_ZEND_REAL_HASH_KEY_T *real_key;
-
- char *key;
- unsigned key_len;
-
- zend_ulong index;
-
-
- ht = Z_ARRVAL_P(php_array);
-
- amqp_table->entries = (amqp_table_entry_t *)ecalloc((size_t)zend_hash_num_elements(ht), sizeof(amqp_table_entry_t));
- amqp_table->num_entries = 0;
-
- PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) {
- char *string_key;
- amqp_table_entry_t *table_entry;
- amqp_field_value_t *field;
-
-
- /* Now pull the key */
-
- if (!PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, index, pos)) {
- if (allow_int_keys) {
- /* Convert to strings non-string keys */
- char str[32];
-
- key_len = sprintf(str, "%lu", index);
- key = str;
- } else {
- /* Skip things that are not strings */
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ignoring non-string header field '%lu'", index);
-
- continue;
- }
- } else {
- PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len);
- }
-
- /* Build the value */
- table_entry = &amqp_table->entries[amqp_table->num_entries++];
- field = &table_entry->value;
-
- if (!php_amqp_type_internal_convert_php_to_amqp_field_value(value, &field, key TSRMLS_CC)) {
- /* Reset entries counter back */
- amqp_table->num_entries --;
-
- continue;
- }
-
- string_key = estrndup(key, key_len);
- table_entry->key = amqp_cstring_bytes(string_key);
-
- } PHP5to7_ZEND_HASH_FOREACH_END();
+ HashTable *ht;
+ zval *value_nested;
+ zend_string *zkey;
+ zend_ulong index;
+ char *key;
+ unsigned key_len;
+ ht = Z_ARRVAL_P(array);
+
+ amqp_table->entries =
+ (amqp_table_entry_t *) ecalloc((size_t) zend_hash_num_elements(ht), sizeof(amqp_table_entry_t));
+ amqp_table->num_entries = 0;
+
+ ZEND_HASH_FOREACH_KEY_VAL(ht, index, zkey, value_nested)
+ char *string_key;
+ amqp_table_entry_t *table_entry;
+ amqp_field_value_t *field;
+
+ /* Now pull the key */
+ if (!zkey) {
+ if (depth > 0) {
+ /* Convert to strings non-string keys */
+ char str[32];
+
+ key_len = snprintf(str, 32, ZEND_ULONG_FMT, index);
+ key = str;
+ } else {
+ /* Skip things that are not strings */
+ php_error_docref(NULL, E_WARNING, "Ignoring non-string header field '" ZEND_ULONG_FMT "'", index);
+
+ continue;
+ }
+ } else {
+ key_len = ZSTR_LEN(zkey);
+ key = ZSTR_VAL(zkey);
+ }
+
+ string_key = estrndup(key, key_len);
+
+ /* Build the array */
+ table_entry = &amqp_table->entries[amqp_table->num_entries++];
+ field = &table_entry->value;
+
+ if (!php_amqp_type_zval_to_amqp_value_internal(value_nested, &field, key, depth + 1)) {
+ /* Reset entries counter back */
+ amqp_table->num_entries--;
+ efree(string_key);
+
+ continue;
+ }
+
+ table_entry->key = amqp_cstring_bytes(string_key);
+ ZEND_HASH_FOREACH_END();
}
-void php_amqp_type_internal_convert_zval_to_amqp_array(zval *zvalArguments, amqp_array_t *arguments TSRMLS_DC)
+void php_amqp_type_zval_to_amqp_array_internal(zval *value, amqp_array_t *arguments, zend_ulong depth)
{
- HashTable *ht;
- HashPosition pos;
-
- zval *value;
- zval **data;
+ HashTable *ht;
- PHP5to7_ZEND_REAL_HASH_KEY_T *real_key;
+ zval *value_nested;
- char *key;
- unsigned key_len;
+ zend_string *zkey;
- zend_ulong index;
+ ht = Z_ARRVAL_P(value);
- char type[16];
+ /* Allocate all the memory necessary for storing the arguments */
+ arguments->entries =
+ (amqp_field_value_t *) ecalloc((size_t) zend_hash_num_elements(ht), sizeof(amqp_field_value_t));
+ arguments->num_entries = 0;
- ht = Z_ARRVAL_P(zvalArguments);
+ ZEND_HASH_FOREACH_STR_KEY_VAL(ht, zkey, value_nested)
+ amqp_field_value_t *field = &arguments->entries[arguments->num_entries++];
- /* Allocate all the memory necessary for storing the arguments */
- arguments->entries = (amqp_field_value_t *)ecalloc((size_t)zend_hash_num_elements(ht), sizeof(amqp_field_value_t));
- arguments->num_entries = 0;
+ if (!php_amqp_type_zval_to_amqp_value_internal(value_nested, &field, ZSTR_VAL(zkey), depth)) {
+ /* Reset entries counter back */
+ arguments->num_entries--;
- PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, index, real_key, key, key_len, data, value, pos) {
- amqp_field_value_t *field = &arguments->entries[arguments->num_entries++];
-
- if (!php_amqp_type_internal_convert_php_to_amqp_field_value(value, &field, key TSRMLS_CC)) {
- /* Reset entries counter back */
- arguments->num_entries --;
-
- continue;
- }
- } PHP5to7_ZEND_HASH_FOREACH_END();
+ continue;
+ }
+ ZEND_HASH_FOREACH_END ();
}
-zend_bool php_amqp_type_internal_convert_php_to_amqp_field_value(zval *value, amqp_field_value_t **fieldPtr, char *key TSRMLS_DC)
+bool php_amqp_type_zval_to_amqp_value_internal(zval *value, amqp_field_value_t **field_ptr, char *key, zend_ulong depth)
{
- zend_bool result;
- char type[16];
- amqp_field_value_t *field;
-
- result = 1;
- field = *fieldPtr;
-
- switch (Z_TYPE_P(value)) {
- PHP5to7_CASE_IS_BOOL:
- field->kind = AMQP_FIELD_KIND_BOOLEAN;
- field->value.boolean = (amqp_boolean_t) !PHP5to7_IS_FALSE_P(value);
- break;
- case IS_DOUBLE:
- field->kind = AMQP_FIELD_KIND_F64;
- field->value.f64 = Z_DVAL_P(value);
- break;
- case IS_LONG:
- field->kind = AMQP_FIELD_KIND_I64;
- field->value.i64 = Z_LVAL_P(value);
- break;
- case IS_STRING:
- field->kind = AMQP_FIELD_KIND_UTF8;
-
- if (Z_STRLEN_P(value)) {
- amqp_bytes_t bytes;
- bytes.len = (size_t) Z_STRLEN_P(value);
- bytes.bytes = estrndup(Z_STRVAL_P(value), (unsigned) Z_STRLEN_P(value));
-
- field->value.bytes = bytes;
- } else {
- field->value.bytes = amqp_empty_bytes;
- }
-
- break;
- case IS_ARRAY:
- php_amqp_type_internal_convert_zval_array(value, &field, 1 TSRMLS_CC);
- break;
- case IS_NULL:
- field->kind = AMQP_FIELD_KIND_VOID;
- break;
- case IS_OBJECT:
- if (instanceof_function(Z_OBJCE_P(value), amqp_timestamp_class_entry TSRMLS_CC)) {
- PHP5to7_zval_t result_zv PHP5to7_MAYBE_SET_TO_NULL;
-
- zend_call_method_with_0_params(PHP5to8_OBJ_PROP(PHP5to7_MAYBE_PARAM_PTR(value)), amqp_timestamp_class_entry, NULL, "gettimestamp", &result_zv);
+ bool result;
+ char type[16];
+ amqp_field_value_t *field;
+
+ if (depth > PHP_AMQP_G(serialization_depth)) {
+ zend_throw_exception_ex(
+ amqp_exception_class_entry,
+ 0,
+ "Maximum serialization depth of " ZEND_LONG_FMT " reached while serializing value",
+ PHP_AMQP_G(serialization_depth)
+ );
+ return 0;
+ }
+
+ result = 1;
+ field = *field_ptr;
+
+ switch (Z_TYPE_P(value)) {
+ case IS_TRUE:
+ case IS_FALSE:
+ field->kind = AMQP_FIELD_KIND_BOOLEAN;
+ field->value.boolean = (amqp_boolean_t) Z_TYPE_P(value) != IS_FALSE;
+ break;
+ case IS_DOUBLE:
+ field->kind = AMQP_FIELD_KIND_F64;
+ field->value.f64 = Z_DVAL_P(value);
+ break;
+ case IS_LONG:
+ field->kind = AMQP_FIELD_KIND_I64;
+ field->value.i64 = Z_LVAL_P(value);
+ break;
+ case IS_STRING:
+ field->kind = AMQP_FIELD_KIND_UTF8;
+
+ if (Z_STRLEN_P(value)) {
+ amqp_bytes_t bytes;
+ bytes.len = (size_t) Z_STRLEN_P(value);
+ bytes.bytes = estrndup(Z_STRVAL_P(value), (unsigned) Z_STRLEN_P(value));
+
+ field->value.bytes = bytes;
+ } else {
+ field->value.bytes = amqp_empty_bytes;
+ }
+
+ break;
+ case IS_ARRAY:
+ php_amqp_type_zval_to_amqp_container_internal(value, &field, depth + 1);
+ break;
+ case IS_NULL:
+ field->kind = AMQP_FIELD_KIND_VOID;
+ break;
+ case IS_OBJECT:
+ if (instanceof_function(Z_OBJCE_P(value), amqp_timestamp_class_entry)) {
+ zval result_zv;
+
+ zend_call_method_with_0_params(
+ PHP_AMQP_COMPAT_OBJ_P(value),
+ amqp_timestamp_class_entry,
+ NULL,
+ "gettimestamp",
+ &result_zv
+ );
field->kind = AMQP_FIELD_KIND_TIMESTAMP;
- field->value.u64 = strtoimax(Z_STRVAL(PHP5to7_MAYBE_DEREF(result_zv)), NULL, 10);
-
- PHP5to7_MAYBE_DESTROY(result_zv);
-
- break;
- } else if (instanceof_function(Z_OBJCE_P(value), amqp_decimal_class_entry TSRMLS_CC)) {
- field->kind = AMQP_FIELD_KIND_DECIMAL;
- PHP5to7_zval_t result_zv PHP5to7_MAYBE_SET_TO_NULL;
-
- zend_call_method_with_0_params(PHP5to8_OBJ_PROP(PHP5to7_MAYBE_PARAM_PTR(value)), amqp_decimal_class_entry, NULL, "getexponent", &result_zv);
- field->value.decimal.decimals = (uint8_t)Z_LVAL(PHP5to7_MAYBE_DEREF(result_zv));
- PHP5to7_MAYBE_DESTROY(result_zv);
-
- zend_call_method_with_0_params(PHP5to8_OBJ_PROP(PHP5to7_MAYBE_PARAM_PTR(value)), amqp_decimal_class_entry, NULL, "getsignificand", &result_zv);
- field->value.decimal.value = (uint32_t)Z_LVAL(PHP5to7_MAYBE_DEREF(result_zv));
-
- PHP5to7_MAYBE_DESTROY(result_zv);
-
- break;
- }
- default:
- switch(Z_TYPE_P(value)) {
- case IS_OBJECT:
- strcpy(type, "object");
- break;
- case IS_RESOURCE:
- strcpy(type, "resource");
- break;
- default:
- strcpy(type, "unknown");
- break;
- }
-
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Ignoring field '%s' due to unsupported value type (%s)", key, type);
- result = 0;
- break;
- }
-
- return result;
+ field->value.u64 = Z_DVAL(result_zv);
+
+ zval_ptr_dtor(&result_zv);
+
+ break;
+ } else if (instanceof_function(Z_OBJCE_P(value), amqp_decimal_class_entry)) {
+ field->kind = AMQP_FIELD_KIND_DECIMAL;
+ zval result_zv;
+
+ zend_call_method_with_0_params(
+ PHP_AMQP_COMPAT_OBJ_P(value),
+ amqp_decimal_class_entry,
+ NULL,
+ "getexponent",
+ &result_zv
+ );
+ field->value.decimal.decimals = (uint8_t) Z_LVAL(result_zv);
+ zval_ptr_dtor(&result_zv);
+
+ zend_call_method_with_0_params(
+ PHP_AMQP_COMPAT_OBJ_P(value),
+ amqp_decimal_class_entry,
+ NULL,
+ "getsignificand",
+ &result_zv
+ );
+ field->value.decimal.value = (uint32_t) Z_LVAL(result_zv);
+ zval_ptr_dtor(&result_zv);
+
+ break;
+ } else if (instanceof_function(Z_OBJCE_P(value), amqp_value_class_entry)) {
+ zval result_zv;
+ zend_call_method_with_0_params(
+ PHP_AMQP_COMPAT_OBJ_P(value),
+ Z_OBJCE_P(value),
+ NULL,
+ "toamqpvalue",
+ &result_zv
+ );
+ bool recursion_res = php_amqp_type_zval_to_amqp_value_internal(&result_zv, field_ptr, key, depth + 1);
+ zval_ptr_dtor(&result_zv);
+
+ return recursion_res;
+ }
+ default:
+ switch (Z_TYPE_P(value)) {
+ case IS_OBJECT:
+ strcpy(type, "object");
+ break;
+ case IS_RESOURCE:
+ strcpy(type, "resource");
+ break;
+ default:
+ strcpy(type, "unknown");
+ break;
+ }
+
+ php_error_docref(NULL, E_WARNING, "Ignoring field '%s' due to unsupported value type (%s)", key, type);
+ result = 0;
+ break;
+ }
+
+ return result;
}
-amqp_table_t *php_amqp_type_convert_zval_to_amqp_table(zval *php_array TSRMLS_DC)
+amqp_table_t *php_amqp_type_convert_zval_to_amqp_table(zval *php_array)
{
- amqp_table_t *amqp_table;
- /* In setArguments, we are overwriting all the existing values */
- amqp_table = (amqp_table_t *)emalloc(sizeof(amqp_table_t));
+ amqp_table_t *amqp_table;
+ /* In setArguments, we are overwriting all the existing values */
+ amqp_table = (amqp_table_t *) emalloc(sizeof(amqp_table_t));
- php_amqp_type_internal_convert_zval_to_amqp_table(php_array, amqp_table, 0 TSRMLS_CC);
+ php_amqp_type_zval_to_amqp_table_internal(php_array, amqp_table, 0);
- return amqp_table;
+ return amqp_table;
}
-static void php_amqp_type_internal_free_amqp_array(amqp_array_t *array) {
- if (!array) {
- return;
- }
-
- int macroEntryCounter;
- for (macroEntryCounter = 0; macroEntryCounter < array->num_entries; macroEntryCounter++) {
-
- amqp_field_value_t *entry = &array->entries[macroEntryCounter];
-
- switch (entry->kind) {
- case AMQP_FIELD_KIND_TABLE:
- php_amqp_type_internal_free_amqp_table(&entry->value.table, 0);
- break;
- case AMQP_FIELD_KIND_ARRAY:
- php_amqp_type_internal_free_amqp_array(&entry->value.array);
- break;
- case AMQP_FIELD_KIND_UTF8:
- if (entry->value.bytes.bytes) {
- efree(entry->value.bytes.bytes);
- }
- break;
- //
- default:
- break;
- }
- }
-
- if (array->entries) {
- efree(array->entries);
- }
-}
-
-static void php_amqp_type_internal_free_amqp_table(amqp_table_t *object, zend_bool clear_root)
+static void php_amqp_type_free_amqp_array_internal(amqp_array_t *array)
{
- if (!object) {
- return;
- }
-
- if (object->entries) {
- int macroEntryCounter;
- for (macroEntryCounter = 0; macroEntryCounter < object->num_entries; macroEntryCounter++) {
-
- amqp_table_entry_t *entry = &object->entries[macroEntryCounter];
- efree(entry->key.bytes);
-
- switch (entry->value.kind) {
- case AMQP_FIELD_KIND_TABLE:
- php_amqp_type_internal_free_amqp_table(&entry->value.value.table, 0);
- break;
- case AMQP_FIELD_KIND_ARRAY:
- php_amqp_type_internal_free_amqp_array(&entry->value.value.array);
- break;
- case AMQP_FIELD_KIND_UTF8:
- if (entry->value.value.bytes.bytes) {
- efree(entry->value.value.bytes.bytes);
- }
- break;
- default:
- break;
- }
- }
- efree(object->entries);
- }
-
- if (clear_root) {
- efree(object);
- }
+ if (!array) {
+ return;
+ }
+
+ int macroEntryCounter;
+ for (macroEntryCounter = 0; macroEntryCounter < array->num_entries; macroEntryCounter++) {
+
+ amqp_field_value_t *entry = &array->entries[macroEntryCounter];
+
+ switch (entry->kind) {
+ case AMQP_FIELD_KIND_TABLE:
+ php_amqp_type_free_amqp_table_internal(&entry->value.table, 0);
+ break;
+ case AMQP_FIELD_KIND_ARRAY:
+ php_amqp_type_free_amqp_array_internal(&entry->value.array);
+ break;
+ case AMQP_FIELD_KIND_UTF8:
+ if (entry->value.bytes.bytes) {
+ efree(entry->value.bytes.bytes);
+ }
+ break;
+ //
+ default:
+ break;
+ }
+ }
+
+ if (array->entries) {
+ efree(array->entries);
+ }
}
-void php_amqp_type_free_amqp_table(amqp_table_t *object)
+static void php_amqp_type_free_amqp_table_internal(amqp_table_t *object, bool clear_root)
{
- php_amqp_type_internal_free_amqp_table(object, 1);
+ if (!object) {
+ return;
+ }
+
+ if (object->entries) {
+ int macroEntryCounter;
+ for (macroEntryCounter = 0; macroEntryCounter < object->num_entries; macroEntryCounter++) {
+
+ amqp_table_entry_t *entry = &object->entries[macroEntryCounter];
+ efree(entry->key.bytes);
+
+ switch (entry->value.kind) {
+ case AMQP_FIELD_KIND_TABLE:
+ php_amqp_type_free_amqp_table_internal(&entry->value.value.table, 0);
+ break;
+ case AMQP_FIELD_KIND_ARRAY:
+ php_amqp_type_free_amqp_array_internal(&entry->value.value.array);
+ break;
+ case AMQP_FIELD_KIND_UTF8:
+ if (entry->value.value.bytes.bytes) {
+ efree(entry->value.value.bytes.bytes);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ efree(object->entries);
+ }
+
+ if (clear_root) {
+ efree(object);
+ }
}
+
+void php_amqp_type_free_amqp_table(amqp_table_t *object) { php_amqp_type_free_amqp_table_internal(object, 1); }
diff --git a/amqp_type.h b/amqp_type.h
index 90787770..6dac1c86 100644
--- a/amqp_type.h
+++ b/amqp_type.h
@@ -21,28 +21,22 @@
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
-#include "config.h"
+ #include "config.h"
#endif
#include "php.h"
-#include
-#if PHP_MAJOR_VERSION >= 7
- #include "php7_support.h"
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
#else
- #include "php5_support.h"
+ #include
#endif
+#include "php_amqp.h"
PHP_MINIT_FUNCTION(amqp_type);
char *php_amqp_type_amqp_bytes_to_char(amqp_bytes_t bytes);
-amqp_bytes_t php_amqp_type_char_to_amqp_long(char const *cstr, PHP5to7_param_str_len_type_t len);
+amqp_bytes_t php_amqp_type_char_to_amqp_long(char const *cstr, size_t len);
-amqp_table_t *php_amqp_type_convert_zval_to_amqp_table(zval *php_array TSRMLS_DC);
+amqp_table_t *php_amqp_type_convert_zval_to_amqp_table(zval *php_array);
void php_amqp_type_free_amqp_table(amqp_table_t *object);
-
-/** Internal functions */
-zend_bool php_amqp_type_internal_convert_php_to_amqp_field_value(zval *value, amqp_field_value_t **fieldPtr, char *key TSRMLS_DC);
-void php_amqp_type_internal_convert_zval_array(zval *php_array, amqp_field_value_t **field, zend_bool allow_int_keys TSRMLS_DC);
-void php_amqp_type_internal_convert_zval_to_amqp_table(zval *php_array, amqp_table_t *amqp_table, zend_bool allow_int_keys TSRMLS_DC);
-void php_amqp_type_internal_convert_zval_to_amqp_array(zval *php_array, amqp_array_t *amqp_array TSRMLS_DC);
\ No newline at end of file
diff --git a/amqp_value.c b/amqp_value.c
new file mode 100644
index 00000000..7e2c9bc4
--- /dev/null
+++ b/amqp_value.c
@@ -0,0 +1,49 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include "php.h"
+
+zend_class_entry *amqp_value_class_entry;
+#define this_ce amqp_value_class_entry
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_amqp_value_class_toAmqpValue, ZEND_SEND_BY_VAL, ZEND_RETURN_VALUE, 0)
+ZEND_END_ARG_INFO()
+
+zend_function_entry amqp_value_class_functions[] = {
+ PHP_ABSTRACT_ME(amqp_value_class, toAmqpValue, arginfo_amqp_value_class_toAmqpValue)
+
+ {NULL, NULL, NULL}
+};
+
+PHP_MINIT_FUNCTION(amqp_value)
+{
+ zend_class_entry ce;
+
+ INIT_CLASS_ENTRY(ce, "AMQPValue", amqp_value_class_functions);
+ amqp_value_class_entry = zend_register_internal_interface(&ce);
+
+ return SUCCESS;
+}
diff --git a/amqp_value.h b/amqp_value.h
new file mode 100644
index 00000000..d22ba8d9
--- /dev/null
+++ b/amqp_value.h
@@ -0,0 +1,27 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2007 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
+ | Lead: |
+ | - Pieter de Zwart |
+ | Maintainers: |
+ | - Brad Rodriguez |
+ | - Jonathan Tansavatdi |
+ +----------------------------------------------------------------------+
+*/
+#include "php.h"
+
+extern zend_class_entry *amqp_value_class_entry;
+
+PHP_MINIT_FUNCTION(amqp_value);
diff --git a/appveyor/build.ps1 b/appveyor/build.ps1
deleted file mode 100644
index 1602328d..00000000
--- a/appveyor/build.ps1
+++ /dev/null
@@ -1,19 +0,0 @@
-$ErrorActionPreference = "Stop"
-
-cd c:\projects\amqp
-#echo "@echo off" | Out-File -Encoding "ASCII" task.bat
-#echo "" | Out-File -Encoding "ASCII" -Append task.bat
-echo "" | Out-File -Encoding "ASCII" task.bat
-# echo "call phpsdk_deps -d c:\build-cache\deps -c" | Out-File -Encoding "ASCII" -Append task.bat
-# echo "if errorlevel 7 call phpsdk_deps -d c:\build-cache\deps -un" | Out-File -Encoding "ASCII" -Append task.bat
-echo "call phpize 2>&1" | Out-File -Encoding "ASCII" -Append task.bat
-echo "call configure --with-php-build=c:\build-cache\deps --with-amqp --enable-debug-pack 2>&1" | Out-File -Encoding "ASCII" -Append task.bat
-echo "nmake /nologo 2>&1" | Out-File -Encoding "ASCII" -Append task.bat
-echo "exit %errorlevel%" | Out-File -Encoding "ASCII" -Append task.bat
-$here = (Get-Item -Path "." -Verbose).FullName
-$runner = 'c:\build-cache\php-sdk-' + $env:BIN_SDK_VER + '\phpsdk' + '-' + $env:VC + '-' + $env:ARCH + '.bat'
-$task = $here + '\task.bat'
-& $runner -t $task
-if (-not $?) {
- throw "build failed with errorlevel $LastExitCode"
-}
diff --git a/appveyor/install.ps1 b/appveyor/install.ps1
deleted file mode 100644
index 7c2bdc04..00000000
--- a/appveyor/install.ps1
+++ /dev/null
@@ -1,36 +0,0 @@
-if (-not (Test-Path c:\build-cache)) {
- mkdir c:\build-cache
-}
-$bname = 'php-sdk-' + $env:BIN_SDK_VER + '.zip'
-if (-not (Test-Path c:\build-cache\$bname)) {
- Invoke-WebRequest "https://github.com/microsoft/php-sdk-binary-tools/archive/$bname" -OutFile "c:\build-cache\$bname"
-}
-$dname0 = 'php-sdk-binary-tools-php-sdk-' + $env:BIN_SDK_VER
-$dname1 = 'php-sdk-' + $env:BIN_SDK_VER
-if (-not (Test-Path c:\build-cache\$dname1)) {
- 7z x c:\build-cache\$bname -oc:\build-cache
- move c:\build-cache\$dname0 c:\build-cache\$dname1
-}
-$ts_part = ''
-if ('0' -eq $env:TS) { $ts_part = '-nts' }
-$bname = 'php-devel-pack-' + $env:PHP_VER + $ts_part + '-Win32-' + $env:VC + '-' + $env:ARCH + '.zip'
-if (-not (Test-Path c:\build-cache\$bname)) {
- Invoke-WebRequest "http://windows.php.net/downloads/releases/archives/$bname" -OutFile "c:\build-cache\$bname"
- if (-not (Test-Path c:\build-cache\$bname)) {
- Invoke-WebRequest "http://windows.php.net/downloads/releases/$bname" -OutFile "c:\build-cache\$bname"
- }
-}
-$dname0 = 'php-' + $env:PHP_VER + '-devel-' + $env:VC + '-' + $env:ARCH
-$dname1 = 'php-' + $env:PHP_VER + $ts_part + '-devel-' + $env:VC + '-' + $env:ARCH
-if (-not (Test-Path c:\build-cache\$dname1)) {
- 7z x c:\build-cache\$bname -oc:\build-cache
- if ($dname0 -ne $dname1) {
- move c:\build-cache\$dname0 c:\build-cache\$dname1
- }
-}
-$env:PATH = 'c:\build-cache\' + $dname1 + ';' + $env:PATH
-$bname = $env:DEP + '-' + $env:VC + '-' + $env:ARCH + '.zip'
-if (-not (Test-Path c:\build-cache\$bname)) {
- Invoke-WebRequest "http://windows.php.net/downloads/pecl/deps/$bname" -OutFile "c:\build-cache\$bname"
- 7z x c:\build-cache\$bname -oc:\build-cache\deps
-}
diff --git a/appveyor/package.ps1 b/appveyor/package.ps1
deleted file mode 100644
index 878361e8..00000000
--- a/appveyor/package.ps1
+++ /dev/null
@@ -1,20 +0,0 @@
-$ts_part = ''
-if ('0' -eq $env:TS) { $ts_part = '-nts' }
-$arch_part = ''
-if ('x64' -eq $env:ARCH) { $arch_part = '-x86_64' }
-if ($env:APPVEYOR_REPO_TAG -eq "true") {
- $bname = 'php_amqp-' + $env:APPVEYOR_REPO_TAG_NAME + '-' + $env:PHP_VER.substring(0, 3) + '-' + $env:VC + $ts_part + $arch_part
-} else {
- #$bname = 'php_amqp-' + $env:APPVEYOR_REPO_COMMIT.substring(0, 8) + '-' + $env:PHP_VER.substring(0, 3) + '-' + $env:VC + $ts_part + $arch_part
- $bname = 'php_amqp-' + $env:PHP_VER.substring(0, 3) + '-' + $env:VC + $ts_part + $arch_part
-}
-$zip_bname = $bname + '.zip'
-$dll_bname = $bname + '.dll'
-$dir = 'c:\projects\amqp\';
-if ('x64' -eq $env:ARCH) { $dir = $dir + 'x64\' }
-$dir = $dir + 'Release'
-if ('1' -eq $env:TS) { $dir = $dir + '_TS' }
-cp $dir\php_amqp.dll $dir\$dll_bname
-cp c:\build-cache\deps\LICENSE-MIT $dir\LICENSE-MIT.LIBRABBITMQ
-& 7z a c:\$zip_bname $dir\$dll_bname $dir\php_amqp.pdb c:\projects\amqp\LICENSE c:\build-cache\deps\bin\rabbitmq.4.* $dir\LICENSE-MIT.LIBRABBITMQ
-Push-AppveyorArtifact c:\$zip_bname
diff --git a/benchmark.php b/benchmark.php
index f640dbec..dbc3a237 100644
--- a/benchmark.php
+++ b/benchmark.php
@@ -23,6 +23,7 @@
$conn = new AMQPConnection();
+$conn->setHost(getenv('PHP_AMQP_HOST'));
$conn->connect();
$ch = new AMQPChannel($conn);
@@ -30,7 +31,7 @@
$exchange = new AMQPExchange($ch);
$exchange->setType(AMQP_EX_TYPE_FANOUT);
$exchange->setFlags(AMQP_AUTODELETE);
-$exchange->setName('benchmark_exchange_' . microtime(true));
+$exchange->setName('benchmark_exchange_' . bin2hex(random_bytes(32)));
$exchange->declareExchange();
$q = new AMQPQueue($ch);
@@ -70,7 +71,7 @@
$exchange = new AMQPExchange($ch);
$exchange->setType(AMQP_EX_TYPE_FANOUT);
$exchange->setFlags(AMQP_AUTODELETE);
-$exchange->setName('benchmark_exchange_' . microtime(true));
+$exchange->setName('benchmark_exchange_' . bin2hex(random_bytes(32)));
$exchange->declareExchange();
$q = new AMQPQueue($ch);
diff --git a/composer.json b/composer.json
index 545ec1d1..b8a946d5 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
- "name": "pdezwart/php-amqp",
- "type": "library",
+ "name": "php-amqp/php-amqp",
+ "type": "php-ext",
"description": "PHP AMQP Binding Library",
"keywords": [
"rabbitmq",
@@ -8,18 +8,42 @@
"message",
"queue"
],
- "homepage": "https://github.com/pdezwart/php-amqp",
+ "homepage": "https://github.com/php-amqp/php-amqp",
"license": "PHP-3.01",
"authors": [
{
- "name": "Pieter de Zwart",
- "email": "pdezwart@php.net",
+ "name": "Lars Strojny",
+ "email": "lstrojny@php.net",
"role": "lead"
}
],
"require": {
- "php": ">=7.1",
+ "php": ">=7.4"
+ },
+ "require-dev": {
+ "ext-json": "*",
"ext-dom": "*",
- "ext-simplexml": "*"
+ "ext-simplexml": "*",
+ "symplify/easy-coding-standard": "*",
+ "slevomat/coding-standard": "^8.13"
+ },
+ "config": {
+ "allow-plugins": {
+ "dealerdirect/phpcodesniffer-composer-installer": false
+ }
+ },
+ "php-ext": {
+ "extension-name": "amqp",
+ "configure-options": [
+ {
+ "name": "with-amqp",
+ "description": "Include amqp support"
+ },
+ {
+ "name": "with-librabbitmq-dir",
+ "description": "Set the path to librabbitmq install prefix.",
+ "needs-value": true
+ }
+ ]
}
}
diff --git a/composer.lock b/composer.lock
new file mode 100644
index 00000000..a8707838
--- /dev/null
+++ b/composer.lock
@@ -0,0 +1,373 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
+ "This file is @generated automatically"
+ ],
+ "content-hash": "485d9b9a9c05994c0b1c905e172de702",
+ "packages": [],
+ "packages-dev": [
+ {
+ "name": "dealerdirect/phpcodesniffer-composer-installer",
+ "version": "v1.2.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/composer-installer.git",
+ "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/845eb62303d2ca9b289ef216356568ccc075ffd1",
+ "reference": "845eb62303d2ca9b289ef216356568ccc075ffd1",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^2.2",
+ "php": ">=5.4",
+ "squizlabs/php_codesniffer": "^3.1.0 || ^4.0"
+ },
+ "require-dev": {
+ "composer/composer": "^2.2",
+ "ext-json": "*",
+ "ext-zip": "*",
+ "php-parallel-lint/php-parallel-lint": "^1.4.0",
+ "phpcompatibility/php-compatibility": "^9.0 || ^10.0.0@dev",
+ "yoast/phpunit-polyfills": "^1.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Franck Nijhof",
+ "email": "opensource@frenck.dev",
+ "homepage": "https://frenck.dev",
+ "role": "Open source developer"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
+ "keywords": [
+ "PHPCodeSniffer",
+ "PHP_CodeSniffer",
+ "code quality",
+ "codesniffer",
+ "composer",
+ "installer",
+ "phpcbf",
+ "phpcs",
+ "plugin",
+ "qa",
+ "quality",
+ "standard",
+ "standards",
+ "style guide",
+ "stylecheck",
+ "tests"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/composer-installer/issues",
+ "security": "https://github.com/PHPCSStandards/composer-installer/security/policy",
+ "source": "https://github.com/PHPCSStandards/composer-installer"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/PHPCSStandards",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/jrfnl",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/php_codesniffer",
+ "type": "open_collective"
+ },
+ {
+ "url": "https://thanks.dev/u/gh/phpcsstandards",
+ "type": "thanks_dev"
+ }
+ ],
+ "time": "2025-11-11T04:32:07+00:00"
+ },
+ {
+ "name": "phpstan/phpdoc-parser",
+ "version": "2.3.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/phpstan/phpdoc-parser.git",
+ "reference": "a004701b11273a26cd7955a61d67a7f1e525a45a"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/a004701b11273a26cd7955a61d67a7f1e525a45a",
+ "reference": "a004701b11273a26cd7955a61d67a7f1e525a45a",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^7.4 || ^8.0"
+ },
+ "require-dev": {
+ "doctrine/annotations": "^2.0",
+ "nikic/php-parser": "^5.3.0",
+ "php-parallel-lint/php-parallel-lint": "^1.2",
+ "phpstan/extension-installer": "^1.0",
+ "phpstan/phpstan": "^2.0",
+ "phpstan/phpstan-phpunit": "^2.0",
+ "phpstan/phpstan-strict-rules": "^2.0",
+ "phpunit/phpunit": "^9.6",
+ "symfony/process": "^5.2"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-4": {
+ "PHPStan\\PhpDocParser\\": [
+ "src/"
+ ]
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "PHPDoc parser with support for nullable, intersection and generic types",
+ "support": {
+ "issues": "https://github.com/phpstan/phpdoc-parser/issues",
+ "source": "https://github.com/phpstan/phpdoc-parser/tree/2.3.2"
+ },
+ "time": "2026-01-25T14:56:51+00:00"
+ },
+ {
+ "name": "slevomat/coding-standard",
+ "version": "8.28.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/slevomat/coding-standard.git",
+ "reference": "0cd4b30cc1037eca54091c188d260d570e61770c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/0cd4b30cc1037eca54091c188d260d570e61770c",
+ "reference": "0cd4b30cc1037eca54091c188d260d570e61770c",
+ "shasum": ""
+ },
+ "require": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.2.0",
+ "php": "^7.4 || ^8.0",
+ "phpstan/phpdoc-parser": "^2.3.2",
+ "squizlabs/php_codesniffer": "^4.0.1"
+ },
+ "require-dev": {
+ "phing/phing": "3.0.1|3.1.2",
+ "php-parallel-lint/php-parallel-lint": "1.4.0",
+ "phpstan/phpstan": "2.1.40",
+ "phpstan/phpstan-deprecation-rules": "2.0.4",
+ "phpstan/phpstan-phpunit": "2.0.16",
+ "phpstan/phpstan-strict-rules": "2.0.10",
+ "phpunit/phpunit": "9.6.34|10.5.63|11.4.4|11.5.50|12.5.14"
+ },
+ "type": "phpcodesniffer-standard",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "8.x-dev"
+ }
+ },
+ "autoload": {
+ "psr-4": {
+ "SlevomatCodingStandard\\": "SlevomatCodingStandard/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
+ "keywords": [
+ "dev",
+ "phpcs"
+ ],
+ "support": {
+ "issues": "https://github.com/slevomat/coding-standard/issues",
+ "source": "https://github.com/slevomat/coding-standard/tree/8.28.0"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/kukulich",
+ "type": "github"
+ },
+ {
+ "url": "https://tidelift.com/funding/github/packagist/slevomat/coding-standard",
+ "type": "tidelift"
+ }
+ ],
+ "time": "2026-02-23T21:35:24+00:00"
+ },
+ {
+ "name": "squizlabs/php_codesniffer",
+ "version": "4.0.1",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git",
+ "reference": "0525c73950de35ded110cffafb9892946d7771b5"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0525c73950de35ded110cffafb9892946d7771b5",
+ "reference": "0525c73950de35ded110cffafb9892946d7771b5",
+ "shasum": ""
+ },
+ "require": {
+ "ext-simplexml": "*",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "php": ">=7.2.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^8.4.0 || ^9.3.4 || ^10.5.32 || 11.3.3 - 11.5.28 || ^11.5.31"
+ },
+ "bin": [
+ "bin/phpcbf",
+ "bin/phpcs"
+ ],
+ "type": "library",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Greg Sherwood",
+ "role": "Former lead"
+ },
+ {
+ "name": "Juliette Reinders Folmer",
+ "role": "Current lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors"
+ }
+ ],
+ "description": "PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.",
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "keywords": [
+ "phpcs",
+ "standards",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues",
+ "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy",
+ "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki"
+ },
+ "funding": [
+ {
+ "url": "https://github.com/PHPCSStandards",
+ "type": "github"
+ },
+ {
+ "url": "https://github.com/jrfnl",
+ "type": "github"
+ },
+ {
+ "url": "https://opencollective.com/php_codesniffer",
+ "type": "open_collective"
+ },
+ {
+ "url": "https://thanks.dev/u/gh/phpcsstandards",
+ "type": "thanks_dev"
+ }
+ ],
+ "time": "2025-11-10T16:43:36+00:00"
+ },
+ {
+ "name": "symplify/easy-coding-standard",
+ "version": "13.0.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/easy-coding-standard/easy-coding-standard.git",
+ "reference": "5c7e7a07e5d6a98b9dd2e6fc0a9155efb7c166c8"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/easy-coding-standard/easy-coding-standard/zipball/5c7e7a07e5d6a98b9dd2e6fc0a9155efb7c166c8",
+ "reference": "5c7e7a07e5d6a98b9dd2e6fc0a9155efb7c166c8",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=7.2"
+ },
+ "conflict": {
+ "friendsofphp/php-cs-fixer": "<3.92.4",
+ "phpcsstandards/php_codesniffer": "<4.0.1",
+ "symplify/coding-standard": "<12.1"
+ },
+ "suggest": {
+ "ext-dom": "Needed to support checkstyle output format in class CheckstyleOutputFormatter"
+ },
+ "bin": [
+ "bin/ecs"
+ ],
+ "type": "library",
+ "autoload": {
+ "files": [
+ "bootstrap.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "description": "Use Coding Standard with 0-knowledge of PHP-CS-Fixer and PHP_CodeSniffer",
+ "keywords": [
+ "Code style",
+ "automation",
+ "fixer",
+ "static analysis"
+ ],
+ "support": {
+ "issues": "https://github.com/easy-coding-standard/easy-coding-standard/issues",
+ "source": "https://github.com/easy-coding-standard/easy-coding-standard/tree/13.0.4"
+ },
+ "funding": [
+ {
+ "url": "https://www.paypal.me/rectorphp",
+ "type": "custom"
+ },
+ {
+ "url": "https://github.com/tomasvotruba",
+ "type": "github"
+ }
+ ],
+ "time": "2026-01-05T09:10:04+00:00"
+ }
+ ],
+ "aliases": [],
+ "minimum-stability": "stable",
+ "stability-flags": {},
+ "prefer-stable": false,
+ "prefer-lowest": false,
+ "platform": {
+ "php": ">=7.4"
+ },
+ "platform-dev": {
+ "ext-json": "*",
+ "ext-dom": "*",
+ "ext-simplexml": "*"
+ },
+ "plugin-api-version": "2.6.0"
+}
diff --git a/config.m4 b/config.m4
index 3e30d485..94624fa4 100644
--- a/config.m4
+++ b/config.m4
@@ -7,12 +7,18 @@ PHP_ARG_WITH(librabbitmq-dir, for amqp,
[ --with-librabbitmq-dir[=DIR] Set the path to librabbitmq install prefix.], yes)
dnl Set test wrapper binary to ignore any local ini settings
-PHP_EXECUTABLE="$PWD/php-test-bin"
if test "$PHP_AMQP" != "no"; then
- AC_MSG_CHECKING([for supported PHP versions])
- PHP_REF_FOUND_VERSION=`${PHP_CONFIG} --version`
- PHP_REF_FOUND_VERNUM=`${PHP_CONFIG} --vernum`
+ AC_MSG_CHECKING([for supported PHP versions])
+ PHP_REF_FOUND_VERSION=$PHP_VERSION
+ PHP_REF_FOUND_VERNUM=$PHP_VERSION_ID
+ if test -z "$PHP_REF_FOUND_VERNUM"; then
+ if test -z "$PHP_CONFIG"; then
+ AC_MSG_ERROR([php-config not found])
+ fi
+ PHP_REF_FOUND_VERSION=`${PHP_CONFIG} --version`
+ PHP_REF_FOUND_VERNUM=`${PHP_CONFIG} --vernum`
+ fi
if test "$PHP_REF_FOUND_VERNUM" -lt "50600"; then
AC_MSG_ERROR([PHP version not supported, >= 5.6 required, but $PHP_REF_FOUND_VERSION found])
@@ -24,9 +30,12 @@ if test "$PHP_AMQP" != "no"; then
dnl # --with-amqp -> check with-path
- SEARCH_FOR="amqp_framing.h"
+ NEW_LAYOUT=rabbitmq-c/framing.h
+ OLD_LAYOUT=amqp_framing.h
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
+ HAVE_LIBRABBITMQ_NEW_LAYOUT=0
+
if test "$PHP_LIBRABBITMQ_DIR" = "yes" -a -x $PKG_CONFIG; then
AC_MSG_CHECKING([for amqp using pkg-config])
@@ -34,11 +43,19 @@ if test "$PHP_AMQP" != "no"; then
AC_MSG_ERROR([librabbitmq not found])
fi
- PHP_AMQP_VERSION=`$PKG_CONFIG librabbitmq --modversion`
- AC_MSG_RESULT([found version $PHP_AMQP_VERSION])
+ LIBRABBITMQ_VERSION=`$PKG_CONFIG librabbitmq --modversion`
+ AC_MSG_RESULT([found version $LIBRABBITMQ_VERSION])
+
+ if ! $PKG_CONFIG librabbitmq --atleast-version 0.8.0 ; then
+ AC_MSG_ERROR([librabbitmq must be version 0.8.0 or greater])
+ fi
+
+ if ! $PKG_CONFIG librabbitmq --atleast-version 0.10.0 ; then
+ AC_MSG_WARN([librabbitmq 0.10.0 or greater recommended, current version is $LIBRABBITMQ_VERSION])
+ fi
- if ! $PKG_CONFIG librabbitmq --atleast-version 0.7.1 ; then
- AC_MSG_ERROR([librabbitmq must be version 0.7.1 or greater])
+ if test -r `$PKG_CONFIG librabbitmq --variable=includedir`/$NEW_LAYOUT; then
+ HAVE_LIBRABBITMQ_NEW_LAYOUT=1
fi
PHP_AMQP_LIBS=`$PKG_CONFIG librabbitmq --libs`
@@ -51,8 +68,13 @@ if test "$PHP_AMQP" != "no"; then
AC_MSG_CHECKING([for amqp files in default path])
if test "$PHP_LIBRABBITMQ_DIR" != "no" && test "$PHP_LIBRABBITMQ_DIR" != "yes"; then
for i in $PHP_LIBRABBITMQ_DIR; do
- if test -r $i/include/$SEARCH_FOR;
- then
+ if test -r $i/include/$NEW_LAYOUT; then
+ AMQP_DIR=$i
+ HAVE_LIBRABBITMQ_NEW_LAYOUT=1
+ AC_MSG_RESULT(found in $i)
+ break
+ fi
+ if test -r $i/include/$OLD_LAYOUT; then
AMQP_DIR=$i
AC_MSG_RESULT(found in $i)
break
@@ -60,8 +82,13 @@ if test "$PHP_AMQP" != "no"; then
done
else
for i in $PHP_AMQP /usr/local /usr ; do
- if test -r $i/include/$SEARCH_FOR;
- then
+ if test -r $i/include/$NEW_LAYOUT; then
+ AMQP_DIR=$i
+ HAVE_LIBRABBITMQ_NEW_LAYOUT=1
+ AC_MSG_RESULT(found in $i)
+ break
+ fi
+ if test -r $i/include/$OLD_LAYOUT; then
AMQP_DIR=$i
AC_MSG_RESULT(found in $i)
break
@@ -110,12 +137,12 @@ if test "$PHP_AMQP" != "no"; then
IFS=$ac_IFS
LIBRABBITMQ_API_VERSION=`expr [$]1 \* 1000000 + [$]2 \* 1000 + [$]3`
- if test "$LIBRABBITMQ_API_VERSION" -lt 5001 ; then
- AC_MSG_ERROR([librabbitmq must be version 0.5.2 or greater, $ac_cv_librabbitmq_version version given instead])
+ if test "$LIBRABBITMQ_API_VERSION" -lt 8000 ; then
+ AC_MSG_ERROR([librabbitmq must be version 0.8.0 or greater, $ac_cv_librabbitmq_version version given instead])
fi
- if test "$LIBRABBITMQ_API_VERSION" -lt 6000 ; then
- AC_MSG_WARN([librabbitmq 0.6.0 or greater recommended, current version is $ac_cv_librabbitmq_version])
+ if test "$LIBRABBITMQ_API_VERSION" -lt 10000 ; then
+ AC_MSG_WARN([librabbitmq 0.10.0 or greater recommended, current version is $ac_cv_librabbitmq_version])
fi
else
AC_MSG_ERROR([could not determine librabbitmq version])
@@ -127,9 +154,14 @@ if test "$PHP_AMQP" != "no"; then
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $AMQP_DIR/$PHP_LIBDIR, AMQP_SHARED_LIBADD)
fi
+
+ AC_MSG_CHECKING([for new librabbitmq layout])
+ AC_MSG_RESULT([${HAVE_LIBRABBITMQ_NEW_LAYOUT}])
+ AC_DEFINE_UNQUOTED(HAVE_LIBRABBITMQ_NEW_LAYOUT, ${HAVE_LIBRABBITMQ_NEW_LAYOUT}, ["Librabbitmq new layout"])
+
PHP_SUBST(AMQP_SHARED_LIBADD)
- AMQP_SOURCES="amqp.c amqp_type.c amqp_exchange.c amqp_queue.c amqp_connection.c amqp_connection_resource.c amqp_channel.c amqp_envelope.c amqp_basic_properties.c amqp_methods_handling.c amqp_timestamp.c amqp_decimal.c"
+ AMQP_SOURCES="amqp.c amqp_envelope_exception.c amqp_type.c amqp_exchange.c amqp_queue.c amqp_connection.c amqp_connection_resource.c amqp_channel.c amqp_envelope.c amqp_basic_properties.c amqp_methods_handling.c amqp_value.c amqp_timestamp.c amqp_decimal.c"
PHP_NEW_EXTENSION(amqp, $AMQP_SOURCES, $ext_shared)
fi
diff --git a/config.w32 b/config.w32
index b9d32299..4d5420bc 100644
--- a/config.w32
+++ b/config.w32
@@ -4,7 +4,7 @@ if (PHP_AMQP != "no") {
if (CHECK_HEADER_ADD_INCLUDE("amqp.h", "CFLAGS_AMQP", PHP_PHP_BUILD + "\\include;" + PHP_PHP_BUILD + "\\include\\librabbitmq;" + PHP_AMQP) &&
CHECK_LIB("rabbitmq.4.lib", "amqp", PHP_PHP_BUILD + "\\lib;" + PHP_AMQP)) {
// ADD_FLAG("CFLAGS_AMQP", "/D HAVE_AMQP_GETSOCKOPT");
- EXTENSION('amqp', 'amqp.c amqp_type.c amqp_exchange.c amqp_queue.c amqp_connection.c amqp_connection_resource.c amqp_channel.c amqp_envelope.c amqp_basic_properties.c amqp_methods_handling.c amqp_timestamp.c amqp_decimal.c');
+ EXTENSION('amqp', 'amqp.c amqp_envelope_exception.c amqp_type.c amqp_exchange.c amqp_queue.c amqp_connection.c amqp_connection_resource.c amqp_channel.c amqp_envelope.c amqp_basic_properties.c amqp_methods_handling.c amqp_value.c amqp_timestamp.c amqp_decimal.c');
AC_DEFINE('HAVE_AMQP', 1);
} else {
WARNING("amqp not enabled; libraries and headers not found");
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 00000000..d5dcdbb8
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,238 @@
+services:
+ rabbitmq:
+ image: rabbitmq:3-management-alpine
+ volumes:
+ - type: bind
+ source: ./infra/rabbitmq/rabbitmq.conf
+ target: /etc/rabbitmq/rabbitmq.conf
+ read_only: true
+ - type: bind
+ source: ./infra/rabbitmq/enabled_plugins
+ target: /etc/rabbitmq/enabled_plugins
+ read_only: true
+ - type: bind
+ source: ./infra/rabbitmq/definitions.json
+ target: /etc/rabbitmq/definitions.json
+ read_only: true
+ - type: bind
+ source: ./infra/tls/certificates
+ target: /etc/rabbitmq/certificates
+ read_only: true
+ ports:
+ # Plain TCP
+ - "5672:5672/tcp"
+ # SSL
+ - "5671:5671/tcp"
+ # Management console
+ - "15672:15672/tcp"
+ depends_on:
+ ca:
+ condition: service_completed_successfully
+ extra_hosts:
+ - "${PHP_AMQP_SSL_HOST}:127.0.0.1"
+ restart: on-failure
+
+ ca:
+ build:
+ context: infra/tls
+ volumes:
+ - ./:/src
+
+ centos-74: ¢os-dev
+ build: ¢os-dev-build
+ context: infra/dev
+ target: redhatish
+ args:
+ php_version: "7.4"
+ additional_contexts:
+ base: docker-image://quay.io/centos/centos:stream9
+ volumes:
+ - ./:/src
+ depends_on:
+ - rabbitmq
+ ulimits:
+ core: -1
+ working_dir: /src/build/centos-74
+ env_file: .env
+ links:
+ - "rabbitmq:${PHP_AMQP_SSL_HOST}"
+
+ centos-80:
+ <<: *centos-dev
+ build:
+ <<: *centos-dev-build
+ args:
+ php_version: "8.0"
+ working_dir: /src/build/centos-80
+
+ centos-81:
+ <<: *centos-dev
+ build:
+ <<: *centos-dev-build
+ args:
+ php_version: "8.1"
+ working_dir: /src/build/centos-81
+
+ centos-82:
+ <<: *centos-dev
+ build:
+ <<: *centos-dev-build
+ args:
+ php_version: "8.2"
+ working_dir: /src/build/centos-82
+
+ centos-83:
+ <<: *centos-dev
+ build:
+ <<: *centos-dev-build
+ args:
+ php_version: "8.3"
+ working_dir: /src/build/centos-83
+
+ centos-84:
+ <<: *centos-dev
+ build:
+ <<: *centos-dev-build
+ args:
+ php_version: "8.4"
+ working_dir: /src/build/centos-84
+
+ centos-85:
+ <<: *centos-dev
+ build:
+ <<: *centos-dev-build
+ args:
+ php_version: "8.5"
+ working_dir: /src/build/centos-85
+
+ ubuntu-74: &ubuntu-dev
+ build: &ubuntu-dev-build
+ context: infra/dev
+ target: ubuntu-php
+ args:
+ php_version: "7.4"
+ additional_contexts:
+ base: docker-image://ubuntu:jammy
+ volumes:
+ - ./:/src
+ depends_on:
+ - rabbitmq
+ ulimits:
+ core: -1
+ working_dir: /src/build/ubuntu-74
+ env_file: .env
+ links:
+ - "rabbitmq:${PHP_AMQP_SSL_HOST}"
+
+ ubuntu-80:
+ <<: *ubuntu-dev
+ build:
+ <<: *ubuntu-dev-build
+ args:
+ php_version: "8.0"
+ working_dir: /src/build/ubuntu-80
+
+ ubuntu-81:
+ <<: *ubuntu-dev
+ build:
+ <<: *ubuntu-dev-build
+ args:
+ php_version: "8.1"
+ working_dir: /src/build/ubuntu-81
+
+ ubuntu-82:
+ <<: *ubuntu-dev
+ build:
+ <<: *ubuntu-dev-build
+ args:
+ php_version: "8.2"
+ working_dir: /src/build/ubuntu-82
+
+ ubuntu-83:
+ <<: *ubuntu-dev
+ build:
+ <<: *ubuntu-dev-build
+ args:
+ php_version: "8.3"
+ working_dir: /src/build/ubuntu-83
+
+ ubuntu-84:
+ <<: *ubuntu-dev
+ build:
+ <<: *ubuntu-dev-build
+ args:
+ php_version: "8.4"
+ working_dir: /src/build/ubuntu-84
+
+ ubuntu-85:
+ <<: *ubuntu-dev
+ build:
+ <<: *ubuntu-dev-build
+ args:
+ php_version: "8.5"
+ working_dir: /src/build/ubuntu-85
+
+ debian-74: &debian-dev
+ build: &debian-dev-build
+ context: infra/dev
+ target: debian-php
+ additional_contexts:
+ base: docker-image://php:7.4-zts-bullseye
+ volumes:
+ - ./:/src
+ depends_on:
+ - rabbitmq
+ ulimits:
+ core: -1
+ working_dir: /src/build/debian-74
+ env_file: .env
+ links:
+ - "rabbitmq:${PHP_AMQP_SSL_HOST}"
+
+ debian-80:
+ <<: *debian-dev
+ build:
+ <<: *debian-dev-build
+ additional_contexts:
+ base: docker-image://php:8.0-zts-bullseye
+ working_dir: /src/build/debian-80
+
+ debian-81:
+ <<: *debian-dev
+ build:
+ <<: *debian-dev-build
+ additional_contexts:
+ base: docker-image://php:8.1-zts-bookworm
+ working_dir: /src/build/debian-81
+
+ debian-82:
+ <<: *debian-dev
+ build:
+ <<: *debian-dev-build
+ additional_contexts:
+ base: docker-image://php:8.2-zts-bookworm
+ working_dir: /src/build/debian-82
+
+ debian-83:
+ <<: *debian-dev
+ build:
+ <<: *debian-dev-build
+ additional_contexts:
+ base: docker-image://php:8.3-rc-zts-bookworm
+ working_dir: /src/build/debian-83
+
+ debian-84:
+ <<: *debian-dev
+ build:
+ <<: *debian-dev-build
+ additional_contexts:
+ base: docker-image://php:8.4-rc-zts-trixie
+ working_dir: /src/build/debian-84
+
+ debian-85:
+ <<: *debian-dev
+ build:
+ <<: *debian-dev-build
+ additional_contexts:
+ base: docker-image://php:8.5-rc-zts-trixie
+ working_dir: /src/build/debian-85
diff --git a/ecs.php b/ecs.php
new file mode 100644
index 00000000..e2756280
--- /dev/null
+++ b/ecs.php
@@ -0,0 +1,115 @@
+rules(
+ [
+ NoUnusedImportsFixer::class,
+ PhpdocIndentFixer::class,
+ OrderedImportsFixer::class,
+ FullyQualifiedStrictTypesFixer::class,
+ GlobalNamespaceImportFixer::class,
+ NoLeadingImportSlashFixer::class,
+ StaticLambdaFixer::class,
+ ReferenceUsedNamesOnlySniff::class,
+ ]
+ );
+
+ $ecsConfig->rules(
+ [
+ StandaloneLinePromotedPropertyFixer::class,
+ BlankLineAfterOpeningTagFixer::class,
+ MethodChainingIndentationFixer::class,
+ CastSpacesFixer::class,
+ ClassAttributesSeparationFixer::class,
+ SingleTraitInsertPerStatementFixer::class,
+ FunctionTypehintSpaceFixer::class,
+ NoBlankLinesAfterClassOpeningFixer::class,
+ NoSinglelineWhitespaceBeforeSemicolonsFixer::class,
+ PhpdocSingleLineVarSpacingFixer::class,
+ NoLeadingNamespaceWhitespaceFixer::class,
+ NoSpacesAroundOffsetFixer::class,
+ NoWhitespaceInBlankLineFixer::class,
+ ReturnTypeDeclarationFixer::class,
+ SpaceAfterSemicolonFixer::class,
+ TernaryOperatorSpacesFixer::class,
+ MethodArgumentSpaceFixer::class,
+ LanguageConstructSpacingSniff::class,
+ ]
+ );
+ $ecsConfig->ruleWithConfiguration(ClassAttributesSeparationFixer::class, [
+ 'elements' => [
+ 'const' => 'one',
+ 'property' => 'one',
+ 'method' => 'one',
+ ],
+ ]);
+ $ecsConfig->ruleWithConfiguration(ConcatSpaceFixer::class, [
+ 'spacing' => 'one',
+ ]);
+ $ecsConfig->ruleWithConfiguration(SuperfluousWhitespaceSniff::class, [
+ 'ignoreBlankLines' => false,
+ ]);
+ $ecsConfig->ruleWithConfiguration(BinaryOperatorSpacesFixer::class, [
+ 'operators' => [
+ '=>' => 'single_space',
+ '=' => 'single_space',
+ ],
+ ]);
+
+ $ecsConfig->sets([
+ SetList::CLEAN_CODE,
+ SetList::ARRAY,
+ SetList::DOCBLOCK,
+ SetList::NAMESPACES,
+ SetList::COMMENTS,
+ SetList::CONTROL_STRUCTURES,
+ SetList::SYMPLIFY,
+ SetList::PSR_12,
+ ]);
+
+ $ecsConfig->ruleWithConfiguration(GeneralPhpdocAnnotationRemoveFixer::class, [
+ 'annotations' => ['author', 'package', 'category'],
+ ]);
+ $ecsConfig->ruleWithConfiguration(PhpdocAlignFixer::class, [
+ 'align' => 'left',
+ ]);
+
+ $ecsConfig->paths([...glob(__DIR__ . '/infra/tools/*'), __DIR__ . '/stubs', __DIR__ . '/infra']);
+};
diff --git a/infra/dev/Dockerfile b/infra/dev/Dockerfile
new file mode 100644
index 00000000..2cc35e97
--- /dev/null
+++ b/infra/dev/Dockerfile
@@ -0,0 +1,54 @@
+# syntax=docker/dockerfile:1.4
+FROM base AS common
+RUN echo 'PATH=$PATH:/src/infra/tools' | tee -a /etc/bashrc /etc/bash.bashrc
+COPY --from=composer /usr/bin/composer /usr/local/bin/composer
+CMD PHP_AMQP_DOCKER_ENTRYPOINT=1 php /src/infra/tools/pamqp-docker-setup && sleep infinity
+
+FROM common AS redhatish
+RUN dnf install -y 'dnf-command(config-manager)'
+RUN dnf config-manager --set-enabled crb
+RUN dnf install -y gcc clang libtool pkg-config autoconf gdb valgrind git unzip librabbitmq-devel
+RUN dnf install -y https://rpms.remirepo.net/enterprise/remi-release-9.rpm
+ARG php_version
+RUN dnf module install -y php:remi-${php_version}
+RUN dnf install -y php-devel
+
+# Install packages on Debian flavored distributions
+FROM common AS debianish
+ENV DEBIAN_FRONTEND=noninteractive
+RUN apt-get update -yqq
+RUN apt-get install -yqq curl
+RUN . /etc/os-release && \
+ curl https://apt.llvm.org/llvm-snapshot.gpg.key > /etc/apt/trusted.gpg.d/llvm-snapshot.asc && \
+ echo "deb https://apt.llvm.org/$VERSION_CODENAME llvm-toolchain-$VERSION_CODENAME-20 main" > /etc/apt/sources.list.d/llvm.list
+RUN apt-get update -yqq
+RUN apt-get install -yqq gcc clang libtool pkg-config autoconf gdb valgrind librabbitmq-dev git unzip
+RUN apt-get install -yqq clang-format-20
+
+# Install PHP on Ubuntu
+FROM debianish AS ubuntu-php
+RUN apt-get install -yqq software-properties-common
+RUN add-apt-repository ppa:ondrej/php
+RUN sed -e "s:main:main main/debug:" -i /etc/apt/sources.list.d/ondrej-*.list
+RUN apt-get update -yqq
+ARG php_version
+RUN apt-get install -yqq php${php_version}-dev php${php_version}-common-dbgsym php${php_version}-cli-dbgsym
+
+FROM debianish AS debian-php
+# Rebuild to enable debug build
+RUN apt-get install -y --no-install-recommends \
+ libargon2-dev \
+ libcurl4-openssl-dev \
+ libonig-dev \
+ libreadline-dev \
+ libsodium-dev \
+ libsqlite3-dev \
+ libssl-dev \
+ libxml2-dev \
+ zlib1g-dev \
+ && \
+ docker-php-source extract && \
+ cd /usr/src/php && \
+ sh -c 'eval $(php --info | grep "^Configure Command" | cut -d " " -f 5-) --enable-debug' && \
+ make -j $(nproc) && \
+ make install \
diff --git a/infra/rabbitmq/definitions.json b/infra/rabbitmq/definitions.json
new file mode 100644
index 00000000..782e2f7a
--- /dev/null
+++ b/infra/rabbitmq/definitions.json
@@ -0,0 +1,44 @@
+{
+ "users": [
+ {
+ "name": "guest",
+ "password": "guest",
+ "tags": [
+ "administrator"
+ ]
+ },
+ {
+ "name": "CN=sasl-client.example.org,O=Example Org,L=Lisboa,ST=Lisboa,C=PT",
+ "password": "",
+ "tags": [
+ "administrator"
+ ]
+ }
+ ],
+ "permissions": [
+ {
+ "configure": ".*",
+ "read": ".*",
+ "user": "guest",
+ "vhost": "/",
+ "write": ".*"
+ },
+ {
+ "configure": ".*",
+ "read": ".*",
+ "user": "CN=sasl-client.example.org,O=Example Org,L=Lisboa,ST=Lisboa,C=PT",
+ "vhost": "/",
+ "write": ".*"
+ }
+ ],
+ "vhosts": [
+ {
+ "limits": [],
+ "metadata": {
+ "description": "Default virtual host",
+ "tags": []
+ },
+ "name": "/"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/infra/rabbitmq/enabled_plugins b/infra/rabbitmq/enabled_plugins
new file mode 100644
index 00000000..9fee0096
--- /dev/null
+++ b/infra/rabbitmq/enabled_plugins
@@ -0,0 +1 @@
+[rabbitmq_management,rabbitmq_auth_mechanism_ssl].
\ No newline at end of file
diff --git a/infra/rabbitmq/rabbitmq.conf b/infra/rabbitmq/rabbitmq.conf
new file mode 100644
index 00000000..7f4430ce
--- /dev/null
+++ b/infra/rabbitmq/rabbitmq.conf
@@ -0,0 +1,12 @@
+listeners.ssl.default = 5671
+
+ssl_options.cacertfile = /etc/rabbitmq/certificates/testca/cacert.pem
+ssl_options.certfile = /etc/rabbitmq/certificates/server/cert.pem
+ssl_options.keyfile = /etc/rabbitmq/certificates/server/key.pem
+ssl_options.verify = verify_peer
+ssl_options.fail_if_no_peer_cert = false
+
+auth_mechanisms.0 = PLAIN
+auth_mechanisms.1 = EXTERNAL
+
+load_definitions = /etc/rabbitmq/definitions.json
diff --git a/infra/tls/Dockerfile b/infra/tls/Dockerfile
new file mode 100644
index 00000000..b614bd15
--- /dev/null
+++ b/infra/tls/Dockerfile
@@ -0,0 +1,4 @@
+FROM alpine:3
+RUN apk add openssl
+RUN apk add acl
+CMD /src/infra/tools/pamqp-certificates-generate /src/infra/tls/certificates
diff --git a/infra/tls/certificates/.gitignore b/infra/tls/certificates/.gitignore
new file mode 100644
index 00000000..72e8ffc0
--- /dev/null
+++ b/infra/tls/certificates/.gitignore
@@ -0,0 +1 @@
+*
diff --git a/tools/functions.php b/infra/tools/functions.php
similarity index 74%
rename from tools/functions.php
rename to infra/tools/functions.php
index 5b338e7e..93c60358 100644
--- a/tools/functions.php
+++ b/infra/tools/functions.php
@@ -1,5 +1,6 @@
' . VERSION_REGEX . ')"';
function re(string ...$regex): string
@@ -130,9 +137,9 @@ function setDate(DateTimeImmutable $now): void
$xml->time = $now->format('H:i:s');
}
-function addFilesToPackageXml(SimpleXMLElement $dir, string $expression, string $role): void {
+function addFilesToPackageXml(SimpleXMLElement $dir, string $expression, string $role): void
+{
foreach (glob(BASE_DIR . $expression) as $file) {
-
$file = str_replace(realpath(BASE_DIR) . '/', '', realpath($file));
if ($file === 'config.h') {
@@ -145,7 +152,8 @@ function addFilesToPackageXml(SimpleXMLElement $dir, string $expression, string
}
}
-function removeFromPackageXmlNodes(SimpleXMLElement $el, string $expression): void {
+function removeFromPackageXmlNodes(SimpleXMLElement $el, string $expression): void
+{
$nodesToDelete = [];
foreach ($el->children() as $file) {
@@ -161,7 +169,8 @@ function removeFromPackageXmlNodes(SimpleXMLElement $el, string $expression): vo
}
}
-function updateFiles(): void {
+function updateFiles(): void
+{
$xml = simplexml_import_dom(packageXml());
assert($xml !== null);
$sourceExpression = '*.[ch]';
@@ -188,12 +197,29 @@ function getSourceVersion(): string
function setSourceVersion(string $nextVersion): void
{
+ [$major, $minor, $patchExtra] = explode('.', $nextVersion);
+ assert(preg_match('/^(?P\d+)(?P\w*)$/', $patchExtra, $matches) === 1);
+ $patch = $matches['patch'];
+ $extra = $matches['extra'];
+
+ if ($major > 0) {
+ $id = sprintf('%d%02d%02d', $major, $minor, $patch);
+ } else {
+ $id = sprintf('%02d%02d', $minor, $patch);
+ }
+ assert(strlen($id) === 5);
+
file_put_contents(
HEADER_VERSION_FILE,
- preg_replace(
- re(SOURCE_VERSION_REGEX),
- '\1"' . $nextVersion . '"',
- file_get_contents(HEADER_VERSION_FILE)
+ strtr(
+ HEADER_VERSION_TEMPLATE,
+ [
+ '{major}' => $major,
+ '{minor}' => $minor,
+ '{patch}' => $patch,
+ '{extra}' => $extra,
+ '{id}' => $id,
+ ]
)
);
}
@@ -225,7 +251,7 @@ function buildChangelog(string $nextTag, string $previousTag): string
$commits = array_filter(
explode(
"\n",
- trim(executeCommand(sprintf('git log --oneline %s..origin/master --pretty=%%h --no-merges', $previousTag)))
+ trim(executeCommand(sprintf('git log --oneline %s..origin/latest --pretty=%%h --no-merges', $previousTag)))
)
);
@@ -246,26 +272,65 @@ function buildChangelog(string $nextTag, string $previousTag): string
$issueId = $matches['issueId'];
}
- $url = $issueId ? sprintf(ISSUE_URL_TEMPLATE, $issueId): sprintf(COMMIT_URL_TEMPLATE, $commit);
+ $url = $issueId ? sprintf(ISSUE_URL_TEMPLATE, $issueId) : sprintf(COMMIT_URL_TEMPLATE, $commit);
$committer = strpos($committerEmail, '@users.noreply.github.com') !== false
? $committerName
: sprintf('%s <%s>', $committerName, $committerEmail);
$changeLines[] = sprintf(' - %s (%s) (%s)', ucfirst($message), $committer, $url);
}
+ usort($changeLines, 'AMQP\\compareChangelogLines');
+
$changes = implode(PHP_EOL, $changeLines);
$changelog = << $rightPriority;
+ }
+
+ return $left <=> $right;
+}
+
+function getChangelogPriority(string $line): int
+{
+ $lineWithoutDash = substr($line, 3);
+
+ if (strStartsWithCaseInsensitive($lineWithoutDash, 'bump')) {
+ return 100;
+ }
+
+ if (strStartsWithCaseInsensitive($lineWithoutDash, 'refactor')) {
+ return 50;
+ }
+
+ if (strStartsWithCaseInsensitive($lineWithoutDash, 'fix')) {
+ return 30;
+ }
+
+ return 0;
+}
+
+function strStartsWithCaseInsensitive(string $haystack, string $needle): bool
+{
+ return strnatcasecmp(substr($haystack, 0, strlen($needle)), $needle) === 0;
+}
+
+function archiveRelease(): void
+{
$dom = packageXml();
$xml = simplexml_import_dom($dom);
assert($xml !== null);
@@ -295,12 +360,15 @@ function setStability(string $nextVersion): void
: 'stable';
$stability = $stability === 'dev' ? 'devel' : $stability;
$stability = strpos($stability, 'RC') === 0 ? 'beta' : $stability;
+ $stability = strpos($stability, 'alpha') === 0 ? 'alpha' : $stability;
+ $stability = strpos($stability, 'beta') === 0 ? 'beta' : $stability;
$xml->stability->release = $stability;
$xml->stability->api = $stability;
}
-function executeCommand(string $command): string {
+function executeCommand(string $command): string
+{
exec($command, $output, $returnCode);
if ($returnCode !== 0) {
@@ -313,34 +381,38 @@ function executeCommand(string $command): string {
return implode("\n", $output);
}
-function validatePackage(): void {
+function validatePackage(): void
+{
executeCommand('pecl package-validate');
}
-function peclPackage(int $step, string $nextVersion): void {
+function peclPackage(int $step, string $nextVersion): void
+{
executeCommand('pecl package');
$archive = 'amqp-' . $nextVersion . '.tgz';
if (!file_exists(BASE_DIR . $archive)) {
- echo "Could find $archive\n";
+ echo "Could find {$archive}\n";
exit(1);
}
printf("%d) Upload %s to PECL\n", $step, $archive);
}
-function gitCommit(int $step, string $nextVersion, string $message): void {
+function gitCommit(int $step, string $nextVersion, string $message): void
+{
executeCommand(
sprintf('git commit -m "[RM] %s %s" %s %s', $message, $nextVersion, HEADER_VERSION_FILE, PACKAGE_XML)
);
- printf("%d) Run \"git push origin master\"\n", $step);
+ printf("%d) Run \"git push origin latest\"\n", $step);
}
-function gitTag(int $step, string $nextVersion): void {
+function gitTag(int $step, string $nextVersion): void
+{
$nextTag = versionToTag($nextVersion);
- executeCommand("git tag ${nextTag}");
+ executeCommand(sprintf("git tag %s -m '[RM] release %s'", $nextTag, $nextVersion));
printf("%d) Run \"git push origin %s\"\n", $step, $nextTag);
}
diff --git a/infra/tools/pamqp-arguments-validate b/infra/tools/pamqp-arguments-validate
new file mode 100755
index 00000000..671d7e67
--- /dev/null
+++ b/infra/tools/pamqp-arguments-validate
@@ -0,0 +1,186 @@
+#!/usr/bin/env php
+ 0);
+
+ $fileName = 'amqp_' . implode('_', array_map('strtolower', $parts)) . '.c';
+
+ $path = __DIR__ . '/../../' . $fileName;
+
+ if (file_exists($path)) {
+ return file_get_contents($path);
+ }
+
+ if (end($parts) === 'Exception') {
+ return file_get_contents(__DIR__ . '/../../amqp.c');
+ }
+
+ return null;
+}
+
+function validate(string $class)
+{
+ $refl = new ReflectionClass($class);
+
+ if ($refl->isInterface()) {
+ return;
+ }
+
+ $source = getSource($class);
+
+ if ($source === null) {
+ error('Could not load source for "%s"', $class);
+ return;
+ }
+
+ foreach ($refl->getMethods() as $method) {
+ if ($method->getName() == 'declare') {
+ continue;
+ }
+
+ if ($method->getDeclaringClass()->getName() !== $class) {
+ continue;
+ }
+
+ assert(preg_match('/
+ PHP_METHOD\(.*?,\s*' . preg_quote($method->getName(), '/') . '\).*?
+ \{.*?
+ ((?zend_parse_parameters)\(.+?,\s*\"(?.*?)\"|PHP_AMQP_NOPARAMS|zend_parse_parameters_none)
+ /xs', $source, $matches), $class . ' ' . $method->getName());
+
+ $parametersString = $matches['def'] ?? '';
+
+ try {
+ [$types, $numberOfRequiredParameters] = parseParameterString($parametersString);
+ } catch (Throwable $t) {
+ throw new RuntimeException(sprintf(
+ 'Could not parse parameter string "%s" for %s::%s',
+ $parametersString,
+ $class,
+ $method->getName()
+ ), 0, $t);
+ }
+
+ if ($method->getNumberOfRequiredParameters() !== $numberOfRequiredParameters) {
+ error(
+ '%s::%s(): Number of required parameters do not match. Parameter parsing: %d (%s). Reflection: %d',
+ $class,
+ $method->getName(),
+ $numberOfRequiredParameters,
+ $parametersString,
+ $method->getNumberOfRequiredParameters()
+ );
+ }
+
+ if ($method->getNumberOfParameters() !== count($types)) {
+ error(
+ '%s::%s(): Number of parameters do not match. Parameter parsing: %d (%s). Reflection: %d',
+ $class,
+ $method->getName(),
+ count($types),
+ $parametersString,
+ $method->getNumberOfParameters()
+ );
+ }
+
+ foreach ($method->getParameters() as $pos => $parameter) {
+ $reflectionType = $parameter->hasType() ? ($parameter->getType()->isBuiltin() ? $parameter->getType()->getName() : 'object') : 'mixed';
+
+ if ($reflectionType !== $types[$pos]['type']) {
+ error(
+ '%s::%s(): type parsing and Reflection info do not match. Parameter parsing: %s (%s). Reflection: %s',
+ $class,
+ $method->getName(),
+ $types[$pos]['type'],
+ $parametersString,
+ $reflectionType
+ );
+ }
+
+ $reflectionNullable = $parameter->allowsNull() || !$parameter->hasType();
+ if ($reflectionNullable !== $types[$pos]['nullable']) {
+ error(
+ '%s::%s(%s): type parsing and Reflection nullability differs. Parameter parsing: %s (%s). Reflection: %s',
+ $class,
+ $method->getName(),
+ $parameter->getName(),
+ $types[$pos]['nullable'] ? 'nullable' : 'not nullable',
+ $parametersString,
+ $reflectionNullable ? 'nullable' : 'not nullable'
+ );
+ }
+ }
+ }
+}
+
+$isError = false;
+function error(string $message, ...$args): void
+{
+ global $isError;
+ $isError = true;
+ vprintf('ERROR: ' . $message . PHP_EOL, $args);
+}
+
+function parseParameterString(string $str): array
+{
+ if ($str == '') {
+ return [[], 0];
+ }
+
+ $types = [
+ 's' => 'string',
+ 'O' => 'object',
+ 'l' => 'int',
+ 'a' => 'array',
+ 'f' => 'callable',
+ 'd' => 'float',
+ 'b' => 'bool',
+ 'z' => 'mixed',
+ ];
+ $parameters = [];
+ $requiredCount = null;
+ $count = 0;
+ foreach (str_split($str) as $char) {
+ if (isset($types[$char])) {
+ if (isset($currentInfo)) {
+ $parameters[] = $currentInfo;
+ }
+ $currentInfo = [
+ 'type' => $types[$char],
+ 'nullable' => $types[$char] === 'mixed',
+ ];
+ $count++;
+ } elseif ($char == '!') {
+ $currentInfo['nullable'] = true;
+ } elseif ($char === '|') {
+ $requiredCount = $count;
+ } elseif ($char === '/') {
+ // Ignored
+ } else {
+ throw new InvalidArgumentException(sprintf('Cannot handle char <%s>', $char));
+ }
+ }
+
+ if ($requiredCount === null) {
+ $requiredCount = $count;
+ }
+
+ if (isset($currentInfo)) {
+ $parameters[] = $currentInfo;
+ }
+
+ return [$parameters, $requiredCount];
+}
+
+function getAmqpClasses(): array
+{
+ $ext = new ReflectionExtension('amqp');
+ return $ext->getClassNames();
+}
+
+array_map('validate', getAmqpClasses());
+
+exit((int) $isError);
diff --git a/infra/tools/pamqp-build b/infra/tools/pamqp-build
new file mode 100755
index 00000000..6a67e2ff
--- /dev/null
+++ b/infra/tools/pamqp-build
@@ -0,0 +1,23 @@
+#!/usr/bin/env sh
+
+set -o errexit
+set -o nounset
+
+base_dir=`dirname $0`/../../
+real_base_dir=`realpath $base_dir`
+
+mode="${1:-}"
+
+if test ! -x $real_base_dir/configure -o "$mode" = "clean"; then
+ (cd $real_base_dir && phpize)
+fi
+
+if test ! -f Makefile -o "$mode" = "clean"; then
+ $real_base_dir/configure
+fi
+
+if test "$mode" = "clean"; then
+ make clean
+fi
+
+make
diff --git a/infra/tools/pamqp-certificates-generate b/infra/tools/pamqp-certificates-generate
new file mode 100755
index 00000000..68fd78c9
--- /dev/null
+++ b/infra/tools/pamqp-certificates-generate
@@ -0,0 +1,39 @@
+#!/usr/bin/env sh
+
+set -o errexit
+set -o nounset
+
+cert_dir="${1:-}"
+
+if test -z "$cert_dir"; then
+ echo "$(basename $0) "
+ exit 1
+fi
+
+mkdir -p $cert_dir
+rm -rf $cert_dir/*
+
+mkdir -p $cert_dir/testca/private $cert_dir/server $cert_dir/sasl-client $cert_dir/client
+
+(cd $cert_dir/testca &&
+ openssl req -new -x509 -keyout private/cakey.pem -out cacert.pem -days 365 -nodes -subj "/C=PT/ST=Lisboa/L=Lisboa/O=Example Org")
+
+(cd $cert_dir/server &&
+ openssl genrsa -out key.pem 2048 &&
+ openssl req -new -key key.pem -out req.pem -subj "/C=PT/ST=Lisboa/L=Lisboa/O=Example Org/CN=*.example.org" &&
+ openssl x509 -req -in req.pem -CA ../testca/cacert.pem -CAkey ../testca/private/cakey.pem -CAcreateserial -out cert.pem -days 365)
+
+(cd $cert_dir/sasl-client &&
+ openssl genrsa -out key.pem 2048 &&
+ openssl req -new -key key.pem -out req.pem -subj "/C=PT/ST=Lisboa/L=Lisboa/O=Example Org/CN=sasl-client.example.org" &&
+ openssl x509 -req -in req.pem -CA ../testca/cacert.pem -CAkey ../testca/private/cakey.pem -CAcreateserial -out cert.pem -days 365)
+
+(cd $cert_dir/client &&
+ openssl genrsa -out key.pem 2048 &&
+ openssl req -new -key key.pem -out req.pem -subj "/C=PT/ST=Lisboa/L=Lisboa/O=Example Org/CN=client.example.org" &&
+ openssl x509 -req -in req.pem -CA ../testca/cacert.pem -CAkey ../testca/private/cakey.pem -CAcreateserial -out cert.pem -days 365)
+
+# Set permissions for the different images consuming the certificates
+# - 100 is the UID of the rabbitmq user of the rabbitmq image that runs the rabbitmq process
+# - 1001 is the UID of the GitHub Action runner user that runs the tests
+setfacl -R -m u:100:rX -m u:1001:rX $cert_dir || true
diff --git a/infra/tools/pamqp-check b/infra/tools/pamqp-check
new file mode 100755
index 00000000..a09d791b
--- /dev/null
+++ b/infra/tools/pamqp-check
@@ -0,0 +1,12 @@
+#!/usr/bin/env sh
+
+set -o errexit
+set -o nounset
+
+make test
+pamqp-stubs-lint
+pamqp-stubs-validate
+php -d extension=modules/amqp.so $(which pamqp-arguments-validate)
+
+pamqp-format-check
+pamqp-stubs-format-check
diff --git a/infra/tools/pamqp-diff-bc b/infra/tools/pamqp-diff-bc
new file mode 100755
index 00000000..034d4d1f
--- /dev/null
+++ b/infra/tools/pamqp-diff-bc
@@ -0,0 +1,356 @@
+#!/usr/bin/env php
+implements|extends)\s+(?[A-Za-z_]+)/',
+ static function ($matches) use ($className) {
+ $suffix = strpos($matches['class'], 'AMQP') === 0 ?
+ (pamqp_string_ends_with($className, PREV_SUFFIX) ? PREV_SUFFIX : NEXT_SUFFIX)
+ : '';
+
+ return $matches['stmt'] . ' ' . $matches['class'] . $suffix;
+ },
+ $source
+ );
+ $source = preg_replace('/^<\?php.*/', '', $source);
+ eval($source);
+});
+
+function compare(string $className)
+{
+ $prev = new ReflectionClass($className . PREV_SUFFIX);
+ $next = new ReflectionClass($className . NEXT_SUFFIX);
+
+ $prevConstantNames = array_keys($prev->getConstants());
+ $nextConstantNames = array_keys($prev->getConstants());
+ $removedConstantNames = array_diff($prevConstantNames, $nextConstantNames);
+ $addedConstantNames = array_diff($nextConstantNames, $prevConstantNames);
+
+ $removedConstants = [];
+ foreach ($removedConstantNames as $removedConstantName) {
+ $removedConstants[] = sprintf(' * `%s`', $removedConstantName);
+ }
+
+ $addedConstants = [];
+ foreach ($addedConstantNames as $addedConstantName) {
+ $addedConstants[] = sprintf(' * `%s`', $addedConstantName);
+ }
+
+ $prevMethodNames = getMethodNames($prev);
+ $nextMethodNames = getMethodNames($next);
+
+ $removedMethods = [];
+ foreach (array_diff($prevMethodNames, $nextMethodNames) as $removedMethodName) {
+ $removedMethods[] = sprintf(' * `%s()`', $removedMethodName);
+ }
+
+ $addedMethods = [];
+ foreach (array_diff($nextMethodNames, $prevMethodNames) as $addedMethodName) {
+ $addedMethods[] = sprintf(' * `%s`', getParameterString($className, $next->getMethod($addedMethodName)));
+ }
+
+ $constantChanges = [];
+ foreach ($prevConstantNames as $prevConstantName) {
+ $prevValue = $prev->getConstant($prevConstantName);
+ $nextValue = $next->getConstant($prevConstantName);
+
+ if ($prevValue === $nextValue) {
+ continue;
+ }
+
+ $prevConst = sprintf('const %s = %s', $prevConstantName, var_export($prevValue, true));
+ $nextConst = sprintf('const %s = %s', $prevConstantName, var_export($nextValue, true));
+
+ $constantChanges[] = sprintf("```diff\n%s\n```\n", diff($prevConst, $nextConst));
+ }
+
+ $methodTypeChanges = [];
+ $methodParameterNameChanges = [];
+ foreach ($prevMethodNames as $methodName) {
+ $prevSignature = getParameterString($className, $prev->getMethod($methodName));
+ $nextSignature = getParameterString($className, $next->getMethod($methodName));
+
+ if (strtolower($prevSignature) == strtolower($nextSignature)) {
+ continue;
+ }
+
+ $prevSignatureNorm = getParameterString($className, $prev->getMethod($methodName), true);
+ $nextSignatureNorm = getParameterString($className, $next->getMethod($methodName), true);
+
+ if (strtolower($prevSignatureNorm) === strtolower($nextSignatureNorm)) {
+ $methodParameterNameChanges[] = sprintf("```diff\n%s\n```\n", diff($prevSignature, $nextSignature));
+ continue;
+ }
+
+ $methodTypeChanges[] = sprintf("```diff\n%s\n```", diff($prevSignature, $nextSignature));
+ }
+
+ $report = [
+ ...($addedConstants ? ["### Constant additions\n", ...$addedConstants, ''] : []),
+ ...($removedConstants ? ["### Constant removals\n", ...$removedConstants, ''] : []),
+ ...($constantChanges ? ["### Public constant changes\n", ...$constantChanges, ''] : []),
+ ...($addedMethods ? ["### Public method additions\n", ...$addedMethods, ''] : []),
+ ...($removedMethods ? ["### Public method removals\n", ...$removedMethods, ''] : []),
+ ...($methodTypeChanges ? ["### Public method type changes\n", ...$methodTypeChanges, ''] : []),
+ ...($methodParameterNameChanges ? ["### Parameter name changes\n", ...$methodParameterNameChanges, ''] : []),
+ ];
+
+ return $report ? [sprintf("## `%s` breaking changes\n", $className), ...$report] : [];
+}
+
+function diff(string $prev, string $next): string
+{
+ if (strpos($prev, "\n") === false && strpos($next, "\n") === false) {
+ return sprintf("- %s\n+ %s\n", $prev, $next);
+ }
+
+ if (substr_count($prev, "\n") === substr_count($next, "\n")) {
+ return implode("\n", array_map(static function ($old, $new) {
+ return $old === $new ? sprintf(' %s', $new) : sprintf("- %s\n+ %s", $old, $new);
+ }, explode("\n", $prev), explode("\n", $next)));
+ }
+
+ $oldFile = tmpfile();
+ $newFile = tmpfile();
+
+ fwrite($oldFile, $prev);
+ fwrite($newFile, $next);
+
+ exec(
+ sprintf(
+ 'diff --suppress-common-lines -d -u %s %s',
+ escapeshellarg(stream_get_meta_data($oldFile)['uri']),
+ escapeshellarg(stream_get_meta_data($newFile)['uri'])
+ ),
+ $output,
+ $exitCode
+ );
+
+ assert($exitCode === 1);
+
+ return implode(
+ "\n",
+ array_filter(
+ $output,
+ static function (string $line) {
+ return !in_array(substr($line, 0, 3), ['---', '+++', '\\ N', '@@ '], true);
+ }
+ )
+ );
+}
+
+function getMethodNames(ReflectionClass $class): array
+{
+ return array_map(
+ static function (ReflectionMethod $m) {
+ return $m->getName();
+ },
+ array_filter(
+ $class->getMethods(ReflectionMethod::IS_PUBLIC),
+ static function (ReflectionMethod $method) use ($class) {
+ return $method->getDeclaringClass()
+ ->getName() === $class->getName();
+ }
+ )
+ );
+}
+
+const BASE_TYPE_REGEX = '(string|bool(?:ean)?|int(?:eger)?|double|float|array|object|resource|[A-Za-z_\\\]+(?:\[\])?)';
+const TYPE_REGEX = BASE_TYPE_REGEX . '(?:\s*\|\s*(' . BASE_TYPE_REGEX . '))*';
+
+function getParamTypeFromDocBlock(string $docComment, string $parameter): ?string
+{
+ if (!preg_match('/@param\s+(?' . TYPE_REGEX . ')\s+' . '\$' . $parameter . '/', $docComment, $matches)) {
+ return null;
+ }
+
+ return normalizeType($matches['type']);
+}
+
+function getReturnTypeFromDocBlock(string $docComment): ?string
+{
+ if (!preg_match('/@return\s+(?' . TYPE_REGEX . ')/', $docComment, $matches)) {
+ return null;
+ }
+
+ return normalizeType($matches['type']);
+}
+
+function normalizeType(string $type): string
+{
+ $types = [];
+ foreach (explode('|', str_replace(' ', '', $type)) as $actualType) {
+ switch (strtolower($actualType)) {
+ case 'boolean':
+ $actualType = 'bool';
+ break;
+ case 'integer':
+ $actualType = 'int';
+ break;
+ case 'double':
+ $actualType = 'float';
+ break;
+ case 'int':
+ case 'float':
+ case 'string':
+ case 'bool':
+ case 'object':
+ case 'resource':
+ case 'null':
+ case 'array':
+ $actualType = strtolower($actualType);
+ break;
+ default:
+ $actualType = $actualType;
+ break;
+ }
+ // Normalize typed arrays as array
+ if (pamqp_string_ends_with($actualType, '[]')) {
+ $actualType = 'array';
+ }
+ $types[] = $actualType;
+ }
+
+ if (count($types) == 2 && in_array('null', $types, true)) {
+ $types = array_map(static function ($type) {
+ return '?' . $type;
+ }, array_filter($types, static function ($type) {
+ return $type !== 'null';
+ }));
+ }
+
+ sort($types);
+ $index = array_search('null', $types, true);
+ if ($index !== false) {
+ unset($types[$index]);
+ // Sort to the end
+ $types[] = 'null';
+ }
+
+ return implode('|', $types);
+}
+
+function getParameterString(string $className, ReflectionMethod $method, bool $normalizeNames = false): string
+{
+ $parameters = [];
+
+ foreach ($method->getParameters() as $pos => $reflParameter) {
+ $parameterTokens = [];
+ $typeFound = false;
+ if ($reflParameter->hasType()) {
+ $typeFound = true;
+ $parameterTokens[] = ($reflParameter->allowsNull() || ($reflParameter->isDefaultValueAvailable() && $reflParameter->getDefaultValue() === null) ? '?' : '') . $reflParameter->getType()->getName();
+ } elseif ($method->getDocComment()) {
+ $docBlockParamType = getParamTypeFromDocBlock($method->getDocComment(), $reflParameter->getName());
+ if ($docBlockParamType !== null) {
+ $typeFound = true;
+ $parameterTokens[] = $docBlockParamType;
+ }
+ }
+ if (!$typeFound) {
+ $parameterTokens[] = 'unknown';
+ }
+ $parameterTokens[] = sprintf('$%s', $normalizeNames ? chr($pos + 97) : $reflParameter->getName());
+
+ if ($reflParameter->isDefaultValueAvailable()) {
+ $parameterTokens[] = '=';
+ $defaultValue = $reflParameter->getDefaultValue();
+ $parameterTokens[] = $defaultValue === [] ? '[]' : ($defaultValue === null ? 'null' : var_export(
+ $defaultValue,
+ true
+ ));
+ }
+
+ $parameters[] = implode(' ', $parameterTokens);
+ }
+
+ $returnTypeTokens = [];
+ $returnTypeFound = false;
+ if ($method->hasReturnType()) {
+ $returnTypeFound = true;
+ $returnType = $method->getReturnType();
+ $returnTypeTokens[] = ':';
+ $returnTypeTokens[] = ($returnType->allowsNull() ? '?' : '') . $returnType->getName();
+ } elseif ($method->getDocComment()) {
+ $docBlockReturnType = getReturnTypeFromDocBlock($method->getDocComment());
+ if ($docBlockReturnType !== null) {
+ $returnTypeFound = true;
+ $returnTypeTokens[] = ':';
+ $returnTypeTokens[] = $docBlockReturnType;
+ }
+ }
+ if (!$returnTypeFound && $method->getName() !== '__construct') {
+ $returnTypeTokens[] = ':';
+ $returnTypeTokens[] = 'void';
+ }
+
+ $signature = sprintf('%s(%s)%s', $method->getName(), implode(', ', $parameters), implode(' ', $returnTypeTokens));
+
+ if (strlen($signature) <= 120) {
+ return $signature;
+ }
+
+ return sprintf(
+ "%s(\n %s\n)%s",
+ $method->getName(),
+ implode(",\n ", $parameters),
+ implode(' ', $returnTypeTokens)
+ );
+}
+
+$report = [];
+const CLASSES = [
+ 'AMQPBasicProperties',
+ 'AMQPChannel',
+ 'AMQPChannelException',
+ 'AMQPConnection',
+ 'AMQPConnectionException',
+ 'AMQPDecimal',
+ 'AMQPEnvelope',
+ 'AMQPEnvelopeException',
+ 'AMQPException',
+ 'AMQPExchange',
+ 'AMQPExchangeException',
+ 'AMQPQueue',
+ 'AMQPQueueException',
+ 'AMQPTimestamp',
+ 'AMQPValueException',
+];
+
+require $next . '/AMQP.php';
+
+foreach (CLASSES as $class) {
+ $report = [...$report, ...compare($class)];
+}
+echo implode(PHP_EOL, $report);
+echo PHP_EOL;
diff --git a/infra/tools/pamqp-docker-setup b/infra/tools/pamqp-docker-setup
new file mode 100755
index 00000000..46f23cc1
--- /dev/null
+++ b/infra/tools/pamqp-docker-setup
@@ -0,0 +1,26 @@
+#!/usr/bin/env php
+ [],
+ 'constants' => [],
+ 'classNames' => [],
+];
+
+function sortByName(array $array): array
+{
+ usort($array, static function (array $left, array $right) {
+ return $left['name'] <=> $right['name'];
+ });
+
+ return $array;
+}
+
+function getTypeMetadata(?ReflectionType $type): ?array
+{
+ if ($type == null) {
+ return [
+ 'name' => 'mixed',
+ 'nullable' => true,
+ 'builtin' => true,
+ ];
+ }
+
+ if ($type instanceof ReflectionNamedType) {
+ return [
+ 'name' => $type->getName(),
+ 'nullable' => $type->allowsNull(),
+ 'builtin' => $type->isBuiltin(),
+ ];
+ }
+
+ if ($type instanceof ReflectionUnionType || $type instanceof ReflectionIntersectionType) {
+ return [
+ 'type' => $type instanceof ReflectionUnionType ? 'union' : 'intersection',
+ 'types' => array_map('getTypeMetadata', $type->getTypes()),
+ ];
+ }
+
+ assert(false, 'Unreachable');
+}
+
+$error = false;
+function error(string $message, ...$args): void
+{
+ global $error;
+ vprintf('ERROR: ' . $message . PHP_EOL, $args);
+ $error = true;
+}
+
+const MAGIC_METHODS = ['__construct', '__toString', '__wakeup', '__clone'];
+
+function getParents(ReflectionClass $r): array
+{
+ $parents = [];
+ while ($r = $r->getParentClass()) {
+ $parents[] = $r->getName();
+ }
+
+ return $parents;
+}
+
+function getClassMetadata(string $class): array
+{
+ $refl = new ReflectionClass($class);
+ $classMetadata = [
+ 'name' => $refl->getName(),
+ 'constants' => [],
+ 'properties' => [],
+ 'methods' => [],
+ 'final' => $refl->isFinal(),
+ 'abstract' => $refl->isAbstract(),
+ 'interface' => $refl->isInterface(),
+ 'implements' => $refl->getInterfaceNames(),
+ 'readonly' => method_exists($refl, 'isReadonly')
+ ? $refl->isReadonly() || strpos($refl->getDocComment(), '@readonly') !== false
+ : null,
+ 'extends' => getParents($refl),
+ ];
+
+ sort($classMetadata['implements']);
+ sort($classMetadata['extends']);
+
+ foreach ($refl->getReflectionConstants() as $constant) {
+ if ($constant->getDeclaringClass()->getName() !== $refl->getName()) {
+ continue;
+ }
+
+ $classMetadata['constants'][] = [
+ 'name' => $class . '::' . $constant->getName(),
+ 'value' => $constant->getValue(),
+ 'visibility' => $constant->isPublic() ? 'public' : ($constant->isProtected() ? 'protected' : ($constant->isPrivate() ? 'private' : 'unknown')),
+ ];
+ }
+
+ foreach ($refl->getMethods() as $method) {
+ if ($method->getDeclaringClass()->getName() !== $refl->getName()) {
+ continue;
+ }
+
+ $methodMetadata = [
+ 'name' => $class . '::' . $method->getName(),
+ 'visibility' => $method->isPublic() ? 'public' : ($method->isProtected() ? 'protected' : ($method->isPrivate() ? 'private' : 'unknown')),
+ 'final' => $method->isFinal(),
+ 'static' => $method->isStatic(),
+ 'parameterCount' => $method->getNumberOfParameters(),
+ 'requiredParameterCount' => $method->getNumberOfRequiredParameters(),
+ 'return' => getTypeMetadata($method->getReturnType()),
+ 'parameters' => [],
+ ];
+
+ if (!in_array($method->getName(), MAGIC_METHODS, true) && strpos($method->getName(), '_') !== false) {
+ error('%s::%s contains underscore', $class, $method->getName());
+ }
+
+ $prefix = substr($method->getName(), 0, 3);
+ if (in_array($prefix, ['set', 'has', 'get'], true) && !in_array(
+ $method->getName(),
+ ['set', 'has', 'get'],
+ true
+ )) {
+ $hasPlural = $refl->hasMethod($method->getName() . 's');
+ $isPlural = substr($method->getName(), -1) === 's';
+
+ if ($prefix === 'get' && $method->getNumberOfParameters() !== 0 && !$hasPlural) {
+ error('%s::%s() should have no arguments', $class, $method->getName());
+ }
+
+ if ($prefix === 'set' && $isPlural) {
+ if ($method->getParameters()[0]->getName() !== ($expectedName = lcfirst(
+ substr($method->getName(), 3)
+ ))) {
+ error(
+ '%s::%s(%s) must be "%s"',
+ $class,
+ $method->getName(),
+ $method->getParameters()[0]
+ ->getName(),
+ $expectedName
+ );
+ }
+ }
+
+ if ($prefix === 'get' && $hasPlural) {
+ if ($method->getNumberOfRequiredParameters() !== 1 || $method->getNumberOfParameters() !== 1) {
+ error('%s::%s() should have exactly one required parameter', $class, $method->getName());
+ }
+ }
+
+ if ($hasPlural) {
+ if ($method->getParameters()[0]->getName() !== ($expectedName = lcfirst(
+ substr($method->getName(), 3) . 'Name'
+ ))) {
+ error(
+ '%s::%s(%s) must be "%s"',
+ $class,
+ $method->getName(),
+ $method->getParameters()[0]
+ ->getName(),
+ $expectedName
+ );
+ }
+
+ if ($prefix === 'set' && $method->getParameters()[1]->getName() !== ($expectedName = lcfirst(
+ substr($method->getName(), 3) . 'Value'
+ ))) {
+ error(
+ '%s::%s(…, %s) must be "%s"',
+ $class,
+ $method->getName(),
+ $method->getParameters()[1]
+ ->getName(),
+ $expectedName
+ );
+ }
+ }
+ }
+
+ foreach ($method->getParameters() as $parameter) {
+ if (strpos($parameter->getName(), '_') !== false) {
+ error('%s::%s(…%s…) contains underscore', $class, $method->getName(), $parameter->getName());
+ }
+
+ $default = 'unknown';
+ if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
+ // Cannot set default values before 8.0 in native extension
+ $default = $parameter->isDefaultValueAvailable() ? $parameter->getDefaultValue() : 'none';
+ }
+
+ $methodMetadata['parameters'][] = [
+ 'method' => $class . '::' . $method->getName(),
+ 'name' => sprintf('$%s', $parameter->getName()),
+ 'default' => $default,
+ 'type' => getTypeMetadata($parameter->getType()),
+ 'byRef' => $parameter->isPassedByReference(),
+ ];
+ }
+
+ $classMetadata['methods'][] = $methodMetadata;
+ }
+
+ foreach ($refl->getProperties() as $property) {
+ if ($property->getDeclaringClass()->getName() !== $refl->getName()) {
+ continue;
+ }
+ if (strpos($property->getName(), '_') !== false) {
+ error('Property %s::%s contains underscore', $class, $property->getName());
+ }
+ $default = 'unknown';
+ if (version_compare(PHP_VERSION, '8.0.0', '>=')) {
+ // Cannot set default values before 8.0 in native extension
+ $default = $property->isDefault() ? $property->getDefaultValue() : 'none';
+ }
+ $propertyTypeMetadata = getTypeMetadata($property->getType());
+ if ($propertyTypeMetadata === null) {
+ error('Property %s::%s has no type declared', $class, $property->getName());
+ }
+ $propertyMetadata = [
+ 'name' => $class . '::' . $property->getName(),
+ 'visibility' => $property->isPublic() ? 'public' : ($property->isProtected() ? 'protected' : ($property->isPrivate() ? 'private' : 'unknown')),
+ 'type' => $propertyTypeMetadata,
+ 'default' => $default,
+ ];
+
+ $classMetadata['properties'][] = $propertyMetadata;
+ }
+
+ $classMetadata['properties'] = sortByName($classMetadata['properties']);
+ $classMetadata['constants'] = sortByName($classMetadata['constants']);
+ $classMetadata['methods'] = sortByName($classMetadata['methods']);
+
+ return $classMetadata;
+}
+
+
+spl_autoload_register(function (string $class) {
+ require_once __DIR__ . '/../../stubs/' . $class . '.php';
+});
+
+if (!extension_loaded('amqp')) {
+ require_once __DIR__ . '/../../stubs/AMQP.php';
+}
+
+const NON_DETERMINISTIC_CONSTANTS = [
+ 'AMQP_OS_SOCKET_TIMEOUT_ERRNO',
+ 'AMQP_EXTENSION_VERSION',
+ 'AMQP_EXTENSION_VERSION_MAJOR',
+ 'AMQP_EXTENSION_VERSION_MINOR',
+ 'AMQP_EXTENSION_VERSION_PATCH',
+ 'AMQP_EXTENSION_VERSION_EXTRA',
+ 'AMQP_EXTENSION_VERSION_ID',
+];
+
+foreach (get_defined_constants() as $constant => $value) {
+ if (in_array($constant, NON_DETERMINISTIC_CONSTANTS, true)) {
+ // Value differs across OS, so normalize
+ $value = 0xDEADBEEF;
+ }
+
+ if (strpos($constant, 'AMQP_') === 0) {
+ $symbols['constants'][] = [
+ 'name' => $constant,
+ 'value' => $value,
+ ];
+ }
+}
+$symbols['constants'] = sortByName($symbols['constants']);
+$symbols['classes'][] = getClassMetadata('AMQPValueException');
+$symbols['classes'][] = getClassMetadata('AMQPTimestamp');
+$symbols['classes'][] = getClassMetadata('AMQPQueueException');
+$symbols['classes'][] = getClassMetadata('AMQPQueue');
+$symbols['classes'][] = getClassMetadata('AMQPExchangeException');
+$symbols['classes'][] = getClassMetadata('AMQPExchange');
+$symbols['classes'][] = getClassMetadata('AMQPException');
+$symbols['classes'][] = getClassMetadata('AMQPEnvelopeException');
+$symbols['classes'][] = getClassMetadata('AMQPEnvelope');
+$symbols['classes'][] = getClassMetadata('AMQPDecimal');
+$symbols['classes'][] = getClassMetadata('AMQPConnectionException');
+$symbols['classes'][] = getClassMetadata('AMQPConnection');
+$symbols['classes'][] = getClassMetadata('AMQPChannelException');
+$symbols['classes'][] = getClassMetadata('AMQPChannel');
+$symbols['classes'][] = getClassMetadata('AMQPBasicProperties');
+$symbols['classes'][] = getClassMetadata('AMQPValue');
+
+// Ensure we captured all AMQP classes
+foreach (get_declared_classes() as $className) {
+ if (strpos($className, 'AMQP') === 0) {
+ $symbols['classNames'][] = $className;
+ }
+}
+sort($symbols['classNames']);
+
+$filename = $_SERVER['argv'][1] ?? null;
+assert($filename !== null, 'Output filename must be passed');
+
+file_put_contents($filename, json_encode($symbols, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR));
+
+if ($error) {
+ exit(1);
+}
diff --git a/infra/tools/pamqp-format b/infra/tools/pamqp-format
new file mode 100755
index 00000000..506e0973
--- /dev/null
+++ b/infra/tools/pamqp-format
@@ -0,0 +1,8 @@
+#!/usr/bin/env sh
+
+set -o errexit
+set -o nounset
+
+base_dir=`dirname $0`/../../
+
+clang-format-20 -i $base_dir/*.c $base_dir/*.h $@
diff --git a/infra/tools/pamqp-format-check b/infra/tools/pamqp-format-check
new file mode 100755
index 00000000..3922cf94
--- /dev/null
+++ b/infra/tools/pamqp-format-check
@@ -0,0 +1,6 @@
+#!/usr/bin/env sh
+
+set -o errexit
+set -o nounset
+
+$(dirname $0)/pamqp-format --dry-run --Werror
\ No newline at end of file
diff --git a/provision/install_rabbitmq-c.sh b/infra/tools/pamqp-install-librabbitmq
similarity index 89%
rename from provision/install_rabbitmq-c.sh
rename to infra/tools/pamqp-install-librabbitmq
index 3af4b4e5..19e1b5c4 100755
--- a/provision/install_rabbitmq-c.sh
+++ b/infra/tools/pamqp-install-librabbitmq
@@ -1,6 +1,5 @@
-#!/bin/sh
+#!/usr/bin/env sh
-# Setup a sane environment
set -o errexit
set -o nounset
@@ -32,6 +31,7 @@ mkdir -p $BUILD_TMP
# Download and extract the source code
curl -sSLf "https://codeload.github.com/alanxz/rabbitmq-c/tar.gz/$LIBRABBITMQ_VERSION" | tar xz --directory=$BUILD_TMP
+export CFLAGS=""
cd $BUILD_TMP/rabbitmq-c-*
sed -e "s:@VERSION@:@RMQ_VERSION@:g" -i librabbitmq.pc.in
@@ -43,7 +43,11 @@ cmake ..
cmake --build . --parallel $(nproc)
# Install
-sudo cmake --build . --target install
+sudo=""
+if ! test `id -u` -eq 0; then
+ sudo="sudo"
+fi
+$sudo cmake --build . --target install
# Cleanup
rm -rf $BUILD_TMP
diff --git a/infra/tools/pamqp-matrix b/infra/tools/pamqp-matrix
new file mode 100755
index 00000000..9dbb53c6
--- /dev/null
+++ b/infra/tools/pamqp-matrix
@@ -0,0 +1,18 @@
+#!/usr/bin/env node
+const PHP_VERSIONS = ["8.5", "8.4", "8.3", "8.2", "8.1", "8.0", "7.4"]
+const LIBRABBITMQ_VERSIONS = ["master", "0.15.0", "0.14.0", "0.13.0", "0.12.0", "0.11.0"]
+
+const toOutput = (k, v) => console.log(`${k}=${JSON.stringify(v)}`)
+const stringSum = (s) => ([...s].map(c => c.charCodeAt(0)).reduce((c, v) => c + v, 0))
+
+const memoryBuilds = PHP_VERSIONS.flatMap(php => [LIBRABBITMQ_VERSIONS[0], LIBRABBITMQ_VERSIONS.slice(-1)[0]].map(librabbitmq => ({
+ "php-version": php,
+ "php-thread-safe": (stringSum(php) + stringSum(librabbitmq)) % 2 === 0,
+ "librabbitmq-version": librabbitmq,
+ "test-php-args": "-m",
+ "compiler": "gcc"
+})))
+
+toOutput('php_versions', PHP_VERSIONS)
+toOutput('librabbitmq_versions', LIBRABBITMQ_VERSIONS)
+toOutput('memory_build_matrix', memoryBuilds)
diff --git a/infra/tools/pamqp-php-cli-deterministic b/infra/tools/pamqp-php-cli-deterministic
new file mode 100755
index 00000000..9fff7aa6
--- /dev/null
+++ b/infra/tools/pamqp-php-cli-deterministic
@@ -0,0 +1,36 @@
+#!/usr/bin/env sh
+
+set -o errexit
+set -o nounset
+
+cache_dir=${XDG_CACHE_HOME:-${HOME}/.cache}
+cached_script=${XDG_CACHE_HOME:-${HOME}/.cache}/pamqp-php-cli-deterministic-cached.sh
+
+if ! test -f "$cached_script"; then
+ extensions="json simplexml sodium"
+ args="-n \
+ -d date.timezone=UTC \
+ -d precision=20 \
+ -d zend.enable_gc=On \
+ -d display_errors=On \
+ -d display_startup_errors=On \
+ -d error_reporting=-1"
+
+ extension_dir=$(php -r "echo ini_get('extension_dir');")
+
+ for extension in $extensions; do
+ code="echo extension_loaded('$extension') ? 'true' : 'false';"
+ exists=$(php -r "$code")
+ bundled=$(php -n -r "$code")
+ if test "$exists" = "true" -a "${bundled}" = "false"; then
+ args="${args} -d extension=$extension_dir/$extension.so"
+ fi
+ done
+
+ mkdir -p "$cache_dir"
+ echo "php $args \$@" > $cached_script.$$
+ chmod +x $cached_script.$$
+ mv $cached_script.$$ $cached_script
+fi
+
+. $cached_script $@
diff --git a/tools/make-release.php b/infra/tools/pamqp-release-cut
old mode 100644
new mode 100755
similarity index 95%
rename from tools/make-release.php
rename to infra/tools/pamqp-release-cut
index 8347585f..4e1c3218
--- a/tools/make-release.php
+++ b/infra/tools/pamqp-release-cut
@@ -1,5 +1,7 @@
+#!/usr/bin/env php
pinepain@gmail.com
yes
- 2021-12-01
-
+ 2026-01-02
+
- 1.12.0dev
- 1.12.0dev
+ 2.2.1dev
+ 2.2.1dev
devel
@@ -36,7 +36,7 @@
@@ -59,6 +59,8 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
+
@@ -69,13 +71,16 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
-
-
+
+
+
+
+
@@ -94,6 +99,7 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
@@ -109,11 +115,13 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
+
@@ -144,9 +152,11 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
-
-
+
+
+
+
@@ -166,16 +176,18 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
+
-
+
@@ -189,6 +201,7 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
@@ -206,6 +219,7 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
@@ -225,15 +239,18 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
+
-
+
+
@@ -246,7 +263,11 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
+
+
+
@@ -262,6 +283,7 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
@@ -269,7 +291,7 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
- 5.6.0
+ 7.4.0
1.4.0
@@ -281,6 +303,321 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0...master
+
+ 2026-01-02
+
+
+ 2.2.0
+ 2.2.0
+
+
+ stable
+ stable
+
+ PHP License
+ ) (https://github.com/php-amqp/php-amqp/issues/589)
+ - Enable support for PIE (James Titcumb ) (https://github.com/php-amqp/php-amqp/issues/584)
+ - Ignore codebase reformatting for blame (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/2ed7b6a)
+ - PHP 8.5 toolchain update (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/604)
+ - Restore changelog for 2.1.1 (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/533)
+ - Update runner images, no longer build against ancient librabbitmq versions (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/e12a99c)
+ - Upgrade GH actions (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/99acba7)
+ - Use ZEND_LONG_FMT and ZEND_ULONG_FMT to fix warnings on 32-bit (Andy Postnikov ) (https://github.com/php-amqp/php-amqp/issues/607)
+ - Use php_format_date instead of php_std_date (Remi Collet ) (https://github.com/php-amqp/php-amqp/commit/6f1c675)
+ - Use zend_ce_exception (Remi Collet ) (https://github.com/php-amqp/php-amqp/commit/a7141b2)
+ - Fix formatting (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/8b76bad)
+ - Fix non-deterministic tests (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/43209e0)
+ - Fix segmentation fault in php_amqp_close_channel #598 (Paul Johnston ) (https://github.com/php-amqp/php-amqp/issues/606)
+ - Fix: SIGPIPE handling (Kévin Dunglas ) (https://github.com/php-amqp/php-amqp/issues/550)
+ - Bump awalsh128/cache-apt-pkgs-action from 1.3.1 to 1.4.1 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/538)
+ - Bump squizlabs/php_codesniffer from 3.8.1 to 3.9.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/539)
+
+For a complete list of changes see:
+https://github.com/php-amqp/php-amqp/compare/v2.1.2...v2.2.0]]>
+
+
+ 2024-01-22
+
+
+ 2.1.2
+ 2.1.2
+
+
+ stable
+ stable
+
+ PHP License
+ ) (https://github.com/php-amqp/php-amqp/issues/531)
+ - Fix nullability issue in AMQPBasicProperties (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/532)
+ - Ignore setfacl errors (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/5548760)
+ - Only restart on failure (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/a37c5f1)
+ - Bump actions/checkout from 4.1.0 to 4.1.1 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/506)
+ - Bump awalsh128/cache-apt-pkgs-action from 1.3.0 to 1.3.1 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/509)
+ - Bump fkirc/skip-duplicate-actions from 5.3.0 to 5.3.1 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/507)
+ - Bump phpstan/phpdoc-parser from 1.24.2 to 1.24.3 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/513)
+ - Bump phpstan/phpdoc-parser from 1.24.3 to 1.24.4 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/516)
+ - Bump phpstan/phpdoc-parser from 1.24.4 to 1.24.5 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/521)
+ - Bump phpstan/phpdoc-parser from 1.24.5 to 1.25.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/524)
+ - Bump shivammathur/setup-php from 2.26.0 to 2.27.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/510)
+ - Bump shivammathur/setup-php from 2.27.0 to 2.27.1 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/512)
+ - Bump shivammathur/setup-php from 2.27.1 to 2.28.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/515)
+ - Bump shivammathur/setup-php from 2.28.0 to 2.29.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/528)
+ - Bump squizlabs/php_codesniffer from 3.7.2 to 3.8.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/520)
+ - Bump squizlabs/php_codesniffer from 3.8.0 to 3.8.1 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/527)
+ - Bump symplify/easy-coding-standard from 12.0.11 to 12.0.13 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/519)
+ - Bump symplify/easy-coding-standard from 12.0.13 to 12.1.3 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/526)
+ - Bump symplify/easy-coding-standard from 12.0.8 to 12.0.9 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/517)
+ - Bump symplify/easy-coding-standard from 12.0.9 to 12.0.11 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/518)
+ - Bump symplify/easy-coding-standard from 12.1.3 to 12.1.7 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/529)
+ - Bump symplify/easy-coding-standard from 12.1.7 to 12.1.8 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/530)
+
+For a complete list of changes see:
+https://github.com/php-amqp/php-amqp/compare/v2.1.1...v2.1.2]]>
+
+
+ 2023-10-12
+
+
+ 2.1.1
+ 2.1.1
+
+
+ stable
+ stable
+
+ PHP License
+ ) (https://github.com/php-amqp/php-amqp/issues/502)
+ - FIX: #494 Param "verify" always true (Daniel Kozak ) (https://github.com/php-amqp/php-amqp/issues/497)
+ - Remove assert on undefined variable (Remi Collet ) (https://github.com/php-amqp/php-amqp/issues/486)
+ - Semantically sort changelog (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/e5bd909)
+ - Set custom PHP executable dynamically (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/503)
+ - Fixes in stub comments (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/6539de5)
+ - Refactor test skipping (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/504)
+ - Bump actions/checkout from 4.0.0 to 4.1.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/499)
+ - Bump phpstan/phpdoc-parser from 1.23.1 to 1.24.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/491)
+ - Bump phpstan/phpdoc-parser from 1.24.0 to 1.24.1 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/495)
+ - Bump shivammathur/setup-php from 2.25.5 to 2.26.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/493)
+ - Bump slevomat/coding-standard from 8.13.4 to 8.14.1 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/501)
+ - Bump symplify/easy-coding-standard from 12.0.7 to 12.0.8 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/492)
+
+For a complete list of changes see:
+https://github.com/php-amqp/php-amqp/compare/v2.1.0...v2.1.1]]>
+
+
+ 2023-09-07
+
+
+ 2.1.0
+ 2.1.0
+
+
+ stable
+ stable
+
+ PHP License
+ ) (https://github.com/php-amqp/php-amqp/issues/473)
+ - Implement AMQPQueue::recover() to provide the basic.recover method (fixes #478) (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/484)
+ - Fix double free when an error occurs in AMQPQueue::consume() (Jan Prachar ) (https://github.com/php-amqp/php-amqp/issues/482)
+ - Revamp error handling (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/485)
+ - Refactor AMQPQueue::consume error handling (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/483)
+ - Use RETURN_THROWS for parameter parsing errors (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/474)
+ - Fix auto-formatting (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/877b2f4)
+ - Remove appveyor badge (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/4971c80)
+ - Replace microtime() as a randomness source (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/4503e53)
+ - Fix version test for release builds (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/00a6715)
+ - Remove non-ASCII characters from package.xml to work around pecl.php.net issue (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/732f7e8)
+ - Bump actions/checkout from 3.5.3 to 3.6.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/475)
+ - Bump symplify/easy-coding-standard from 12.0.6 to 12.0.7 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/472)
+ - Bump actions/checkout from 3.5.3 to 3.6.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/471)
+ - Bump actions/checkout from 3.6.0 to 4.0.0 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/481)
+
+For a complete list of changes see:
+https://github.com/php-amqp/php-amqp/compare/v2.0.0...v2.1.0]]>
+
+
+ 2023-08-20
+
+
+ 2.0.0
+ 2.0.0
+
+
+ stable
+ stable
+
+ PHP License
+ ) (https://github.com/php-amqp/php-amqp/issues/467)
+ - Ubuntu development containers (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/466)
+ - Test against upcoming PHP 8.3 (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/465)
+ - Make test host configurable (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/464)
+ - Cosmetics on type functions (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/350202f)
+ - Configurable serialization/deserialization depth (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/463)
+ - Allow bitmask flags arguments to be nullable where previously AMQP_NOPARAM/zero was required (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/462)
+ - Fix generated commit URLs in changelogs (Lars Strojny ) (https://github.com/php-amqp/php-amqp/commit/4ee6159)
+ - Handle nested AMQP value serialization/deserialization (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/461)
+ - Document lack of reliability of AMQPConnection::isConnected (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/306)
+ - Prevent reuse of channel ID of broken channels (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/460)
+ - Gracefully handle zero as a heartbeat value (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/459)
+ - Build with the clang compiler on CI (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/457)
+ - Include stdint.h for PHP >= 8.0 on Windows (Jan Ehrhardt) (https://github.com/php-amqp/php-amqp/issues/456)
+ - Fix segfault in setPort (Remi Collet ) (https://github.com/php-amqp/php-amqp/issues/455)
+ - Document BC changes (Lars Strojny )
+ - Document pseudo-bool method changes (Lars Strojny )
+ - Fix mangled header on MacOS (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/60)
+ - Validate argument parsing, add AMQPExchange::removeArgument() and AMQPQueue::removeArgument() (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/452)
+ - Skip SSL tests if certificates are missing (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/450)
+ - Check coding style and formatting of stub files (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/447)
+ - Parallelize test execution (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/444)
+ - Deterministic configuration for PHP CLI (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/443)
+ - Fix tag creation during release management (Lars Strojny )
+ - Move test-report.sh into infra (Lars Strojny )
+ - The big fat API renovation (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/437)
+ - Handle alpha/beta stability correctly (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/5546436)
+ - Expose better version information (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/438)
+ - Auto-format the codebase (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/436)
+ - More consistent return types for AMQPEnvelope (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/435)
+ - Update stubs (Lars Strojny )
+ - Fix parameter error handling in AMQPConnection and AMQPChannel (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/434)
+ - Increase credentials and identifier limits (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/433)
+ - Reliably clear consumer tag on AMQPQueue::cancel (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/432)
+ - Ignore failures on experimental builds (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/25)
+ - Update branch name (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/7)
+ - Bump shivammathur/setup-php from 2.25.3 to 2.25.4 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/431)
+ - PHP 8.2 refactorings (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/430)
+ - Fix php version check for static building (Misha Kulakovsky ) (https://github.com/php-amqp/php-amqp/issues/425)
+ - Fix stub exception class (closes #427) (Lars Strojny )
+ - Document custom connection name in stubs (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/700000)
+ - Expose Delivery Mode through constants (Flavio Heleno ) (https://github.com/php-amqp/php-amqp/issues/420)
+ - Fix deprecation issue in PHP 8.1 for $consumerTag argument to AMQPQueue::consume() method (Liviu-Ionut Iosif) (https://github.com/php-amqp/php-amqp/issues/421)
+ - Fix: Deprecated: Creation of dynamic property (8.2) (Remi Collet ) (https://github.com/php-amqp/php-amqp/issues/418)
+ - Fix AMQPEnvelope::getDeliveryTag() return type (Flavio Heleno ) (https://github.com/php-amqp/php-amqp/issues/415)
+ - Fix ack/nack/reject param documentation (Flavio Heleno ) (https://github.com/php-amqp/php-amqp/issues/414)
+ - Mention time units in all timeout-related methods (Andrii Dembitskyi ) (https://github.com/php-amqp/php-amqp/issues/410)
+
+For a complete list of changes see:
+https://github.com/php-amqp/php-amqp/compare/v1.11.0...v2.0.0]]>
+
+
+ 2023-08-15
+
+
+ 2.0.0RC1
+ 2.0.0RC1
+
+
+ beta
+ beta
+
+ PHP License
+ ) (https://github.com/php-amqp/php-amqp/issues/461)
+ - Document lack of reliability of AMQPConnection::isConnected (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/306)
+ - Prevent reuse of channel ID of broken channels (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/460)
+ - Gracefully handle zero as a heartbeat value (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/459)
+ - Build with the clang compiler on CI (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/457)
+
+For a complete list of changes see:
+https://github.com/php-amqp/php-amqp/compare/v2.0.0beta2...v2.0.0RC1]]>
+
+
+ 2023-08-03
+
+
+ 2.0.0beta2
+ 2.0.0beta2
+
+
+ beta
+ beta
+
+ PHP License
+ = 8.0 on Windows (Jan Ehrhardt) (https://github.com/php-amqp/php-amqp/issues/456)
+ - Fix segfault in setPort (Remi Collet ) (https://github.com/php-amqp/php-amqp/issues/455)
+
+(!) Check out https://github.com/php-amqp/php-amqp/tree/latest/UPGRADING.md for backward incompatible changes
+
+For a complete list of changes see:
+https://github.com/php-amqp/php-amqp/compare/v2.0.0beta1...v2.0.0beta2]]>
+
+
+ 2023-08-02
+
+
+ 2.0.0beta1
+ 2.0.0beta1
+
+
+ beta
+ beta
+
+ PHP License
+ ) (https://github.com/php-amqp/php-amqp/issues/0)
+ - Document pseudo-bool method changes (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/0)
+ - Fix mangled header on MacOS (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/60)
+ - Validate argument parsing, add AMQPExchange::removeArgument() and AMQPQueue::removeArgument() (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/452)
+ - Skip SSL tests if certificates are missing (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/450)
+ - Bump shivammathur/setup-php from 2.25.4 to 2.25.5 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/449)
+ - Check coding style and formatting of stub files (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/447)
+ - Parallelize test execution (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/444)
+ - Deterministic configuration for PHP CLI (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/443)
+ - Fix tag creation during release management (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/0)
+ - Move test-report.sh into infra (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/0)
+
+(!) Check out https://github.com/php-amqp/php-amqp/tree/latest/UPGRADING.md for backward incompatible changes
+
+For a complete list of changes see:
+https://github.com/php-amqp/php-amqp/compare/v2.0.0alpha2...v2.0.0beta1]]>
+
+
+ 2023-07-29
+
+
+ 2.0.0alpha1
+ 2.0.0alpha1
+
+
+ alpha
+ alpha
+
+ PHP License
+ ) (https://github.com/php-amqp/php-amqp/issues/437)
+ - Handle alpha/beta stability correctly (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/5546436)
+ - Expose better version information (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/438)
+ - Auto-format the codebase (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/436)
+ - More consistent return types for AMQPEnvelope (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/435)
+ - Update stubs (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/0)
+ - Fix parameter error handling in AMQPConnection and AMQPChannel (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/434)
+ - Increase credentials and identifier limits (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/433)
+ - Reliably clear consumer tag on AMQPQueue::cancel (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/432)
+ - Ignore failures on experimental builds (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/25)
+ - Update branch name (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/7)
+ - Bump shivammathur/setup-php from 2.25.3 to 2.25.4 (dependabot[bot]) (https://github.com/php-amqp/php-amqp/issues/431)
+ - PHP 8.2 refactorings (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/430)
+ - Fix php version check for static building (Misha Kulakovsky ) (https://github.com/php-amqp/php-amqp/issues/425)
+ - Fix stub exception class (closes #427) (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/0)
+ - Document custom connection name in stubs (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/700000)
+ - Expose Delivery Mode through constants (Flavio Heleno ) (https://github.com/php-amqp/php-amqp/issues/420)
+ - Fix deprecation issue in PHP 8.1 for $consumerTag argument to AMQPQueue::consume() method (Liviu-Ionut Iosif) (https://github.com/php-amqp/php-amqp/issues/421)
+ - Fix: Deprecated: Creation of dynamic property (8.2) (Remi Collet ) (https://github.com/php-amqp/php-amqp/issues/418)
+ - Fix AMQPEnvelope::getDeliveryTag() return type (Flavio Heleno ) (https://github.com/php-amqp/php-amqp/issues/415)
+ - Fix ack/nack/reject param documentation (Flavio Heleno ) (https://github.com/php-amqp/php-amqp/issues/414)
+ - Mention time units in all timeout-related methods (Andrii Dembitskyi ) (https://github.com/php-amqp/php-amqp/issues/410)
+
+For a complete list of changes see:
+https://github.com/php-amqp/php-amqp/compare/v1.11.0...v2.0.0alpha1]]>
+
2021-12-01
@@ -312,7 +649,7 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0RC1...v1.11.0]]>
beta
PHP License
- ) (https://github.com/php-amqp/php-amqp/issues/396) - Add installation instructions for Windows (Marcos Rezende ) (https://github.com/php-amqp/php-amqp/issues/394) - Fixes AMQPConnection Stub typo (Grégoire Pineau ) (https://github.com/php-amqp/php-amqp/issues/401) - Fix AMQPQueue stub (Gocha Ossinkine ) (https://github.com/php-amqp/php-amqp/issues/404) - SetReadTimeout accepts float param (Andrii Dembitskyi ) (https://github.com/php-amqp/php-amqp/issues/388) - Move from Travis CI to Github Actions (Vadim Borodavko ) (https://github.com/php-amqp/php-amqp/issues/391) - Release tooling: handle RC stability properly (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/71) - More robust release tooling (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/0)For a complete list of changes see:https://github.com/php-amqp/php-amqp/compare/v1.11.0beta...v1.11.0RC1]]>
+ ) (https://github.com/php-amqp/php-amqp/issues/396) - Add installation instructions for Windows (Marcos Rezende ) (https://github.com/php-amqp/php-amqp/issues/394) - Fixes AMQPConnection Stub typo (Gregoire Pineau ) (https://github.com/php-amqp/php-amqp/issues/401) - Fix AMQPQueue stub (Gocha Ossinkine ) (https://github.com/php-amqp/php-amqp/issues/404) - SetReadTimeout accepts float param (Andrii Dembitskyi ) (https://github.com/php-amqp/php-amqp/issues/388) - Move from Travis CI to Github Actions (Vadim Borodavko ) (https://github.com/php-amqp/php-amqp/issues/391) - Release tooling: handle RC stability properly (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/71) - More robust release tooling (Lars Strojny ) (https://github.com/php-amqp/php-amqp/issues/0)For a complete list of changes see:https://github.com/php-amqp/php-amqp/compare/v1.11.0beta...v1.11.0RC1]]>
2020-04-05
@@ -354,7 +691,7 @@ https://github.com/php-amqp/php-amqp/compare/v1.11.0RC1...v1.11.0]]>
stable
PHP License
- ) (https://github.com/pdezwart/php-amqp/issues/367) - Fix minimal librabbitmq in config.m4 and readme (Remi Collet ) (https://github.com/pdezwart/php-amqp/issues/347) - Support connection_name parameter for custom connection names in RabbitMQ (Alexandr Zolotukhin ) (https://github.com/pdezwart/php-amqp/issues/363) - Fixed build on Travis CI (Alexandr Zolotukhin ) (https://github.com/pdezwart/php-amqp/issues/365) - Make use of rpc_timeout in newer librabbitmq by introducing new constructor hash parameter (modulatix ) (https://github.com/pdezwart/php-amqp/issues/334) - Fix #355: Compile failure on php 7.4 (Christoph M. Becker ) (https://github.com/pdezwart/php-amqp/issues/359) - Update amqp_type.c (Paweł Mikołajczuk ) (https://github.com/pdezwart/php-amqp/issues/360) - Build against PHP 7.4 (Carlos Barrero ) (https://github.com/pdezwart/php-amqp/issues/361) - Pass params by value in AMQPConnection::__construct() (Sergei Karpov) (https://github.com/pdezwart/php-amqp/issues/346) - Fix explicit null-string for $routing_key in Queue::bind() and Exchange::publish() (Sergei Karpov) (https://github.com/pdezwart/php-amqp/issues/341) - No longer limited to PHP 5 (Lars Strojny ) (https://github.com/pdezwart/php-amqp/issues/0) - Fix minimal version to 5.6 (Remi Collet ) (https://github.com/pdezwart/php-amqp/issues/338) - Back to dev (Lars Strojny ) (https://github.com/pdezwart/php-amqp/issues/1)For a complete list of changes see:https://github.com/pdezwart/php-amqp/compare/v1.9.4...v1.10.0]]>
+ ) (https://github.com/pdezwart/php-amqp/issues/367) - Fix minimal librabbitmq in config.m4 and readme (Remi Collet ) (https://github.com/pdezwart/php-amqp/issues/347) - Support connection_name parameter for custom connection names in RabbitMQ (Alexandr Zolotukhin ) (https://github.com/pdezwart/php-amqp/issues/363) - Fixed build on Travis CI (Alexandr Zolotukhin ) (https://github.com/pdezwart/php-amqp/issues/365) - Make use of rpc_timeout in newer librabbitmq by introducing new constructor hash parameter (modulatix ) (https://github.com/pdezwart/php-amqp/issues/334) - Fix #355: Compile failure on php 7.4 (Christoph M. Becker ) (https://github.com/pdezwart/php-amqp/issues/359) - Update amqp_type.c (Pawel Mikolajczuk ) (https://github.com/pdezwart/php-amqp/issues/360) - Build against PHP 7.4 (Carlos Barrero ) (https://github.com/pdezwart/php-amqp/issues/361) - Pass params by value in AMQPConnection::__construct() (Sergei Karpov) (https://github.com/pdezwart/php-amqp/issues/346) - Fix explicit null-string for $routing_key in Queue::bind() and Exchange::publish() (Sergei Karpov) (https://github.com/pdezwart/php-amqp/issues/341) - No longer limited to PHP 5 (Lars Strojny ) (https://github.com/pdezwart/php-amqp/issues/0) - Fix minimal version to 5.6 (Remi Collet ) (https://github.com/pdezwart/php-amqp/issues/338) - Back to dev (Lars Strojny ) (https://github.com/pdezwart/php-amqp/issues/1)For a complete list of changes see:https://github.com/pdezwart/php-amqp/compare/v1.9.4...v1.10.0]]>
2017-10-19
diff --git a/php-test-bin b/php-test-bin
deleted file mode 100755
index f9052648..00000000
--- a/php-test-bin
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-# Isolate tests better by running PHP without any ini files during test
-`which php` -n $@
diff --git a/php5_support.h b/php5_support.h
deleted file mode 100644
index 25c2d963..00000000
--- a/php5_support.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
- | Lead: |
- | - Pieter de Zwart |
- | Maintainers: |
- | - Brad Rodriguez |
- | - Jonathan Tansavatdi |
- +----------------------------------------------------------------------+
-*/
-
-#ifndef PHP_AMQP_PHP5_SUPPORT_H
-#define PHP_AMQP_PHP5_SUPPORT_H
-
-typedef int PHP5to7_param_str_len_type_t;
-typedef long PHP5to7_param_long_type_t;
-typedef zval* PHP5to7_zval_t;
-
-#define PHP5to7_MAYBE_SET_TO_NULL = NULL
-
-#define PHP5to7_MAYBE_DEREF(zv) (*(zv))
-#define PHP5to7_MAYBE_PTR(zv) (zv)
-#define PHP5to7_MAYBE_PTR_TYPE PHP5to7_zval_t
-#define PHP5to7_MAYBE_PARAM_PTR(zv) (&(zv))
-
-#define PHP5to7_MAYBE_INIT(zv) MAKE_STD_ZVAL(zv);
-#define PHP5to7_ARRAY_INIT(zv) array_init(zv);
-#define PHP5to7_MAYBE_DESTROY(zv) zval_ptr_dtor(&(zv));
-#define PHP5to7_MAYBE_DESTROY2(zv, pzv) zval_ptr_dtor(&pzv);
-
-#define PHP5to7_ZVAL_STRINGL_DUP(z, s, l) ZVAL_STRINGL((z), (s), (l), 1)
-
-#define PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(arg, str, length) add_next_index_stringl((arg), (str), (unsigned)(length), 1)
-
-#define PHP5to7_ZEND_HASH_FIND(ht, str, len, res) \
- (zend_hash_find((ht), (str), (unsigned)(len), (void **) &(res)) != FAILURE)
-
-#define PHP5to7_ZEND_HASH_STRLEN(len) (unsigned)((len) + 1)
-#define PHP5to7_ZEND_HASH_DEL(ht, key, len) zend_hash_del_key_or_index((ht), (key), (unsigned)(len), 0, HASH_DEL_KEY);
-#define PHP5to7_ZEND_HASH_ADD(ht, key, len, pData, nDataSize) (zend_hash_add((ht), (key), (unsigned)(len), &(pData), nDataSize, NULL) != FAILURE)
-#define PHP5to7_ZEND_HASH_STR_UPD_MEM(ht, key, len, pData, nDataSize) PHP5to7_ZEND_HASH_ADD((ht), (key), (len), (pData), (nDataSize))
-#define PHP5to7_ZEND_HASH_STR_FIND_PTR(ht, key, len, res) PHP5to7_ZEND_HASH_FIND((ht), (key), (len), (res))
-#define PHP5to7_ZEND_HASH_STR_DEL(ht, key, len) PHP5to7_ZEND_HASH_DEL((ht), (key), (len))
-
-#define PHP5to7_SET_FCI_RETVAL_PTR(fci, pzv) (fci).retval_ptr_ptr = &(pzv);
-#define PHP5to7_CHECK_FCI_RETVAL_PTR(fci) ((fci).retval_ptr_ptr && *(fci).retval_ptr_ptr)
-
-#define PHP5to7_IS_FALSE_P(pzv) ((Z_TYPE_P(pzv) == IS_BOOL && !Z_BVAL_P(pzv)))
-
-#define PHP5to7_obj_free_zend_object void
-#define PHP5to7_zend_object_value zend_object_value
-#define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce), NULL TSRMLS_CC)
-
-#define PHP5to7_ECALLOC_CONNECTION_OBJECT(ce) (amqp_connection_object*)ecalloc(1, sizeof(amqp_connection_object))
-#define PHP5to7_ECALLOC_CHANNEL_OBJECT(ce) (amqp_channel_object*)ecalloc(1, sizeof(amqp_channel_object))
-
-#define PHP5to7_CASE_IS_BOOL case IS_BOOL
-
-#define PHP5to7_READ_PROP_RV_PARAM_DECL
-#define PHP5to7_READ_PROP_RV_PARAM_CC
-
-
-#define PHP5to7_ZEND_REAL_HASH_KEY_T void
-
-#define PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, real_key, key, key_len, data, val, pos) \
- for ( \
- zend_hash_internal_pointer_reset_ex((ht), &(pos)); \
- zend_hash_get_current_data_ex((ht), (void**) &(data), &(pos)) == SUCCESS && ((value) = *(data)); \
- zend_hash_move_forward_ex((ht), &(pos)) \
- )
-
-#define PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, num_key, pos) \
- (zend_hash_get_current_key_ex((ht), &(key), &(key_len), &(num_key), 0, &(pos)) == HASH_KEY_IS_STRING)
-
-#define PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len)
-
-#define PHP5to7_ZEND_HASH_FOREACH_END()
-
-#define Z_TRY_ADDREF_P(pz) Z_ADDREF_P(pz)
-
-/* Resources stuff */
-
-typedef int PHP5to7_zend_resource_t;
-typedef zend_rsrc_list_entry PHP5to7_zend_resource_store_t;
-typedef zend_rsrc_list_entry PHP5to7_zend_resource_le_t;
-
-#define PHP5to7_ZEND_RESOURCE_DTOR_ARG rsrc
-#define Z_RES_P(le) (le)
-
-#define PHP5to7_ZEND_RESOURCE_EMPTY 0
-#define PHP5to7_ZEND_RESOURCE_LE_EMPTY NULL
-#define PHP5to7_ZEND_RSRC_TYPE_P(le) Z_TYPE_P(le)
-#define PHP5to7_ZEND_REGISTER_RESOURCE(rsrc_pointer, rsrc_type) ZEND_REGISTER_RESOURCE(NULL, (rsrc_pointer), (rsrc_type))
-
-#define PHP5to7_PARENT_CLASS_NAME_C(name) , (name)
-
-#define ZEND_ULONG_FMT "%" PRIu64
-#define PHP5to7_ZEND_ACC_FINAL_CLASS ZEND_ACC_FINAL_CLASS
-
-#define PHP5to8_OBJ_PROP(zv) (zv)
-
-#endif //PHP_AMQP_PHP5_SUPPORT_H
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/php7_support.h b/php7_support.h
deleted file mode 100644
index 0dbd6b22..00000000
--- a/php7_support.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 5 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2007 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010 |
- | Lead: |
- | - Pieter de Zwart |
- | Maintainers: |
- | - Brad Rodriguez |
- | - Jonathan Tansavatdi |
- +----------------------------------------------------------------------+
-*/
-
-#ifndef PHP_AMQP_PHP7_SUPPORT_H
-#define PHP_AMQP_PHP7_SUPPORT_H
-
-typedef size_t PHP5to7_param_str_len_type_t;
-typedef zend_long PHP5to7_param_long_type_t;
-typedef zval PHP5to7_zval_t;
-
-#define PHP5to7_MAYBE_SET_TO_NULL
-
-#define PHP5to7_MAYBE_DEREF(zv) (zv)
-#define PHP5to7_MAYBE_PTR(zv) (&(zv))
-#define PHP5to7_MAYBE_PTR_TYPE PHP5to7_zval_t *
-#define PHP5to7_MAYBE_PARAM_PTR(zv) (zv)
-
-#define PHP5to7_MAYBE_INIT(zv) ZVAL_UNDEF(&(zv))
-#define PHP5to7_ARRAY_INIT(zv) array_init(&(zv));
-#define PHP5to7_MAYBE_DESTROY(zv) if (!Z_ISUNDEF(zv)) { zval_ptr_dtor(&(zv)); }
-#define PHP5to7_MAYBE_DESTROY2(zv, pzv) if (!Z_ISUNDEF(zv)) { zval_ptr_dtor(pzv); }
-
-#define PHP5to7_ZVAL_STRINGL_DUP(z, s, l) ZVAL_STRINGL((z), (s), (l))
-#define PHP5to7_ADD_NEXT_INDEX_STRINGL_DUP(arg, str, length) add_next_index_stringl((arg), (str), (size_t)(length))
-
-#define PHP5to7_ZEND_HASH_FIND(ht, str, len, res) \
- ((res = zend_hash_str_find((ht), (str), (size_t)(len - 1))) != NULL)
-
-#define PHP5to7_ZEND_HASH_STRLEN(len) (PHP5to7_param_str_len_type_t)((len) + 1)
-#define PHP5to7_ZEND_HASH_DEL(ht, key, len) zend_hash_str_del_ind((ht), (key), (unsigned)(len - 1))
-#define PHP5to7_ZEND_HASH_ADD(ht, key, len, pData, nDataSize) zend_hash_str_add((ht), (key), (unsigned)(len - 1), (pData))
-#define PHP5to7_ZEND_HASH_STR_UPD_MEM(ht, key, len, pData, nDataSize) zend_hash_str_update_mem((ht), (key), (size_t)(len), &(pData), (nDataSize))
-#define PHP5to7_ZEND_HASH_STR_FIND_PTR(ht, key, len, res) ((res = zend_hash_str_find_ptr((ht), (key), (size_t)(len))) != NULL)
-#define PHP5to7_ZEND_HASH_STR_DEL(ht, key, len) zend_hash_str_del_ind((ht), (key), (unsigned)(len))
-
-#define PHP5to7_SET_FCI_RETVAL_PTR(fci, pzv) (fci).retval = (pzv);
-#define PHP5to7_CHECK_FCI_RETVAL_PTR(fci) ((fci).retval)
-
-#define PHP5to7_IS_FALSE_P(pzv) (Z_TYPE_P(pzv) == IS_FALSE)
-
-#define PHP5to7_obj_free_zend_object zend_object
-#define PHP5to7_zend_object_value zend_object *
-#define PHP5to7_zend_register_internal_class_ex(ce, parent_ce) zend_register_internal_class_ex((ce), (parent_ce) TSRMLS_CC)
-
-#define PHP5to7_ECALLOC_CONNECTION_OBJECT(ce) (amqp_connection_object*)ecalloc(1, sizeof(amqp_connection_object) + zend_object_properties_size(ce))
-#define PHP5to7_ECALLOC_CHANNEL_OBJECT(ce) (amqp_channel_object*)ecalloc(1, sizeof(amqp_channel_object) + zend_object_properties_size(ce))
-
-#define PHP5to7_CASE_IS_BOOL case IS_TRUE: case IS_FALSE
-
-#define PHP5to7_READ_PROP_RV_PARAM_DECL zval rv;
-#define PHP5to7_READ_PROP_RV_PARAM_CC , (&rv)
-
-#define Z_BVAL_P(zval_p) (Z_TYPE_P(zval_p) == IS_TRUE)
-
-#define PHP5to7_ZEND_REAL_HASH_KEY_T zend_string
-
-#define PHP5to7_ZEND_HASH_FOREACH_KEY_VAL(ht, num_key, real_key, key, key_len, data, val, pos) \
- ZEND_HASH_FOREACH_KEY_VAL((ht), (num_key), (real_key), (val))
-
-#define PHP5to7_ZEND_HASH_KEY_IS_STRING(ht, real_key, key, key_len, num_key, pos) \
- (real_key)
-
-#define PHP5to7_ZEND_HASH_KEY_MAYBE_UNPACK(real_key, key, key_len) \
- (key_len) = ZSTR_LEN(real_key); \
- (key) = ZSTR_VAL(real_key);
-
-#define PHP5to7_ZEND_HASH_FOREACH_END() ZEND_HASH_FOREACH_END();
-
-/* Resources stuff */
-typedef zend_resource* PHP5to7_zend_resource_t;
-typedef zend_resource PHP5to7_zend_resource_store_t;
-typedef zval PHP5to7_zend_resource_le_t;
-
-#define PHP5to7_ZEND_RESOURCE_DTOR_ARG res
-#define PHP5to7_ZEND_RESOURCE_EMPTY NULL
-#define PHP5to7_ZEND_RESOURCE_LE_EMPTY NULL
-#define PHP5to7_ZEND_RSRC_TYPE_P(le) (le)->type
-#define PHP5to7_ZEND_REGISTER_RESOURCE(rsrc_pointer, rsrc_type) zend_register_resource((rsrc_pointer), (rsrc_type))
-
-#define PHP5to7_PARENT_CLASS_NAME_C(name)
-
-#define PHP5to7_ZEND_ACC_FINAL_CLASS ZEND_ACC_FINAL
-
-
-/* Small change to let it build after a major internal change for php8.0
- * More info:
- * https://github.com/php/php-src/blob/php-8.0.0alpha3/UPGRADING.INTERNALS#L47
- */
-#if PHP_MAJOR_VERSION >= 8
-
-# define TSRMLS_DC
-# define TSRMLS_D
-# define TSRMLS_CC
-# define TSRMLS_C
-
-#define PHP5to8_OBJ_PROP(zv) Z_OBJ_P(zv)
-
-#else
-
-#define PHP5to8_OBJ_PROP(zv) (zv)
-
-# endif
-
-#endif //PHP_AMQP_PHP7_SUPPORT_H
-
-/*
-*Local variables:
-*tab-width: 4
-*c-basic-offset: 4
-*End:
-*vim600: noet sw=4 ts=4 fdm=marker
-*vim<600: noet sw=4 ts=4
-*/
diff --git a/php_amqp.h b/php_amqp.h
index 254819aa..b1fe0757 100644
--- a/php_amqp.h
+++ b/php_amqp.h
@@ -23,15 +23,16 @@
#ifndef PHP_AMQP_H
#define PHP_AMQP_H
-/* True global resources - no need for thread safety here */
-extern zend_class_entry *amqp_exception_class_entry,
- *amqp_connection_exception_class_entry,
- *amqp_channel_exception_class_entry,
- *amqp_exchange_exception_class_entry,
- *amqp_queue_exception_class_entry,
- *amqp_envelope_exception_class_entry,
- *amqp_value_exception_class_entry;
+#ifdef HAVE_CONFIG_H
+ #include "config.h"
+#endif
+
+#include
+/* True global resources - no need for thread safety here */
+extern zend_class_entry *amqp_exception_class_entry, *amqp_connection_exception_class_entry,
+ *amqp_channel_exception_class_entry, *amqp_exchange_exception_class_entry, *amqp_queue_exception_class_entry,
+ *amqp_value_exception_class_entry;
typedef struct _amqp_connection_resource amqp_connection_resource;
typedef struct _amqp_connection_object amqp_connection_object;
@@ -40,144 +41,197 @@ typedef struct _amqp_channel_resource amqp_channel_resource;
typedef struct _amqp_channel_callbacks amqp_channel_callbacks;
typedef struct _amqp_callback_bucket amqp_callback_bucket;
-#if PHP_VERSION_ID < 50600
-// should never get her, but just in case
-#error PHP >= 5.6 required
-#endif
-
-#if PHP_MAJOR_VERSION >= 7
- #include "php7_support.h"
+#if HAVE_LIBRABBITMQ_NEW_LAYOUT
+ #include
#else
- #include "php5_support.h"
+ #include
#endif
-#include "amqp_connection_resource.h"
-
-#include
-
extern zend_module_entry amqp_module_entry;
#define phpext_amqp_ptr &amqp_module_entry
#ifdef PHP_WIN32
-#define PHP_AMQP_API __declspec(dllexport)
+ #define PHP_AMQP_API __declspec(dllexport)
#else
-#define PHP_AMQP_API
+ #define PHP_AMQP_API
#endif
#ifdef ZTS
-#include "TSRM.h"
+ #include "TSRM.h"
+#endif
+
+#include "php_amqp_version.h"
+
+#if PHP_VERSION_ID >= 80000
+ #define PHP_AMQP_COMPAT_OBJ_P(zv) Z_OBJ_P(zv)
+ #define PHP_AMQP_DECLARE_PROPERTY_TYPE(type, nullable) (zend_type) ZEND_TYPE_INIT_CODE(type, nullable, 0)
+ #define PHP_AMQP_DECLARE_PROPERTY_OBJ_TYPE(class_name, nullable) \
+ (zend_type) ZEND_TYPE_INIT_CLASS(class_name, nullable, 0)
+#else
+ #define PHP_AMQP_COMPAT_OBJ_P(zv) (zv)
+ #define ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(pass_by_ref, name, type_hint, allow_null, default_value) \
+ ZEND_ARG_TYPE_INFO(pass_by_ref, name, type_hint, allow_null)
+ #define PHP_AMQP_DECLARE_PROPERTY_TYPE(type, nullable) ZEND_TYPE_ENCODE(type, nullable)
+ #define PHP_AMQP_DECLARE_PROPERTY_OBJ_TYPE(class_name, nullable) ZEND_TYPE_ENCODE_CLASS(class_name, nullable)
+ #define RETURN_THROWS() \
+ do { \
+ ZEND_ASSERT(EG(exception)); \
+ (void) return_value; \
+ return; \
+ } while (0)
+#endif
+#if PHP_VERSION_ID < 80200
+ #define zend_ini_parse_quantity_warn(v, name) (zend_atol(ZSTR_VAL(v), ZSTR_LEN(v)))
#endif
+#define PHP_AMQP_NULLABLE_DEFAULT_INIT(val, nullable) \
+ zval val; \
+ if (nullable) { \
+ ZVAL_NULL(&val); \
+ } else { \
+ ZVAL_UNDEF(&val); \
+ }
+#define PHP_AMQP_DECLARE_TYPED_PROPERTY_ZVAL(class_entry, name, flags, type_info, val) \
+ { \
+ zend_string *__name = zend_string_init(ZEND_STRL(name), 1); \
+ zend_declare_typed_property(class_entry, __name, &(val), flags, NULL, type_info); \
+ zend_string_release(__name); \
+ }
+#define PHP_AMQP_DECLARE_TYPED_PROPERTY(class_entry, name, flags, type, nullable) \
+ { \
+ PHP_AMQP_NULLABLE_DEFAULT_INIT(__val, nullable); \
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_ZVAL( \
+ class_entry, \
+ name, \
+ flags, \
+ PHP_AMQP_DECLARE_PROPERTY_TYPE(type, nullable), \
+ __val \
+ ) \
+ }
+#define PHP_AMQP_DECLARE_TYPED_PROPERTY_WITH_DEFAULT(class_entry, name, flags, type, nullable, init) \
+ { \
+ zval __val; \
+ ZVAL_UNDEF(&__val); \
+ init(&__val); \
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_ZVAL( \
+ class_entry, \
+ name, \
+ flags, \
+ PHP_AMQP_DECLARE_PROPERTY_TYPE(type, nullable), \
+ __val \
+ ) \
+ }
+#define PHP_AMQP_DECLARE_TYPED_PROPERTY_OBJ(class_entry, name, flags, class_name, nullable) \
+ { \
+ PHP_AMQP_NULLABLE_DEFAULT_INIT(__val, nullable); \
+ zend_string *__class_name = zend_string_init(ZEND_STRL(#class_name), 1); \
+ PHP_AMQP_DECLARE_TYPED_PROPERTY_ZVAL( \
+ class_entry, \
+ name, \
+ flags, \
+ PHP_AMQP_DECLARE_PROPERTY_OBJ_TYPE(__class_name, nullable), \
+ __val \
+ ); \
+ }
+
+#include "amqp_connection_resource.h"
+
#define AMQP_TOCHKA_EXTENSION 1
-#define AMQP_NOPARAM 0
+#define AMQP_NOPARAM 0
/* Where is 1?*/
-#define AMQP_JUST_CONSUME 1
-#define AMQP_DURABLE 2
-#define AMQP_PASSIVE 4
-#define AMQP_EXCLUSIVE 8
-#define AMQP_AUTODELETE 16
-#define AMQP_INTERNAL 32
-#define AMQP_NOLOCAL 64
-#define AMQP_AUTOACK 128
-#define AMQP_IFEMPTY 256
-#define AMQP_IFUNUSED 512
-#define AMQP_MANDATORY 1024
-#define AMQP_IMMEDIATE 2048
-#define AMQP_MULTIPLE 4096
-#define AMQP_NOWAIT 8192
-#define AMQP_REQUEUE 16384
+#define AMQP_JUST_CONSUME 1
+#define AMQP_DURABLE 2
+#define AMQP_PASSIVE 4
+#define AMQP_EXCLUSIVE 8
+#define AMQP_AUTODELETE 16
+#define AMQP_INTERNAL 32
+#define AMQP_NOLOCAL 64
+#define AMQP_AUTOACK 128
+#define AMQP_IFEMPTY 256
+#define AMQP_IFUNUSED 512
+#define AMQP_MANDATORY 1024
+#define AMQP_IMMEDIATE 2048
+#define AMQP_MULTIPLE 4096
+#define AMQP_NOWAIT 8192
+#define AMQP_REQUEUE 16384
/* passive, durable, auto-delete, internal, no-wait (see https://www.rabbitmq.com/amqp-0-9-1-reference.html#exchange.declare) */
-#define PHP_AMQP_EXCHANGE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_AUTODELETE | AMQP_INTERNAL)
+#define PHP_AMQP_EXCHANGE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_AUTODELETE | AMQP_INTERNAL)
/* passive, durable, exclusive, auto-delete, no-wait (see https://www.rabbitmq.com/amqp-0-9-1-reference.html#queue.declare) */
/* We don't support no-wait flag */
-#define PHP_AMQP_QUEUE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_EXCLUSIVE | AMQP_AUTODELETE)
+#define PHP_AMQP_QUEUE_FLAGS (AMQP_PASSIVE | AMQP_DURABLE | AMQP_EXCLUSIVE | AMQP_AUTODELETE)
-#define AMQP_EX_TYPE_DIRECT "direct"
-#define AMQP_EX_TYPE_FANOUT "fanout"
-#define AMQP_EX_TYPE_TOPIC "topic"
-#define AMQP_EX_TYPE_HEADERS "headers"
+#define AMQP_EX_TYPE_DIRECT "direct"
+#define AMQP_EX_TYPE_FANOUT "fanout"
+#define AMQP_EX_TYPE_TOPIC "topic"
+#define AMQP_EX_TYPE_HEADERS "headers"
#define PHP_AMQP_CONNECTION_RES_NAME "AMQP Connection Resource"
struct _amqp_channel_resource {
- char is_connected;
- amqp_channel_t channel_id;
- amqp_connection_resource *connection_resource;
+ char is_connected;
+ amqp_channel_t channel_id;
+ amqp_connection_resource *connection_resource;
amqp_channel_object *parent;
};
struct _amqp_callback_bucket {
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
+ zend_fcall_info fci;
+ zend_fcall_info_cache fcc;
};
struct _amqp_channel_callbacks {
- amqp_callback_bucket basic_return;
- amqp_callback_bucket basic_ack;
- amqp_callback_bucket basic_nack;
+ amqp_callback_bucket basic_return;
+ amqp_callback_bucket basic_ack;
+ amqp_callback_bucket basic_nack;
};
/* NOTE: due to how internally PHP works with custom object, zend_object position in structure matters */
struct _amqp_channel_object {
-#if PHP_MAJOR_VERSION >= 7
- amqp_channel_callbacks callbacks;
- zval *gc_data;
- int gc_data_count;
- amqp_channel_resource *channel_resource;
- zend_object zo;
-#else
- zend_object zo;
- zval *this_ptr;
- amqp_channel_resource *channel_resource;
- amqp_channel_callbacks callbacks;
- zval **gc_data;
- long gc_data_count;
-#endif
+ amqp_channel_callbacks callbacks;
+ zval *gc_data;
+ int gc_data_count;
+ amqp_channel_resource *channel_resource;
+ zend_object zo;
};
struct _amqp_connection_resource {
- zend_bool is_connected;
- zend_bool is_persistent;
- zend_bool is_dirty;
- PHP5to7_zend_resource_t resource;
- amqp_connection_object *parent;
- amqp_channel_t max_slots;
- amqp_channel_t used_slots;
- amqp_channel_resource **slots;
- amqp_connection_state_t connection_state;
- amqp_socket_t *socket;
+ bool is_connected;
+ bool is_persistent;
+ bool is_dirty;
+ zend_resource *resource;
+ amqp_connection_object *parent;
+ amqp_channel_t max_slots;
+ amqp_channel_t used_slots;
+ amqp_channel_resource **slots;
+ amqp_connection_state_t connection_state;
+ amqp_socket_t *socket;
};
struct _amqp_connection_object {
-#if PHP_MAJOR_VERSION >= 7
- amqp_connection_resource *connection_resource;
- zend_object zo;
-#else
- zend_object zo;
- amqp_connection_resource *connection_resource;
-#endif
+ amqp_connection_resource *connection_resource;
+ zend_object zo;
};
-#define DEFAULT_PORT "5672" /* default AMQP port */
-#define DEFAULT_HOST "localhost"
-#define DEFAULT_TIMEOUT ""
-#define DEFAULT_READ_TIMEOUT "0"
-#define DEFAULT_WRITE_TIMEOUT "0"
-#define DEFAULT_CONNECT_TIMEOUT "0"
-#define DEFAULT_RPC_TIMEOUT "0"
-#define DEFAULT_VHOST "/"
-#define DEFAULT_LOGIN "guest"
-#define DEFAULT_PASSWORD "guest"
-#define DEFAULT_AUTOACK "0" /* These are all strings to facilitate setting default ini values */
-#define DEFAULT_PREFETCH_COUNT "3"
-#define DEFAULT_PREFETCH_SIZE "0"
-#define DEFAULT_GLOBAL_PREFETCH_COUNT "0"
-#define DEFAULT_GLOBAL_PREFETCH_SIZE "0"
-#define DEFAULT_SASL_METHOD "0"
+#define DEFAULT_PORT "5672" /* default AMQP port */
+#define DEFAULT_HOST "localhost"
+#define DEFAULT_TIMEOUT ""
+#define DEFAULT_READ_TIMEOUT "0"
+#define DEFAULT_WRITE_TIMEOUT "0"
+#define DEFAULT_CONNECT_TIMEOUT "0"
+#define DEFAULT_RPC_TIMEOUT "0"
+#define DEFAULT_VHOST "/"
+#define DEFAULT_LOGIN "guest"
+#define DEFAULT_PASSWORD "guest"
+#define DEFAULT_AUTOACK "0" /* These are all strings to facilitate setting default ini values */
+#define DEFAULT_PREFETCH_COUNT "3"
+#define DEFAULT_PREFETCH_SIZE "0"
+#define DEFAULT_GLOBAL_PREFETCH_COUNT "0"
+#define DEFAULT_GLOBAL_PREFETCH_SIZE "0"
+#define DEFAULT_SASL_METHOD AMQP_SASL_METHOD_PLAIN
/* Usually, default is 0 which means 65535, but underlying rabbitmq-c library pool allocates minimal pool for each channel,
* so it takes a lot of memory to keep all that channels. Even after channel closing that buffer still keep memory allocation.
@@ -188,13 +242,20 @@ struct _amqp_connection_object {
/* AMQP_DEFAULT_FRAME_SIZE 131072 */
#if PHP_AMQP_PROTOCOL_MAX_CHANNELS > 0
- #define PHP_AMQP_MAX_CHANNELS PHP_AMQP_PROTOCOL_MAX_CHANNELS
+ #define PHP_AMQP_MAX_CHANNELS PHP_AMQP_PROTOCOL_MAX_CHANNELS
#else
- #define PHP_AMQP_MAX_CHANNELS 65535 // Note that the maximum number of channels the protocol supports is 65535 (2^16, with the 0-channel reserved)
+ #define PHP_AMQP_MAX_CHANNELS \
+ 65535// Note that the maximum number of channels the protocol supports is 65535 (2^16, with the 0-channel reserved)
#endif
-#define PHP_AMQP_MAX_FRAME INT_MAX
+#define PHP_AMQP_MAX_FRAME_SIZE INT_MAX
#define PHP_AMQP_MAX_HEARTBEAT INT_MAX
+#define PHP_AMQP_MAX_CREDENTIALS_LENGTH 1024
+#define PHP_AMQP_MAX_IDENTIFIER_LENGTH 512
+#define PHP_AMQP_MIN_PORT 1
+#define PHP_AMQP_MAX_PORT 65535
+#define PHP_AMQP_MAX_PREFETCH_COUNT UINT16_MAX
+#define PHP_AMQP_MAX_PREFETCH_SIZE UINT32_MAX
#define PHP_AMQP_DEFAULT_CHANNEL_MAX PHP_AMQP_MAX_CHANNELS
#define PHP_AMQP_DEFAULT_FRAME_MAX AMQP_DEFAULT_FRAME_SIZE
@@ -203,201 +264,207 @@ struct _amqp_connection_object {
#define PHP_AMQP_STRINGIFY(value) PHP_AMQP_TO_STRING(value)
#define PHP_AMQP_TO_STRING(value) #value
-
-#define DEFAULT_CHANNEL_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_MAX_CHANNELS)
-#define DEFAULT_FRAME_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_FRAME_MAX)
-#define DEFAULT_HEARTBEAT PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_HEARTBEAT)
-#define DEFAULT_CACERT ""
+#define DEFAULT_CHANNEL_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_MAX_CHANNELS)
+#define DEFAULT_FRAME_MAX PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_FRAME_MAX)
+#define DEFAULT_HEARTBEAT PHP_AMQP_STRINGIFY(PHP_AMQP_DEFAULT_HEARTBEAT)
#define DEFAULT_CAPATH ""
#define DEFAULT_USE_DEFAULT_CACERT "0"
#define DEFAULT_USE_DEFAULT_CAPATH "0"
-#define DEFAULT_CERT ""
-#define DEFAULT_KEY ""
-#define DEFAULT_VERIFY "1"
-
-
-#define IS_PASSIVE(bitmask) (AMQP_PASSIVE & (bitmask)) ? 1 : 0
-#define IS_DURABLE(bitmask) (AMQP_DURABLE & (bitmask)) ? 1 : 0
-#define IS_EXCLUSIVE(bitmask) (AMQP_EXCLUSIVE & (bitmask)) ? 1 : 0
-#define IS_AUTODELETE(bitmask) (AMQP_AUTODELETE & (bitmask)) ? 1 : 0
-#define IS_INTERNAL(bitmask) (AMQP_INTERNAL & (bitmask)) ? 1 : 0
-#define IS_NOWAIT(bitmask) (AMQP_NOWAIT & (bitmask)) ? 1 : 0 /* NOTE: always 0 in rabbitmq-c internals, so don't use it unless you are clearly understand aftermath*/
-
-#define PHP_AMQP_NOPARAMS() if (zend_parse_parameters_none() == FAILURE) { return; }
-
-#define PHP_AMQP_RETURN_THIS_PROP(prop_name) \
- zval * _zv = zend_read_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(prop_name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC); \
+#define DEFAULT_CACERT ""
+#define DEFAULT_CERT ""
+#define DEFAULT_KEY ""
+#define DEFAULT_VERIFY "1"
+#define DEFAULT_SERIALIZATION_DEPTH "128"
+
+#define IS_PASSIVE(bitmask) (AMQP_PASSIVE & (bitmask)) ? 1 : 0
+#define IS_DURABLE(bitmask) (AMQP_DURABLE & (bitmask)) ? 1 : 0
+#define IS_EXCLUSIVE(bitmask) (AMQP_EXCLUSIVE & (bitmask)) ? 1 : 0
+#define IS_AUTODELETE(bitmask) (AMQP_AUTODELETE & (bitmask)) ? 1 : 0
+#define IS_INTERNAL(bitmask) (AMQP_INTERNAL & (bitmask)) ? 1 : 0
+
+#define PHP_AMQP_NOPARAMS() \
+ if (zend_parse_parameters_none() == FAILURE) { \
+ RETURN_THROWS(); \
+ }
+
+#define PHP_AMQP_RETURN_THIS_PROP(prop_name) \
+ zval *_zv = zend_read_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL(prop_name), 0, &rv); \
RETURN_ZVAL(_zv, 1, 0);
-#define PHP_AMQP_READ_OBJ_PROP(cls, obj, name) zend_read_property((cls), PHP5to8_OBJ_PROP(obj), ZEND_STRL(name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC)
+#define PHP_AMQP_READ_OBJ_PROP(cls, obj, name) \
+ zend_read_property((cls), PHP_AMQP_COMPAT_OBJ_P(obj), ZEND_STRL(name), 0, &rv)
#define PHP_AMQP_READ_OBJ_PROP_DOUBLE(cls, obj, name) Z_DVAL_P(PHP_AMQP_READ_OBJ_PROP((cls), (obj), (name)))
-#define PHP_AMQP_READ_THIS_PROP_CE(name, ce) zend_read_property((ce), PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC)
-#define PHP_AMQP_READ_THIS_PROP(name) zend_read_property(this_ce, PHP5to8_OBJ_PROP(getThis()), ZEND_STRL(name), 0 PHP5to7_READ_PROP_RV_PARAM_CC TSRMLS_CC)
-#define PHP_AMQP_READ_THIS_PROP_BOOL(name) Z_BVAL_P(PHP_AMQP_READ_THIS_PROP(name))
+#define PHP_AMQP_READ_THIS_PROP_CE(name, ce) \
+ zend_read_property((ce), PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL(name), 0, &rv)
+#define PHP_AMQP_READ_THIS_PROP(name) \
+ zend_read_property(this_ce, PHP_AMQP_COMPAT_OBJ_P(getThis()), ZEND_STRL(name), 0, &rv)
+#define PHP_AMQP_READ_THIS_PROP_BOOL(name) Z_TYPE_P(PHP_AMQP_READ_THIS_PROP(name)) == IS_TRUE
#define PHP_AMQP_READ_THIS_PROP_STR(name) Z_STRVAL_P(PHP_AMQP_READ_THIS_PROP(name))
-#define PHP_AMQP_READ_THIS_PROP_STRLEN(name) (Z_TYPE_P(PHP_AMQP_READ_THIS_PROP(name)) == IS_STRING ? Z_STRLEN_P(PHP_AMQP_READ_THIS_PROP(name)) : 0)
+#define PHP_AMQP_READ_THIS_PROP_STRLEN(name) \
+ (Z_TYPE_P(PHP_AMQP_READ_THIS_PROP(name)) == IS_STRING ? Z_STRLEN_P(PHP_AMQP_READ_THIS_PROP(name)) : 0)
#define PHP_AMQP_READ_THIS_PROP_ARR(name) Z_ARRVAL_P(PHP_AMQP_READ_THIS_PROP(name))
#define PHP_AMQP_READ_THIS_PROP_LONG(name) Z_LVAL_P(PHP_AMQP_READ_THIS_PROP(name))
#define PHP_AMQP_READ_THIS_PROP_DOUBLE(name) Z_DVAL_P(PHP_AMQP_READ_THIS_PROP(name))
-#if PHP_MAJOR_VERSION >= 7
- static inline amqp_connection_object *php_amqp_connection_object_fetch(zend_object *obj) {
- return (amqp_connection_object *)((char *)obj - XtOffsetOf(amqp_connection_object, zo));
- }
-
- static inline amqp_channel_object *php_amqp_channel_object_fetch(zend_object *obj) {
- return (amqp_channel_object *)((char *)obj - XtOffsetOf(amqp_channel_object, zo));
- }
-
- #define PHP_AMQP_GET_CONNECTION(obj) php_amqp_connection_object_fetch(Z_OBJ_P(obj))
- #define PHP_AMQP_GET_CHANNEL(obj) php_amqp_channel_object_fetch(Z_OBJ_P(obj))
-
- #define PHP_AMQP_FETCH_CONNECTION(obj) php_amqp_connection_object_fetch(obj)
- #define PHP_AMQP_FETCH_CHANNEL(obj) php_amqp_channel_object_fetch(obj)
-
-#else
- #define PHP_AMQP_GET_CONNECTION(obj) (amqp_connection_object *)zend_object_store_get_object((obj) TSRMLS_CC)
- #define PHP_AMQP_GET_CHANNEL(obj) (amqp_channel_object *)zend_object_store_get_object((obj) TSRMLS_CC)
-
- #define PHP_AMQP_FETCH_CONNECTION(obj) (amqp_connection_object*)(obj)
- #define PHP_AMQP_FETCH_CHANNEL(obj) (amqp_channel_object*)(obj)
-#endif
-
-
-#define PHP_AMQP_GET_CHANNEL_RESOURCE(obj) (IS_OBJECT == Z_TYPE_P(obj) ? (PHP_AMQP_GET_CHANNEL(obj))->channel_resource : NULL)
-
-#define PHP_AMQP_VERIFY_CONNECTION_ERROR(error, reason) \
- char verify_connection_error_tmp[255]; \
- snprintf(verify_connection_error_tmp, 255, "%s %s", error, reason); \
- zend_throw_exception(amqp_connection_exception_class_entry, verify_connection_error_tmp, 0 TSRMLS_CC); \
- return; \
-
-#define PHP_AMQP_VERIFY_CONNECTION(connection, error) \
- if (!connection) { \
- PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \
- } \
- if (!(connection)->connection_resource || !(connection)->connection_resource->is_connected) { \
- PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \
- } \
-
-#define PHP_AMQP_VERIFY_CHANNEL_ERROR(error, reason) \
- char verify_channel_error_tmp[255]; \
- snprintf(verify_channel_error_tmp, 255, "%s %s", error, reason); \
- zend_throw_exception(amqp_channel_exception_class_entry, verify_channel_error_tmp, 0 TSRMLS_CC); \
- return; \
-
-#define PHP_AMQP_VERIFY_CHANNEL_RESOURCE(resource, error) \
- if (!resource) { \
- PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "Stale reference to the channel object.") \
- } \
- if (!(resource)->is_connected) { \
- PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "No channel available.") \
- } \
- if (!(resource)->connection_resource) { \
- PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \
- } \
- if (!(resource)->connection_resource->is_connected) { \
- PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \
- } \
-
-#define PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(resource, error) \
- if (!resource) { \
- PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "Stale reference to the channel object.") \
- } \
- if (!(resource)->connection_resource) { \
- PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \
- } \
- if (!(resource)->connection_resource->is_connected) { \
- PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \
- } \
-
-#define PHP_AMQP_MAYBE_ERROR(res, channel_resource) (\
- (AMQP_RESPONSE_NORMAL != (res).reply_type) \
- && \
- PHP_AMQP_RESOURCE_RESPONSE_OK != php_amqp_error(res, &PHP_AMQP_G(error_message), (channel_resource)->connection_resource, (channel_resource) TSRMLS_CC) \
- )
-
-#define PHP_AMQP_MAYBE_ERROR_RECOVERABLE(res, channel_resource) (\
- (AMQP_RESPONSE_NORMAL != (res).reply_type) \
- && \
- PHP_AMQP_RESOURCE_RESPONSE_OK != php_amqp_error_advanced(res, &PHP_AMQP_G(error_message), (channel_resource)->connection_resource, (channel_resource), 0 TSRMLS_CC) \
- )
-
-#define PHP_AMQP_IS_ERROR_RECOVERABLE(res, channel_resource, channel_object) ( \
- AMQP_RESPONSE_LIBRARY_EXCEPTION == (res).reply_type && AMQP_STATUS_UNEXPECTED_STATE == (res).library_error \
- && (0 <= php_amqp_connection_resource_error_advanced(res, &PHP_AMQP_G(error_message), (channel_resource)->connection_resource, (amqp_channel_t)(channel_resource ? (channel_resource)->channel_id : 0), (channel_object) TSRMLS_CC)) \
-)
+static inline amqp_connection_object *php_amqp_connection_object_fetch(zend_object *obj)
+{
+ return (amqp_connection_object *) ((char *) obj - XtOffsetOf(amqp_connection_object, zo));
+}
+
+static inline amqp_channel_object *php_amqp_channel_object_fetch(zend_object *obj)
+{
+ return (amqp_channel_object *) ((char *) obj - XtOffsetOf(amqp_channel_object, zo));
+}
+
+#define PHP_AMQP_GET_CONNECTION(obj) php_amqp_connection_object_fetch(Z_OBJ_P(obj))
+#define PHP_AMQP_GET_CHANNEL(obj) php_amqp_channel_object_fetch(Z_OBJ_P(obj))
+
+#define PHP_AMQP_FETCH_CONNECTION(obj) php_amqp_connection_object_fetch(obj)
+#define PHP_AMQP_FETCH_CHANNEL(obj) php_amqp_channel_object_fetch(obj)
+
+#define PHP_AMQP_GET_CHANNEL_RESOURCE(obj) \
+ (IS_OBJECT == Z_TYPE_P(obj) ? (PHP_AMQP_GET_CHANNEL(obj))->channel_resource : NULL)
+
+#define PHP_AMQP_VERIFY_CONNECTION_ERROR(error, reason) \
+ char verify_connection_error_tmp[255]; \
+ snprintf(verify_connection_error_tmp, 255, "%s %s", error, reason); \
+ zend_throw_exception(amqp_connection_exception_class_entry, verify_connection_error_tmp, 0); \
+ return;
+
+#define PHP_AMQP_VERIFY_CONNECTION(connection, error) \
+ if (!connection) { \
+ PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \
+ } \
+ if (!(connection)->connection_resource || !(connection)->connection_resource->is_connected) { \
+ PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \
+ }
+
+#define PHP_AMQP_VERIFY_CHANNEL_ERROR(error, reason) \
+ char verify_channel_error_tmp[255]; \
+ snprintf(verify_channel_error_tmp, 255, "%s %s", error, reason); \
+ zend_throw_exception(amqp_channel_exception_class_entry, verify_channel_error_tmp, 0); \
+ return;
+
+#define PHP_AMQP_VERIFY_CHANNEL_RESOURCE(resource, error) \
+ if (!resource) { \
+ PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "Stale reference to the channel object.") \
+ } \
+ if (!(resource)->is_connected) { \
+ PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "No channel available.") \
+ } \
+ if (!(resource)->connection_resource) { \
+ PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \
+ } \
+ if (!(resource)->connection_resource->is_connected) { \
+ PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \
+ }
+
+#define PHP_AMQP_VERIFY_CHANNEL_CONNECTION_RESOURCE(resource, error) \
+ if (!resource) { \
+ PHP_AMQP_VERIFY_CHANNEL_ERROR(error, "Stale reference to the channel object.") \
+ } \
+ if (!(resource)->connection_resource) { \
+ PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "Stale reference to the connection object.") \
+ } \
+ if (!(resource)->connection_resource->is_connected) { \
+ PHP_AMQP_VERIFY_CONNECTION_ERROR(error, "No connection available.") \
+ }
+
+#define PHP_AMQP_MAYBE_ERROR(res, channel_resource, connection_resource) \
+ ((AMQP_RESPONSE_NORMAL != (res).reply_type) && \
+ PHP_AMQP_RESOURCE_RESPONSE_OK != \
+ php_amqp_error(res, &PHP_AMQP_G(error_message), (connection_resource), (channel_resource)))
#if ZEND_MODULE_API_NO >= 20100000
- #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) object_properties_init(&(obj), ce);
+ #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) object_properties_init(&(obj), ce);
#else
- #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) \
- do { \
- zval *tmp; \
- zend_hash_copy((obj).properties, &(ce)->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); \
- } while (0);
+ #define AMQP_OBJECT_PROPERTIES_INIT(obj, ce) \
+ do { \
+ zval *tmp; \
+ zend_hash_copy( \
+ (obj).properties, \
+ &(ce)->default_properties, \
+ (copy_ctor_func_t) zval_add_ref, \
+ (void *) &tmp, \
+ sizeof(zval *) \
+ ); \
+ } while (0);
#endif
#define AMQP_ERROR_CATEGORY_MASK (1 << 29)
+#define PHP_AMQP_RECURSION_DEPTH_LIMIT (1 << 7)
#ifdef PHP_WIN32
-# define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | WSAETIMEDOUT
+ #define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | WSAETIMEDOUT
#else
-# define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | EAGAIN
+ #define AMQP_OS_SOCKET_TIMEOUT_ERRNO AMQP_ERROR_CATEGORY_MASK | EAGAIN
#endif
ZEND_BEGIN_MODULE_GLOBALS(amqp)
- char *error_message;
- PHP5to7_param_long_type_t error_code;
+char *error_message;
+zend_long error_code;
+zend_long deserialization_depth;
+zend_long serialization_depth;
ZEND_END_MODULE_GLOBALS(amqp)
-ZEND_EXTERN_MODULE_GLOBALS(amqp);
+ZEND_EXTERN_MODULE_GLOBALS(amqp)
#ifdef ZEND_MODULE_GLOBALS_ACCESSOR
- #define PHP_AMQP_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(amqp, v)
+ #define PHP_AMQP_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(amqp, v)
- #if defined(ZTS) && defined(COMPILE_DL_WEAK)
- ZEND_TSRMLS_CACHE_EXTERN();
- #endif
+ #if defined(ZTS) && defined(COMPILE_DL_WEAK)
+ZEND_TSRMLS_CACHE_EXTERN();
+ #endif
#else
- #ifdef ZTS
- #define PHP_AMQP_G(v) TSRMG(amqp_globals_id, zend_amqp_globals *, v)
- #else
- #define PHP_AMQP_G(v) (amqp_globals.v)
- #endif
-#endif
-
-#ifndef PHP_AMQP_VERSION
-#define PHP_AMQP_VERSION "1.12.0dev"
-#endif
-
-#ifndef PHP_AMQP_REVISION
-#define PHP_AMQP_REVISION "release"
+ #ifdef ZTS
+ #define PHP_AMQP_G(v) TSRMG(amqp_globals_id, zend_amqp_globals *, v)
+ #else
+ #define PHP_AMQP_G(v) (amqp_globals.v)
+ #endif
#endif
-int php_amqp_error(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource TSRMLS_DC);
-int php_amqp_error_advanced(amqp_rpc_reply_t reply, char **message, amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource, int fail_on_errors TSRMLS_DC);
+int php_amqp_error(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *connection_resource,
+ amqp_channel_resource *channel_resource
+);
+int php_amqp_error_advanced(
+ amqp_rpc_reply_t reply,
+ char **message,
+ amqp_connection_resource *connection_resource,
+ amqp_channel_resource *channel_resource,
+ int fail_on_errors
+);
/**
* @deprecated
*/
-void php_amqp_zend_throw_exception(amqp_rpc_reply_t reply, zend_class_entry *exception_ce, const char *message, PHP5to7_param_long_type_t code TSRMLS_DC);
-void php_amqp_zend_throw_exception_short(amqp_rpc_reply_t reply, zend_class_entry *exception_ce TSRMLS_DC);
-void php_amqp_maybe_release_buffers_on_channel(amqp_connection_resource *connection_resource, amqp_channel_resource *channel_resource);
-
-#endif /* PHP_AMQP_H */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
+void php_amqp_zend_throw_exception(
+ amqp_rpc_reply_t reply,
+ zend_class_entry *exception_ce,
+ const char *message,
+ zend_long code
+);
+void php_amqp_zend_throw_exception_short(amqp_rpc_reply_t reply, zend_class_entry *exception_ce);
+void php_amqp_maybe_release_buffers_on_channel(
+ amqp_connection_resource *connection_resource,
+ amqp_channel_resource *channel_resource
+);
+
+bool php_amqp_is_valid_identifier(zend_string *val);
+bool php_amqp_is_valid_credential(zend_string *val);
+bool php_amqp_is_valid_port(zend_long val);
+bool php_amqp_is_valid_timeout(double timeout);
+bool php_amqp_is_valid_channel_max(zend_long val);
+bool php_amqp_is_valid_frame_size_max(zend_long val);
+bool php_amqp_is_valid_heartbeat(zend_long val);
+bool php_amqp_is_valid_prefetch_count(zend_long val);
+bool php_amqp_is_valid_prefetch_size(zend_long val);
+
+#endif /* PHP_AMQP_H */
diff --git a/php_amqp_version.h b/php_amqp_version.h
new file mode 100644
index 00000000..740e6d07
--- /dev/null
+++ b/php_amqp_version.h
@@ -0,0 +1,6 @@
+#define PHP_AMQP_VERSION_MAJOR 2
+#define PHP_AMQP_VERSION_MINOR 2
+#define PHP_AMQP_VERSION_PATCH 1
+#define PHP_AMQP_VERSION_EXTRA "dev"
+#define PHP_AMQP_VERSION "2.2.1dev"
+#define PHP_AMQP_VERSION_ID 20201
diff --git a/provision/.bashrc b/provision/.bashrc
deleted file mode 100644
index 2e86786c..00000000
--- a/provision/.bashrc
+++ /dev/null
@@ -1,127 +0,0 @@
-# ~/.bashrc: executed by bash(1) for non-login shells.
-# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
-# for examples
-
-# If not running interactively, don't do anything
-case $- in
- *i*) ;;
- *) return;;
-esac
-
-# don't put duplicate lines or lines starting with space in the history.
-# See bash(1) for more options
-HISTCONTROL=ignoreboth
-
-# append to the history file, don't overwrite it
-shopt -s histappend
-
-# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
-HISTSIZE=1000
-HISTFILESIZE=2000
-
-# check the window size after each command and, if necessary,
-# update the values of LINES and COLUMNS.
-shopt -s checkwinsize
-
-# If set, the pattern "**" used in a pathname expansion context will
-# match all files and zero or more directories and subdirectories.
-#shopt -s globstar
-
-# make less more friendly for non-text input files, see lesspipe(1)
-[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
-
-# set variable identifying the chroot you work in (used in the prompt below)
-if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
- debian_chroot=$(cat /etc/debian_chroot)
-fi
-
-# set a fancy prompt (non-color, unless we know we "want" color)
-case "$TERM" in
- xterm-color) color_prompt=yes;;
-esac
-
-# uncomment for a colored prompt, if the terminal has the capability; turned
-# off by default to not distract the user: the focus in a terminal window
-# should be on the output of commands, not on the prompt
-#force_color_prompt=yes
-
-if [ -n "$force_color_prompt" ]; then
- if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
- # We have color support; assume it's compliant with Ecma-48
- # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
- # a case would tend to support setf rather than setaf.)
- color_prompt=yes
- else
- color_prompt=
- fi
-fi
-
-if [ "$color_prompt" = yes ]; then
- PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
-else
- PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
-fi
-unset color_prompt force_color_prompt
-
-# If this is an xterm set the title to user@host:dir
-case "$TERM" in
-xterm*|rxvt*)
- PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
- ;;
-*)
- ;;
-esac
-
-# enable color support of ls and also add handy aliases
-if [ -x /usr/bin/dircolors ]; then
- test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
- alias ls='ls --color=auto'
- #alias dir='dir --color=auto'
- #alias vdir='vdir --color=auto'
-
- alias grep='grep --color=auto'
- alias fgrep='fgrep --color=auto'
- alias egrep='egrep --color=auto'
-fi
-
-# some more ls aliases
-alias ll='ls -alF'
-alias la='ls -A'
-alias l='ls -CF'
-
-# Add an "alert" alias for long running commands. Use like so:
-# sleep 10; alert
-alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
-
-# Alias definitions.
-# You may want to put all your additions into a separate file like
-# ~/.bash_aliases, instead of adding them here directly.
-# See /usr/share/doc/bash-doc/examples in the bash-doc package.
-
-if [ -f ~/.bash_aliases ]; then
- . ~/.bash_aliases
-fi
-
-# enable programmable completion features (you don't need to enable
-# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
-# sources /etc/bash.bashrc).
-if ! shopt -oq posix; then
- if [ -f /usr/share/bash-completion/bash_completion ]; then
- . /usr/share/bash-completion/bash_completion
- elif [ -f /etc/bash_completion ]; then
- . /etc/bash_completion
- fi
-fi
-
-PHPBREW_SET_PROMPT=1
-
-source ~/.phpbrew/bashrc
-
-if [ $(id -u) -eq 0 ];
-then
- PS1='${debian_chroot:+()}\[\e[01;31m\]\u\[\e[0m\]@\[\e[01;31m\]\h\[\e[0m\] (\[\e[0;36m\]$(phpbrew_current_php_version)\[\e[0m\]):\[\033[01;34m\]\w\[\033[00m\]# '
-else
- PS1='${debian_chroot:+()}\[\e[01;32m\]\u\[\e[0m\]@\[\e[01;32m\]\h\[\e[0m\] (\[\e[0;36m\]$(phpbrew_current_php_version)\[\e[0m\]):\[\033[01;34m\]\w\[\033[00m\]$ '
-fi
-
-EDITOR=vim
\ No newline at end of file
diff --git a/provision/apache/000-default.conf b/provision/apache/000-default.conf
deleted file mode 100644
index ad10d426..00000000
--- a/provision/apache/000-default.conf
+++ /dev/null
@@ -1,33 +0,0 @@
-
- # The ServerName directive sets the request scheme, hostname and port that
- # the server uses to identify itself. This is used when creating
- # redirection URLs. In the context of virtual hosts, the ServerName
- # specifies what hostname must appear in the request's Host: header to
- # match this virtual host. For the default virtual host (this file) this
- # value is not decisive as it is used as a last resort host regardless.
- # However, you must set it for any further virtual host explicitly.
- #ServerName www.example.com
-
- ServerAdmin webmaster@localhost
- DocumentRoot /var/www/html
-
- DirectoryIndex index.php index-apache.html
-
- # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
- # error, crit, alert, emerg.
- # It is also possible to configure the loglevel for particular
- # modules, e.g.
- #LogLevel info ssl:warn
-
- ErrorLog ${APACHE_LOG_DIR}/error.log
- CustomLog ${APACHE_LOG_DIR}/access.log combined
-
- # For most configuration files from conf-available/, which are
- # enabled or disabled at a global level, it is possible to
- # include a line for only one particular virtual host. For example the
- # following line enables the CGI configuration for this host only
- # after it has been globally disabled with "a2disconf".
- #Include conf-available/serve-cgi-bin.conf
-
-
-# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
diff --git a/provision/apache/ports.conf b/provision/apache/ports.conf
deleted file mode 100644
index 03d5dd24..00000000
--- a/provision/apache/ports.conf
+++ /dev/null
@@ -1,15 +0,0 @@
-# If you just change the port or add more ports here, you will likely also
-# have to change the VirtualHost statement in
-# /etc/apache2/sites-enabled/000-default.conf
-
-Listen 8080
-
-
- Listen 443
-
-
-
- Listen 443
-
-
-# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
diff --git a/provision/nginx/default b/provision/nginx/default
deleted file mode 100644
index 39cc12ac..00000000
--- a/provision/nginx/default
+++ /dev/null
@@ -1,21 +0,0 @@
-server {
- listen 80 default_server;
- listen [::]:80 default_server ipv6only=on;
-
- root /var/www/html;
-
- server_name _;
-
- location / {
- try_files $uri $uri/ /index.php?$args;
- index index.php index-nginx.html;
- }
-
- location ~ \.php$ {
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- fastcgi_intercept_errors off;
- }
-}
diff --git a/provision/php/amqp.ini b/provision/php/amqp.ini
deleted file mode 100644
index 38bfff19..00000000
--- a/provision/php/amqp.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-; configuration for php AMQP module
-; priority=10
-extension=amqp.so
diff --git a/provision/php/www.conf b/provision/php/www.conf
deleted file mode 100644
index 0bf9ef99..00000000
--- a/provision/php/www.conf
+++ /dev/null
@@ -1,414 +0,0 @@
-; Start a new pool named 'www'.
-; the variable $pool can be used in any directive and will be replaced by the
-; pool name ('www' here)
-[www]
-
-; Per pool prefix
-; It only applies on the following directives:
-; - 'access.log'
-; - 'slowlog'
-; - 'listen' (unixsocket)
-; - 'chroot'
-; - 'chdir'
-; - 'php_values'
-; - 'php_admin_values'
-; When not set, the global prefix (or /usr) applies instead.
-; Note: This directive can also be relative to the global prefix.
-; Default Value: none
-;prefix = /path/to/pools/$pool
-
-; Unix user/group of processes
-; Note: The user is mandatory. If the group is not set, the default user's group
-; will be used.
-user = www-data
-group = www-data
-
-; The address on which to accept FastCGI requests.
-; Valid syntaxes are:
-; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
-; a specific port;
-; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
-; a specific port;
-; 'port' - to listen on a TCP socket to all addresses
-; (IPv6 and IPv4-mapped) on a specific port;
-; '/path/to/unix/socket' - to listen on a unix socket.
-; Note: This value is mandatory.
-;listen = /run/php/php7.0-fpm.sock
-listen = 127.0.0.1:9000
-
-; Set listen(2) backlog.
-; Default Value: 511 (-1 on FreeBSD and OpenBSD)
-;listen.backlog = 511
-
-; Set permissions for unix socket, if one is used. In Linux, read/write
-; permissions must be set in order to allow connections from a web server. Many
-; BSD-derived systems allow connections regardless of permissions.
-; Default Values: user and group are set as the running user
-; mode is set to 0660
-listen.owner = www-data
-listen.group = www-data
-;listen.mode = 0660
-; When POSIX Access Control Lists are supported you can set them using
-; these options, value is a comma separated list of user/group names.
-; When set, listen.owner and listen.group are ignored
-;listen.acl_users =
-;listen.acl_groups =
-
-; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
-; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
-; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
-; must be separated by a comma. If this value is left blank, connections will be
-; accepted from any ip address.
-; Default Value: any
-;listen.allowed_clients = 127.0.0.1
-
-; Specify the nice(2) priority to apply to the pool processes (only if set)
-; The value can vary from -19 (highest priority) to 20 (lower priority)
-; Note: - It will only work if the FPM master process is launched as root
-; - The pool processes will inherit the master process priority
-; unless it specified otherwise
-; Default Value: no set
-; process.priority = -19
-
-; Choose how the process manager will control the number of child processes.
-; Possible Values:
-; static - a fixed number (pm.max_children) of child processes;
-; dynamic - the number of child processes are set dynamically based on the
-; following directives. With this process management, there will be
-; always at least 1 children.
-; pm.max_children - the maximum number of children that can
-; be alive at the same time.
-; pm.start_servers - the number of children created on startup.
-; pm.min_spare_servers - the minimum number of children in 'idle'
-; state (waiting to process). If the number
-; of 'idle' processes is less than this
-; number then some children will be created.
-; pm.max_spare_servers - the maximum number of children in 'idle'
-; state (waiting to process). If the number
-; of 'idle' processes is greater than this
-; number then some children will be killed.
-; ondemand - no children are created at startup. Children will be forked when
-; new requests will connect. The following parameter are used:
-; pm.max_children - the maximum number of children that
-; can be alive at the same time.
-; pm.process_idle_timeout - The number of seconds after which
-; an idle process will be killed.
-; Note: This value is mandatory.
-pm = dynamic
-
-; The number of child processes to be created when pm is set to 'static' and the
-; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.
-; This value sets the limit on the number of simultaneous requests that will be
-; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.
-; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP
-; CGI. The below defaults are based on a server without much resources. Don't
-; forget to tweak pm.* to fit your needs.
-; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'
-; Note: This value is mandatory.
-pm.max_children = 5
-
-; The number of child processes created on startup.
-; Note: Used only when pm is set to 'dynamic'
-; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
-pm.start_servers = 2
-
-; The desired minimum number of idle server processes.
-; Note: Used only when pm is set to 'dynamic'
-; Note: Mandatory when pm is set to 'dynamic'
-pm.min_spare_servers = 1
-
-; The desired maximum number of idle server processes.
-; Note: Used only when pm is set to 'dynamic'
-; Note: Mandatory when pm is set to 'dynamic'
-pm.max_spare_servers = 3
-
-; The number of seconds after which an idle process will be killed.
-; Note: Used only when pm is set to 'ondemand'
-; Default Value: 10s
-;pm.process_idle_timeout = 10s;
-
-; The number of requests each child process should execute before respawning.
-; This can be useful to work around memory leaks in 3rd party libraries. For
-; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.
-; Default Value: 0
-;pm.max_requests = 500
-
-; The URI to view the FPM status page. If this value is not set, no URI will be
-; recognized as a status page. It shows the following informations:
-; pool - the name of the pool;
-; process manager - static, dynamic or ondemand;
-; start time - the date and time FPM has started;
-; start since - number of seconds since FPM has started;
-; accepted conn - the number of request accepted by the pool;
-; listen queue - the number of request in the queue of pending
-; connections (see backlog in listen(2));
-; max listen queue - the maximum number of requests in the queue
-; of pending connections since FPM has started;
-; listen queue len - the size of the socket queue of pending connections;
-; idle processes - the number of idle processes;
-; active processes - the number of active processes;
-; total processes - the number of idle + active processes;
-; max active processes - the maximum number of active processes since FPM
-; has started;
-; max children reached - number of times, the process limit has been reached,
-; when pm tries to start more children (works only for
-; pm 'dynamic' and 'ondemand');
-; Value are updated in real time.
-; Example output:
-; pool: www
-; process manager: static
-; start time: 01/Jul/2011:17:53:49 +0200
-; start since: 62636
-; accepted conn: 190460
-; listen queue: 0
-; max listen queue: 1
-; listen queue len: 42
-; idle processes: 4
-; active processes: 11
-; total processes: 15
-; max active processes: 12
-; max children reached: 0
-;
-; By default the status page output is formatted as text/plain. Passing either
-; 'html', 'xml' or 'json' in the query string will return the corresponding
-; output syntax. Example:
-; http://www.foo.bar/status
-; http://www.foo.bar/status?json
-; http://www.foo.bar/status?html
-; http://www.foo.bar/status?xml
-;
-; By default the status page only outputs short status. Passing 'full' in the
-; query string will also return status for each pool process.
-; Example:
-; http://www.foo.bar/status?full
-; http://www.foo.bar/status?json&full
-; http://www.foo.bar/status?html&full
-; http://www.foo.bar/status?xml&full
-; The Full status returns for each process:
-; pid - the PID of the process;
-; state - the state of the process (Idle, Running, ...);
-; start time - the date and time the process has started;
-; start since - the number of seconds since the process has started;
-; requests - the number of requests the process has served;
-; request duration - the duration in ?s of the requests;
-; request method - the request method (GET, POST, ...);
-; request URI - the request URI with the query string;
-; content length - the content length of the request (only with POST);
-; user - the user (PHP_AUTH_USER) (or '-' if not set);
-; script - the main script called (or '-' if not set);
-; last request cpu - the %cpu the last request consumed
-; it's always 0 if the process is not in Idle state
-; because CPU calculation is done when the request
-; processing has terminated;
-; last request memory - the max amount of memory the last request consumed
-; it's always 0 if the process is not in Idle state
-; because memory calculation is done when the request
-; processing has terminated;
-; If the process is in Idle state, then informations are related to the
-; last request the process has served. Otherwise informations are related to
-; the current request being served.
-; Example output:
-; ************************
-; pid: 31330
-; state: Running
-; start time: 01/Jul/2011:17:53:49 +0200
-; start since: 63087
-; requests: 12808
-; request duration: 1250261
-; request method: GET
-; request URI: /test_mem.php?N=10000
-; content length: 0
-; user: -
-; script: /home/fat/web/docs/php/test_mem.php
-; last request cpu: 0.00
-; last request memory: 0
-;
-; Note: There is a real-time FPM status monitoring sample web page available
-; It's available in: /usr/share/php/7.0/fpm/status.html
-;
-; Note: The value must start with a leading slash (/). The value can be
-; anything, but it may not be a good idea to use the .php extension or it
-; may conflict with a real PHP file.
-; Default Value: not set
-;pm.status_path = /status
-
-; The ping URI to call the monitoring page of FPM. If this value is not set, no
-; URI will be recognized as a ping page. This could be used to test from outside
-; that FPM is alive and responding, or to
-; - create a graph of FPM availability (rrd or such);
-; - remove a server from a group if it is not responding (load balancing);
-; - trigger alerts for the operating team (24/7).
-; Note: The value must start with a leading slash (/). The value can be
-; anything, but it may not be a good idea to use the .php extension or it
-; may conflict with a real PHP file.
-; Default Value: not set
-;ping.path = /ping
-
-; This directive may be used to customize the response of a ping request. The
-; response is formatted as text/plain with a 200 response code.
-; Default Value: pong
-;ping.response = pong
-
-; The access log file
-; Default: not set
-;access.log = log/$pool.access.log
-
-; The access log format.
-; The following syntax is allowed
-; %%: the '%' character
-; %C: %CPU used by the request
-; it can accept the following format:
-; - %{user}C for user CPU only
-; - %{system}C for system CPU only
-; - %{total}C for user + system CPU (default)
-; %d: time taken to serve the request
-; it can accept the following format:
-; - %{seconds}d (default)
-; - %{miliseconds}d
-; - %{mili}d
-; - %{microseconds}d
-; - %{micro}d
-; %e: an environment variable (same as $_ENV or $_SERVER)
-; it must be associated with embraces to specify the name of the env
-; variable. Some exemples:
-; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e
-; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e
-; %f: script filename
-; %l: content-length of the request (for POST request only)
-; %m: request method
-; %M: peak of memory allocated by PHP
-; it can accept the following format:
-; - %{bytes}M (default)
-; - %{kilobytes}M
-; - %{kilo}M
-; - %{megabytes}M
-; - %{mega}M
-; %n: pool name
-; %o: output header
-; it must be associated with embraces to specify the name of the header:
-; - %{Content-Type}o
-; - %{X-Powered-By}o
-; - %{Transfert-Encoding}o
-; - ....
-; %p: PID of the child that serviced the request
-; %P: PID of the parent of the child that serviced the request
-; %q: the query string
-; %Q: the '?' character if query string exists
-; %r: the request URI (without the query string, see %q and %Q)
-; %R: remote IP address
-; %s: status (response code)
-; %t: server time the request was received
-; it can accept a strftime(3) format:
-; %d/%b/%Y:%H:%M:%S %z (default)
-; The strftime(3) format must be encapsuled in a %{}t tag
-; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
-; %T: time the log has been written (the request has finished)
-; it can accept a strftime(3) format:
-; %d/%b/%Y:%H:%M:%S %z (default)
-; The strftime(3) format must be encapsuled in a %{}t tag
-; e.g. for a ISO8601 formatted timestring, use: %{%Y-%m-%dT%H:%M:%S%z}t
-; %u: remote user
-;
-; Default: "%R - %u %t \"%m %r\" %s"
-;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"
-
-; The log file for slow requests
-; Default Value: not set
-; Note: slowlog is mandatory if request_slowlog_timeout is set
-;slowlog = log/$pool.log.slow
-
-; The timeout for serving a single request after which a PHP backtrace will be
-; dumped to the 'slowlog' file. A value of '0s' means 'off'.
-; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
-; Default Value: 0
-;request_slowlog_timeout = 0
-
-; The timeout for serving a single request after which the worker process will
-; be killed. This option should be used when the 'max_execution_time' ini option
-; does not stop script execution for some reason. A value of '0' means 'off'.
-; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
-; Default Value: 0
-;request_terminate_timeout = 0
-
-; Set open file descriptor rlimit.
-; Default Value: system defined value
-;rlimit_files = 1024
-
-; Set max core size rlimit.
-; Possible Values: 'unlimited' or an integer greater or equal to 0
-; Default Value: system defined value
-;rlimit_core = 0
-
-; Chroot to this directory at the start. This value must be defined as an
-; absolute path. When this value is not set, chroot is not used.
-; Note: you can prefix with '$prefix' to chroot to the pool prefix or one
-; of its subdirectories. If the pool prefix is not set, the global prefix
-; will be used instead.
-; Note: chrooting is a great security feature and should be used whenever
-; possible. However, all PHP paths will be relative to the chroot
-; (error_log, sessions.save_path, ...).
-; Default Value: not set
-;chroot =
-
-; Chdir to this directory at the start.
-; Note: relative path can be used.
-; Default Value: current directory or / when chroot
-;chdir = /var/www
-
-; Redirect worker stdout and stderr into main error log. If not set, stdout and
-; stderr will be redirected to /dev/null according to FastCGI specs.
-; Note: on highloaded environement, this can cause some delay in the page
-; process time (several ms).
-; Default Value: no
-;catch_workers_output = yes
-
-; Clear environment in FPM workers
-; Prevents arbitrary environment variables from reaching FPM worker processes
-; by clearing the environment in workers before env vars specified in this
-; pool configuration are added.
-; Setting to "no" will make all environment variables available to PHP code
-; via getenv(), $_ENV and $_SERVER.
-; Default Value: yes
-;clear_env = no
-
-; Limits the extensions of the main script FPM will allow to parse. This can
-; prevent configuration mistakes on the web server side. You should only limit
-; FPM to .php extensions to prevent malicious users to use other extensions to
-; execute php code.
-; Note: set an empty value to allow all extensions.
-; Default Value: .php
-;security.limit_extensions = .php .php3 .php4 .php5 .php7
-
-; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from
-; the current environment.
-; Default Value: clean env
-;env[HOSTNAME] = $HOSTNAME
-;env[PATH] = /usr/local/bin:/usr/bin:/bin
-;env[TMP] = /tmp
-;env[TMPDIR] = /tmp
-;env[TEMP] = /tmp
-
-; Additional php.ini defines, specific to this pool of workers. These settings
-; overwrite the values previously defined in the php.ini. The directives are the
-; same as the PHP SAPI:
-; php_value/php_flag - you can set classic ini defines which can
-; be overwritten from PHP call 'ini_set'.
-; php_admin_value/php_admin_flag - these directives won't be overwritten by
-; PHP call 'ini_set'
-; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.
-
-; Defining 'extension' will load the corresponding shared extension from
-; extension_dir. Defining 'disable_functions' or 'disable_classes' will not
-; overwrite previously defined php.ini values, but will append the new value
-; instead.
-
-; Note: path INI options can be relative and will be expanded with the prefix
-; (pool, global or /usr)
-
-; Default Value: nothing is defined by default except the values in php.ini and
-; specified at startup with the -d argument
-;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
-;php_flag[display_errors] = off
-;php_admin_value[error_log] = /var/log/fpm-php.www.log
-;php_admin_flag[log_errors] = on
-;php_admin_value[memory_limit] = 32M
diff --git a/provision/provision.sh b/provision/provision.sh
deleted file mode 100644
index d6380645..00000000
--- a/provision/provision.sh
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/bin/bash
-
-echo Provisioning...
-sudo apt-get update
-sudo apt-get -y autoremove
-
-# Make sure these tools installed
-sudo DEBIAN_FRONTEND=noninteractive apt-get install -y git htop curl tshark pkgconf
-# Add PPA with fresh PHP 5:
-sudo add-apt-repository -u -y ppa:ondrej/php
-
-# Install available php from packages
-sudo apt-get install -y php7.0 php7.0-cli php7.0-dev php7.0-fpm
-
-sudo cp ~/php-amqp/provision/php/www.conf /etc/php/7.0/fpm/pool.d/www.conf
-sudo service php7.0-fpm restart
-
-# Install phpbrew to manage php versions
-
-curl -L -O -s https://github.com/phpbrew/phpbrew/raw/master/phpbrew
-chmod +x phpbrew
-sudo mv phpbrew /usr/bin/phpbrew
-phpbrew init
-
-cp ~/php-amqp/provision/.bashrc ~/.bashrc
-
-sudo mkdir -p /var/www/html/
-sudo chown -R vagrant:vagrant /var/www
-
-# Requirements to build php from sources
-sudo apt-get install -y \
- libxml2-dev \
- libcurl4-openssl-dev \
- libjpeg-dev \
- libpng-dev \
- libxpm-dev \
- libmcrypt-dev \
- libmysqlclient-dev \
- libpq-dev \
- libicu-dev \
- libfreetype6-dev \
- libldap2-dev \
- libxslt-dev \
- libbz2-dev \
- libreadline-dev \
- autoconf \
- libtool \
- pkg-config \
- valgrind
-
-# Benchmarking...
-sudo apt-get install -y apache2-utils
-# For Apache-based installation
-sudo apt-get install -y apache2 libapache2-mod-php7.0
-
-# Move Apache to port 8080
-sudo cp ~/php-amqp/provision/apache/000-default.conf /etc/apache2/sites-available/000-default.conf
-sudo cp ~/php-amqp/provision/apache/ports.conf /etc/apache2/ports.conf
-sudo service apache2 restart
-
-sudo cp -f /var/www/html/index.html /var/www/html/index-apache.html
-
-sudo bash -c "echo ' /var/www/html/index.php"
-
-# For Nginx-based installation
-sudo apt-get install -y nginx
-sudo cp ~/php-amqp/provision/nginx/default /etc/nginx/sites-available/default
-sudo service nginx restart
-sudo cp -f /usr/share/nginx/html/index.html /var/www/html/index-nginx.html
-
-# add hosts entry for rabbitmq.example.org
-sudo bash -c 'grep -q rabbitmq.example.org /etc/hosts || echo "127.0.0.1 rabbitmq.example.org rabbitmq" >> /etc/hosts'
-
-# Install and configure RabbitMQ
-wget -qO - https://www.rabbitmq.com/rabbitmq-release-signing-key.asc | sudo apt-key add -
-sudo add-apt-repository 'deb http://www.rabbitmq.com/debian/ testing main'
-sudo apt-get update
-#sudo apt-get install --only-upgrade -y rabbitmq-server
-sudo apt-get install -y rabbitmq-server
-sudo rabbitmq-plugins enable rabbitmq_management
-sudo rabbitmq-plugins enable rabbitmq_auth_mechanism_ssl
-sudo rabbitmqctl add_user "sasl-client.example.org" dummy
-sudo rabbitmqctl set_permissions -p / "sasl-client.example.org" ".*" ".*" ".*"
-sudo rabbitmqctl clear_password "sasl-client.example.org"
-
-sudo cp ~/php-amqp/provision/rabbitmq.config /etc/rabbitmq/
-sudo service rabbitmq-server restart
-
-# Note: it may be good idea to checkout latest stable rabbitmq-c version, but master branch for dev reasons also good
-cd ~
-git clone -q git://github.com/alanxz/rabbitmq-c.git
-cd rabbitmq-c
-sudo apt-get install -y cmake
-mkdir build && cd build
-cmake ..
-sudo cmake --build . --target install
-# or install packaged version:
-#sudo apt-get install -y librabbitmq1 librabbitmq-dev librabbitmq-dbg
-
-# Do it manually when you need it,
-#cd ~/php-amqp
-#phpize --clean && phpize && ./configure && sudo make install
-#sudo cp ~/php-amqp/provision/php/amqp.ini /etc/php/7.0/mods-available/
-#sudo phpenmod amqp
-#sudo service php7.0-fpm restart
-
-# For debugging segfault when amqp fails in php-fpm mode:
-#sudo sh -c "echo '/home/vagrant/php-amqp/coredump-%e.%p' > /proc/sys/kernel/core_pattern"
-
-# To test with typical dev configuration - with xdebug:
-#sudo apt-get install -y php5-xdebug
-
-# Cleanup unused stuff
-sudo apt-get autoremove -y
-
-# At this point it is good idea to do `phpbrew install 5.6` (or other version you want to test extension with)
-# and `phpbrew ext install ~/php-amqp/`
-
-date > /home/vagrant/vagrant_provisioned_at
diff --git a/provision/rabbitmq.config b/provision/rabbitmq.config
deleted file mode 100644
index a3a6ad21..00000000
--- a/provision/rabbitmq.config
+++ /dev/null
@@ -1,601 +0,0 @@
-%% -*- mode: erlang -*-
-%% ----------------------------------------------------------------------------
-%% RabbitMQ Sample Configuration File.
-%%
-%% See http://www.rabbitmq.com/configure.html for details.
-%% ----------------------------------------------------------------------------
-[
- {rabbit,
- [%%
- %% Network Connectivity
- %% ====================
- %%
-
- %% By default, RabbitMQ will listen on all interfaces, using
- %% the standard (reserved) AMQP port.
- %%
- %% {tcp_listeners, [5672]},
-
- %% To listen on a specific interface, provide a tuple of {IpAddress, Port}.
- %% For example, to listen only on localhost for both IPv4 and IPv6:
- %%
- %% {tcp_listeners, [{"127.0.0.1", 5672},
- %% {"::1", 5672}]},
-
- %% SSL listeners are configured in the same fashion as TCP listeners,
- %% including the option to control the choice of interface.
- %%
- %% {ssl_listeners, [5671]},
- {ssl_listeners, [5671]},
- {ssl_options, [{cacertfile,"/home/vagrant/php-amqp/provision/test_certs/testca/cacert.pem"},
- {certfile,"/home/vagrant/php-amqp/provision/test_certs/server/cert.pem"},
- {keyfile,"/home/vagrant/php-amqp/provision/test_certs/server/key.pem"},
- {verify,verify_peer},
- %% {verify,verify_none},
- {fail_if_no_peer_cert,true}
- ]},
-
- %% Maximum time for AMQP 0-8/0-9/0-9-1 handshake (after socket connection
- %% and SSL handshake), in milliseconds.
- %%
- %% {handshake_timeout, 10000},
-
- %% Log levels (currently just used for connection logging).
- %% One of 'debug', 'info', 'warning', 'error' or 'none', in decreasing
- %% order of verbosity. Defaults to 'info'.
- %%
- {log_levels, [{connection, debug}, {channel, debug}]},
-
- %% Set to 'true' to perform reverse DNS lookups when accepting a
- %% connection. Hostnames will then be shown instead of IP addresses
- %% in rabbitmqctl and the management plugin.
- %%
- %% {reverse_dns_lookups, true},
-
- %%
- %% Security / AAA
- %% ==============
- %%
-
- %% The default "guest" user is only permitted to access the server
- %% via a loopback interface (e.g. localhost).
- %% {loopback_users, [<<"guest">>]},
- %%
- %% Uncomment the following line if you want to allow access to the
- %% guest user from anywhere on the network.
- {loopback_users, []},
-
- %% Configuring SSL.
- %% See http://www.rabbitmq.com/ssl.html for full documentation.
- %%
- %% {ssl_options, [{cacertfile, "/path/to/testca/cacert.pem"},
- %% {certfile, "/path/to/server/cert.pem"},
- %% {keyfile, "/path/to/server/key.pem"},
- %% {verify, verify_peer},
- %% {fail_if_no_peer_cert, false}]},
-
- %% Choose the available SASL mechanism(s) to expose.
- %% The two default (built in) mechanisms are 'PLAIN' and
- %% 'AMQPLAIN'. Additional mechanisms can be added via
- %% plugins.
- %%
- %% See http://www.rabbitmq.com/authentication.html for more details.
- %%
- %% {auth_mechanisms, ['PLAIN', 'AMQPLAIN']},
-
- %% Select an authentication database to use. RabbitMQ comes bundled
- %% with a built-in auth-database, based on mnesia.
- %%
- %% {auth_backends, [rabbit_auth_backend_internal]},
-
- %% Configurations supporting the rabbitmq_auth_mechanism_ssl and
- %% rabbitmq_auth_backend_ldap plugins.
- %%
- %% NB: These options require that the relevant plugin is enabled.
- %% See http://www.rabbitmq.com/plugins.html for further details.
-
- %% The RabbitMQ-auth-mechanism-ssl plugin makes it possible to
- %% authenticate a user based on the client's SSL certificate.
- %%
- %% To use auth-mechanism-ssl, add to or replace the auth_mechanisms
- %% list with the entry 'EXTERNAL'.
- %%
- {auth_mechanisms, ['PLAIN', 'EXTERNAL']},
-
- %% The rabbitmq_auth_backend_ldap plugin allows the broker to
- %% perform authentication and authorisation by deferring to an
- %% external LDAP server.
- %%
- %% For more information about configuring the LDAP backend, see
- %% http://www.rabbitmq.com/ldap.html.
- %%
- %% Enable the LDAP auth backend by adding to or replacing the
- %% auth_backends entry:
- %%
- %% {auth_backends, [rabbit_auth_backend_ldap]},
-
- %% This pertains to both the rabbitmq_auth_mechanism_ssl plugin and
- %% STOMP ssl_cert_login configurations. See the rabbitmq_stomp
- %% configuration section later in this file and the README in
- %% https://github.com/rabbitmq/rabbitmq-auth-mechanism-ssl for further
- %% details.
- %%
- %% To use the SSL cert's CN instead of its DN as the username
- %%
- {ssl_cert_login_from, common_name}
-
- %% SSL handshake timeout, in milliseconds.
- %%
- %% {ssl_handshake_timeout, 5000},
-
- %%
- %% Default User / VHost
- %% ====================
- %%
-
- %% On first start RabbitMQ will create a vhost and a user. These
- %% config items control what gets created. See
- %% http://www.rabbitmq.com/access-control.html for further
- %% information about vhosts and access control.
- %%
- %% {default_vhost, <<"/">>},
- %% {default_user, <<"guest">>},
- %% {default_pass, <<"guest">>},
- %% {default_permissions, [<<".*">>, <<".*">>, <<".*">>]},
-
- %% Tags for default user
- %%
- %% For more details about tags, see the documentation for the
- %% Management Plugin at http://www.rabbitmq.com/management.html.
- %%
- %% {default_user_tags, [administrator]},
-
- %%
- %% Additional network and protocol related configuration
- %% =====================================================
- %%
-
- %% Set the default AMQP heartbeat delay (in seconds).
- %%
- %% {heartbeat, 600},
-
- %% Set the max permissible size of an AMQP frame (in bytes).
- %%
- %% {frame_max, 131072},
-
- %% Set the max permissible number of channels per connection.
- %% 0 means "no limit".
- %%
- %% {channel_max, 128},
-
- %% Customising Socket Options.
- %%
- %% See (http://www.erlang.org/doc/man/inet.html#setopts-2) for
- %% further documentation.
- %%
- %% {tcp_listen_options, [binary,
- %% {packet, raw},
- %% {reuseaddr, true},
- %% {backlog, 128},
- %% {nodelay, true},
- %% {exit_on_close, false}]},
-
- %%
- %% Resource Limits & Flow Control
- %% ==============================
- %%
- %% See http://www.rabbitmq.com/memory.html for full details.
-
- %% Memory-based Flow Control threshold.
- %%
- %% {vm_memory_high_watermark, 0.4},
-
- %% Fraction of the high watermark limit at which queues start to
- %% page message out to disc in order to free up memory.
- %%
- %% Values greater than 0.9 can be dangerous and should be used carefully.
- %%
- %% {vm_memory_high_watermark_paging_ratio, 0.5},
-
- %% Set disk free limit (in bytes). Once free disk space reaches this
- %% lower bound, a disk alarm will be set - see the documentation
- %% listed above for more details.
- %%
- %% {disk_free_limit, 50000000},
-
- %% Alternatively, we can set a limit relative to total available RAM.
- %%
- %% Values lower than 1.0 can be dangerous and should be used carefully.
- %% {disk_free_limit, {mem_relative, 2.0}},
-
- %%
- %% Misc/Advanced Options
- %% =====================
- %%
- %% NB: Change these only if you understand what you are doing!
- %%
-
- %% To announce custom properties to clients on connection:
- %%
- %% {server_properties, []},
-
- %% How to respond to cluster partitions.
- %% See http://www.rabbitmq.com/partitions.html for further details.
- %%
- %% {cluster_partition_handling, ignore},
-
- %% Make clustering happen *automatically* at startup - only applied
- %% to nodes that have just been reset or started for the first time.
- %% See http://www.rabbitmq.com/clustering.html#auto-config for
- %% further details.
- %%
- %% {cluster_nodes, {['rabbit@my.host.com'], disc}},
-
- %% Interval (in milliseconds) at which we send keepalive messages
- %% to other cluster members. Note that this is not the same thing
- %% as net_ticktime; missed keepalive messages will not cause nodes
- %% to be considered down.
- %%
- %% {cluster_keepalive_interval, 10000},
-
- %% Set (internal) statistics collection granularity.
- %%
- %% {collect_statistics, none},
-
- %% Statistics collection interval (in milliseconds).
- %%
- %% {collect_statistics_interval, 5000},
-
- %% Explicitly enable/disable hipe compilation.
- %%
- %% {hipe_compile, true},
-
- %% Timeout used when waiting for Mnesia tables in a cluster to
- %% become available.
- %%
- %% {mnesia_table_loading_timeout, 30000},
-
- %% Size in bytes below which to embed messages in the queue index. See
- %% http://www.rabbitmq.com/persistence-conf.html
- %%
- %% {queue_index_embed_msgs_below, 4096}
-
- ]},
-
- %% ----------------------------------------------------------------------------
- %% Advanced Erlang Networking/Clustering Options.
- %%
- %% See http://www.rabbitmq.com/clustering.html for details
- %% ----------------------------------------------------------------------------
- {kernel,
- [%% Sets the net_kernel tick time.
- %% Please see http://erlang.org/doc/man/kernel_app.html and
- %% http://www.rabbitmq.com/nettick.html for further details.
- %%
- %% {net_ticktime, 60}
- ]},
-
- %% ----------------------------------------------------------------------------
- %% RabbitMQ Management Plugin
- %%
- %% See http://www.rabbitmq.com/management.html for details
- %% ----------------------------------------------------------------------------
-
- {rabbitmq_management,
- [%% Pre-Load schema definitions from the following JSON file. See
- %% http://www.rabbitmq.com/management.html#load-definitions
- %%
- %% {load_definitions, "/path/to/schema.json"},
-
- %% Log all requests to the management HTTP API to a file.
- %%
- %% {http_log_dir, "/path/to/access.log"},
-
- %% Change the port on which the HTTP listener listens,
- %% specifying an interface for the web server to bind to.
- %% Also set the listener to use SSL and provide SSL options.
- %%
- %% {listener, [{port, 12345},
- %% {ip, "127.0.0.1"},
- %% {ssl, true},
- %% {ssl_opts, [{cacertfile, "/path/to/cacert.pem"},
- %% {certfile, "/path/to/cert.pem"},
- %% {keyfile, "/path/to/key.pem"}]}]},
-
- %% One of 'basic', 'detailed' or 'none'. See
- %% http://www.rabbitmq.com/management.html#fine-stats for more details.
- %% {rates_mode, basic},
-
- %% Configure how long aggregated data (such as message rates and queue
- %% lengths) is retained. Please read the plugin's documentation in
- %% http://www.rabbitmq.com/management.html#configuration for more
- %% details.
- %%
- %% {sample_retention_policies,
- %% [{global, [{60, 5}, {3600, 60}, {86400, 1200}]},
- %% {basic, [{60, 5}, {3600, 60}]},
- %% {detailed, [{10, 5}]}]}
- ]},
-
- %% ----------------------------------------------------------------------------
- %% RabbitMQ Shovel Plugin
- %%
- %% See http://www.rabbitmq.com/shovel.html for details
- %% ----------------------------------------------------------------------------
-
- {rabbitmq_shovel,
- [{shovels,
- [%% A named shovel worker.
- %% {my_first_shovel,
- %% [
-
- %% List the source broker(s) from which to consume.
- %%
- %% {sources,
- %% [%% URI(s) and pre-declarations for all source broker(s).
- %% {brokers, ["amqp://user:password@host.domain/my_vhost"]},
- %% {declarations, []}
- %% ]},
-
- %% List the destination broker(s) to publish to.
- %% {destinations,
- %% [%% A singular version of the 'brokers' element.
- %% {broker, "amqp://"},
- %% {declarations, []}
- %% ]},
-
- %% Name of the queue to shovel messages from.
- %%
- %% {queue, <<"your-queue-name-goes-here">>},
-
- %% Optional prefetch count.
- %%
- %% {prefetch_count, 10},
-
- %% when to acknowledge messages:
- %% - no_ack: never (auto)
- %% - on_publish: after each message is republished
- %% - on_confirm: when the destination broker confirms receipt
- %%
- %% {ack_mode, on_confirm},
-
- %% Overwrite fields of the outbound basic.publish.
- %%
- %% {publish_fields, [{exchange, <<"my_exchange">>},
- %% {routing_key, <<"from_shovel">>}]},
-
- %% Static list of basic.properties to set on re-publication.
- %%
- %% {publish_properties, [{delivery_mode, 2}]},
-
- %% The number of seconds to wait before attempting to
- %% reconnect in the event of a connection failure.
- %%
- %% {reconnect_delay, 2.5}
-
- %% ]} %% End of my_first_shovel
- ]}
- %% Rather than specifying some values per-shovel, you can specify
- %% them for all shovels here.
- %%
- %% {defaults, [{prefetch_count, 0},
- %% {ack_mode, on_confirm},
- %% {publish_fields, []},
- %% {publish_properties, [{delivery_mode, 2}]},
- %% {reconnect_delay, 2.5}]}
- ]},
-
- %% ----------------------------------------------------------------------------
- %% RabbitMQ Stomp Adapter
- %%
- %% See http://www.rabbitmq.com/stomp.html for details
- %% ----------------------------------------------------------------------------
-
- {rabbitmq_stomp,
- [%% Network Configuration - the format is generally the same as for the broker
-
- %% Listen only on localhost (ipv4 & ipv6) on a specific port.
- %% {tcp_listeners, [{"127.0.0.1", 61613},
- %% {"::1", 61613}]},
-
- %% Listen for SSL connections on a specific port.
- %% {ssl_listeners, [61614]},
-
- %% Additional SSL options
-
- %% Extract a name from the client's certificate when using SSL.
- %%
- %% {ssl_cert_login, true},
-
- %% Set a default user name and password. This is used as the default login
- %% whenever a CONNECT frame omits the login and passcode headers.
- %%
- %% Please note that setting this will allow clients to connect without
- %% authenticating!
- %%
- %% {default_user, [{login, "guest"},
- %% {passcode, "guest"}]},
-
- %% If a default user is configured, or you have configured use SSL client
- %% certificate based authentication, you can choose to allow clients to
- %% omit the CONNECT frame entirely. If set to true, the client is
- %% automatically connected as the default user or user supplied in the
- %% SSL certificate whenever the first frame sent on a session is not a
- %% CONNECT frame.
- %%
- %% {implicit_connect, true}
- ]},
-
- %% ----------------------------------------------------------------------------
- %% RabbitMQ MQTT Adapter
- %%
- %% See https://github.com/rabbitmq/rabbitmq-mqtt/blob/stable/README.md
- %% for details
- %% ----------------------------------------------------------------------------
-
- {rabbitmq_mqtt,
- [%% Set the default user name and password. Will be used as the default login
- %% if a connecting client provides no other login details.
- %%
- %% Please note that setting this will allow clients to connect without
- %% authenticating!
- %%
- %% {default_user, <<"guest">>},
- %% {default_pass, <<"guest">>},
-
- %% Enable anonymous access. If this is set to false, clients MUST provide
- %% login information in order to connect. See the default_user/default_pass
- %% configuration elements for managing logins without authentication.
- %%
- %% {allow_anonymous, true},
-
- %% If you have multiple chosts, specify the one to which the
- %% adapter connects.
- %%
- %% {vhost, <<"/">>},
-
- %% Specify the exchange to which messages from MQTT clients are published.
- %%
- %% {exchange, <<"amq.topic">>},
-
- %% Specify TTL (time to live) to control the lifetime of non-clean sessions.
- %%
- %% {subscription_ttl, 1800000},
-
- %% Set the prefetch count (governing the maximum number of unacknowledged
- %% messages that will be delivered).
- %%
- %% {prefetch, 10},
-
- %% TCP/SSL Configuration (as per the broker configuration).
- %%
- %% {tcp_listeners, [1883]},
- %% {ssl_listeners, []},
-
- %% TCP/Socket options (as per the broker configuration).
- %%
- %% {tcp_listen_options, [binary,
- %% {packet, raw},
- %% {reuseaddr, true},
- %% {backlog, 128},
- %% {nodelay, true}]}
- ]},
-
- %% ----------------------------------------------------------------------------
- %% RabbitMQ AMQP 1.0 Support
- %%
- %% See https://github.com/rabbitmq/rabbitmq-amqp1.0/blob/stable/README.md
- %% for details
- %% ----------------------------------------------------------------------------
-
- {rabbitmq_amqp1_0,
- [%% Connections that are not authenticated with SASL will connect as this
- %% account. See the README for more information.
- %%
- %% Please note that setting this will allow clients to connect without
- %% authenticating!
- %%
- %% {default_user, "guest"},
-
- %% Enable protocol strict mode. See the README for more information.
- %%
- %% {protocol_strict_mode, false}
- ]},
-
- %% ----------------------------------------------------------------------------
- %% RabbitMQ LDAP Plugin
- %%
- %% See http://www.rabbitmq.com/ldap.html for details.
- %%
- %% ----------------------------------------------------------------------------
-
- {rabbitmq_auth_backend_ldap,
- [%%
- %% Connecting to the LDAP server(s)
- %% ================================
- %%
-
- %% Specify servers to bind to. You *must* set this in order for the plugin
- %% to work properly.
- %%
- %% {servers, ["your-server-name-goes-here"]},
-
- %% Connect to the LDAP server using SSL
- %%
- %% {use_ssl, false},
-
- %% Specify the LDAP port to connect to
- %%
- %% {port, 389},
-
- %% LDAP connection timeout, in milliseconds or 'infinity'
- %%
- %% {timeout, infinity},
-
- %% Enable logging of LDAP queries.
- %% One of
- %% - false (no logging is performed)
- %% - true (verbose logging of the logic used by the plugin)
- %% - network (as true, but additionally logs LDAP network traffic)
- %%
- %% Defaults to false.
- %%
- %% {log, false},
-
- %%
- %% Authentication
- %% ==============
- %%
-
- %% Pattern to convert the username given through AMQP to a DN before
- %% binding
- %%
- %% {user_dn_pattern, "cn=${username},ou=People,dc=example,dc=com"},
-
- %% Alternatively, you can convert a username to a Distinguished
- %% Name via an LDAP lookup after binding. See the documentation for
- %% full details.
-
- %% When converting a username to a dn via a lookup, set these to
- %% the name of the attribute that represents the user name, and the
- %% base DN for the lookup query.
- %%
- %% {dn_lookup_attribute, "userPrincipalName"},
- %% {dn_lookup_base, "DC=gopivotal,DC=com"},
-
- %% Controls how to bind for authorisation queries and also to
- %% retrieve the details of users logging in without presenting a
- %% password (e.g., SASL EXTERNAL).
- %% One of
- %% - as_user (to bind as the authenticated user - requires a password)
- %% - anon (to bind anonymously)
- %% - {UserDN, Password} (to bind with a specified user name and password)
- %%
- %% Defaults to 'as_user'.
- %%
- %% {other_bind, as_user},
-
- %%
- %% Authorisation
- %% =============
- %%
-
- %% The LDAP plugin can perform a variety of queries against your
- %% LDAP server to determine questions of authorisation. See
- %% http://www.rabbitmq.com/ldap.html#authorisation for more
- %% information.
-
- %% Set the query to use when determining vhost access
- %%
- %% {vhost_access_query, {in_group,
- %% "ou=${vhost}-users,ou=vhosts,dc=example,dc=com"}},
-
- %% Set the query to use when determining resource (e.g., queue) access
- %%
- %% {resource_access_query, {constant, true}},
-
- %% Set queries to determine which tags a user has
- %%
- %% {tag_queries, []}
- ]}
-].
diff --git a/provision/test_certs/certgen.sh b/provision/test_certs/certgen.sh
deleted file mode 100644
index 2f03a0e7..00000000
--- a/provision/test_certs/certgen.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-mkdir testca; cd testca; mkdir private
-openssl req -new -x509 -keyout private/cakey.pem -out cacert.pem -days 365 -nodes -subj "/C=PT/ST=Lisboa/L=Lisboa/O=Example Org"
-
-cd ..
-mkdir server;cd server
-openssl genrsa -out key.pem 2048
-openssl req -new -key key.pem -out req.pem -subj "/C=PT/ST=Lisboa/L=Lisboa/O=Example Org/CN=*.example.org"
-openssl x509 -req -in req.pem -CA ../testca/cacert.pem -CAkey ../testca/private/cakey.pem -CAcreateserial -out cert.pem -days 365
-
-cd ..
-mkdir sasl-client; cd sasl-client
-openssl genrsa -out key.pem 2048
-openssl req -new -key key.pem -out req.pem -subj "/C=PT/ST=Lisboa/L=Lisboa/O=Example Org/CN=sasl-client.example.org"
-openssl x509 -req -in req.pem -CA ../testca/cacert.pem -CAkey ../testca/private/cakey.pem -CAcreateserial -out cert.pem -days 365
-
-cd ..
-mkdir client; cd client
-openssl genrsa -out key.pem 2048
-openssl req -new -key key.pem -out req.pem -subj "/C=PT/ST=Lisboa/L=Lisboa/O=Example Org/CN=client.example.org"
-openssl x509 -req -in req.pem -CA ../testca/cacert.pem -CAkey ../testca/private/cakey.pem -CAcreateserial -out cert.pem -days 365
\ No newline at end of file
diff --git a/provision/test_certs/client/cert.pem b/provision/test_certs/client/cert.pem
deleted file mode 100644
index d81cf23e..00000000
--- a/provision/test_certs/client/cert.pem
+++ /dev/null
@@ -1,19 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDIzCCAgsCCQD/3A+eiHuqpzANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJQ
-VDEPMA0GA1UECAwGTGlzYm9hMQ8wDQYDVQQHDAZMaXNib2ExFDASBgNVBAoMC0V4
-YW1wbGUgT3JnMB4XDTE4MDYxMDEwMzA0MFoXDTE5MDYxMDEwMzA0MFowYjELMAkG
-A1UEBhMCUFQxDzANBgNVBAgMBkxpc2JvYTEPMA0GA1UEBwwGTGlzYm9hMRQwEgYD
-VQQKDAtFeGFtcGxlIE9yZzEbMBkGA1UEAwwSY2xpZW50LmV4YW1wbGUub3JnMIIB
-IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzmgZMCuXgmc4moKvweny7mXT
-gKL8GNpB9uLwpmr0np4veWZh2b5WFFy6oma/4hS072PRXR1+miaEZHvlCgRopKp7
-Lm4CF45E8YamG0MjfTxWtTf+JAXjYibijl94GQLkXmMM9OBY080r01szP2RXxkfU
-3UMf0HjiDcj5YyJn2LVwkgqRx6JYcTNm/wRhk82vw6nclB6jeZ0OcJK/4lrNCaX/
-VfPTnyZoCXRteFGBiCWmf/Y2uvtjUqpwSAIDvNQaV6WrcmdTBt8szbigc1wR2WyX
-NR3WKy2aCPOPbbsCLDA/bilFnKUN0Ho53g3e8J0VUZv4G9WZKf2GrhHWax3lAQID
-AQABMA0GCSqGSIb3DQEBCwUAA4IBAQBY/0zo+2kz2ws1X0nRfz1J0cPvamlQj/jI
-C1G6h964nDjmcljmvybWlX/TCWDjtTS/bkEjUSZhAAqfF5Zt44g1WkwE03vzdPgF
-hN06NNbc5dQMYFa5cUnHbE3gkbN31qCf8T/IjzOBaqxDspwZyzvAXQwKFPke6TuA
-XjYinMlEVNL3TytEf5PhdDjvssrRRR/lKHdFF9ABTN8w/UWyMKrawuYrWynk/IdH
-F0i9GAPvULeZKHpYytwtwwitnucxsVJkkz0JVJcsrGRgwiy4zmIjSjATVD4kB+Dy
-MAcQTltJIAu/PSPFWvVAA73Wh87FdqGb2rWBKfer9MdzX4h7HnQO
------END CERTIFICATE-----
diff --git a/provision/test_certs/client/key.pem b/provision/test_certs/client/key.pem
deleted file mode 100644
index 2f52b074..00000000
--- a/provision/test_certs/client/key.pem
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEpAIBAAKCAQEAzmgZMCuXgmc4moKvweny7mXTgKL8GNpB9uLwpmr0np4veWZh
-2b5WFFy6oma/4hS072PRXR1+miaEZHvlCgRopKp7Lm4CF45E8YamG0MjfTxWtTf+
-JAXjYibijl94GQLkXmMM9OBY080r01szP2RXxkfU3UMf0HjiDcj5YyJn2LVwkgqR
-x6JYcTNm/wRhk82vw6nclB6jeZ0OcJK/4lrNCaX/VfPTnyZoCXRteFGBiCWmf/Y2
-uvtjUqpwSAIDvNQaV6WrcmdTBt8szbigc1wR2WyXNR3WKy2aCPOPbbsCLDA/bilF
-nKUN0Ho53g3e8J0VUZv4G9WZKf2GrhHWax3lAQIDAQABAoIBAFeW/1Fcvk+9Q9z1
-pmYQxGF8XpORFo/pVuLRDTRh4OrKz/ShiNahGeBMNXsjRTxIczu/TSJJmOcLf1Uw
-6lIk6s8t9VYPot2iJwmjjSu2gwHrMBR47WUWBpcpTy0BwHJEsuqG+AGWjrtarsVj
-R00YZNMkumUmzgJmue8FoSb7e7wPB8IPmlxAj0DheqnOVwfBCMJTCNCbmA2fLJen
-avLFzoURjlT6SlcQEv8cmz7jMskbwCTSlgCw5VtdYAQQLN4UnSfbMmInVNY2sSlM
-uVlKdU8UxhA1QoW9EUju9q0zI7wD0W8k6+jaRxLe8LBkwI0jh/nAcZtaKs5cQdxp
-/dDb8U0CgYEA7X8Uj2bjHaq7BNZY60BdDDMVwxxfSJhl99nhaACRNFk5JSSoZDCH
-GIB+DN+SiNH/Voh65Grnotf/i+bvG0TbjAVOrK35T7F2dvHZ8OeyR1EAl9EgW3z7
-c5Wjj+XwqhJL2fW01xcxOoR/Qs6Y7WsFaWM9PI+OqV16pVyR26eZ6ScCgYEA3nzs
-7eXs79oPmRd011+P9843j3hHETqHdH2GtZ1ZwycmhcJsjUo0G9tCOSFcxDjKiUpG
-Hkic4yueF/p0cd6ClSW9B8Hh8NX2B/oGxtWERB3dN7mtKwxPvniJ5FZe2U9np8ib
-zQynU/Z5nIRbK4Oone/bfmatQggKEmJM5iClCZcCgYEAhHSWu+/PBTG+QlFloDby
-biZjocDGJ4/Pdu8OdtmyIjcM1vld7RrfjbvEEVvzttkgBlvx5kj1TW4YOSef/V5m
-7+3Z1hblcBvyjR4PxfsDBCFaKlHZMQ1AlFNFuLCui7vOkA4oQLnPm+pfq5vb0LYa
-e498jLUoBK99ApLhSldsUIsCgYAFcgFKgUofRLMFCDHv44LeicmKVWNH5KrUCw50
-+3jq8dZbh7qoapyD4gXo6AwhMVKjsZGtxBEy7ipcY+DduJhxlg7eVbx17IatA02P
-KEKoeCKl7oFygEajXsfhMsv3fZ4H2T0W86xUvb+UORkSI5LI6snwegrbht7YPFet
-ejcP2QKBgQCv+TNpIFFMlhWwCbzp/I1sKM1QrQWI+Io+djxlyzxU4lFX2VX2xM9s
-k6maQT5VA7PHvQ+/aMTusVHVC6Rw2/b6rjej4zs0Z+pFXXR8Z2IJGBPMUZC9SKgi
-pUZjKSy0fXI2aR4QaNuZeYOYz6IR5TAhnCku8U+BAqaQ/uTtxj3J5w==
------END RSA PRIVATE KEY-----
diff --git a/provision/test_certs/client/req.pem b/provision/test_certs/client/req.pem
deleted file mode 100644
index 8cbba5ed..00000000
--- a/provision/test_certs/client/req.pem
+++ /dev/null
@@ -1,17 +0,0 @@
------BEGIN CERTIFICATE REQUEST-----
-MIICpzCCAY8CAQAwYjELMAkGA1UEBhMCUFQxDzANBgNVBAgMBkxpc2JvYTEPMA0G
-A1UEBwwGTGlzYm9hMRQwEgYDVQQKDAtFeGFtcGxlIE9yZzEbMBkGA1UEAwwSY2xp
-ZW50LmV4YW1wbGUub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
-zmgZMCuXgmc4moKvweny7mXTgKL8GNpB9uLwpmr0np4veWZh2b5WFFy6oma/4hS0
-72PRXR1+miaEZHvlCgRopKp7Lm4CF45E8YamG0MjfTxWtTf+JAXjYibijl94GQLk
-XmMM9OBY080r01szP2RXxkfU3UMf0HjiDcj5YyJn2LVwkgqRx6JYcTNm/wRhk82v
-w6nclB6jeZ0OcJK/4lrNCaX/VfPTnyZoCXRteFGBiCWmf/Y2uvtjUqpwSAIDvNQa
-V6WrcmdTBt8szbigc1wR2WyXNR3WKy2aCPOPbbsCLDA/bilFnKUN0Ho53g3e8J0V
-UZv4G9WZKf2GrhHWax3lAQIDAQABoAAwDQYJKoZIhvcNAQELBQADggEBAEgsC/yd
-GAoFCtNvwLsdbZBSWiFroImdD0lU01sY7UtXzEdosjYESZkXVz2b1sh2TRKleCq6
-Go99vW/AYqu2ietx6Np2bO7uNS0VwjWDaqCZbpw/fTPXPORF6sirqmoq03g15EGf
-1xM90dD1/EMuAiszTnhtprmr7j3fFIqN1x/9wHYVNEgUaNxCeevbX9LzHYzajzvu
-hkzT8YRxASSUex/1FfJOY+UYYwf46bKlB0tlmDuLXWKSrnBDJUTKwundLerdj/y5
-gZ6evfkxwvZOvr4JTYPcq2NwbhMzTkSnHOSK2AhzLsFVSA6CWTBTFHwQNDSblQdq
-FMjb5jvuyG83DTA=
------END CERTIFICATE REQUEST-----
diff --git a/provision/test_certs/sasl-client/cert.pem b/provision/test_certs/sasl-client/cert.pem
deleted file mode 100644
index 7c4faa69..00000000
--- a/provision/test_certs/sasl-client/cert.pem
+++ /dev/null
@@ -1,19 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDKDCCAhACCQDa/hd6atDdTzANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJQ
-VDEPMA0GA1UECAwGTGlzYm9hMQ8wDQYDVQQHDAZMaXNib2ExFDASBgNVBAoMC0V4
-YW1wbGUgT3JnMB4XDTE4MDYxMDEwMzAzOVoXDTE5MDYxMDEwMzAzOVowZzELMAkG
-A1UEBhMCUFQxDzANBgNVBAgMBkxpc2JvYTEPMA0GA1UEBwwGTGlzYm9hMRQwEgYD
-VQQKDAtFeGFtcGxlIE9yZzEgMB4GA1UEAwwXc2FzbC1jbGllbnQuZXhhbXBsZS5v
-cmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDD+p1IkyU1/E+A2B7T
-YIQV5+F/S4MTBI5VYx7WKzH6PgeUxNTBTyTPC6KzYtfTg+Yo6NRQ9QwwO1oSB+1e
-2HBi1avvUGHeV+6Gbou0odoTlu/MbBFNnqfsLzvtm9vzgh3kBgdeaNuD/EDKa9yU
-/MKCKoOK0fXsZzbMWxdWTHe5UYrhQFaX8QaM0+rH/payIGWEtdmA6L3oCPqRAKws
-svMADZT01duuS0/igVY7ZsbqMxFWwg9fstahY00mRZgbeAtcQEdHP/NIzEMH9/U3
-RRK3g2QmQX9EWPb8YLEro/prrHukL7XjyRhMMjtJf9h7beT/u9Vik2N0/KY1m9vA
-V293AgMBAAEwDQYJKoZIhvcNAQELBQADggEBAB2/5h/xW5CoE0/TU3sR64Vyp1yf
-og4jSnLISX3PFZU6I5U9m4JuH79tOItWyJmwgFLtk+sBThbh6qHNO6wvFlu0BMlW
-RuAAmvk2wohNNcbCQRYp4fSKYoWd/1swK72KBAXW4rqXR7mofA6uybtPMDvKH6UC
-XqPV532EcovNbncWFGCl32ryIeGUvEtQh43I+ds2G2YYslSqs/0B4ZZ5YHudG6PY
-075cez6N/4tTS0gi5RnbsaFvfoXuQ7nfIpXIcYPmSvKA0du1/qCMHZ4u2suHsrrl
-s5PZnDqiP7+UvCPWMUh9DvA2n2sjucPWtNW73zstmIAeBbp2+HW/oHCHwfg=
------END CERTIFICATE-----
diff --git a/provision/test_certs/sasl-client/key.pem b/provision/test_certs/sasl-client/key.pem
deleted file mode 100644
index e01aa555..00000000
--- a/provision/test_certs/sasl-client/key.pem
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEowIBAAKCAQEAw/qdSJMlNfxPgNge02CEFefhf0uDEwSOVWMe1isx+j4HlMTU
-wU8kzwuis2LX04PmKOjUUPUMMDtaEgftXthwYtWr71Bh3lfuhm6LtKHaE5bvzGwR
-TZ6n7C877Zvb84Id5AYHXmjbg/xAymvclPzCgiqDitH17Gc2zFsXVkx3uVGK4UBW
-l/EGjNPqx/6WsiBlhLXZgOi96Aj6kQCsLLLzAA2U9NXbrktP4oFWO2bG6jMRVsIP
-X7LWoWNNJkWYG3gLXEBHRz/zSMxDB/f1N0USt4NkJkF/RFj2/GCxK6P6a6x7pC+1
-48kYTDI7SX/Ye23k/7vVYpNjdPymNZvbwFdvdwIDAQABAoIBAAZ32AcULC8685jK
-CUJqthFPBOdBo8LV7Kiuy86/wDeFIpTrZiY3KXzX4nfPNFZbzRXekVtWqx9QZimg
-L1ppBFSOvsz4NzKybkHrlhrRGLR6z9FMY8nPCbXG3VB7S2gfDEOBW27nQQ97HNxR
-cQdNzFGle4/yXA6AXZOjEgMcJPttwb7yJ/kOGCWN/yFtmt8TORIjnY25WZWCkdIz
-REVkfSBGlN5TISoX49UAnAxAxVLMlyw+6m2JHYuk7smrfhxcgrWNGm+UL5zCcK3M
-ruDXDxo6JXcJ/8Tj9TnsJ0Tj5HYzZiLTbwGttsrZaTqLH8TbWre7EvJOEN4k4vgX
-82I8VPECgYEA6JJvYnPvaaniT4r8gFgH746pjxndBt6t7gRMpQ8iE67+RidqAeNt
-4iXAd0XlELWCFS5Mb4zzgF8W9qdnhWPhCYA12Nz0wz26ivzRv02IVoVBcMefU7ka
-kuccfiDSfnJgxq1rTXnLFC4703GDwgi9MD8QhP/H2sxa3LVdCdZj1Q8CgYEA17iE
-n/dCrwlGB7gCaCwpuSS3d5LZJCz2SluTbLQkCyKzF8dirfmbwD4uOWXYokE/P/6N
-NyUOvjPNaT4YNgEDpeQcbDRAKHmbE4DAG+56lPy7ax9CU3E89PZzC4G+vh9sGJds
-ui73c2vvDvcR8jvgsJmjEUIgunYBZ2NCE9CoTxkCgYEAnZHo6TlHMb2p2N5/qKz7
-43AyrQOG3oqsKKC9FO+l1NQw7nLxvYnK/vc46RZv1dxD3/nYS5Ohvo2uTzqoRpWe
-+ALneKBrLIR8CIK10PjEsGnkJnb5GY5F1NXEVigCtSzlKHaCRqGH14pjeiRkcmfd
-VfzEQnfRfgoKXZJ7EJkyVj0CgYA38Z5TbehZRGpo7guRwIJBhYge9nJhs1dcCUu+
-USlXyfPwIsEwpR8DSBzsvcDks08X5Yfx2SZtpTmMJZJZzwGHMBU+6n4JASB6elVX
-6QzZPoHMUhr9UMyiKpfDUC6LV9LMvdhwoGWEBWXF18VLsMOgiPeFLkUWlivfCBrG
-0MIVYQKBgEnK29Wm6ukYxLV9j1RufN4ivTSny5cViyfWPB7GN9rWAeyFn9pkL6+q
-O0O08dPRJTAi9/7fQmJNi/+w0Ui3ty6dEPTVWBkxqd3LfRYRo+wOt+9tE4CI4PkC
-d63+MvyalKXyUY8at2+oWJ8lOJ6QyBtHsYQoNfzHUlR0JyS0AHln
------END RSA PRIVATE KEY-----
diff --git a/provision/test_certs/sasl-client/req.pem b/provision/test_certs/sasl-client/req.pem
deleted file mode 100644
index ea0fcdb5..00000000
--- a/provision/test_certs/sasl-client/req.pem
+++ /dev/null
@@ -1,17 +0,0 @@
------BEGIN CERTIFICATE REQUEST-----
-MIICrDCCAZQCAQAwZzELMAkGA1UEBhMCUFQxDzANBgNVBAgMBkxpc2JvYTEPMA0G
-A1UEBwwGTGlzYm9hMRQwEgYDVQQKDAtFeGFtcGxlIE9yZzEgMB4GA1UEAwwXc2Fz
-bC1jbGllbnQuZXhhbXBsZS5vcmcwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
-AoIBAQDD+p1IkyU1/E+A2B7TYIQV5+F/S4MTBI5VYx7WKzH6PgeUxNTBTyTPC6Kz
-YtfTg+Yo6NRQ9QwwO1oSB+1e2HBi1avvUGHeV+6Gbou0odoTlu/MbBFNnqfsLzvt
-m9vzgh3kBgdeaNuD/EDKa9yU/MKCKoOK0fXsZzbMWxdWTHe5UYrhQFaX8QaM0+rH
-/payIGWEtdmA6L3oCPqRAKwssvMADZT01duuS0/igVY7ZsbqMxFWwg9fstahY00m
-RZgbeAtcQEdHP/NIzEMH9/U3RRK3g2QmQX9EWPb8YLEro/prrHukL7XjyRhMMjtJ
-f9h7beT/u9Vik2N0/KY1m9vAV293AgMBAAGgADANBgkqhkiG9w0BAQsFAAOCAQEA
-YToEWLnXTEHvvHFtnypKJUmKuM4iVCYZ91BnATI302PQNObg/DpNxslsaOMQ/AD8
-sHHr2DCnKZvofzCwSkSleMqsUn8Z6WGkI5jrW/umDXlfdgwWD4NqmiwYB5uebVYU
-cQje2nJJX7ERxnqSVMz1JjQLIbIe/eq8PJ8tdkLy2lzc6p3HrvNphnyb/hidRt5y
-ydeOjQx71/eur3EVKigXcMdoLI9P/Ilo7ju9H4FjGsW1eRDn9LY/YvaJfze/yMNz
-tGgwcZZHKdjTyg/WZeVgdYQJInR81FLD82AgNr3fsKB2QMNtT7mwB5bAx6zKCBhP
-VVXvUmqBv2i5lEVOn1l1gA==
------END CERTIFICATE REQUEST-----
diff --git a/provision/test_certs/server/cert.pem b/provision/test_certs/server/cert.pem
deleted file mode 100644
index 7831b2b7..00000000
--- a/provision/test_certs/server/cert.pem
+++ /dev/null
@@ -1,19 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDHjCCAgYCCQCvidFhSQh+AzANBgkqhkiG9w0BAQsFADBFMQswCQYDVQQGEwJQ
-VDEPMA0GA1UECAwGTGlzYm9hMQ8wDQYDVQQHDAZMaXNib2ExFDASBgNVBAoMC0V4
-YW1wbGUgT3JnMB4XDTE4MDYxMDEwMzAzOVoXDTE5MDYxMDEwMzAzOVowXTELMAkG
-A1UEBhMCUFQxDzANBgNVBAgMBkxpc2JvYTEPMA0GA1UEBwwGTGlzYm9hMRQwEgYD
-VQQKDAtFeGFtcGxlIE9yZzEWMBQGA1UEAwwNKi5leGFtcGxlLm9yZzCCASIwDQYJ
-KoZIhvcNAQEBBQADggEPADCCAQoCggEBALYkPyHJFpch8hZ8H3qlKjay737i4ic+
-g6V9urG1p+jmo1QnKzVV++4Pl26owPoe+T50SKLhhTFHJMEWeFB56Z9i58bhTalF
-vv6XF6W0rx62Dqd9joBn5ij/90EjCOKXhDV/ec9s4l3mjXV9EHa8H89q5lxW5RcZ
-KIcXJQgvWVkPAOCvGg9DnYnQLZhvKSwU3rfrdvkTVyoGiNjemQh42ca5JSF0Oi8B
-4siqdAgsa7uYsS2DzBTsHCDucDkSYSrWe+oS/vDRC86A2eZk4abVIcBlHOlxcwMT
-OKQ3oH3czOr3Ly8a8tTien3+5AfwZPjHxRDHeEU2Edyx9TnhO9wrdq8CAwEAATAN
-BgkqhkiG9w0BAQsFAAOCAQEAI1cqejtWM50BEUAzRXKPhrQFYqbStoOPMIFOQe41
-ytb7dSSh0qNhESoUSsCqNEGknMWdj8G7H0CxM+ti5TRVoKXjzrV+Ga6kyH6Mn9wL
-hrf84jl6EJFIlJkyz6/khLDH5HsCk0AAkxb9pr7HEjqWO3MrE9cdoHxOunb/qqme
-KIKtNNEE9HPuzfQHTQBKTi2QmcUj2AZn9kW1BbR3dye9mkGv19L3E3eWmzcYedN4
-OCxmAj01j8WN2cQ/fD3mNJUtr7eoN6hx51Z9s5+LQtULpKRDwbygxNXwEeVsqy17
-e6BUVOoUk+b1tTbUqtL/jM3XerGaHNdJzVZKO/K0Ywapzw==
------END CERTIFICATE-----
diff --git a/provision/test_certs/server/key.pem b/provision/test_certs/server/key.pem
deleted file mode 100644
index a5e9815a..00000000
--- a/provision/test_certs/server/key.pem
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEpQIBAAKCAQEAtiQ/IckWlyHyFnwfeqUqNrLvfuLiJz6DpX26sbWn6OajVCcr
-NVX77g+XbqjA+h75PnRIouGFMUckwRZ4UHnpn2LnxuFNqUW+/pcXpbSvHrYOp32O
-gGfmKP/3QSMI4peENX95z2ziXeaNdX0Qdrwfz2rmXFblFxkohxclCC9ZWQ8A4K8a
-D0OdidAtmG8pLBTet+t2+RNXKgaI2N6ZCHjZxrklIXQ6LwHiyKp0CCxru5ixLYPM
-FOwcIO5wORJhKtZ76hL+8NELzoDZ5mThptUhwGUc6XFzAxM4pDegfdzM6vcvLxry
-1OJ6ff7kB/Bk+MfFEMd4RTYR3LH1OeE73Ct2rwIDAQABAoIBAQCYs4q6KHxn+G2d
-rDI4AICDm0BugIhZnm+ALwh2NHWxLKuBwdTXwl6UFz495/zhtVYApjy/UZL43UxT
-FSOJVKwolCL8+abCY1bc2o9YvUKT3M4sXXc67+BmPzJryZOJZL3SnCzjWcXuM3wl
-I9TJtq50lorKn48w7kar+xtw4UFnB2KXRnM7TZiS7kGmRNKZx+VvH3praiBLcwke
-ZgBmfdZUIHDbvRHahqQ9TeXp02J83zY32yBlTnOlV6jkfpSh41fYCvOihKzkwv2v
-78FBI+y6f9Sn2sXC5bqyV1W1t9Y6eDFIUNn+Cg36yl2gNH6u5eG4Rw7zDJj0PIOj
-3n+hktoBAoGBAOKUEsorPvzzbdzHfh05oXOWxPqehJY5sjm9Td2Yx0nyQjkf33PT
-bXX+3MzJ1LaLER0EnBmJ7VPyjaguMf1NxaWrfykzRILtVbynn5Plk8IfDcvl+jFW
-oJdcg19L7Ey53VVdeCtTCqBmYrsUZF+s4/C6CpFZpj5F96KCOFVhYnWZAoGBAM3L
-AMEySk/sYZ+XzqNvt9uXNmULN3oqiUqz30/hBAcGKCzhnARr3clb+7WYbbd/12fr
-ZWwqwiHYcgKn11PCRAGnOxFRCr+N5ev0dSiNDBTKbvPKvKwj0jZqD8NL0bsmJlH9
-KY1wYUN7Ph1r7uCaSzm7yPH7FrQgGHD7fTLRLOuHAoGBAMAN4Utqks6YjJQqqPSe
-yAKRVtBUk3A+4ZpdouXlvW8poQaIxMCKA2uUJ5aSsfI1OMFPCf3/0qJoo7hdx9O9
-G36NOpEyuqz7/cOWlgYoADH4XpppisRNeHw0V8rsMRTsKvdT7itTDVvezWtkIpyS
-kPeYyqJfyjFY30npdVSx4mJpAoGASO3NCapBzYsOmZkZwK+hr28p9qr/8QpL9y5B
-UDSE0dxrtmQJf0OeqHIxhIxNLX9fndM88RVCEO58kNZcJ7Grmg5ij2Nx9Kpbtb+/
-GSzLAD8xDLJnJHXZVDFH/sTKwZDmeZ3G8PnHbjupqpGKaQwk5oPW1XJO/Gx3XOqy
-1qRsT9cCgYEAilHVQmFJWhWzFqvFV2wmt8KtxvyfDGU7HAP3417AQhQUv0ZvSZ1U
-snH5kFc+OlZs1+86QyvIgiRl2nInVyEzGHZqE0/pp77nsZQcNX0xQGBa9x+3bM1f
-6DB4+W9pC3oiU16mXytqDdmAQ93Vkb+WCxqDk/JgTl24ByxVsOgllY0=
------END RSA PRIVATE KEY-----
diff --git a/provision/test_certs/server/req.pem b/provision/test_certs/server/req.pem
deleted file mode 100644
index 911fe6a3..00000000
--- a/provision/test_certs/server/req.pem
+++ /dev/null
@@ -1,17 +0,0 @@
------BEGIN CERTIFICATE REQUEST-----
-MIICojCCAYoCAQAwXTELMAkGA1UEBhMCUFQxDzANBgNVBAgMBkxpc2JvYTEPMA0G
-A1UEBwwGTGlzYm9hMRQwEgYDVQQKDAtFeGFtcGxlIE9yZzEWMBQGA1UEAwwNKi5l
-eGFtcGxlLm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALYkPyHJ
-Fpch8hZ8H3qlKjay737i4ic+g6V9urG1p+jmo1QnKzVV++4Pl26owPoe+T50SKLh
-hTFHJMEWeFB56Z9i58bhTalFvv6XF6W0rx62Dqd9joBn5ij/90EjCOKXhDV/ec9s
-4l3mjXV9EHa8H89q5lxW5RcZKIcXJQgvWVkPAOCvGg9DnYnQLZhvKSwU3rfrdvkT
-VyoGiNjemQh42ca5JSF0Oi8B4siqdAgsa7uYsS2DzBTsHCDucDkSYSrWe+oS/vDR
-C86A2eZk4abVIcBlHOlxcwMTOKQ3oH3czOr3Ly8a8tTien3+5AfwZPjHxRDHeEU2
-Edyx9TnhO9wrdq8CAwEAAaAAMA0GCSqGSIb3DQEBCwUAA4IBAQCwq50gKVOAiT9U
-QFHC6pC8l4fexD7/pATf28XNa8ILwsETmNNAIbU+ESulWm921Nrxv1TjK+6qdvs6
-gZrnt6fyJ8mHt5fHqQoLUyLjWnlSoAAF5EFdCNtASlhOXVlhy5N2h+D5wsKMV6a6
-jNGQzAgyQNf6AAEEM2J47JfrYOgiEY/WBYK6O39VNhxyPIFbnkJIZIEI4lbHZCub
-xRWMNyDV4ngZGZmu9r6SzVjG1XDPc65Z3qg2LvzDZad7/fEpkLbxfZI9JcCXvMm4
-u6f6LUYgXDe2BXuXeF1Mo4Y8x7A6Wt5RuZibNq+Ls00D7P+ilvQjBy2F9laI2Sqw
-wHp0RISb
------END CERTIFICATE REQUEST-----
diff --git a/provision/test_certs/testca/cacert.pem b/provision/test_certs/testca/cacert.pem
deleted file mode 100644
index 49deb2ca..00000000
--- a/provision/test_certs/testca/cacert.pem
+++ /dev/null
@@ -1,21 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIDXTCCAkWgAwIBAgIJALr5iv/qdSQuMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
-BAYTAlBUMQ8wDQYDVQQIDAZMaXNib2ExDzANBgNVBAcMBkxpc2JvYTEUMBIGA1UE
-CgwLRXhhbXBsZSBPcmcwHhcNMTgwNjEwMTAzMDM5WhcNMTkwNjEwMTAzMDM5WjBF
-MQswCQYDVQQGEwJQVDEPMA0GA1UECAwGTGlzYm9hMQ8wDQYDVQQHDAZMaXNib2Ex
-FDASBgNVBAoMC0V4YW1wbGUgT3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
-CgKCAQEAsSAEBvCMGgZUqA+gIpviF3TigeVdMi3wu+9QmIviUcoIAXHr9zMxUyAP
-dxzEzJwhKkLXpLSt5uSUb07UUg32cLQdMmPbecuug41vdCsTz/6RaZlB9UKddYIO
-M4FQ31GElOfM3PsDIHjENQsarVTyt+lhIOXQdVCCkP0ebBa53pJwp0NOSl+ay+eq
-W7MQn56pFaD+AWd7SEAd2c/YV/aWU/sKHDIz/Ud/5ayFS4hZ6HU8lTqyeROzXYBL
-z85wcp+xTwUbvCJXTVZ3C6N+88bpi+9/1ORtSSOj7chIQ8ZdX+c58dCo1nJxw6fY
-HAwYSRsllSOIVVmtlL/oBLrYCM3+wwIDAQABo1AwTjAdBgNVHQ4EFgQUxBYlRH1g
-hokMTkwNbZaB4PRG7+swHwYDVR0jBBgwFoAUxBYlRH1ghokMTkwNbZaB4PRG7+sw
-DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAEn3kN7VPWnFu1sIveQII
-Sh2zQQYdgMS1zCnTVsZykhCliNBKwlUm6k/GEucibiggL56PESH1sUNwDK7bCR9k
-ngLAeA5YcNPyGLw0x0wcz0JH9rPqF+z5tHI1IeIEzilkWUim0MGf30B/jfn6+d3v
-gCk9OM7+bbTvZAvLhslHGKpgNwMEEAWzj3O4rvxp7M50VQ5XT3lvRXgeSUTeoepT
-Jq7WQOKVNPrWxGOHDqhnQz33yd7m1M0hge/W0IrlkwXY0/SDtuETv+xqAiUHYlNl
-s3INAWNFIMX/d7vBA4hsTujJMA9VzE+5jYQC+juXWsse61jW1eA+Fiu6m6lkXQE3
-Aw==
------END CERTIFICATE-----
diff --git a/provision/test_certs/testca/private/cakey.pem b/provision/test_certs/testca/private/cakey.pem
deleted file mode 100644
index 22214fb4..00000000
--- a/provision/test_certs/testca/private/cakey.pem
+++ /dev/null
@@ -1,28 +0,0 @@
------BEGIN PRIVATE KEY-----
-MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCxIAQG8IwaBlSo
-D6Aim+IXdOKB5V0yLfC771CYi+JRyggBcev3MzFTIA93HMTMnCEqQtektK3m5JRv
-TtRSDfZwtB0yY9t5y66DjW90KxPP/pFpmUH1Qp11gg4zgVDfUYSU58zc+wMgeMQ1
-CxqtVPK36WEg5dB1UIKQ/R5sFrneknCnQ05KX5rL56pbsxCfnqkVoP4BZ3tIQB3Z
-z9hX9pZT+wocMjP9R3/lrIVLiFnodTyVOrJ5E7NdgEvPznByn7FPBRu8IldNVncL
-o37zxumL73/U5G1JI6PtyEhDxl1f5znx0KjWcnHDp9gcDBhJGyWVI4hVWa2Uv+gE
-utgIzf7DAgMBAAECggEAFdOoK2LBIQPesscaKKmk9tcEgpVNIr3eiIo5GFNElGed
-DPCI73FzhpbQ0RDOf5hNzfNmt3k8ZNOOJxlDuMjXsZPAdVEw3pVm7/ch4OLeEieA
-q86i/iIzXSOltFsfKCXXfLID4Mdd30aChzbTFsD9GAS+X1tykMJXFJ7cfN1gEjks
-+6puuQ3PNpn3A8/jzcJn1b8eGfuxpJLclWbi2Fs2mLA4ZNnLXt+/IaTfJpSTteRD
-cPvfIVekIageihx+2BFfZGaM+BTAwTRb/TnWS+I7eRPnPLu4CL9/auxOoZPE8SRE
-lSczfo3QPpXNpgQw/VKnFP5BsRwKsPArUWX99kP3AQKBgQDdNf1JNBmCXSmfJeEp
-NIlv6oHDCcx65KoZRujQA4p5Z4fOJ8VZo8GAfiT6Au6xJKZxK8i34xgrbhcSsXIL
-ztL94gd/p90BJy+qyBOvNSb2ZjHv3WA1Au0lBGIAKt+xsLTZIpf5DavnnWTbOq74
-vxpcQnGp9ZR2oPpGINKz+AIx4wKBgQDM+x5iTEWUbO4MS4ljoCPhjEfPSHGtlUYZ
-nRAbPw4w1Wku3GQ5TF1cDDyVMOXq37QgElvJOVWCUKe6ICqotg0hTRp5wtBHIAex
-942rzpWSrY7kRAHZixPgFks5lTYXbn4lrYAtw2ifT8khRr3mTmupgjNeVK8ol+Gl
-ZA4zJWcVoQKBgQCYpNO1utzLZ0v8ROA9VcJs1s5Z7p4KQ1XZAWRPfdIE+lrs9+an
-d2dkKieL2ZAp7pdnyoXD1lHsThhfztBas4pGpLz16riHPioXV961bSEIr/ZPhVwI
-2I8Zlw+k+/DGJaB1oPhrZHK17ZcV7EWm4f/nn/XdCNg8j9KDp8ydYUrqbwKBgAjc
-Xh7fry5QWyX66fB9jq+EUeJa/lcDmeknifezjRh9UTOuYUK801hUSxYj6/xwOSgd
-wwv6x4B/nhCErXNnkz+6Roe27Sv17X869UvU/VA+4mtpqS7PPUe1jwDpO1Jd+2QD
-kQPpa49fcpFWroTTJQJJ15CfVocJsb5liduaJU+hAoGBANhM7PdXv0kfeVlEAqGW
-lXU6UXNYmEU0jmTcG+qr8lirr4xT8q8J1dPf3Eieu8q+9LdTI1wcKL3O9dtmZudR
-fdMPBpVCfmI6e9APwnDN/vMoYlfAUptkgfrBmBzZt0jP79p5v5of4ObG7QfqYPgr
-BWup9HG/UkSnk46Tc9z2V+6S
------END PRIVATE KEY-----
diff --git a/stubs/AMQP.php b/stubs/AMQP.php
index c7a309b3..e65c4663 100644
--- a/stubs/AMQP.php
+++ b/stubs/AMQP.php
@@ -4,29 +4,29 @@
* Passing in this constant as a flag will forcefully disable all other flags.
* Use this if you want to temporarily disable the amqp.auto_ack ini setting.
*/
-define('AMQP_NOPARAM', 0);
+const AMQP_NOPARAM = 0;
/**
* Passing in this constant as a flag to proper methods will forcefully ignore all other flags.
* Do not send basic.consume request during AMQPQueue::consume(). Use this if you want to run callback on top of previously
* declared consumers.
*/
-define('AMQP_JUST_CONSUME', 1);
+const AMQP_JUST_CONSUME = 1;
/**
* Durable exchanges and queues will survive a broker restart, complete with all of their data.
*/
-define('AMQP_DURABLE', 2);
+const AMQP_DURABLE = 2;
/**
* Passive exchanges and queues will not be redeclared, but the broker will throw an error if the exchange or queue does not exist.
*/
-define('AMQP_PASSIVE', 4);
+const AMQP_PASSIVE = 4;
/**
* Valid for queues only, this flag indicates that only one client can be listening to and consuming from this queue.
*/
-define('AMQP_EXCLUSIVE', 8);
+const AMQP_EXCLUSIVE = 8;
/**
* For exchanges, the auto delete flag indicates that the exchange will be deleted as soon as no more queues are bound
@@ -35,44 +35,44 @@
* subscription has ever been active, the queue will never be deleted. Note: Exclusive queues will always be
* automatically deleted with the client disconnects.
*/
-define('AMQP_AUTODELETE', 16);
+const AMQP_AUTODELETE = 16;
/**
* Clients are not allowed to make specific queue bindings to exchanges defined with this flag.
*/
-define('AMQP_INTERNAL', 32);
+const AMQP_INTERNAL = 32;
/**
* When passed to the consume method for a clustered environment, do not consume from the local node.
*/
-define('AMQP_NOLOCAL', 64);
+const AMQP_NOLOCAL = 64;
/**
* When passed to the {@link AMQPQueue::get()} and {@link AMQPQueue::consume()} methods as a flag,
* the messages will be immediately marked as acknowledged by the server upon delivery.
*/
-define('AMQP_AUTOACK', 128);
+const AMQP_AUTOACK = 128;
/**
* Passed on queue creation, this flag indicates that the queue should be deleted if it becomes empty.
*/
-define('AMQP_IFEMPTY', 256);
+const AMQP_IFEMPTY = 256;
/**
* Passed on queue or exchange creation, this flag indicates that the queue or exchange should be
* deleted when no clients are connected to the given queue or exchange.
*/
-define('AMQP_IFUNUSED', 512);
+const AMQP_IFUNUSED = 512;
/**
* When publishing a message, the message must be routed to a valid queue. If it is not, an error will be returned.
*/
-define('AMQP_MANDATORY', 1024);
+const AMQP_MANDATORY = 1024;
/**
* When publishing a message, mark this message for immediate processing by the broker. (High priority message.)
*/
-define('AMQP_IMMEDIATE', 2048);
+const AMQP_IMMEDIATE = 2048;
/**
* If set during a call to {@link AMQPQueue::ack()}, the delivery tag is treated as "up to and including", so that multiple
@@ -80,59 +80,91 @@
* If the AMQP_MULTIPLE flag is set, and the delivery tag is zero, this indicates acknowledgement of all outstanding
* messages.
*/
-define('AMQP_MULTIPLE', 4096);
+const AMQP_MULTIPLE = 4096;
/**
* If set during a call to {@link AMQPExchange::bind()}, the server will not respond to the method.The client should not wait
* for a reply method. If the server could not complete the method it will raise a channel or connection exception.
*/
-define('AMQP_NOWAIT', 8192);
+const AMQP_NOWAIT = 8192;
/**
* If set during a call to {@link AMQPQueue::nack()}, the message will be placed back to the queue.
*/
-define('AMQP_REQUEUE', 16384);
+const AMQP_REQUEUE = 16384;
/**
* A direct exchange type.
*/
-define('AMQP_EX_TYPE_DIRECT', 'direct');
+const AMQP_EX_TYPE_DIRECT = 'direct';
/**
* A fanout exchange type.
*/
-define('AMQP_EX_TYPE_FANOUT', 'fanout');
+const AMQP_EX_TYPE_FANOUT = 'fanout';
/**
* A topic exchange type.
*/
-define('AMQP_EX_TYPE_TOPIC', 'topic');
+const AMQP_EX_TYPE_TOPIC = 'topic';
/**
* A header exchange type.
*/
-define('AMQP_EX_TYPE_HEADERS', 'headers');
+const AMQP_EX_TYPE_HEADERS = 'headers';
+
+
+const AMQP_OS_SOCKET_TIMEOUT_ERRNO = 536870947;
+
+
+
+const PHP_AMQP_MAX_CHANNELS = 256;
+
+
+const AMQP_SASL_METHOD_PLAIN = 0;
+
+
+const AMQP_SASL_METHOD_EXTERNAL = 1;
+
+/**
+ * Default delivery mode, keeps the message in memory when the message is placed in a queue.
+ */
+const AMQP_DELIVERY_MODE_TRANSIENT = 1;
+
+/**
+ * Writes the message to the disk when the message is placed in a durable queue.
+ */
+const AMQP_DELIVERY_MODE_PERSISTENT = 2;
/**
- *
+ * Extension version string
*/
-define('AMQP_OS_SOCKET_TIMEOUT_ERRNO', 536870947);
+const AMQP_EXTENSION_VERSION = '1.1.12alpha3';
+/**
+ * Extension major version
+ */
+const AMQP_EXTENSION_VERSION_MAJOR = 0;
+
+/**
+ * Extension minor version
+ */
+const AMQP_EXTENSION_VERSION_MINOR = 1;
/**
- *
+ * Extension patch version
*/
-define('PHP_AMQP_MAX_CHANNELS', 256);
+const AMQP_EXTENSION_VERSION_PATCH = 12;
/**
- *
+ * Extension extra version suffix
*/
-define('AMQP_SASL_METHOD_PLAIN', 0);
+const AMQP_EXTENSION_VERSION_EXTRA = 'alpha3';
/**
- *
+ * Extension version ID
*/
-define('AMQP_SASL_METHOD_EXTERNAL', 1);
+const AMQP_EXTENSION_VERSION_ID = '10112';
/**
diff --git a/stubs/AMQPBasicProperties.php b/stubs/AMQPBasicProperties.php
index 947db8b9..99549ed1 100644
--- a/stubs/AMQPBasicProperties.php
+++ b/stubs/AMQPBasicProperties.php
@@ -5,55 +5,67 @@
*/
class AMQPBasicProperties
{
- /**
- * @param string $content_type
- * @param string $content_encoding
- * @param array $headers
- * @param int $delivery_mode
- * @param int $priority
- * @param string $correlation_id
- * @param string $reply_to
- * @param string $expiration
- * @param string $message_id
- * @param int $timestamp
- * @param string $type
- * @param string $user_id
- * @param string $app_id
- * @param string $cluster_id
- */
+ private ?string $contentType = null;
+
+ private ?string $contentEncoding = null;
+
+ private array $headers = [];
+
+ private int $deliveryMode = AMQP_DELIVERY_MODE_TRANSIENT;
+
+ private int $priority = 0;
+
+ private ?string $correlationId = null;
+
+ private ?string $replyTo = null;
+
+ private ?string $expiration = null;
+
+ private ?string $messageId = null;
+
+ private ?int $timestamp = null;
+
+ private ?string $type = null;
+
+ private ?string $userId = null;
+
+ private ?string $appId = null;
+
+ private ?string $clusterId = null;
+
public function __construct(
- $content_type = "",
- $content_encoding = "",
+ ?string $contentType = null,
+ ?string $contentEncoding = null,
array $headers = [],
- $delivery_mode = 2,
- $priority = 0,
- $correlation_id = "",
- $reply_to = "",
- $expiration = "",
- $message_id = "",
- $timestamp = 0,
- $type = "",
- $user_id = "",
- $app_id = "",
- $cluster_id = ""
+ int $deliveryMode = AMQP_DELIVERY_MODE_TRANSIENT,
+ int $priority = 0,
+ ?string $correlationId = null,
+ ?string $replyTo = null,
+ ?string $expiration = null,
+ ?string $messageId = null,
+ ?int $timestamp = null,
+ ?string $type = null,
+ ?string $userId = null,
+ ?string $appId = null,
+ ?string $clusterId = null
) {
}
/**
* Get the message content type.
*
- * @return string The content type of the message.
+ * @return string|null The content type of the message.
*/
- public function getContentType()
+ public function getContentType(): ?string
{
}
/**
* Get the content encoding of the message.
*
- * @return string The content encoding of the message.
+ * @return string|null The content encoding of the message.
*/
- public function getContentEncoding()
+ public function getContentEncoding(): ?string
{
}
@@ -62,16 +74,16 @@ public function getContentEncoding()
*
* @return array An array of key value pairs associated with the message.
*/
- public function getHeaders()
+ public function getHeaders(): array
{
}
/**
* Get the delivery mode of the message.
*
- * @return integer The delivery mode of the message.
+ * @return int The delivery mode of the message.
*/
- public function getDeliveryMode()
+ public function getDeliveryMode(): int
{
}
@@ -80,88 +92,88 @@ public function getDeliveryMode()
*
* @return int The message priority.
*/
- public function getPriority()
+ public function getPriority(): int
{
}
/**
* Get the message correlation id.
*
- * @return string The correlation id of the message.
+ * @return string|null The correlation id of the message.
*/
- public function getCorrelationId()
+ public function getCorrelationId(): ?string
{
}
/**
* Get the reply-to address of the message.
*
- * @return string The contents of the reply to field.
+ * @return string|null The contents of the reply to field.
*/
- public function getReplyTo()
+ public function getReplyTo(): ?string
{
}
/**
* Get the expiration of the message.
*
- * @return string The message expiration.
+ * @return string|null The message expiration.
*/
- public function getExpiration()
+ public function getExpiration(): ?string
{
}
/**
* Get the message id of the message.
*
- * @return string The message id
+ * @return string|null The message id
*/
- public function getMessageId()
+ public function getMessageId(): ?string
{
}
/**
* Get the timestamp of the message.
*
- * @return string The message timestamp.
+ * @return int|null The message timestamp.
*/
- public function getTimestamp()
+ public function getTimestamp(): ?int
{
}
/**
* Get the message type.
*
- * @return string The message type.
+ * @return string|null The message type.
*/
- public function getType()
+ public function getType(): ?string
{
}
/**
* Get the message user id.
*
- * @return string The message user id.
+ * @return string|null The message user id.
*/
- public function getUserId()
+ public function getUserId(): ?string
{
}
/**
* Get the application id of the message.
*
- * @return string The application id of the message.
+ * @return string|null The application id of the message.
*/
- public function getAppId()
+ public function getAppId(): ?string
{
}
/**
* Get the cluster id of the message.
*
- * @return string The cluster id of the message.
+ * @return string|null The cluster id of the message.
*/
- public function getClusterId()
+ public function getClusterId(): ?string
{
}
}
diff --git a/stubs/AMQPChannel.php b/stubs/AMQPChannel.php
index d2e26ba6..59bdc741 100644
--- a/stubs/AMQPChannel.php
+++ b/stubs/AMQPChannel.php
@@ -5,30 +5,40 @@
*/
class AMQPChannel
{
+ private AMQPConnection $connection;
+
+ private ?int $prefetchCount = null;
+
+ private ?int $prefetchSize;
+
+ private ?int $globalPrefetchCount;
+
+ private ?int $globalPrefetchSize;
+
+ private array $consumers = [];
+
/**
- * Commit a pending transaction.
+ * Create an instance of an AMQPChannel object.
*
- * @throws AMQPChannelException If no transaction was started prior to
- * calling this method.
- * @throws AMQPConnectionException If the connection to the broker was lost.
+ * @param AMQPConnection $connection An instance of AMQPConnection
+ * with an active connection to a
+ * broker.
*
- * @return bool TRUE on success or FALSE on failure.
+ * @throws AMQPConnectionException If the connection to the broker
+ * was lost.
*/
- public function commitTransaction()
+ public function __construct(AMQPConnection $connection)
{
}
/**
- * Create an instance of an AMQPChannel object.
- *
- * @param AMQPConnection $amqp_connection An instance of AMQPConnection
- * with an active connection to a
- * broker.
+ * Commit a pending transaction.
*
- * @throws AMQPConnectionException If the connection to the broker
- * was lost.
+ * @throws AMQPChannelException If no transaction was started prior to
+ * calling this method.
+ * @throws AMQPConnectionException If the connection to the broker was lost.
*/
- public function __construct(AMQPConnection $amqp_connection)
+ public function commitTransaction(): void
{
}
@@ -37,14 +47,14 @@ public function __construct(AMQPConnection $amqp_connection)
*
* @return bool Indicates whether the channel is connected.
*/
- public function isConnected()
+ public function isConnected(): bool
{
}
/**
* Closes the channel.
*/
- public function close()
+ public function close(): void
{
}
@@ -53,7 +63,7 @@ public function close()
*
* @return integer
*/
- public function getChannelId()
+ public function getChannelId(): int
{
}
@@ -72,15 +82,13 @@ public function getChannelId()
* flag set, the client will not do any prefetching of data, regardless of
* the QOS settings.
*
- * @param integer $size The window size, in octets, to prefetch.
- * @param integer $count The number of messages to prefetch.
- * @param bool $global TRUE for global, FALSE for consumer. FALSE by default.
+ * @param integer $size The window size, in octets, to prefetch.
+ * @param integer $count The number of messages to prefetch.
+ * @param bool $global TRUE for global, FALSE for consumer. FALSE by default.
*
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return bool TRUE on success or FALSE on failure.
*/
- public function qos($size, $count, $global)
+ public function qos(int $size, int $count, bool $global = false): void
{
}
@@ -90,13 +98,11 @@ public function qos($size, $count, $global)
* Rollback an existing transaction. AMQPChannel::startTransaction() must
* be called prior to this.
*
- * @throws AMQPChannelException If no transaction was started prior to
- * calling this method.
+ * @throws AMQPChannelException If no transaction was started prior to
+ * calling this method.
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return bool TRUE on success or FALSE on failure.
*/
- public function rollbackTransaction()
+ public function rollbackTransaction(): void
{
}
@@ -109,10 +115,8 @@ public function rollbackTransaction()
* @param integer $count The number of messages to prefetch.
*
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return boolean TRUE on success or FALSE on failure.
*/
- public function setPrefetchCount($count)
+ public function setPrefetchCount(int $count): void
{
}
@@ -121,7 +125,7 @@ public function setPrefetchCount($count)
*
* @return integer
*/
- public function getPrefetchCount()
+ public function getPrefetchCount(): int
{
}
@@ -138,10 +142,8 @@ public function getPrefetchCount()
* @param integer $size The window size, in octets, to prefetch.
*
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return bool TRUE on success or FALSE on failure.
*/
- public function setPrefetchSize($size)
+ public function setPrefetchSize(int $size): void
{
}
@@ -150,7 +152,7 @@ public function setPrefetchSize($size)
*
* @return integer
*/
- public function getPrefetchSize()
+ public function getPrefetchSize(): int
{
}
@@ -163,10 +165,8 @@ public function getPrefetchSize()
* @param integer $count The number of messages to prefetch.
*
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return boolean TRUE on success or FALSE on failure.
*/
- public function setGlobalPrefetchCount($count)
+ public function setGlobalPrefetchCount(int $count): void
{
}
@@ -175,7 +175,7 @@ public function setGlobalPrefetchCount($count)
*
* @return integer
*/
- public function getGlobalPrefetchCount()
+ public function getGlobalPrefetchCount(): int
{
}
@@ -192,10 +192,8 @@ public function getGlobalPrefetchCount()
* @param integer $size The window size, in octets, to prefetch.
*
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return bool TRUE on success or FALSE on failure.
*/
- public function setGlobalPrefetchSize($size)
+ public function setGlobalPrefetchSize(int $size): void
{
}
@@ -204,7 +202,7 @@ public function setGlobalPrefetchSize($size)
*
* @return integer
*/
- public function getGlobalPrefetchSize()
+ public function getGlobalPrefetchSize(): int
{
}
@@ -215,56 +213,46 @@ public function getGlobalPrefetchSize()
* AMQPChannel::commitTransaction() or AMQPChannel::rollbackTransaction().
*
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return bool TRUE on success or FALSE on failure.
*/
- public function startTransaction()
+ public function startTransaction(): void
{
}
/**
* Get the AMQPConnection object in use
- *
- * @return AMQPConnection
*/
- public function getConnection()
+ public function getConnection(): AMQPConnection
{
}
/**
* Redeliver unacknowledged messages.
- *
- * @param bool $requeue
*/
- public function basicRecover($requeue = true)
+ public function basicRecover(bool $requeue = true): void
{
}
/**
* Set the channel to use publisher acknowledgements. This can only used on a non-transactional channel.
*/
- public function confirmSelect()
+ public function confirmSelect(): void
{
}
/**
* Set callback to process basic.ack and basic.nac AMQP server methods (applicable when channel in confirm mode).
*
- * @param callable|null $ack_callback
- * @param callable|null $nack_callback
- *
* Callback functions with all arguments have the following signature:
*
* function ack_callback(int $delivery_tag, bool $multiple) : bool;
* function nack_callback(int $delivery_tag, bool $multiple, bool $requeue) : bool;
*
- * and should return boolean false when wait loop should be canceled.
+ * and should return boolean FALSE when wait loop should be canceled.
*
* Note, basic.nack server method will only be delivered if an internal error occurs in the Erlang process
* responsible for a queue (see https://www.rabbitmq.com/confirms.html for details).
- *
*/
- public function setConfirmCallback(callable $ack_callback=null, callable $nack_callback=null)
+ public function setConfirmCallback(?callable $ackCallback, callable $nackCallback = null): void
{
}
@@ -277,15 +265,13 @@ public function setConfirmCallback(callable $ack_callback=null, callable $nack_c
*
* @throws AMQPQueueException If timeout occurs.
*/
- public function waitForConfirm($timeout = 0.0)
+ public function waitForConfirm(float $timeout = 0.0): void
{
}
/**
* Set callback to process basic.return AMQP server method
*
- * @param callable|null $return_callback
- *
* Callback function with all arguments has the following signature:
*
* function callback(int $reply_code,
@@ -295,10 +281,9 @@ public function waitForConfirm($timeout = 0.0)
* AMQPBasicProperties $properties,
* string $body) : bool;
*
- * and should return boolean false when wait loop should be canceled.
- *
+ * and should return boolean FALSE when wait loop should be canceled.
*/
- public function setReturnCallback(callable $return_callback=null)
+ public function setReturnCallback(?callable $returnCallback): void
{
}
@@ -309,7 +294,7 @@ public function setReturnCallback(callable $return_callback=null)
*
* @throws AMQPQueueException If timeout occurs.
*/
- public function waitForBasicReturn($timeout = 0.0)
+ public function waitForBasicReturn(float $timeout = 0.0): void
{
}
@@ -318,7 +303,7 @@ public function waitForBasicReturn($timeout = 0.0)
*
* @return AMQPQueue[]
*/
- public function getConsumers()
+ public function getConsumers(): array
{
}
}
diff --git a/stubs/AMQPConnection.php b/stubs/AMQPConnection.php
index 01ab1a74..84b8baf4 100644
--- a/stubs/AMQPConnection.php
+++ b/stubs/AMQPConnection.php
@@ -5,17 +5,41 @@
*/
class AMQPConnection
{
- /**
- * Establish a transient connection with the AMQP broker.
- *
- * This method will initiate a connection with the AMQP broker.
- *
- * @throws AMQPConnectionException
- * @return boolean TRUE on success or throw an exception on failure.
- */
- public function connect()
- {
- }
+ private string $login;
+
+ private string $password;
+
+ private string $host;
+
+ private string $vhost;
+
+ private int $port;
+
+ private float $readTimeout;
+
+ private float $writeTimeout;
+
+ private float $connectTimeout;
+
+ private float $rpcTimeout;
+
+ private int $channelMax;
+
+ private int $frameMax;
+
+ private int $heartbeat;
+
+ private ?string $cacert;
+
+ private ?string $key;
+
+ private ?string $cert;
+
+ private bool $verify = true;
+
+ private int $saslMethod = AMQP_SASL_METHOD_PLAIN;
+
+ private ?string $connectionName;
/**
* Create an instance of AMQPConnection.
@@ -30,10 +54,10 @@ public function connect()
* 'vhost' => amqp.vhost The virtual host on the host. Note: Max 128 characters.
* 'login' => amqp.login The login name to use. Note: Max 128 characters.
* 'password' => amqp.password Password. Note: Max 128 characters.
- * 'read_timeout' => Timeout in for income activity. Note: 0 or greater seconds. May be fractional.
- * 'write_timeout' => Timeout in for outcome activity. Note: 0 or greater seconds. May be fractional.
+ * 'read_timeout' => Timeout in for consume. Note: 0 or greater seconds. May be fractional.
+ * 'write_timeout' => Timeout in for publish. Note: 0 or greater seconds. May be fractional.
* 'connect_timeout' => Connection timeout. Note: 0 or greater seconds. May be fractional.
- * 'rpc_timeout' => RPC timeout. Note: 0 or greater seconds. May be fractional.
+ * 'rpc_timeout' => Timeout for RPC-style AMQP methods. Note: 0 or greater seconds. May be fractional.
*
* Connection tuning options (see http://www.rabbitmq.com/amqp-0-9-1-reference.html#connection.tune for details):
* 'channel_max' => Specifies highest channel number that the server permits. 0 means standard extension limit
@@ -53,136 +77,158 @@ public function connect()
* 'key' => Path to the client key in PEM format.
* 'verify' => Enable or disable peer verification. If peer verification is enabled then the common name in the
* server certificate must match the server name. Peer verification is enabled by default.
+ *
+ * 'connection_name' => A user determined name for the connection
* )
*
* @param array $credentials Optional array of credential information for
* connecting to the AMQP broker.
*/
- public function __construct(array $credentials = array())
+ public function __construct(array $credentials = [])
{
}
/**
- * Closes the transient connection with the AMQP broker.
+ * Check whether the connection to the AMQP broker is still valid.
*
- * This method will close an open connection with the AMQP broker.
+ * Cannot reliably detect dropped connections or unusual socket errors, as it does not actively
+ * engage the socket.
*
- * @return boolean true if connection was successfully closed, false otherwise.
+ * @return boolean TRUE if connected, FALSE otherwise.
*/
- public function disconnect()
+ public function isConnected(): bool
{
}
/**
- * Manual send heartbeat if it necessary
+ * Whether connection persistent.
*
- * @return boolean TRUE on success or throws an exception on failure.
+ * When no connection is established, it will always return FALSE. The same disclaimer as for
+ * {@see AMQPConnection::isConnected()} applies.
+ *
+ * @return boolean TRUE if persistently connected, FALSE otherwise.
*/
- public function sendHeartbeat()
+ public function isPersistent(): bool
{
}
/**
- * Get the configured host.
+ * Establish a transient connection with the AMQP broker.
*
- * @return string The configured hostname of the broker
+ * This method will initiate a connection with the AMQP broker.
+ *
+ * @throws AMQPConnectionException
*/
- public function getHost()
+ public function connect(): void
{
}
/**
- * Get the configured login.
+ * Closes the transient connection with the AMQP broker.
*
- * @return string The configured login as a string.
+ * This method will close an open connection with the AMQP broker.
+ *
+ * @throws AMQPConnectionException When attempting to disconnect a persistent connection
*/
- public function getLogin()
+ public function disconnect(): void
{
}
/**
- * Get the configured password.
+ * Close any open transient connections and initiate a new one with the AMQP broker.
*
- * @return string The configured password as a string.
+ * @throws AMQPConnectionException
*/
- public function getPassword()
+ public function reconnect(): void
{
}
/**
- * Get the configured port.
+ * Establish a persistent connection with the AMQP broker.
*
- * @return int The configured port as an integer.
+ * This method will initiate a connection with the AMQP broker
+ * or reuse an existing one if present.
+ *
+ * @throws AMQPConnectionException
*/
- public function getPort()
+ public function pconnect(): void
{
}
/**
- * Get the configured vhost.
+ * Closes a persistent connection with the AMQP broker.
*
- * @return string The configured virtual host as a string.
+ * This method will close an open persistent connection with the AMQP
+ * broker.
+ *
+ * @throws AMQPConnectionException When attempting to disconnect a transient connection
*/
- public function getVhost()
+ public function pdisconnect(): void
{
}
/**
- * Check whether the connection to the AMQP broker is still valid.
- *
- * It does so by checking the return status of the last connect-command.
+ * Close any open persistent connections and initiate a new one with the AMQP broker.
*
- * @return boolean True if connected, false otherwise.
+ * @throws AMQPConnectionException
*/
- public function isConnected()
+ public function preconnect(): void
{
}
/**
- * Establish a persistent connection with the AMQP broker.
- *
- * This method will initiate a connection with the AMQP broker
- * or reuse an existing one if present.
+ * Manual send heartbeat if it necessary
*
- * @throws AMQPConnectionException
* @return boolean TRUE on success or throws an exception on failure.
*/
- public function pconnect()
+ public function sendHeartbeat()
{
}
/**
- * Closes a persistent connection with the AMQP broker.
+ * Get the configured host.
*
- * This method will close an open persistent connection with the AMQP
- * broker.
+ * @return string The configured hostname of the broker
+ */
+ public function getHost(): string
+ {
+ }
+
+ /**
+ * Get the configured login.
*
- * @return boolean true if connection was found and closed,
- * false if no persistent connection with this host,
- * port, vhost and login could be found,
+ * @return string The configured login as a string.
*/
- public function pdisconnect()
+ public function getLogin(): string
{
}
/**
- * Close any open transient connections and initiate a new one with the AMQP broker.
+ * Get the configured password.
*
- * @return boolean TRUE on success or FALSE on failure.
+ * @return string The configured password as a string.
*/
- public function reconnect()
+ public function getPassword(): string
{
}
/**
- * Close any open persistent connections and initiate a new one with the AMQP broker.
+ * Get the configured port.
*
- * @return boolean TRUE on success or FALSE on failure.
+ * @return int The configured port as an integer.
*/
- public function preconnect()
+ public function getPort(): int
{
}
+ /**
+ * Get the configured vhost.
+ *
+ * @return string The configured virtual host as a string.
+ */
+ public function getVhost(): string
+ {
+ }
/**
* Set the hostname used to connect to the AMQP broker.
@@ -190,10 +236,8 @@ public function preconnect()
* @param string $host The hostname of the AMQP broker.
*
* @throws AMQPConnectionException If host is longer then 1024 characters.
- *
- * @return boolean TRUE on success or FALSE on failure.
*/
- public function setHost($host)
+ public function setHost(string $host): void
{
}
@@ -204,10 +248,8 @@ public function setHost($host)
* with the AMQP broker.
*
* @throws AMQPConnectionException If login is longer then 32 characters.
- *
- * @return boolean TRUE on success or FALSE on failure.
*/
- public function setLogin($login)
+ public function setLogin(string $login): void
{
}
@@ -218,10 +260,8 @@ public function setLogin($login)
* with the AMQP broker.
*
* @throws AMQPConnectionException If password is longer then 32characters.
- *
- * @return boolean TRUE on success or FALSE on failure.
*/
- public function setPassword($password)
+ public function setPassword(string $password): void
{
}
@@ -232,10 +272,8 @@ public function setPassword($password)
*
* @throws AMQPConnectionException If port is longer not between
* 1 and 65535.
- *
- * @return boolean TRUE on success or FALSE on failure.
*/
- public function setPort($port)
+ public function setPort(int $port): void
{
}
@@ -246,10 +284,8 @@ public function setPort($port)
* broker.
*
* @throws AMQPConnectionException If host is longer then 32 characters.
- *
- * @return boolean true on success or false on failure.
*/
- public function setVhost($vhost)
+ public function setVhost(string $vhost): void
{
}
@@ -258,13 +294,9 @@ public function setVhost($vhost)
*
* @deprecated use AMQPConnection::setReadTimeout($timeout) instead
*
- * @param float $timeout
- *
* @throws AMQPConnectionException If timeout is less than 0.
- *
- * @return bool
*/
- public function setTimeout($timeout)
+ public function setTimeout(float $timeout): void
{
}
@@ -273,88 +305,73 @@ public function setTimeout($timeout)
* from AMQP broker
*
* @deprecated use AMQPConnection::getReadTimeout() instead
- *
- * @return float
*/
- public function getTimeout()
+ public function getTimeout(): float
{
}
/**
* Sets the interval of time (in seconds) to wait for income activity from AMQP broker
*
- * @param float $timeout
- *
* @throws AMQPConnectionException If timeout is less than 0.
- *
- * @return bool
*/
- public function setReadTimeout($timeout)
+ public function setReadTimeout(float $timeout): void
{
}
/**
* Get the configured interval of time (in seconds) to wait for income activity
* from AMQP broker
- *
- * @return float
*/
- public function getReadTimeout()
+ public function getReadTimeout(): float
{
}
/**
* Sets the interval of time (in seconds) to wait for outcome activity to AMQP broker
*
- * @param float $timeout
- *
* @throws AMQPConnectionException If timeout is less than 0.
- *
- * @return bool
*/
- public function setWriteTimeout($timeout)
+ public function setWriteTimeout(float $timeout): void
{
}
/**
* Get the configured interval of time (in seconds) to wait for outcome activity
* to AMQP broker
- *
- * @return float
*/
- public function getWriteTimeout()
+ public function getWriteTimeout(): float
+ {
+ }
+
+ /**
+ * Get the configured timeout (in seconds) for connecting to the AMQP broker
+ */
+ public function getConnectTimeout(): float
{
}
/**
* Sets the interval of time to wait (in seconds) for RPC activity to AMQP broker
*
- * @param float $timeout
- *
* @throws AMQPConnectionException If timeout is less than 0.
- *
- * @return bool
*/
- public function setRpcTimeout($timeout)
+ public function setRpcTimeout(float $timeout): void
{
}
/**
* Get the configured interval of time (in seconds) to wait for RPC activity
* to AMQP broker
- *
- * @return float
*/
- public function getRpcTimeout()
+ public function getRpcTimeout(): float
{
}
/**
* Return last used channel id during current connection session.
- *
- * @return int
*/
- public function getUsedChannels()
+ public function getUsedChannels(): int
{
}
@@ -363,10 +380,8 @@ public function getUsedChannels()
*
* When connection is connected, effective connection value returned, which is normally the same as original
* correspondent value passed to constructor, otherwise original value passed to constructor returned.
- *
- * @return int
*/
- public function getMaxChannels()
+ public function getMaxChannels(): int
{
}
@@ -375,10 +390,8 @@ public function getMaxChannels()
*
* When connection is connected, effective connection value returned, which is normally the same as original
* correspondent value passed to constructor, otherwise original value passed to constructor returned.
- *
- * @return int
*/
- public function getMaxFrameSize()
+ public function getMaxFrameSize(): int
{
}
@@ -387,39 +400,22 @@ public function getMaxFrameSize()
*
* When connection is connected, effective connection value returned, which is normally the same as original
* correspondent value passed to constructor, otherwise original value passed to constructor returned.
- *
- * @return int
- */
- public function getHeartbeatInterval()
- {
- }
-
- /**
- * Whether connection persistent.
- *
- * When connection is not connected, boolean false always returned
- *
- * @return bool
*/
- public function isPersistent()
+ public function getHeartbeatInterval(): int
{
}
/**
* Get path to the CA cert file in PEM format
- *
- * @return string
*/
- public function getCACert()
+ public function getCACert(): ?string
{
}
/**
* Set path to the CA cert file in PEM format
- *
- * @param string $cacert
*/
- public function setCACert($cacert)
+ public function setCACert(?string $cacert): void
{
}
@@ -479,71 +475,64 @@ public function setUseDefaultCAPath($use_default_capath)
/**
* Get path to the client certificate in PEM format
- *
- * @return string
*/
- public function getCert()
+ public function getCert(): ?string
{
}
/**
* Set path to the client certificate in PEM format
- *
- * @param string $cert
*/
- public function setCert($cert)
+ public function setCert(?string $cert): void
{
}
/**
* Get path to the client key in PEM format
- *
- * @return string
*/
- public function getKey()
+ public function getKey(): ?string
{
}
/**
* Set path to the client key in PEM format
- *
- * @param string $key
*/
- public function setKey($key)
+ public function setKey(?string $key): void
{
}
/**
* Get whether peer verification enabled or disabled
- *
- * @return bool
*/
- public function getVerify()
+ public function getVerify(): bool
{
}
/**
* Enable or disable peer verification
- *
- * @param bool $verify
*/
- public function setVerify($verify)
+ public function setVerify(bool $verify): void
{
}
/**
* set authentication method
*
- * @param int $method AMQP_SASL_METHOD_PLAIN | AMQP_SASL_METHOD_EXTERNAL
+ * @param int $saslMethod AMQP_SASL_METHOD_PLAIN | AMQP_SASL_METHOD_EXTERNAL
*/
- public function setSaslMethod($method)
+ public function setSaslMethod(int $saslMethod): void
{
}
- /**
- * @return int
- */
- public function getSaslMethod()
+ public function getSaslMethod(): int
+ {
+ }
+
+ public function setConnectionName(?string $connectionName): void
+ {
+ }
+
+ public function getConnectionName(): ?string
{
}
}
diff --git a/stubs/AMQPDecimal.php b/stubs/AMQPDecimal.php
index a4d2741a..825d5d0d 100644
--- a/stubs/AMQPDecimal.php
+++ b/stubs/AMQPDecimal.php
@@ -2,31 +2,51 @@
/**
* stub class representing AMQPDecimal from pecl-amqp
+ *
+ * @readonly
*/
-final class AMQPDecimal
+final /* readonly */ class AMQPDecimal implements AMQPValue
{
- const EXPONENT_MIN = 0;
- const EXPONENT_MAX = 255;
- const SIGNIFICAND_MIN = 0;
- const SIGNIFICAND_MAX = 4294967295;
+ /**
+ * @var int
+ */
+ public const EXPONENT_MIN = 0;
+
+ /**
+ * @var int
+ */
+ public const EXPONENT_MAX = 255;
+
+ /**
+ * @var int
+ */
+ public const SIGNIFICAND_MIN = 0;
/**
- * @param $exponent
- * @param $significand
- *
- * @throws AMQPExchangeValue
+ * @var int
*/
- public function __construct($exponent, $significand)
+ public const SIGNIFICAND_MAX = 4294967295;
+
+ private int $exponent;
+
+ private int $significand;
+
+ /**
+ * @throws AMQPValueException
+ */
+ public function __construct(int $exponent, int $significand)
+ {
+ }
+
+ public function getExponent(): int
{
}
- /** @return int */
- public function getExponent()
+ public function getSignificand(): int
{
}
- /** @return int */
- public function getSignificand()
+ public function toAmqpValue()
{
}
}
diff --git a/stubs/AMQPEnvelope.php b/stubs/AMQPEnvelope.php
index 5a38a63a..d72419a6 100644
--- a/stubs/AMQPEnvelope.php
+++ b/stubs/AMQPEnvelope.php
@@ -5,6 +5,18 @@
*/
class AMQPEnvelope extends AMQPBasicProperties
{
+ private string $body = '';
+
+ private ?string $consumerTag = null;
+
+ private ?int $deliveryTag = null;
+
+ private bool $isRedelivery = false;
+
+ private ?string $exchangeName = null;
+
+ private string $routingKey = '';
+
public function __construct()
{
}
@@ -14,7 +26,7 @@ public function __construct()
*
* @return string The contents of the message body.
*/
- public function getBody()
+ public function getBody(): string
{
}
@@ -23,34 +35,34 @@ public function getBody()
*
* @return string The message routing key.
*/
- public function getRoutingKey()
+ public function getRoutingKey(): string
{
}
/**
* Get the consumer tag of the message.
*
- * @return string The consumer tag of the message.
+ * @return string|null The consumer tag of the message.
*/
- public function getConsumerTag()
+ public function getConsumerTag(): ?string
{
}
/**
* Get the delivery tag of the message.
*
- * @return integer The delivery tag of the message.
+ * @return integer|null The delivery tag of the message.
*/
- public function getDeliveryTag()
+ public function getDeliveryTag(): ?int
{
}
/**
* Get the exchange name on which the message was published.
*
- * @return string The exchange name on which the message was published.
+ * @return string|null The exchange name on which the message was published.
*/
- public function getExchangeName()
+ public function getExchangeName(): ?string
{
}
@@ -64,30 +76,29 @@ public function getExchangeName()
*
* @return bool TRUE if this is a redelivery, FALSE otherwise.
*/
- public function isRedelivery()
+ public function isRedelivery(): bool
{
}
/**
* Get a specific message header.
*
- * @param string $header_key Name of the header to get the value from.
+ * @param string $headerName Name of the header to get the value from.
*
- * @return string|boolean The contents of the specified header or FALSE
- * if not set.
+ * @return mixed The contents of the specified header or null if not set.
*/
- public function getHeader($header_key)
+ public function getHeader(string $headerName)
{
}
/**
* Check whether specific message header exists.
*
- * @param string $header_key Name of the header to check.
+ * @param string $headerName Name of the header to check.
*
* @return boolean
*/
- public function hasHeader($header_key)
+ public function hasHeader(string $headerName): bool
{
}
}
diff --git a/stubs/AMQPEnvelopeException.php b/stubs/AMQPEnvelopeException.php
index 4e39c962..fb77bbca 100644
--- a/stubs/AMQPEnvelopeException.php
+++ b/stubs/AMQPEnvelopeException.php
@@ -5,8 +5,9 @@
*/
class AMQPEnvelopeException extends AMQPException
{
- /**
- * @var AMQPEnvelope
- */
- public $envelope;
+ private AMQPEnvelope $envelope;
+
+ public function getEnvelope(): AMQPEnvelope
+ {
+ }
}
diff --git a/stubs/AMQPExchange.php b/stubs/AMQPExchange.php
index 6ae283db..f7aebc1a 100644
--- a/stubs/AMQPExchange.php
+++ b/stubs/AMQPExchange.php
@@ -5,21 +5,56 @@
*/
class AMQPExchange
{
+ private AMQPConnection $connection;
+
+ private AMQPChannel $channel;
+
+ private ?string $name = null;
+
+ private ?string $type = null;
+
+ private bool $passive = false;
+
+ private bool $durable = false;
+
+ private bool $autoDelete = false;
+
+ private bool $internal = false;
+
+ private array $arguments = [];
+
+ /**
+ * Create an instance of AMQPExchange.
+ *
+ * Returns a new instance of an AMQPExchange object, associated with the
+ * given AMQPChannel object.
+ *
+ * @param AMQPChannel $channel A valid AMQPChannel object, connected
+ * to a broker.
+ *
+ * @throws AMQPExchangeException When amqp_channel is not connected to
+ * a broker.
+ * @throws AMQPConnectionException If the connection to the broker was
+ * lost.
+ */
+ public function __construct(AMQPChannel $channel)
+ {
+ }
+
/**
* Bind to another exchange.
*
* Bind an exchange to another exchange using the specified routing key.
*
- * @param string $exchange_name Name of the exchange to bind.
- * @param string $routing_key The routing key to use for binding.
- * @param array $arguments Additional binding arguments.
+ * @param string $exchangeName Name of the exchange to bind.
+ * @param string|null $routingKey The routing key to use for binding.
+ * @param array $arguments Additional binding arguments.
*
- * @throws AMQPExchangeException On failure.
- * @throws AMQPChannelException If the channel is not open.
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
- * @return boolean true on success or false on failure.
+ * @throws AMQPExchangeException On failure.
*/
- public function bind($exchange_name, $routing_key = '', array $arguments = array())
+ public function bind(string $exchangeName, ?string $routingKey = null, array $arguments = []): void
{
}
@@ -28,98 +63,86 @@ public function bind($exchange_name, $routing_key = '', array $arguments = array
*
* Remove a routing key binding on an another exchange from the given exchange.
*
- * @param string $exchange_name Name of the exchange to bind.
- * @param string $routing_key The routing key to use for binding.
- * @param array $arguments Additional binding arguments.
+ * @param string $exchangeName Name of the exchange to bind.
+ * @param string|null $routingKey The routing key to use for binding.
+ * @param array $arguments Additional binding arguments.
*
- * @throws AMQPExchangeException On failure.
- * @throws AMQPChannelException If the channel is not open.
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
- * @return boolean true on success or false on failure.
+ * @throws AMQPExchangeException On failure.
*/
- public function unbind($exchange_name, $routing_key = '', array $arguments = array())
+ public function unbind(string $exchangeName, ?string $routingKey = null, array $arguments = []): void
{
}
/**
- * Create an instance of AMQPExchange.
- *
- * Returns a new instance of an AMQPExchange object, associated with the
- * given AMQPChannel object.
- *
- * @param AMQPChannel $amqp_channel A valid AMQPChannel object, connected
- * to a broker.
+ * Declare a new exchange on the broker.
*
- * @throws AMQPExchangeException When amqp_channel is not connected to
- * a broker.
- * @throws AMQPConnectionException If the connection to the broker was
- * lost.
+ * @throws AMQPExchangeException On failure.
+ * @throws AMQPChannelException If the channel is not open.
+ * @throws AMQPConnectionException If the connection to the broker was lost.
*/
- public function __construct(AMQPChannel $amqp_channel)
+ public function declareExchange(): void
{
}
/**
* Declare a new exchange on the broker.
*
- * @throws AMQPExchangeException On failure.
- * @throws AMQPChannelException If the channel is not open.
+ * @throws AMQPExchangeException On failure.
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return boolean TRUE on success or FALSE on failure.
*/
- public function declareExchange()
+ public function declare(): void
{
}
/**
* Delete the exchange from the broker.
*
- * @param string $exchangeName Optional name of exchange to delete.
- * @param integer $flags Optionally AMQP_IFUNUSED can be specified
- * to indicate the exchange should not be
- * deleted until no clients are connected to
- * it.
+ * @param string $exchangeName Optional name of exchange to delete. If not specified it uses the name of the
+ * exchange object
+ * @param integer $flags Optionally AMQP_IFUNUSED can be specified
+ * to indicate the exchange should not be
+ * deleted until no clients are connected to
+ * it.
*
- * @throws AMQPExchangeException On failure.
- * @throws AMQPChannelException If the channel is not open.
+ * @throws AMQPExchangeException On failure.
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return boolean true on success or false on failure.
*/
- public function delete($exchangeName = null, $flags = AMQP_NOPARAM)
+ public function delete(?string $exchangeName = null, ?int $flags = null): void
{
}
/**
* Get the argument associated with the given key.
*
- * @param string $key The key to look up.
- *
- * @return string|integer|boolean The string or integer value associated
- * with the given key, or FALSE if the key
- * is not set.
+ * @param string $argumentName The key to look up.
+ * @throws AMQPExchangeException If key does not exist
+ * @return bool|int|double|string|null
*/
- public function getArgument($key)
+ public function getArgument(string $argumentName)
{
}
/**
* Check whether argument associated with the given key exists.
*
- * @param string $key The key to look up.
+ * @param string $argumentName The key to look up.
*
- * @return bool
+ * @return boolean
*/
- public function hasArgument($key)
+ public function hasArgument(string $argumentName): bool
{
}
+
/**
* Get all arguments set on the given exchange.
*
- * @return array An array containing all of the set key/value pairs.
+ * @return array An array containing all the set key/value pairs.
*/
- public function getArguments()
+ public function getArguments(): array
{
}
@@ -129,25 +152,25 @@ public function getArguments()
* @return int An integer bitmask of all the flags currently set on this
* exchange object.
*/
- public function getFlags()
+ public function getFlags(): int
{
}
/**
* Get the configured name.
*
- * @return string The configured name as a string.
+ * @return string|null The configured name as a string.
*/
- public function getName()
+ public function getName(): ?string
{
}
/**
* Get the configured type.
*
- * @return string The configured type as a string.
+ * @return string|null The configured type as a string.
*/
- public function getType()
+ public function getType(): ?string
{
}
@@ -156,39 +179,43 @@ public function getType()
*
* Publish a message to the exchange represented by the AMQPExchange object.
*
- * @param string $message The message to publish.
- * @param string $routing_key The optional routing key to which to
- * publish to.
- * @param integer $flags One or more of AMQP_MANDATORY and
- * AMQP_IMMEDIATE.
- * @param array $attributes One of content_type, content_encoding,
- * message_id, user_id, app_id, delivery_mode,
- * priority, timestamp, expiration, type
- * or reply_to, headers.
- *
- * @throws AMQPExchangeException On failure.
- * @throws AMQPChannelException If the channel is not open.
+ * @param string $message The message to publish.
+ * @param string|null $routingKey The optional routing key to which to
+ * publish to.
+ * @param integer $flags One or more of AMQP_MANDATORY and
+ * AMQP_IMMEDIATE.
+ * @param array $headers One of content_type, content_encoding,
+ * message_id, user_id, app_id, delivery_mode,
+ * priority, timestamp, expiration, type
+ * or reply_to, headers.
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return boolean TRUE on success or FALSE on failure.
+ * @throws AMQPExchangeException On failure.
*/
public function publish(
- $message,
- $routing_key = null,
- $flags = AMQP_NOPARAM,
- array $attributes = array()
- ) {
+ string $message,
+ ?string $routingKey = null,
+ ?int $flags = null,
+ array $headers = []
+ ): void {
}
/**
* Set the value for the given key.
*
- * @param string $key Name of the argument to set.
- * @param string|integer $value Value of the argument to set.
+ * @param string $argumentName Name of the argument to set.
+ * @param bool|int|double|string|null $argumentValue Value of the argument to set.
+ */
+ public function setArgument(string $argumentName, $argumentValue): void
+ {
+ }
+
+ /**
+ * Set the value for the given key.
*
- * @return boolean TRUE on success or FALSE on failure.
+ * @param string $argumentName Name of the argument to remove.
*/
- public function setArgument($key, $value)
+ public function removeArgument(string $argumentName): void
{
}
@@ -196,35 +223,29 @@ public function setArgument($key, $value)
* Set all arguments on the exchange.
*
* @param array $arguments An array of key/value pairs of arguments.
- *
- * @return boolean TRUE on success or FALSE on failure.
*/
- public function setArguments(array $arguments)
+ public function setArguments(array $arguments): void
{
}
/**
* Set the flags on an exchange.
*
- * @param integer|null $flags A bitmask of flags. This call currently only
- * considers the following flags:
- * AMQP_DURABLE, AMQP_PASSIVE
- * (and AMQP_DURABLE, if librabbitmq version >= 0.5.3)
- *
- * @return void
+ * @param integer $flags A bitmask of flags. This call currently only
+ * considers the following flags:
+ * AMQP_DURABLE, AMQP_PASSIVE
+ * (and AMQP_DURABLE, if librabbitmq version >= 0.5.3)
*/
- public function setFlags($flags)
+ public function setFlags(?int $flags): void
{
}
/**
* Set the name of the exchange.
*
- * @param string $exchange_name The name of the exchange to set as string.
- *
- * @return void
+ * @param string|null $exchangeName The name of the exchange to set as string.
*/
- public function setName($exchange_name)
+ public function setName(?string $exchangeName): void
{
}
@@ -234,29 +255,23 @@ public function setName($exchange_name)
* Set the type of the exchange. This can be any of AMQP_EX_TYPE_DIRECT,
* AMQP_EX_TYPE_FANOUT, AMQP_EX_TYPE_HEADERS or AMQP_EX_TYPE_TOPIC.
*
- * @param string $exchange_type The type of exchange as a string.
- *
- * @return void
+ * @param string|null $exchangeType The type of exchange as a string.
*/
- public function setType($exchange_type)
+ public function setType(?string $exchangeType): void
{
}
/**
* Get the AMQPChannel object in use
- *
- * @return AMQPChannel
*/
- public function getChannel()
+ public function getChannel(): AMQPChannel
{
}
/**
* Get the AMQPConnection object in use
- *
- * @return AMQPConnection
*/
- public function getConnection()
+ public function getConnection(): AMQPConnection
{
}
}
diff --git a/stubs/AMQPQueue.php b/stubs/AMQPQueue.php
index a46b7829..18e95d25 100644
--- a/stubs/AMQPQueue.php
+++ b/stubs/AMQPQueue.php
@@ -5,6 +5,37 @@
*/
class AMQPQueue
{
+ private AMQPConnection $connection;
+
+ private AMQPChannel $channel;
+
+ private ?string $name = null;
+
+ private ?string $consumerTag = null;
+
+ private bool $passive = false;
+
+ private bool $durable = false;
+
+ private bool $exclusive = false;
+
+ private bool $autoDelete = true;
+
+ private array $arguments = [];
+
+ /**
+ * Create an instance of an AMQPQueue object.
+ *
+ * @param AMQPChannel $channel The amqp channel to use.
+ *
+ * @throws AMQPQueueException When amqp_channel is not connected to a
+ * broker.
+ * @throws AMQPConnectionException If the connection to the broker was lost.
+ */
+ public function __construct(AMQPChannel $channel)
+ {
+ }
+
/**
* Acknowledge the receipt of a message.
*
@@ -12,126 +43,115 @@ class AMQPQueue
* without the AMQP_AUTOACK flag through AMQPQueue::get() or
* AMQPQueue::consume()
*
- * @param integer $delivery_tag The message delivery tag of which to
- * acknowledge receipt.
- * @param integer $flags The only valid flag that can be passed is
- * AMQP_MULTIPLE.
- *
- * @throws AMQPChannelException If the channel is not open.
+ * @param integer $deliveryTag The message delivery tag of which to
+ * acknowledge receipt.
+ * @param integer $flags The only valid flag that can be passed is
+ * AMQP_MULTIPLE.
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return boolean
+ * @throws AMQPChannelException If the channel is not open.
*/
- public function ack($delivery_tag, $flags = AMQP_NOPARAM)
+ public function ack(int $deliveryTag, ?int $flags = null): void
{
}
/**
* Bind the given queue to a routing key on an exchange.
*
- * @param string $exchange_name Name of the exchange to bind to.
- * @param string $routing_key Pattern or routing key to bind with.
- * @param array $arguments Additional binding arguments.
- *
- * @throws AMQPChannelException If the channel is not open.
+ * @param string $exchangeName Name of the exchange to bind to.
+ * @param string $routingKey Pattern or routing key to bind with.
+ * @param array $arguments Additional binding arguments.
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return boolean
+ * @throws AMQPChannelException If the channel is not open.
*/
- public function bind($exchange_name, $routing_key = null, array $arguments = array())
+ public function bind(string $exchangeName, ?string $routingKey = null, array $arguments = []): void
{
}
/**
* Cancel a queue that is already bound to an exchange and routing key.
*
- * @param string $consumer_tag The consumer tag cancel. If no tag provided,
- * or it is empty string, the latest consumer
- * tag on this queue will be used and after
- * successful request it will set to null.
- * If it also empty, no `basic.cancel`
- * request will be sent. When consumer_tag give
- * and it equals to latest consumer_tag on queue,
- * it will be interpreted as latest consumer_tag usage.
- *
- * @throws AMQPChannelException If the channel is not open.
+ * @param string $consumerTag The consumer tag to cancel. If no tag is provided,
+ * or it is empty string, the latest consumer
+ * tag on this queue will be taken and after
+ * the successful cancellation request it will set to null.
+ * If the consumer_tag parameter is empty and the latest
+ * consumer tag is empty, no `basic.cancel` request will be
+ * sent.
+ * If either the consumer tag passed matches the latest tag
+ * or no consumer tag was passed and the latest tag was used
+ * the internal consumer tag will be set to null, so that
+ * `AMQPQueue::getConsumerTag()` will return null afterwards.
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return bool;
+ * @throws AMQPChannelException If the channel is not open.
*/
- public function cancel($consumer_tag = '')
+ public function cancel(string $consumerTag = ''): void
{
}
/**
- * Create an instance of an AMQPQueue object.
+ * Consume messages from a queue.
*
- * @param AMQPChannel $amqp_channel The amqp channel to use.
+ * Blocking function that will retrieve the next message from the queue as
+ * it becomes available and will pass it off to the callback.
*
- * @throws AMQPQueueException When amqp_channel is not connected to a
- * broker.
+ * @param callable|null $callback A callback function to which the
+ * consumed message will be passed. The
+ * function must accept at a minimum
+ * one parameter, an AMQPEnvelope object,
+ * and an optional second parameter
+ * the AMQPQueue object from which callback
+ * was invoked. The AMQPQueue::consume() will
+ * not return the processing thread back to
+ * the PHP script until the callback
+ * function returns FALSE.
+ * If the callback is omitted or null is passed,
+ * then the messages delivered to this client will
+ * be made available to the first real callback
+ * registered. That allows one to have a single
+ * callback consuming from multiple queues.
+ * @param integer $flags A bitmask of any of the flags: AMQP_AUTOACK,
+ * AMQP_JUST_CONSUME. Note: when AMQP_JUST_CONSUME
+ * flag used all other flags are ignored and
+ * $consumerTag parameter has no sense.
+ * AMQP_JUST_CONSUME flag prevent from sending
+ * `basic.consume` request and just run $callback
+ * if it provided. Calling method with empty $callback
+ * and AMQP_JUST_CONSUME makes no sense.
+ * @param string|null $consumerTag A string describing this consumer. Used
+ * for canceling subscriptions with cancel().
+ *
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
+ * @throws AMQPEnvelopeException When no queue found for envelope.
+ * @throws AMQPQueueException If timeout occurs or queue is not exists.
*/
- public function __construct(AMQPChannel $amqp_channel)
+ public function consume(callable $callback = null, ?int $flags = null, ?string $consumerTag = null): void
{
}
/**
- * Consume messages from a queue.
- *
- * Blocking function that will retrieve the next message from the queue as
- * it becomes available and will pass it off to the callback.
+ * Declare a new queue on the broker.
*
- * @param callable | null $callback A callback function to which the
- * consumed message will be passed. The
- * function must accept at a minimum
- * one parameter, an AMQPEnvelope object,
- * and an optional second parameter
- * the AMQPQueue object from which callback
- * was invoked. The AMQPQueue::consume() will
- * not return the processing thread back to
- * the PHP script until the callback
- * function returns FALSE.
- * If the callback is omitted or null is passed,
- * then the messages delivered to this client will
- * be made available to the first real callback
- * registered. That allows one to have a single
- * callback consuming from multiple queues.
- * @param integer $flags A bitmask of any of the flags: AMQP_AUTOACK,
- * AMQP_JUST_CONSUME. Note: when AMQP_JUST_CONSUME
- * flag used all other flags are ignored and
- * $consumerTag parameter has no sense.
- * AMQP_JUST_CONSUME flag prevent from sending
- * `basic.consume` request and just run $callback
- * if it provided. Calling method with empty $callback
- * and AMQP_JUST_CONSUME makes no sense.
- * @param string $consumerTag A string describing this consumer. Used
- * for canceling subscriptions with cancel().
- *
- * @throws AMQPChannelException If the channel is not open.
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
- * @throws AMQPEnvelopeException When no queue found for envelope.
- * @throws AMQPQueueException If timeout occurs or queue is not exists.
+ * @throws AMQPQueueException On failure.
*
- * @return void
+ * @return integer the message count.
*/
- public function consume(
- callable $callback = null,
- $flags = AMQP_NOPARAM,
- $consumerTag = null
- ) {
+ public function declareQueue(): int
+ {
}
/**
* Declare a new queue on the broker.
*
- * @throws AMQPChannelException If the channel is not open.
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
- * @throws AMQPQueueException On failure.
+ * @throws AMQPQueueException On failure.
*
* @return integer the message count.
*/
- public function declareQueue()
+ public function declare(): int
{
}
@@ -140,17 +160,17 @@ public function declareQueue()
*
* This includes its entire contents of unread or unacknowledged messages.
*
- * @param integer $flags Optionally AMQP_IFUNUSED can be specified
- * to indicate the queue should not be
- * deleted until no clients are connected to
- * it.
+ * @param integer $flags Optionally AMQP_IFUNUSED can be specified
+ * to indicate the queue should not be
+ * deleted until no clients are connected to
+ * it.
*
- * @throws AMQPChannelException If the channel is not open.
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
*
* @return integer The number of deleted messages.
*/
- public function delete($flags = AMQP_NOPARAM)
+ public function delete(?int $flags = null): int
{
}
@@ -158,7 +178,7 @@ public function delete($flags = AMQP_NOPARAM)
* Retrieve the next message from the queue.
*
* Retrieve the next available message from the queue. If no messages are
- * present in the queue, this function will return FALSE immediately. This
+ * present in the queue, this function will return NULL immediately. This
* is a non blocking alternative to the AMQPQueue::consume() method.
* Currently, the only supported flag for the flags parameter is
* AMQP_AUTOACK. If this flag is passed in, then the message returned will
@@ -171,35 +191,11 @@ public function delete($flags = AMQP_NOPARAM)
* value is not provided, it will use the
* value of ini-setting amqp.auto_ack.
*
- * @throws AMQPChannelException If the channel is not open.
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
- * @throws AMQPQueueException If queue is not exist.
- *
- * @return AMQPEnvelope|boolean
- */
- public function get($flags = AMQP_NOPARAM)
- {
- }
-
- /**
- * Get the argument associated with the given key.
- *
- * @param string $key The key to look up.
- *
- * @return string|integer|boolean The string or integer value associated
- * with the given key, or false if the key
- * is not set.
- */
- public function getArgument($key)
- {
- }
-
- /**
- * Get all set arguments as an array of key/value pairs.
- *
- * @return array An array containing all of the set key/value pairs.
+ * @throws AMQPQueueException If queue is not exist.
*/
- public function getArguments()
+ public function get(?int $flags = null): ?AMQPEnvelope
{
}
@@ -209,16 +205,16 @@ public function getArguments()
* @return int An integer bitmask of all the flags currently set on this
* exchange object.
*/
- public function getFlags()
+ public function getFlags(): int
{
}
/**
* Get the configured name.
*
- * @return string The configured name as a string.
+ * @return string|null The configured name as a string.
*/
- public function getName()
+ public function getName(): ?string
{
}
@@ -235,17 +231,14 @@ public function getName()
* behavior of calling this method while connected to any other broker is
* undefined.
*
- * @param integer $delivery_tag Delivery tag of last message to reject.
- * @param integer $flags AMQP_REQUEUE to requeue the message(s),
- * AMQP_MULTIPLE to nack all previous
- * unacked messages as well.
- *
- * @throws AMQPChannelException If the channel is not open.
+ * @param integer $deliveryTag Delivery tag of last message to reject.
+ * @param integer $flags AMQP_REQUEUE to requeue the message(s),
+ * AMQP_MULTIPLE to nack all previous
+ * unacked messages as well.
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return boolean
+ * @throws AMQPChannelException If the channel is not open.
*/
- public function nack($delivery_tag, $flags = AMQP_NOPARAM)
+ public function nack(int $deliveryTag, ?int $flags = null): void
{
}
@@ -258,39 +251,71 @@ public function nack($delivery_tag, $flags = AMQP_NOPARAM)
* AMQPQueue::consume() and AMQPQueue::get() and using the AMQP_AUTOACK
* flag are not eligible.
*
- * @param integer $delivery_tag Delivery tag of the message to reject.
- * @param integer $flags AMQP_REQUEUE to requeue the message(s).
- *
- * @throws AMQPChannelException If the channel is not open.
+ * @param integer $deliveryTag Delivery tag of the message to reject.
+ * @param integer $flags AMQP_REQUEUE to requeue the message(s).
* @throws AMQPConnectionException If the connection to the broker was lost.
+ * @throws AMQPChannelException If the channel is not open.
+ */
+ public function reject(int $deliveryTag, ?int $flags = null): void
+ {
+ }
+
+ /**
+ * Recover unacknowledged messages delivered to the current consumer.
*
- * @return boolean
+ * Recover all the unacknowledged messages delivered to the current consumer.
+ * If $requeue is true, the broker can redeliver the messages to different
+ * consumers. If $requeue is FALSE, it can only redeliver it to the current
+ * consumer. RabbitMQ does not implement $request = false.
+ * This method exposes `basic.recover` from the AMQP spec.
+ *
+ * @param bool $requeue If TRUE, deliver to any consumer, if FALSE, deliver to the current consumer only
+ * @throws AMQPConnectionException If the connection to the broker was lost.
+ * @throws AMQPChannelException If the channel is not open.
*/
- public function reject($delivery_tag, $flags = AMQP_NOPARAM)
+ public function recover(bool $requeue = true): void
{
}
/**
* Purge the contents of a queue.
*
- * @throws AMQPChannelException If the channel is not open.
+ * Returns the number of purged messages
+ *
+ * @throws AMQPChannelException If the channel is not open.
* @throws AMQPConnectionException If the connection to the broker was lost.
+ */
+ public function purge(): int
+ {
+ }
+
+ /**
+ * Get the argument associated with the given key.
*
- * @return boolean
+ * @param string $argumentName The key to look up.
+ * @throws AMQPQueueException If key does not exist
+ * @return bool|int|double|string|null|array|AMQPValue|AMQPDecimal|AMQPTimestamp
*/
- public function purge()
+ public function getArgument(string $argumentName)
{
}
/**
* Set a queue argument.
*
- * @param string $key The key to set.
- * @param mixed $value The value to set.
+ * @param string $argumentName The argument name to set.
+ * @param bool|int|double|string|null|array|AMQPValue|AMQPDecimal|AMQPTimestamp $argumentValue The argument value to set.
+ */
+ public function setArgument(string $argumentName, $argumentValue): void
+ {
+ }
+
+ /**
+ * Set a queue argument.
*
- * @return boolean
+ * @param string $argumentName The argument name to set.
*/
- public function setArgument($key, $value)
+ public function removeArgument(string $argumentName): void
{
}
@@ -299,92 +324,83 @@ public function setArgument($key, $value)
*
* All other argument settings will be wiped.
*
- * @param array $arguments An array of key/value pairs of arguments.
+ * @param array $arguments An array of name/value pairs of arguments.
+ */
+ public function setArguments(array $arguments): void
+ {
+ }
+
+ /**
+ * Get all set arguments as an array of key/value pairs.
*
- * @return boolean
+ * @return array An array containing all the set key/value pairs.
*/
- public function setArguments(array $arguments)
+ public function getArguments(): array
{
}
/**
* Check whether a queue has specific argument.
*
- * @param string $key The key to check.
+ * @param string $argumentName The argument name to check.
*
* @return boolean
*/
- public function hasArgument($key)
+ public function hasArgument(string $argumentName): bool
{
}
/**
* Set the flags on the queue.
*
- * @param integer $flags A bitmask of flags:
- * AMQP_DURABLE, AMQP_PASSIVE,
- * AMQP_EXCLUSIVE, AMQP_AUTODELETE.
- *
- * @return boolean
+ * @param integer|null $flags A bitmask of flags:
+ * AMQP_DURABLE, AMQP_PASSIVE,
+ * AMQP_EXCLUSIVE, AMQP_AUTODELETE.
*/
- public function setFlags($flags)
+ public function setFlags(?int $flags): void
{
}
/**
* Set the queue name.
*
- * @param string $queue_name The name of the queue.
- *
- * @return boolean
+ * @param string $name The name of the queue.
*/
- public function setName($queue_name)
+ public function setName(string $name): void
{
}
/**
* Remove a routing key binding on an exchange from the given queue.
*
- * @param string $exchange_name The name of the exchange on which the
- * queue is bound.
- * @param string $routing_key The binding routing key used by the
- * queue.
- * @param array $arguments Additional binding arguments.
- *
- * @throws AMQPChannelException If the channel is not open.
+ * @param string $exchangeName The name of the exchange on which the queue is bound.
+ * @param string $routingKey The binding routing key used by the
+ * @param array $arguments Additional binding arguments.
* @throws AMQPConnectionException If the connection to the broker was lost.
- *
- * @return boolean
+ * @throws AMQPChannelException If the channel is not open.
*/
- public function unbind($exchange_name, $routing_key = null, array $arguments = array())
+ public function unbind(string $exchangeName, ?string $routingKey = null, array $arguments = []): void
{
}
/**
* Get the AMQPChannel object in use
- *
- * @return AMQPChannel
*/
- public function getChannel()
+ public function getChannel(): AMQPChannel
{
}
/**
* Get the AMQPConnection object in use
- *
- * @return AMQPConnection
*/
- public function getConnection()
+ public function getConnection(): AMQPConnection
{
}
/**
* Get latest consumer tag. If no consumer available or the latest on was canceled null will be returned.
- *
- * @return string | null
*/
- public function getConsumerTag()
+ public function getConsumerTag(): ?string
{
}
-
}
diff --git a/stubs/AMQPTimestamp.php b/stubs/AMQPTimestamp.php
index 4b8d9897..0e27d538 100644
--- a/stubs/AMQPTimestamp.php
+++ b/stubs/AMQPTimestamp.php
@@ -2,28 +2,39 @@
/**
* stub class representing AMQPTimestamp from pecl-amqp
+ *
+ * @readonly
*/
-final class AMQPTimestamp
+final /* readonly */ class AMQPTimestamp implements AMQPValue
{
- const MIN = "0";
- const MAX = "18446744073709551616";
+ /**
+ * @var float
+ */
+ public const MIN = 0.0;
/**
- * @param string $timestamp
- *
- * @throws AMQPExchangeValue
+ * @var float
*/
- public function __construct($timestamp)
+ public const MAX = 18446744073709551616;
+
+ private float $timestamp;
+
+ /**
+ * @throws AMQPValueException
+ */
+ public function __construct(float $timestamp)
+ {
+ }
+
+ public function __toString(): string
{
}
- /** @return string */
- public function getTimestamp()
+ public function getTimestamp(): float
{
}
- /** @return string */
- public function __toString()
+ public function toAmqpValue()
{
}
}
diff --git a/stubs/AMQPValue.php b/stubs/AMQPValue.php
new file mode 100644
index 00000000..f1a2205a
--- /dev/null
+++ b/stubs/AMQPValue.php
@@ -0,0 +1,12 @@
+
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
-$channel1 = new AMQPChannel($connection);
+$channel1 = new AMQPChannel($cnn);
$q1 = new AMQPQueue($channel1);
-$q1->setName('q1-' . microtime(true));
+$q1->setName('q1-' . bin2hex(random_bytes(32)));
$q1->declareQueue();
-$channel2 = new AMQPChannel($connection);
+$channel2 = new AMQPChannel($cnn);
$q2_0 = new AMQPQueue($channel2);
-$q2_0->setName('q2.0-' . microtime(true));
+$q2_0->setName('q2.0-' . bin2hex(random_bytes(32)));
$q2_0->declareQueue();
$q2_1 = new AMQPQueue($channel2);
-$q2_1->setName('q2.1-' . microtime(true));
+$q2_1->setName('q2.1-' . bin2hex(random_bytes(32)));
$q2_1->declareQueue();
@@ -72,10 +74,10 @@ Channel holds consumer: c1: 1, c2: 2
Consumers belongs to their channels:
c1:
- test-consumer-0: q1-%f
+ test-consumer-0: q1-%s
c2:
- test-consumer-2-0: q2.0-%f
- test-consumer-2-1: q2.1-%f
+ test-consumer-2-0: q2.0-%s
+ test-consumer-2-1: q2.1-%s
Consumer removed after canceling: c1: 0, c2: 2
Consumer still stored after source variable been destroyed: c1: 0, c2: 2
diff --git a/tests/004-queue-consume-nested.phpt b/tests/004-queue-consume-nested.phpt
index e9965dbf..c0f93155 100644
--- a/tests/004-queue-consume-nested.phpt
+++ b/tests/004-queue-consume-nested.phpt
@@ -1,21 +1,22 @@
--TEST--
AMQPQueue - nested consumers
--SKIPIF--
-
+
--FILE--
setName('ex1-' . microtime(true));
+ $ex1->setName('ex1-' . bin2hex(random_bytes(32)));
$ex1->setType(AMQP_EX_TYPE_FANOUT);
$ex1->declareExchange();
$q1 = new AMQPQueue($channel1);
- $q1->setName('q1-' . microtime(true));
+ $q1->setName('q1-' . bin2hex(random_bytes(32)));
$q1->declareQueue();
$q1->bind($ex1->getName());
@@ -36,12 +37,12 @@ function test(AMQPChannel $channel1)
$channel2 = new \AMQPChannel($queue->getConnection());
$ex2 = new AMQPExchange($channel2);
- $ex2->setName('ex2-' . microtime(true));
+ $ex2->setName('ex2-' . bin2hex(random_bytes(32)));
$ex2->setType(AMQP_EX_TYPE_FANOUT);
$ex2->declareExchange();
$q2 = new AMQPQueue($channel2);
- $q2->setName('q2-' . microtime(true));
+ $q2->setName('q2-' . bin2hex(random_bytes(32)));
$q2->declareQueue();
$q2->bind($ex2->getName());
@@ -63,22 +64,24 @@ function test(AMQPChannel $channel1)
});
}
-$connection1 = new AMQPConnection();
-$connection1->connect();
-$channel1 = new AMQPChannel($connection1);
+$cnn1 = new AMQPConnection();
+$cnn1->setHost(getenv('PHP_AMQP_HOST'));
+$cnn1->connect();
+$channel1 = new AMQPChannel($cnn1);
echo 'With default prefetch = 3', PHP_EOL;
test($channel1);
$channel1->close();
$channel1 = null;
-$connection1->disconnect();
-$connection1 = null;
+$cnn1->disconnect();
+$cnn1 = null;
// var_dump($channel1);
-$connection2 = new AMQPConnection();
-$connection2->connect();
+$cnn2 = new AMQPConnection();
+$cnn2->setHost(getenv('PHP_AMQP_HOST'));
+$cnn2->connect();
-$channel2 = new AMQPChannel($connection2);
+$channel2 = new AMQPChannel($cnn2);
$channel2->setPrefetchCount(1);
echo 'With prefetch = 1', PHP_EOL;
test($channel2);
@@ -88,20 +91,20 @@ test($channel2);
?>
--EXPECTF--
With default prefetch = 3
-1: ex1-%f [message 1 - 0] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue
-2: ex1-%f [message 1 - 1] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue
-2: ex1-%f [message 1 - 2] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue
-2: ex1-%f [message 1 - 3] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue
-1: ex2-%f [message 2 - 0] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue
-2: ex2-%f [message 2 - 1] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue
-1: ex2-%f [message 2 - 2] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue
-2: ex2-%f [message 2 - 3] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue
+1: ex1-%s [message 1 - 0] amq.ctag-%s - amq.ctag-%s (q1-%s): valid queue
+2: ex1-%s [message 1 - 1] amq.ctag-%s - amq.ctag-%s (q1-%s): valid queue
+2: ex1-%s [message 1 - 2] amq.ctag-%s - amq.ctag-%s (q1-%s): valid queue
+2: ex1-%s [message 1 - 3] amq.ctag-%s - amq.ctag-%s (q1-%s): valid queue
+1: ex2-%s [message 2 - 0] amq.ctag-%s - amq.ctag-%s (q2-%s): valid queue
+2: ex2-%s [message 2 - 1] amq.ctag-%s - amq.ctag-%s (q2-%s): valid queue
+1: ex2-%s [message 2 - 2] amq.ctag-%s - amq.ctag-%s (q2-%s): valid queue
+2: ex2-%s [message 2 - 3] amq.ctag-%s - amq.ctag-%s (q2-%s): valid queue
With prefetch = 1
-1: ex1-%f [message 1 - 0] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue
-2: ex1-%f [message 1 - 1] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue
-2: ex2-%f [message 2 - 0] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue
-2: ex2-%f [message 2 - 1] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue
-1: ex2-%f [message 2 - 2] amq.ctag-%s - amq.ctag-%s (q2-%f): valid queue
-2: ex%d-%f [message %d - %d] amq.ctag-%s - amq.ctag-%s (q%d-%f): valid queue
-1: ex%d-%f [message %d - %d] amq.ctag-%s - amq.ctag-%s (q%d-%f): valid queue
-2: ex1-%f [message 1 - 3] amq.ctag-%s - amq.ctag-%s (q1-%f): valid queue
+1: ex1-%s [message 1 - 0] amq.ctag-%s - amq.ctag-%s (q1-%s): valid queue
+2: ex1-%s [message 1 - 1] amq.ctag-%s - amq.ctag-%s (q1-%s): valid queue
+2: ex2-%s [message 2 - 0] amq.ctag-%s - amq.ctag-%s (q2-%s): valid queue
+2: ex2-%s [message 2 - 1] amq.ctag-%s - amq.ctag-%s (q2-%s): valid queue
+1: ex2-%s [message 2 - 2] amq.ctag-%s - amq.ctag-%s (q2-%s): valid queue
+2: ex%d-%s [message %d - %d] amq.ctag-%s - amq.ctag-%s (q%d-%s): valid queue
+1: ex%d-%s [message %d - %d] amq.ctag-%s - amq.ctag-%s (q%d-%s): valid queue
+2: ex1-%s [message 1 - 3] amq.ctag-%s - amq.ctag-%s (q1-%s): valid queue
diff --git a/tests/004-queue-consume-orphaned.phpt b/tests/004-queue-consume-orphaned.phpt
index a9d42865..bd2c6194 100644
--- a/tests/004-queue-consume-orphaned.phpt
+++ b/tests/004-queue-consume-orphaned.phpt
@@ -1,23 +1,25 @@
--TEST--
AMQPQueue - orphaned envelope
--SKIPIF--
-
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
-$channel1 = new AMQPChannel($connection);
+$channel1 = new AMQPChannel($cnn);
$ex1 = new AMQPExchange($channel1);
-$ex1->setName('ex1-' . microtime(true));
+$ex1->setName('ex1-' . bin2hex(random_bytes(32)));
$ex1->setType(AMQP_EX_TYPE_FANOUT);
$ex1->declareExchange();
$q1 = new AMQPQueue($channel1);
-$q1->setName('q1-' . microtime(true));
+$q1->setName('q1-' . bin2hex(random_bytes(32)));
$q1->declareQueue();
$q1->bind($ex1->getName());
@@ -34,7 +36,7 @@ $q1->cancel();
$q1 = null;
$q2 = new AMQPQueue($channel1);
-$q2->setName('q1-' . microtime(true));
+$q2->setName('q1-' . bin2hex(random_bytes(32)));
$q2->declareQueue();
$q2->bind($ex1->getName());
@@ -47,7 +49,7 @@ try {
} catch (AMQPEnvelopeException $e) {
echo get_class($e), ': ', $e->getMessage(), ':', PHP_EOL, PHP_EOL;
- var_dump($e->envelope);
+ var_dump($e->getEnvelope());
}
?>
@@ -55,45 +57,45 @@ try {
AMQPEnvelopeException: Orphaned envelope:
object(AMQPEnvelope)#6 (20) {
- ["content_type":"AMQPBasicProperties":private]=>
+ ["contentType":"AMQPBasicProperties":private]=>
string(10) "text/plain"
- ["content_encoding":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["contentEncoding":"AMQPBasicProperties":private]=>
+ NULL
["headers":"AMQPBasicProperties":private]=>
array(0) {
}
- ["delivery_mode":"AMQPBasicProperties":private]=>
+ ["deliveryMode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
- ["correlation_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["reply_to":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["correlationId":"AMQPBasicProperties":private]=>
+ NULL
+ ["replyTo":"AMQPBasicProperties":private]=>
+ NULL
["expiration":"AMQPBasicProperties":private]=>
- string(0) ""
- ["message_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["messageId":"AMQPBasicProperties":private]=>
+ NULL
["timestamp":"AMQPBasicProperties":private]=>
int(0)
["type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["user_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["app_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["cluster_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["userId":"AMQPBasicProperties":private]=>
+ NULL
+ ["appId":"AMQPBasicProperties":private]=>
+ NULL
+ ["clusterId":"AMQPBasicProperties":private]=>
+ NULL
["body":"AMQPEnvelope":private]=>
string(13) "test orphaned"
- ["consumer_tag":"AMQPEnvelope":private]=>
+ ["consumerTag":"AMQPEnvelope":private]=>
string(31) "amq.ctag-%s"
- ["delivery_tag":"AMQPEnvelope":private]=>
+ ["deliveryTag":"AMQPEnvelope":private]=>
int(2)
- ["is_redelivery":"AMQPEnvelope":private]=>
+ ["isRedelivery":"AMQPEnvelope":private]=>
bool(false)
- ["exchange_name":"AMQPEnvelope":private]=>
- string(%d) "ex1-%f"
- ["routing_key":"AMQPEnvelope":private]=>
+ ["exchangeName":"AMQPEnvelope":private]=>
+ string(%d) "ex1-%s"
+ ["routingKey":"AMQPEnvelope":private]=>
string(0) ""
}
diff --git a/tests/amqp_version.phpt b/tests/amqp_version.phpt
new file mode 100644
index 00000000..70061098
--- /dev/null
+++ b/tests/amqp_version.phpt
@@ -0,0 +1,24 @@
+--TEST--
+AMQP extension version constants
+--SKIPIF--
+
+--FILE--
+
+==DONE==
+--EXPECTF--
+string(%d) "%d.%d.%s"
+int(%d)
+int(%d)
+int(%d)
+string(%d) "%S"
+int(%d)
+==DONE==
diff --git a/tests/amqpbasicproperties.phpt b/tests/amqpbasicproperties.phpt
index dc3153a6..35d4c128 100644
--- a/tests/amqpbasicproperties.phpt
+++ b/tests/amqpbasicproperties.phpt
@@ -1,7 +1,9 @@
--TEST--
AMQPBasicProperties
--SKIPIF--
-
+
--FILE--
--EXPECT--
object(AMQPBasicProperties)#1 (14) {
- ["content_type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["content_encoding":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["contentType":"AMQPBasicProperties":private]=>
+ NULL
+ ["contentEncoding":"AMQPBasicProperties":private]=>
+ NULL
["headers":"AMQPBasicProperties":private]=>
array(0) {
}
- ["delivery_mode":"AMQPBasicProperties":private]=>
+ ["deliveryMode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
- ["correlation_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["reply_to":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["correlationId":"AMQPBasicProperties":private]=>
+ NULL
+ ["replyTo":"AMQPBasicProperties":private]=>
+ NULL
["expiration":"AMQPBasicProperties":private]=>
- string(0) ""
- ["message_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["messageId":"AMQPBasicProperties":private]=>
+ NULL
["timestamp":"AMQPBasicProperties":private]=>
- int(0)
+ NULL
["type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["user_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["app_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["cluster_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["userId":"AMQPBasicProperties":private]=>
+ NULL
+ ["appId":"AMQPBasicProperties":private]=>
+ NULL
+ ["clusterId":"AMQPBasicProperties":private]=>
+ NULL
}
AMQPBasicProperties
getContentType():
- string(0) ""
+ NULL
getContentEncoding():
- string(0) ""
+ NULL
getHeaders():
array(0) {
}
@@ -78,55 +80,55 @@ AMQPBasicProperties
getPriority():
int(0)
getCorrelationId():
- string(0) ""
+ NULL
getReplyTo():
- string(0) ""
+ NULL
getExpiration():
- string(0) ""
+ NULL
getMessageId():
- string(0) ""
+ NULL
getTimestamp():
- int(0)
+ NULL
getType():
- string(0) ""
+ NULL
getUserId():
- string(0) ""
+ NULL
getAppId():
- string(0) ""
+ NULL
getClusterId():
- string(0) ""
+ NULL
object(AMQPBasicProperties)#2 (14) {
- ["content_type":"AMQPBasicProperties":private]=>
+ ["contentType":"AMQPBasicProperties":private]=>
string(12) "content_type"
- ["content_encoding":"AMQPBasicProperties":private]=>
+ ["contentEncoding":"AMQPBasicProperties":private]=>
string(16) "content_encoding"
["headers":"AMQPBasicProperties":private]=>
array(1) {
["test"]=>
string(7) "headers"
}
- ["delivery_mode":"AMQPBasicProperties":private]=>
+ ["deliveryMode":"AMQPBasicProperties":private]=>
int(42)
["priority":"AMQPBasicProperties":private]=>
int(24)
- ["correlation_id":"AMQPBasicProperties":private]=>
+ ["correlationId":"AMQPBasicProperties":private]=>
string(14) "correlation_id"
- ["reply_to":"AMQPBasicProperties":private]=>
+ ["replyTo":"AMQPBasicProperties":private]=>
string(8) "reply_to"
["expiration":"AMQPBasicProperties":private]=>
string(10) "expiration"
- ["message_id":"AMQPBasicProperties":private]=>
+ ["messageId":"AMQPBasicProperties":private]=>
string(10) "message_id"
["timestamp":"AMQPBasicProperties":private]=>
int(99999)
["type":"AMQPBasicProperties":private]=>
string(4) "type"
- ["user_id":"AMQPBasicProperties":private]=>
+ ["userId":"AMQPBasicProperties":private]=>
string(7) "user_id"
- ["app_id":"AMQPBasicProperties":private]=>
+ ["appId":"AMQPBasicProperties":private]=>
string(6) "app_id"
- ["cluster_id":"AMQPBasicProperties":private]=>
+ ["clusterId":"AMQPBasicProperties":private]=>
string(10) "cluster_id"
}
AMQPBasicProperties
diff --git a/tests/amqpbasicproperties_nullability.phpt b/tests/amqpbasicproperties_nullability.phpt
new file mode 100644
index 00000000..8a172cab
--- /dev/null
+++ b/tests/amqpbasicproperties_nullability.phpt
@@ -0,0 +1,97 @@
+--TEST--
+AMQPBasicProperties - explicit nullability
+--SKIPIF--
+
+--FILE--
+ 'headers'),
+ 42,
+ 24,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null
+);
+var_dump($props);
+dump_methods($props);
+
+
+?>
+--EXPECT--
+object(AMQPBasicProperties)#1 (14) {
+ ["contentType":"AMQPBasicProperties":private]=>
+ NULL
+ ["contentEncoding":"AMQPBasicProperties":private]=>
+ NULL
+ ["headers":"AMQPBasicProperties":private]=>
+ array(1) {
+ ["test"]=>
+ string(7) "headers"
+ }
+ ["deliveryMode":"AMQPBasicProperties":private]=>
+ int(42)
+ ["priority":"AMQPBasicProperties":private]=>
+ int(24)
+ ["correlationId":"AMQPBasicProperties":private]=>
+ NULL
+ ["replyTo":"AMQPBasicProperties":private]=>
+ NULL
+ ["expiration":"AMQPBasicProperties":private]=>
+ NULL
+ ["messageId":"AMQPBasicProperties":private]=>
+ NULL
+ ["timestamp":"AMQPBasicProperties":private]=>
+ NULL
+ ["type":"AMQPBasicProperties":private]=>
+ NULL
+ ["userId":"AMQPBasicProperties":private]=>
+ NULL
+ ["appId":"AMQPBasicProperties":private]=>
+ NULL
+ ["clusterId":"AMQPBasicProperties":private]=>
+ NULL
+}
+AMQPBasicProperties
+ getContentType():
+ NULL
+ getContentEncoding():
+ NULL
+ getHeaders():
+ array(1) {
+ ["test"]=>
+ string(7) "headers"
+}
+ getDeliveryMode():
+ int(42)
+ getPriority():
+ int(24)
+ getCorrelationId():
+ NULL
+ getReplyTo():
+ NULL
+ getExpiration():
+ NULL
+ getMessageId():
+ NULL
+ getTimestamp():
+ NULL
+ getType():
+ NULL
+ getUserId():
+ NULL
+ getAppId():
+ NULL
+ getClusterId():
+ NULL
diff --git a/tests/amqpchannel_basicRecover.phpt b/tests/amqpchannel_basicRecover.phpt
index 6e7b6c4c..ac3193a3 100644
--- a/tests/amqpchannel_basicRecover.phpt
+++ b/tests/amqpchannel_basicRecover.phpt
@@ -2,18 +2,19 @@
AMQPChannel::basicRecover
--SKIPIF--
--FILE--
connect();
+$cnn_1 = new AMQPConnection();
+$cnn_1->setHost(getenv('PHP_AMQP_HOST'));
+$cnn_1->connect();
-$channel_1 = new AMQPChannel($connection_1);
+$channel_1 = new AMQPChannel($cnn_1);
$channel_1->setPrefetchCount(5);
$exchange_1 = new AMQPExchange($channel_1);
@@ -45,11 +46,11 @@ $queue_1->consume(function(AMQPEnvelope $e, AMQPQueue $q) use (&$consume) {
});
$queue_1->cancel(); // we have to do that to prevent redelivering to the same consumer
-$connection_2 = new AMQPConnection();
-$connection_2->setReadTimeout(1);
-
-$connection_2->connect();
-$channel_2 = new AMQPChannel($connection_2);
+$cnn_2 = new AMQPConnection();
+$cnn_2->setReadTimeout(1);
+$cnn_2->setHost(getenv('PHP_AMQP_HOST'));
+$cnn_2->connect();
+$channel_2 = new AMQPChannel($cnn_2);
$channel_2->setPrefetchCount(8);
@@ -70,7 +71,7 @@ try {
echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL;
}
$queue_2->cancel();
-//var_dump($connection_2, $channel_2);die;
+//var_dump($cnn_2, $channel_2);die;
// yes, we do it repeatedly, basic.recover works in a slightly different way than it looks like. As it said,
diff --git a/tests/amqpchannel_close.phpt b/tests/amqpchannel_close.phpt
index 5f5aa4d4..d3d8a964 100644
--- a/tests/amqpchannel_close.phpt
+++ b/tests/amqpchannel_close.phpt
@@ -2,18 +2,18 @@
AMQPChannel::close
--SKIPIF--
--FILE--
connect();
+$cnn_1 = new AMQPConnection();
+$cnn_1->setHost(getenv('PHP_AMQP_HOST'));
+$cnn_1->connect();
-$channel_1 = new AMQPChannel($connection_1);
+$channel_1 = new AMQPChannel($cnn_1);
$channel_1->setPrefetchCount(5);
$exchange_1 = new AMQPExchange($channel_1);
diff --git a/tests/amqpchannel_confirmSelect.phpt b/tests/amqpchannel_confirmSelect.phpt
index afa3265e..d363ffb6 100644
--- a/tests/amqpchannel_confirmSelect.phpt
+++ b/tests/amqpchannel_confirmSelect.phpt
@@ -2,13 +2,13 @@
AMQPChannel::confirmSelect()
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_construct_basic.phpt b/tests/amqpchannel_construct_basic.phpt
index 2714111e..dc1ae3b3 100644
--- a/tests/amqpchannel_construct_basic.phpt
+++ b/tests/amqpchannel_construct_basic.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPChannel constructor
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
echo get_class($ch) . "\n";
diff --git a/tests/amqpchannel_construct_ini_global_prefetch_count.phpt b/tests/amqpchannel_construct_ini_global_prefetch_count.phpt
index 3cda5442..f1876592 100644
--- a/tests/amqpchannel_construct_ini_global_prefetch_count.phpt
+++ b/tests/amqpchannel_construct_ini_global_prefetch_count.phpt
@@ -2,15 +2,15 @@
AMQPChannel - constructor with amqp.global_prefetch_count ini value set
--SKIPIF--
--INI--
amqp.global_prefetch_count=123
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_construct_ini_global_prefetch_size.phpt b/tests/amqpchannel_construct_ini_global_prefetch_size.phpt
index 82b95932..b84e3f99 100644
--- a/tests/amqpchannel_construct_ini_global_prefetch_size.phpt
+++ b/tests/amqpchannel_construct_ini_global_prefetch_size.phpt
@@ -3,16 +3,19 @@ AMQPChannel - constructor with amqp.global_prefetch_size ini value set
--SKIPIF--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ch->setGlobalPrefetchSize(123);
} catch (AMQPConnectionException $e) {
if ($e->getCode() === 540 && strpos($e->getMessage(), "NOT_IMPLEMENTED") !== false) {
- print "skip";
+ print "skip prefetch size is not supported by the AMQP server";
}
}
}
@@ -22,6 +25,7 @@ amqp.global_prefetch_size=123
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_construct_ini_prefetch_count.phpt b/tests/amqpchannel_construct_ini_prefetch_count.phpt
index def1c3f6..1919362d 100644
--- a/tests/amqpchannel_construct_ini_prefetch_count.phpt
+++ b/tests/amqpchannel_construct_ini_prefetch_count.phpt
@@ -2,15 +2,15 @@
AMQPChannel - constructor with amqp.prefetch_count ini value set
--SKIPIF--
--INI--
amqp.prefetch_count=123
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_construct_ini_prefetch_size.phpt b/tests/amqpchannel_construct_ini_prefetch_size.phpt
index fc999d1c..6a1ad65a 100644
--- a/tests/amqpchannel_construct_ini_prefetch_size.phpt
+++ b/tests/amqpchannel_construct_ini_prefetch_size.phpt
@@ -3,16 +3,19 @@ AMQPChannel - constructor with amqp.prefetch_size ini value set
--SKIPIF--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ch->setPrefetchSize(123);
} catch (AMQPConnectionException $e) {
if ($e->getCode() === 540 && strpos($e->getMessage(), "NOT_IMPLEMENTED") !== false) {
- print "skip";
+ print "skip prefetch size is not supported by the AMQP server";
}
}
}
@@ -22,6 +25,7 @@ amqp.prefetch_size=123
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_getChannelId.phpt b/tests/amqpchannel_getChannelId.phpt
index 0990b633..00e7da89 100644
--- a/tests/amqpchannel_getChannelId.phpt
+++ b/tests/amqpchannel_getChannelId.phpt
@@ -2,13 +2,13 @@
AMQPChannel::getChannelId
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_get_connection.phpt b/tests/amqpchannel_get_connection.phpt
index 29df770b..8d3f2c07 100644
--- a/tests/amqpchannel_get_connection.phpt
+++ b/tests/amqpchannel_get_connection.phpt
@@ -2,13 +2,13 @@
AMQPChannel getConnection test
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_multi_channel_connection.phpt b/tests/amqpchannel_multi_channel_connection.phpt
index dfc1323e..735352bb 100644
--- a/tests/amqpchannel_multi_channel_connection.phpt
+++ b/tests/amqpchannel_multi_channel_connection.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection - multiple AMQPChannels per AMQPConnection
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_set_global_prefetch_count.phpt b/tests/amqpchannel_set_global_prefetch_count.phpt
index a0a2ee42..01d3fd7d 100644
--- a/tests/amqpchannel_set_global_prefetch_count.phpt
+++ b/tests/amqpchannel_set_global_prefetch_count.phpt
@@ -2,13 +2,13 @@
AMQPChannel::setGlobalPrefetchCount
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_set_global_prefetch_size.phpt b/tests/amqpchannel_set_global_prefetch_size.phpt
index 46d8b04a..f9dbd975 100644
--- a/tests/amqpchannel_set_global_prefetch_size.phpt
+++ b/tests/amqpchannel_set_global_prefetch_size.phpt
@@ -3,16 +3,19 @@ AMQPChannel::setGlobalPrefetchSize
--SKIPIF--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ch->setGlobalPrefetchSize(123);
} catch (AMQPConnectionException $e) {
if ($e->getCode() === 540 && strpos($e->getMessage(), "NOT_IMPLEMENTED") !== false) {
- print "skip";
+ print "skip prefetch size is not supported by the AMQP server";
}
}
}
@@ -20,6 +23,7 @@ if (!extension_loaded("amqp")) {
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_set_prefetch_and_global_prefetch_count.phpt b/tests/amqpchannel_set_prefetch_and_global_prefetch_count.phpt
index 1034a0ed..30e956a9 100644
--- a/tests/amqpchannel_set_prefetch_and_global_prefetch_count.phpt
+++ b/tests/amqpchannel_set_prefetch_and_global_prefetch_count.phpt
@@ -2,13 +2,13 @@
AMQPChannel - Setting both consumer and channel wide prefetch counts.
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_set_prefetch_and_global_prefetch_size.phpt b/tests/amqpchannel_set_prefetch_and_global_prefetch_size.phpt
index ef01d0c4..9dd8724b 100644
--- a/tests/amqpchannel_set_prefetch_and_global_prefetch_size.phpt
+++ b/tests/amqpchannel_set_prefetch_and_global_prefetch_size.phpt
@@ -3,17 +3,20 @@ AMQPChannel - Setting both consumer and channel wide prefetch sizes.
--SKIPIF--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ch->setPrefetchSize(123);
$ch->setGlobalPrefetchSize(123);
} catch (AMQPConnectionException $e) {
if ($e->getCode() === 540 && strpos($e->getMessage(), "NOT_IMPLEMENTED") !== false) {
- print "skip";
+ print "skip prefetch size is not supported by the AMQP server";
}
}
}
@@ -21,6 +24,7 @@ if (!extension_loaded("amqp")) {
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_set_prefetch_count.phpt b/tests/amqpchannel_set_prefetch_count.phpt
index c8faf5cf..2f4b3d1d 100644
--- a/tests/amqpchannel_set_prefetch_count.phpt
+++ b/tests/amqpchannel_set_prefetch_count.phpt
@@ -2,13 +2,13 @@
AMQPChannel::setPrefetchCount
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_set_prefetch_size.phpt b/tests/amqpchannel_set_prefetch_size.phpt
index d4154119..42c410cf 100644
--- a/tests/amqpchannel_set_prefetch_size.phpt
+++ b/tests/amqpchannel_set_prefetch_size.phpt
@@ -3,16 +3,19 @@ AMQPChannel::setPrefetchSize
--SKIPIF--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ch->setPrefetchSize(123);
} catch (AMQPConnectionException $e) {
if ($e->getCode() === 540 && strpos($e->getMessage(), "NOT_IMPLEMENTED") !== false) {
- print "skip";
+ print "skip prefetch size is not supported by the AMQP server";
}
}
}
@@ -20,6 +23,7 @@ if (!extension_loaded("amqp")) {
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpchannel_slots_usage.phpt b/tests/amqpchannel_slots_usage.phpt
index 96d66917..5b09ff18 100644
--- a/tests/amqpchannel_slots_usage.phpt
+++ b/tests/amqpchannel_slots_usage.phpt
@@ -2,13 +2,13 @@
AMQPChannel slots usage
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
echo 'Used channels: ', $cnn->getUsedChannels(), PHP_EOL;
diff --git a/tests/amqpchannel_validation.phpt b/tests/amqpchannel_validation.phpt
new file mode 100644
index 00000000..666371ab
--- /dev/null
+++ b/tests/amqpchannel_validation.phpt
@@ -0,0 +1,68 @@
+--TEST--
+AMQPChannel parameter validation
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+
+$chan = new AMQPChannel($cnn);
+try {
+ $chan->setPrefetchSize(-1);
+} catch (\Throwable $t) {
+ printf("%s: %s\n", get_class($t), $t->getMessage());
+}
+try {
+ $chan->setPrefetchSize(PHP_INT_MAX);
+} catch (\Throwable $t) {
+ printf("%s: %s\n", get_class($t), $t->getMessage());
+}
+try {
+ $chan->setGlobalPrefetchSize(-1);
+} catch (\Throwable $t) {
+ printf("%s: %s\n", get_class($t), $t->getMessage());
+}
+try {
+ $chan->setGlobalPrefetchSize(PHP_INT_MAX);
+} catch (\Throwable $t) {
+ printf("%s: %s\n", get_class($t), $t->getMessage());
+}
+try {
+ $chan->setPrefetchCount(-1);
+} catch (\Throwable $t) {
+ printf("%s: %s\n", get_class($t), $t->getMessage());
+}
+try {
+ $chan->setPrefetchCount(PHP_INT_MAX);
+} catch (\Throwable $t) {
+ printf("%s: %s\n", get_class($t), $t->getMessage());
+}
+try {
+ $chan->setGlobalPrefetchCount(-1);
+} catch (\Throwable $t) {
+ printf("%s: %s\n", get_class($t), $t->getMessage());
+}
+try {
+ $chan->setGlobalPrefetchCount(PHP_INT_MAX);
+} catch (\Throwable $t) {
+ printf("%s: %s\n", get_class($t), $t->getMessage());
+}
+?>
+==DONE==
+--EXPECTF--
+AMQPConnectionException: Parameter 'prefetchSize' must be between 0 and 4294967295.
+AMQPConnectionException: Parameter 'prefetchSize' must be between 0 and 4294967295.
+AMQPConnectionException: Parameter 'globalPrefetchSize' must be between 0 and 4294967295.
+AMQPConnectionException: Parameter 'globalPrefetchSize' must be between 0 and 4294967295.
+AMQPConnectionException: Parameter 'prefetchCount' must be between 0 and 65535.
+AMQPConnectionException: Parameter 'prefetchCount' must be between 0 and 65535.
+AMQPConnectionException: Parameter 'globalPrefetchCount' must be between 0 and 65535.
+AMQPConnectionException: Parameter 'globalPrefetchCount' must be between 0 and 65535.
+==DONE==
\ No newline at end of file
diff --git a/tests/amqpchannel_var_dump.phpt b/tests/amqpchannel_var_dump.phpt
index e56cac33..49c4d4ed 100644
--- a/tests/amqpchannel_var_dump.phpt
+++ b/tests/amqpchannel_var_dump.phpt
@@ -2,13 +2,13 @@
AMQPChannel var_dump
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
@@ -17,7 +17,7 @@ $cnn->disconnect();
var_dump($ch);
?>
---EXPECT--
+--EXPECTF--
object(AMQPChannel)#2 (6) {
["connection":"AMQPChannel":private]=>
object(AMQPConnection)#1 (18) {
@@ -26,45 +26,45 @@ object(AMQPChannel)#2 (6) {
["password":"AMQPConnection":private]=>
string(5) "guest"
["host":"AMQPConnection":private]=>
- string(9) "localhost"
+ string(%d) "%s"
["vhost":"AMQPConnection":private]=>
string(1) "/"
["port":"AMQPConnection":private]=>
int(5672)
- ["read_timeout":"AMQPConnection":private]=>
+ ["readTimeout":"AMQPConnection":private]=>
float(0)
- ["write_timeout":"AMQPConnection":private]=>
+ ["writeTimeout":"AMQPConnection":private]=>
float(0)
- ["connect_timeout":"AMQPConnection":private]=>
+ ["connectTimeout":"AMQPConnection":private]=>
float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
+ ["rpcTimeout":"AMQPConnection":private]=>
float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
+ ["frameMax":"AMQPConnection":private]=>
int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
["heartbeat":"AMQPConnection":private]=>
int(0)
["cacert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["key":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["cert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["verify":"AMQPConnection":private]=>
bool(true)
- ["sasl_method":"AMQPConnection":private]=>
+ ["saslMethod":"AMQPConnection":private]=>
int(0)
- ["connection_name":"AMQPConnection":private]=>
+ ["connectionName":"AMQPConnection":private]=>
NULL
}
- ["prefetch_count":"AMQPChannel":private]=>
+ ["prefetchCount":"AMQPChannel":private]=>
int(3)
- ["prefetch_size":"AMQPChannel":private]=>
+ ["prefetchSize":"AMQPChannel":private]=>
int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
+ ["globalPrefetchCount":"AMQPChannel":private]=>
int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
+ ["globalPrefetchSize":"AMQPChannel":private]=>
int(0)
["consumers":"AMQPChannel":private]=>
array(0) {
@@ -78,45 +78,45 @@ object(AMQPChannel)#2 (6) {
["password":"AMQPConnection":private]=>
string(5) "guest"
["host":"AMQPConnection":private]=>
- string(9) "localhost"
+ string(%d) "%s"
["vhost":"AMQPConnection":private]=>
string(1) "/"
["port":"AMQPConnection":private]=>
int(5672)
- ["read_timeout":"AMQPConnection":private]=>
+ ["readTimeout":"AMQPConnection":private]=>
float(0)
- ["write_timeout":"AMQPConnection":private]=>
+ ["writeTimeout":"AMQPConnection":private]=>
float(0)
- ["connect_timeout":"AMQPConnection":private]=>
+ ["connectTimeout":"AMQPConnection":private]=>
float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
+ ["rpcTimeout":"AMQPConnection":private]=>
float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
+ ["frameMax":"AMQPConnection":private]=>
int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
["heartbeat":"AMQPConnection":private]=>
int(0)
["cacert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["key":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["cert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["verify":"AMQPConnection":private]=>
bool(true)
- ["sasl_method":"AMQPConnection":private]=>
+ ["saslMethod":"AMQPConnection":private]=>
int(0)
- ["connection_name":"AMQPConnection":private]=>
+ ["connectionName":"AMQPConnection":private]=>
NULL
}
- ["prefetch_count":"AMQPChannel":private]=>
+ ["prefetchCount":"AMQPChannel":private]=>
int(3)
- ["prefetch_size":"AMQPChannel":private]=>
+ ["prefetchSize":"AMQPChannel":private]=>
int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
+ ["globalPrefetchCount":"AMQPChannel":private]=>
int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
+ ["globalPrefetchSize":"AMQPChannel":private]=>
int(0)
["consumers":"AMQPChannel":private]=>
array(0) {
diff --git a/tests/amqpconnection_connect_login_failure.phpt b/tests/amqpconnection_connect_login_failure.phpt
index 191fd214..3a9dba0e 100644
--- a/tests/amqpconnection_connect_login_failure.phpt
+++ b/tests/amqpconnection_connect_login_failure.phpt
@@ -1,7 +1,10 @@
--TEST--
AMQPConnection connect login failure
--SKIPIF--
-
+
--FILE--
setLogin('nonexistent-login-'.microtime(true));
-$cnn->setPassword('nonexistent-password-'.microtime(true));
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->setLogin('nonexistent-login-'. bin2hex(random_bytes(32)));
+$cnn->setPassword('nonexistent-password-'. bin2hex(random_bytes(32)));
//var_dump($cnn);
@@ -24,10 +28,8 @@ try {
}
//
echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
-
-// NOTE: in real-world environment (incl. travis ci) "a socket error occurred" happens, but in vagrant environment "connection closed unexpectedly" happens. WTF?
?>
--EXPECTF--
disconnected
-AMQPConnectionException(%d): %s error: %s - Potential login failure.
+AMQPConnectionException(403): %s
disconnected
\ No newline at end of file
diff --git a/tests/amqpconnection_connection_getters.phpt b/tests/amqpconnection_connection_getters.phpt
index e92bc6f7..2fb3c3db 100644
--- a/tests/amqpconnection_connection_getters.phpt
+++ b/tests/amqpconnection_connection_getters.phpt
@@ -2,13 +2,13 @@
AMQPConnection - connection-specific getters
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL;
echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL;
@@ -34,6 +34,7 @@ echo PHP_EOL;
$cnn = new AMQPConnection(array('channel_max' => '10', 'frame_max' => 10240, 'heartbeat' => 10));
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL;
echo 'channel_max: ', var_export($cnn->getMaxChannels(), true), PHP_EOL;
diff --git a/tests/amqpconnection_construct_basic.phpt b/tests/amqpconnection_construct_basic.phpt
index 087eb0fb..3cc5dd39 100644
--- a/tests/amqpconnection_construct_basic.phpt
+++ b/tests/amqpconnection_construct_basic.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection constructor
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
echo get_class($cnn) . "\n";
echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
diff --git a/tests/amqpconnection_construct_ini_read_timeout.phpt b/tests/amqpconnection_construct_ini_read_timeout.phpt
index b108bc30..8ff11596 100644
--- a/tests/amqpconnection_construct_ini_read_timeout.phpt
+++ b/tests/amqpconnection_construct_ini_read_timeout.phpt
@@ -1,12 +1,16 @@
--TEST--
AMQPConnection constructor with amqp.read_timeout ini value set
--SKIPIF--
-
+
--INI--
amqp.read_timeout=202.202
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
var_dump($cnn->getReadTimeout());
?>
--EXPECTF--
diff --git a/tests/amqpconnection_construct_ini_timeout.phpt b/tests/amqpconnection_construct_ini_timeout.phpt
index e600b510..197da239 100644
--- a/tests/amqpconnection_construct_ini_timeout.phpt
+++ b/tests/amqpconnection_construct_ini_timeout.phpt
@@ -1,12 +1,16 @@
--TEST--
AMQPConnection constructor with amqp.timeout ini value set
--SKIPIF--
-
+
--INI--
amqp.timeout=101.101
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
var_dump($cnn->getReadTimeout());
?>
--EXPECTF--
diff --git a/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt b/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt
index 5e0050da..eef96ac2 100644
--- a/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt
+++ b/tests/amqpconnection_construct_ini_timeout_and_read_timeout.phpt
@@ -1,13 +1,17 @@
--TEST--
AMQPConnection constructor with both amqp.timeout and amqp.read_timeout ini values set
--SKIPIF--
-
+
--INI--
amqp.timeout = 101.101
amqp.read_timeout = 202.202
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
var_dump($cnn->getReadTimeout());
?>
--EXPECTF--
diff --git a/tests/amqpconnection_construct_ini_timeout_default.phpt b/tests/amqpconnection_construct_ini_timeout_default.phpt
index e702a095..aef63ac6 100644
--- a/tests/amqpconnection_construct_ini_timeout_default.phpt
+++ b/tests/amqpconnection_construct_ini_timeout_default.phpt
@@ -1,12 +1,16 @@
--TEST--
AMQPConnection constructor with amqp.timeout ini value set in code to it default value
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
var_dump($cnn->getReadTimeout());
?>
--EXPECTF--
diff --git a/tests/amqpconnection_construct_params_by_value.phpt b/tests/amqpconnection_construct_params_by_value.phpt
index fadc9254..d03e2033 100644
--- a/tests/amqpconnection_construct_params_by_value.phpt
+++ b/tests/amqpconnection_construct_params_by_value.phpt
@@ -2,8 +2,9 @@
Params are passed by value in AMQPConnection::__construct()
--SKIPIF--
-
-
+
--FILE--
'custom_connection_name'
];
-$conn = new \AMQPConnection($params);
+$cnn = new AMQPConnection($params);
echo gettype($params['host']) . PHP_EOL;
echo gettype($params['port']) . PHP_EOL;
diff --git a/tests/amqpconnection_construct_with_connect_timeout.phpt b/tests/amqpconnection_construct_with_connect_timeout.phpt
index b89339d1..8bf187e4 100644
--- a/tests/amqpconnection_construct_with_connect_timeout.phpt
+++ b/tests/amqpconnection_construct_with_connect_timeout.phpt
@@ -1,7 +1,11 @@
--TEST--
AMQPConnection constructor with timeout parameter in credentials
--SKIPIF--
-
+
--FILE--
--EXPECTF--
Parameter 'connect_timeout' must be greater than or equal to zero.
-Socket error: could not connect to host.
+Socket error: could not connect to host, request timed out
error: %f
limit: %f
timings OK
diff --git a/tests/amqpconnection_construct_with_connection_name.phpt b/tests/amqpconnection_construct_with_connection_name.phpt
index 4d6915d0..1d8f1b31 100644
--- a/tests/amqpconnection_construct_with_connection_name.phpt
+++ b/tests/amqpconnection_construct_with_connection_name.phpt
@@ -1,7 +1,9 @@
--TEST--
-AMQPConnection constructor with connection_name parameter in creadentials
+AMQPConnection constructor with connection_name parameter in credentials
--SKIPIF--
-
+
--FILE--
+
--FILE--
5,
);
$cnn = new AMQPConnection($credentials);
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
var_dump($cnn);
?>
---EXPECT--
+--EXPECTF--
object(AMQPConnection)#1 (18) {
["login":"AMQPConnection":private]=>
string(5) "guest"
["password":"AMQPConnection":private]=>
string(5) "guest"
["host":"AMQPConnection":private]=>
- string(9) "localhost"
+ string(%d) "%s"
["vhost":"AMQPConnection":private]=>
string(1) "/"
["port":"AMQPConnection":private]=>
int(5672)
- ["read_timeout":"AMQPConnection":private]=>
+ ["readTimeout":"AMQPConnection":private]=>
float(0)
- ["write_timeout":"AMQPConnection":private]=>
+ ["writeTimeout":"AMQPConnection":private]=>
float(0)
- ["connect_timeout":"AMQPConnection":private]=>
+ ["connectTimeout":"AMQPConnection":private]=>
float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
+ ["rpcTimeout":"AMQPConnection":private]=>
float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(10)
- ["frame_max":"AMQPConnection":private]=>
+ ["frameMax":"AMQPConnection":private]=>
int(10240)
+ ["channelMax":"AMQPConnection":private]=>
+ int(10)
["heartbeat":"AMQPConnection":private]=>
int(5)
["cacert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["key":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["cert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["verify":"AMQPConnection":private]=>
bool(true)
- ["sasl_method":"AMQPConnection":private]=>
+ ["saslMethod":"AMQPConnection":private]=>
int(0)
- ["connection_name":"AMQPConnection":private]=>
+ ["connectionName":"AMQPConnection":private]=>
NULL
}
diff --git a/tests/amqpconnection_construct_with_rpc_timeout.phpt b/tests/amqpconnection_construct_with_rpc_timeout.phpt
index 4eb60970..65681900 100644
--- a/tests/amqpconnection_construct_with_rpc_timeout.phpt
+++ b/tests/amqpconnection_construct_with_rpc_timeout.phpt
@@ -1,7 +1,9 @@
--TEST--
-AMQPConnection constructor with rpc_timeout parameter in creadentials
+AMQPConnection constructor with rpc_timeout parameter in credentials
--SKIPIF--
-
+
--FILE--
303.303);
diff --git a/tests/amqpconnection_construct_with_timeout.phpt b/tests/amqpconnection_construct_with_timeout.phpt
index eba2397e..b402cdd9 100644
--- a/tests/amqpconnection_construct_with_timeout.phpt
+++ b/tests/amqpconnection_construct_with_timeout.phpt
@@ -1,7 +1,9 @@
--TEST--
AMQPConnection constructor with timeout parameter in credentials
--SKIPIF--
-
+
--FILE--
101.101);
diff --git a/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt b/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt
index 2f7eca19..6eaf11d5 100644
--- a/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt
+++ b/tests/amqpconnection_construct_with_timeout_and_read_timeout.phpt
@@ -1,7 +1,9 @@
--TEST--
AMQPConnection constructor with both timeout and read_timeout parameters in credentials
--SKIPIF--
-
+
--FILE--
101.101, 'read_timeout' => 202.202);
diff --git a/tests/amqpconnection_construct_with_verify_false.phpt b/tests/amqpconnection_construct_with_verify_false.phpt
new file mode 100644
index 00000000..cb6162f5
--- /dev/null
+++ b/tests/amqpconnection_construct_with_verify_false.phpt
@@ -0,0 +1,14 @@
+--TEST--
+AMQPConnection constructor with verify parameter set to false in $params
+--SKIPIF--
+
+--FILE--
+ false);
+$cnn = new AMQPConnection($params);
+var_dump($cnn->getVerify());
+?>
+--EXPECT--
+bool(false)
diff --git a/tests/amqpconnection_construct_with_write_timeout.phpt b/tests/amqpconnection_construct_with_write_timeout.phpt
index 27e11519..a2a8b586 100644
--- a/tests/amqpconnection_construct_with_write_timeout.phpt
+++ b/tests/amqpconnection_construct_with_write_timeout.phpt
@@ -1,7 +1,9 @@
--TEST--
-AMQPConnection constructor with write_timeout parameter in creadentials
+AMQPConnection constructor with write_timeout parameter in $cnntials
--SKIPIF--
-
+
--FILE--
303.303);
diff --git a/tests/amqpconnection_getUsedChannels.phpt b/tests/amqpconnection_getUsedChannels.phpt
index 17fa5aa5..d8655f1f 100644
--- a/tests/amqpconnection_getUsedChannels.phpt
+++ b/tests/amqpconnection_getUsedChannels.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection::getUsedChannels()
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
echo get_class($cnn), '::getUsedChannels():', $cnn->getUsedChannels(), PHP_EOL;
$cnn->connect();
echo get_class($cnn), '::getUsedChannels():', $cnn->getUsedChannels(), PHP_EOL;
diff --git a/tests/amqpconnection_heartbeat.phpt b/tests/amqpconnection_heartbeat.phpt
index 8717f7ea..6dce9955 100644
--- a/tests/amqpconnection_heartbeat.phpt
+++ b/tests/amqpconnection_heartbeat.phpt
@@ -1,12 +1,17 @@
--TEST--
AMQPConnection - heartbeats support
--SKIPIF--
-
+
--FILE--
$heartbeat);
$cnn = new AMQPConnection($credentials);
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL;
@@ -25,14 +30,12 @@ try {
echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL;
echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL;
echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL;
-
-// NOTE: in real-world environment (incl. travis ci) "a socket error occurred" happens, but in virtual environment "connection closed unexpectedly" happens
?>
---EXPECTF--
+--EXPECTREGEX--
heartbeat: 2
connected: true
persistent: false
-AMQPException(0): Library error: %s
+AMQPConnectionException\(0\): (a socket error occurred|connection closed unexpectedly)
heartbeat: 2
connected: false
persistent: false
diff --git a/tests/amqpconnection_heartbeat_with_consumer.phpt b/tests/amqpconnection_heartbeat_with_consumer.phpt
index df40041a..314edbf3 100644
--- a/tests/amqpconnection_heartbeat_with_consumer.phpt
+++ b/tests/amqpconnection_heartbeat_with_consumer.phpt
@@ -1,20 +1,25 @@
--TEST--
AMQPConnection heartbeats support (with active consumer)
--SKIPIF--
-
+
--FILE--
$heartbeat, 'read_timeout' => $heartbeat * 20);
$cnn = new AMQPConnection($credentials);
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
var_dump($cnn);
$ch = new AMQPChannel($cnn);
-$q_dead_name = 'test.queue.dead.' . microtime(true);
-$q_name = 'test.queue.' . microtime(true);
+$q_dead_name = 'test.queue.dead.' . bin2hex(random_bytes(32));
+$q_name = 'test.queue.' . bin2hex(random_bytes(32));
$e = new AMQPExchange($ch);
@@ -66,36 +71,36 @@ object(AMQPConnection)#1 (18) {
["password":"AMQPConnection":private]=>
string(5) "guest"
["host":"AMQPConnection":private]=>
- string(9) "localhost"
+ string(%d) "%s"
["vhost":"AMQPConnection":private]=>
string(1) "/"
["port":"AMQPConnection":private]=>
int(5672)
- ["read_timeout":"AMQPConnection":private]=>
+ ["readTimeout":"AMQPConnection":private]=>
float(40)
- ["write_timeout":"AMQPConnection":private]=>
+ ["writeTimeout":"AMQPConnection":private]=>
float(0)
- ["connect_timeout":"AMQPConnection":private]=>
+ ["connectTimeout":"AMQPConnection":private]=>
float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
+ ["rpcTimeout":"AMQPConnection":private]=>
float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
+ ["frameMax":"AMQPConnection":private]=>
int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
["heartbeat":"AMQPConnection":private]=>
int(2)
["cacert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["key":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["cert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["verify":"AMQPConnection":private]=>
bool(true)
- ["sasl_method":"AMQPConnection":private]=>
+ ["saslMethod":"AMQPConnection":private]=>
int(0)
- ["connection_name":"AMQPConnection":private]=>
+ ["connectionName":"AMQPConnection":private]=>
NULL
}
Consumed: test message 1 (should be dead lettered)
diff --git a/tests/amqpconnection_heartbeat_with_persistent.phpt b/tests/amqpconnection_heartbeat_with_persistent.phpt
index 79bbcd24..de208245 100644
--- a/tests/amqpconnection_heartbeat_with_persistent.phpt
+++ b/tests/amqpconnection_heartbeat_with_persistent.phpt
@@ -1,13 +1,18 @@
--TEST--
AMQPConnection - heartbeats support with persistent connections
--SKIPIF--
-
+
--FILE--
$heartbeat);
$cnn = new AMQPConnection($credentials);
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL;
echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL;
@@ -37,6 +42,7 @@ echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL;
echo PHP_EOL;
$cnn = new AMQPConnection($credentials);
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
$cnn->pconnect();
echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL;
@@ -60,10 +66,8 @@ echo 'heartbeat: ', var_export($cnn->getHeartbeatInterval(), true), PHP_EOL;
echo 'connected: ', var_export($cnn->isConnected(), true), PHP_EOL;
echo 'persistent: ', var_export($cnn->isPersistent(), true), PHP_EOL;
echo PHP_EOL;
-
-// NOTE: in real-world environment (incl. travis ci) "a socket error occurred" happens, but in virtual environment "connection closed unexpectedly" happens
?>
---EXPECTF--
+--EXPECTREGEX--
heartbeat: 2
connected: false
persistent: false
@@ -72,7 +76,7 @@ heartbeat: 2
connected: true
persistent: true
-AMQPException(0): Library error: %s
+AMQPConnectionException\(0\): (a socket error occurred|connection closed unexpectedly)
heartbeat: 2
connected: false
diff --git a/tests/amqpconnection_nullable_setters.phpt b/tests/amqpconnection_nullable_setters.phpt
new file mode 100644
index 00000000..af36e481
--- /dev/null
+++ b/tests/amqpconnection_nullable_setters.phpt
@@ -0,0 +1,53 @@
+--TEST--
+AMQPConnection - setters and nullability
+--SKIPIF--
+
+--FILE--
+setKey('key');
+var_dump($c->getKey());
+$c->setKey(null);
+var_dump($c->getKey());
+$c->setKey('');
+var_dump($c->getKey());
+
+$c->setCert('cert');
+var_dump($c->getCert());
+$c->setCert(null);
+var_dump($c->getCert());
+$c->setCert('');
+var_dump($c->getCert());
+
+$c->setCACert('cacert');
+var_dump($c->getCACert());
+$c->setCACert(null);
+var_dump($c->getCACert());
+$c->setCACert('');
+var_dump($c->getCACert());
+
+$c->setConnectionName('con');
+var_dump($c->getConnectionName());
+$c->setConnectionName(null);
+var_dump($c->getConnectionName());
+$c->setConnectionName('');
+var_dump($c->getConnectionName());
+?>
+==DONE==
+--EXPECT--
+string(3) "key"
+NULL
+string(0) ""
+string(4) "cert"
+NULL
+string(0) ""
+string(6) "cacert"
+NULL
+string(0) ""
+string(3) "con"
+NULL
+string(0) ""
+==DONE==
\ No newline at end of file
diff --git a/tests/amqpconnection_persistent_construct_basic.phpt b/tests/amqpconnection_persistent_construct_basic.phpt
index 71929bd9..12b5afb9 100644
--- a/tests/amqpconnection_persistent_construct_basic.phpt
+++ b/tests/amqpconnection_persistent_construct_basic.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection persitent constructor
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->pconnect();
echo get_class($cnn) . "\n";
echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
diff --git a/tests/amqpconnection_persistent_in_use.phpt b/tests/amqpconnection_persistent_in_use.phpt
index 5000f9ae..f6e385a9 100644
--- a/tests/amqpconnection_persistent_in_use.phpt
+++ b/tests/amqpconnection_persistent_in_use.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection persitent connection resource can't be used by multiple connection
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
echo get_class($cnn), PHP_EOL;
$cnn->pconnect();
echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
@@ -12,6 +16,7 @@ echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
echo PHP_EOL;
$cnn2 = new AMQPConnection();
+$cnn2->setHost(getenv('PHP_AMQP_HOST'));
echo get_class($cnn), PHP_EOL;
try {
diff --git a/tests/amqpconnection_persistent_reusable.phpt b/tests/amqpconnection_persistent_reusable.phpt
index 69627711..e8b7fa0d 100644
--- a/tests/amqpconnection_persistent_reusable.phpt
+++ b/tests/amqpconnection_persistent_reusable.phpt
@@ -1,12 +1,16 @@
--TEST--
AMQPConnection persistent connection are reusable
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->pconnect();
echo get_class($cnn), PHP_EOL;
echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
@@ -25,6 +29,7 @@ if ($manual) {
}
$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
$cnn->pconnect();
echo get_class($cnn), PHP_EOL;
echo $cnn->isConnected() ? 'true' : 'false', PHP_EOL;
diff --git a/tests/amqpconnection_setConnectionName.phpt b/tests/amqpconnection_setConnectionName.phpt
index ba1f85e8..5128b072 100644
--- a/tests/amqpconnection_setConnectionName.phpt
+++ b/tests/amqpconnection_setConnectionName.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setConnectionName
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
var_dump($cnn->getConnectionName());
$cnn->setConnectionName('custom connection name');
var_dump($cnn->getConnectionName());
diff --git a/tests/amqpconnection_setHost.phpt b/tests/amqpconnection_setHost.phpt
index ec6ccf85..57656bcb 100644
--- a/tests/amqpconnection_setHost.phpt
+++ b/tests/amqpconnection_setHost.phpt
@@ -1,7 +1,9 @@
--TEST--
AMQPConnection setHost
--SKIPIF--
-
+
--FILE--
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
var_dump($cnn->getLogin());
$cnn->setLogin('nonexistent');
var_dump($cnn->getLogin());
diff --git a/tests/amqpconnection_setPassword.phpt b/tests/amqpconnection_setPassword.phpt
index 2285b0cf..a2165f80 100644
--- a/tests/amqpconnection_setPassword.phpt
+++ b/tests/amqpconnection_setPassword.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setPassword
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
var_dump($cnn->getPassword());
$cnn->setPassword('nonexistent');
var_dump($cnn->getPassword());
diff --git a/tests/amqpconnection_setPort_int.phpt b/tests/amqpconnection_setPort_int.phpt
index b7cc3f7a..48acebd5 100644
--- a/tests/amqpconnection_setPort_int.phpt
+++ b/tests/amqpconnection_setPort_int.phpt
@@ -1,16 +1,20 @@
--TEST--
AMQPConnection constructor
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$port = 12345;
-echo var_export($cnn->setPort($port), true), PHP_EOL;
+var_dump($cnn->setPort($port));
echo $cnn->getPort(), PHP_EOL;
echo gettype($port), PHP_EOL;
?>
--EXPECT--
-true
+NULL
12345
integer
diff --git a/tests/amqpconnection_setPort_out_of_range.phpt b/tests/amqpconnection_setPort_out_of_range.phpt
index 7e45d6bf..b20df066 100644
--- a/tests/amqpconnection_setPort_out_of_range.phpt
+++ b/tests/amqpconnection_setPort_out_of_range.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setPort with int out of range
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
try {
$cnn->setPort(1234567890);
} catch (Exception $e) {
@@ -12,4 +16,4 @@ try {
}
?>
--EXPECT--
-Invalid port given. Value must be between 1 and 65535.
\ No newline at end of file
+Parameter 'port' must be a valid port number between 1 and 65535.
\ No newline at end of file
diff --git a/tests/amqpconnection_setPort_string.phpt b/tests/amqpconnection_setPort_string.phpt
index 7aa5afe3..561fd5fa 100644
--- a/tests/amqpconnection_setPort_string.phpt
+++ b/tests/amqpconnection_setPort_string.phpt
@@ -1,16 +1,20 @@
--TEST--
AMQPConnection setPort with string
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$port = '12345';
-echo $cnn->setPort($port), PHP_EOL;
+var_dump($cnn->setPort($port));
var_dump($cnn->getPort());
var_dump($port);
?>
--EXPECT--
-1
+NULL
int(12345)
string(5) "12345"
diff --git a/tests/amqpconnection_setReadTimeout_float.phpt b/tests/amqpconnection_setReadTimeout_float.phpt
index 6b289118..25dcb755 100644
--- a/tests/amqpconnection_setReadTimeout_float.phpt
+++ b/tests/amqpconnection_setReadTimeout_float.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setReadTimeout float
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setReadTimeout(.34);
var_dump($cnn->getReadTimeout());
$cnn->setReadTimeout(4.7e-2);
diff --git a/tests/amqpconnection_setReadTimeout_int.phpt b/tests/amqpconnection_setReadTimeout_int.phpt
index 136744dd..07ca3cdd 100644
--- a/tests/amqpconnection_setReadTimeout_int.phpt
+++ b/tests/amqpconnection_setReadTimeout_int.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setReadTimeout int
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setReadTimeout(3);
var_dump($cnn->getReadTimeout());
?>
diff --git a/tests/amqpconnection_setReadTimeout_out_of_range.phpt b/tests/amqpconnection_setReadTimeout_out_of_range.phpt
index 20e7ce59..6f410ae5 100644
--- a/tests/amqpconnection_setReadTimeout_out_of_range.phpt
+++ b/tests/amqpconnection_setReadTimeout_out_of_range.phpt
@@ -1,7 +1,9 @@
--TEST--
AMQPConnection setReadTimeout out of range
--SKIPIF--
-
+
--FILE--
--EXPECT--
AMQPConnectionException
-Parameter 'read_timeout' must be greater than or equal to zero.
+Parameter 'readTimeout' must be greater than or equal to zero.
diff --git a/tests/amqpconnection_setReadTimeout_string.phpt b/tests/amqpconnection_setReadTimeout_string.phpt
index 395b43b6..ecbad921 100644
--- a/tests/amqpconnection_setReadTimeout_string.phpt
+++ b/tests/amqpconnection_setReadTimeout_string.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setReadTimeout string
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setReadTimeout(".34");
var_dump($cnn->getReadTimeout());
$cnn->setReadTimeout("4.7e-2");
diff --git a/tests/amqpconnection_setRpcTimeout_float.phpt b/tests/amqpconnection_setRpcTimeout_float.phpt
index 3aeb92c6..1fd3dd64 100644
--- a/tests/amqpconnection_setRpcTimeout_float.phpt
+++ b/tests/amqpconnection_setRpcTimeout_float.phpt
@@ -1,11 +1,15 @@
--TEST--
AMQPConnection setRpcTimeout float
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setRpcTimeout($timeout);
var_dump($cnn->getRpcTimeout());
var_dump($timeout);
diff --git a/tests/amqpconnection_setRpcTimeout_int.phpt b/tests/amqpconnection_setRpcTimeout_int.phpt
index 6219b478..23f05171 100644
--- a/tests/amqpconnection_setRpcTimeout_int.phpt
+++ b/tests/amqpconnection_setRpcTimeout_int.phpt
@@ -1,11 +1,15 @@
--TEST--
AMQPConnection setRpcTimeout int
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setRpcTimeout($timeout);
var_dump($cnn->getRpcTimeout());
var_dump($timeout);
diff --git a/tests/amqpconnection_setRpcTimeout_out_of_range.phpt b/tests/amqpconnection_setRpcTimeout_out_of_range.phpt
index c11cec4a..79b7471f 100644
--- a/tests/amqpconnection_setRpcTimeout_out_of_range.phpt
+++ b/tests/amqpconnection_setRpcTimeout_out_of_range.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setRpcTimeout out of range
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
try {
$cnn->setRpcTimeout(-1);
} catch (Exception $e) {
@@ -15,4 +19,4 @@ try {
?>
--EXPECT--
AMQPConnectionException
-Parameter 'rpc_timeout' must be greater than or equal to zero.
+Parameter 'rpcTimeout' must be greater than or equal to zero.
diff --git a/tests/amqpconnection_setRpcTimeout_string.phpt b/tests/amqpconnection_setRpcTimeout_string.phpt
index 807ec1f4..f128dd7f 100644
--- a/tests/amqpconnection_setRpcTimeout_string.phpt
+++ b/tests/amqpconnection_setRpcTimeout_string.phpt
@@ -1,11 +1,15 @@
--TEST--
AMQPConnection setRpcTimeout string
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setRpcTimeout($timeout);
var_dump($cnn->getRpcTimeout());
var_dump($timeout);
diff --git a/tests/amqpconnection_setSaslMethod.phpt b/tests/amqpconnection_setSaslMethod.phpt
index 1752a1c4..14148444 100644
--- a/tests/amqpconnection_setSaslMethod.phpt
+++ b/tests/amqpconnection_setSaslMethod.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setSaslMethod int
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setSaslMethod(0);
var_dump($cnn->getSaslMethod());
$cnn->setSaslMethod(1);
diff --git a/tests/amqpconnection_setSaslMethod_invalid.phpt b/tests/amqpconnection_setSaslMethod_invalid.phpt
index 5e2f35bf..e087ac8e 100644
--- a/tests/amqpconnection_setSaslMethod_invalid.phpt
+++ b/tests/amqpconnection_setSaslMethod_invalid.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setSaslMethod invalid
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
try {
$cnn->setSaslMethod(-1);
} catch (Exception $e) {
diff --git a/tests/amqpconnection_setTimeout_deprecated.phpt b/tests/amqpconnection_setTimeout_deprecated.phpt
index 5875df3e..db949441 100644
--- a/tests/amqpconnection_setTimeout_deprecated.phpt
+++ b/tests/amqpconnection_setTimeout_deprecated.phpt
@@ -1,7 +1,9 @@
--TEST--
AMQPConnection setTimeout deprecated
--SKIPIF--
-
+
--FILE--
---FILE--
-setTimeout(.34);
-var_dump($cnn->getTimeout());
-$cnn->setTimeout(4.7e-2);
-var_dump($cnn->getTimeout());?>
---EXPECTF--
-%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
-
-%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
-float(0.34)
-
-%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5
-
-%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6
-float(0.047)
+--TEST--
+AMQPConnection setTimeout float
+--SKIPIF--
+
+--FILE--
+setTimeout(.34);
+var_dump($cnn->getTimeout());
+$cnn->setTimeout(4.7e-2);
+var_dump($cnn->getTimeout());?>
+--EXPECTF--
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
+float(0.34)
+
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6
+float(0.047)
diff --git a/tests/amqpconnection_setTimeout_int.phpt b/tests/amqpconnection_setTimeout_int.phpt
index 85ecabe6..5a9c516a 100644
--- a/tests/amqpconnection_setTimeout_int.phpt
+++ b/tests/amqpconnection_setTimeout_int.phpt
@@ -1,15 +1,17 @@
---TEST--
-AMQPConnection setTimeout int
---SKIPIF--
-
---FILE--
-setTimeout(3);
-var_dump($cnn->getTimeout());
-?>
---EXPECTF--
-%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
-
-%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
-float(3)
+--TEST--
+AMQPConnection setTimeout int
+--SKIPIF--
+
+--FILE--
+setTimeout(3);
+var_dump($cnn->getTimeout());
+?>
+--EXPECTF--
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
+float(3)
diff --git a/tests/amqpconnection_setTimeout_out_of_range.phpt b/tests/amqpconnection_setTimeout_out_of_range.phpt
index 6769f65c..de5d95bc 100644
--- a/tests/amqpconnection_setTimeout_out_of_range.phpt
+++ b/tests/amqpconnection_setTimeout_out_of_range.phpt
@@ -1,19 +1,21 @@
---TEST--
-AMQPConnection setTimeout out of range
---SKIPIF--
-
---FILE--
-setTimeout(-1);
-} catch (Exception $e) {
- echo get_class($e);
- echo PHP_EOL;
- echo $e->getMessage();
-}
-?>
---EXPECTF--
-%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 4
-AMQPConnectionException
-Parameter 'timeout' must be greater than or equal to zero.
+--TEST--
+AMQPConnection setTimeout out of range
+--SKIPIF--
+
+--FILE--
+setTimeout(-1);
+} catch (Exception $e) {
+ echo get_class($e);
+ echo PHP_EOL;
+ echo $e->getMessage();
+}
+?>
+--EXPECTF--
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 4
+AMQPConnectionException
+Parameter 'timeout' must be greater than or equal to zero.
diff --git a/tests/amqpconnection_setTimeout_string.phpt b/tests/amqpconnection_setTimeout_string.phpt
index c198b4f2..dd395bb9 100644
--- a/tests/amqpconnection_setTimeout_string.phpt
+++ b/tests/amqpconnection_setTimeout_string.phpt
@@ -1,21 +1,23 @@
---TEST--
-AMQPConnection setTimeout string
---SKIPIF--
-
---FILE--
-setTimeout(".34");
-var_dump($cnn->getTimeout());
-$cnn->setTimeout("4.7e-2");
-var_dump($cnn->getTimeout());?>
---EXPECTF--
-%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
-
-%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
-float(0.34)
-
-%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5
-
-%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6
-float(0.047)
+--TEST--
+AMQPConnection setTimeout string
+--SKIPIF--
+
+--FILE--
+setTimeout(".34");
+var_dump($cnn->getTimeout());
+$cnn->setTimeout("4.7e-2");
+var_dump($cnn->getTimeout());?>
+--EXPECTF--
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 3
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 4
+float(0.34)
+
+%s: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line 5
+
+%s: AMQPConnection::getTimeout(): AMQPConnection::getTimeout() method is deprecated; use AMQPConnection::getReadTimeout() instead in %s on line 6
+float(0.047)
diff --git a/tests/amqpconnection_setVhost.phpt b/tests/amqpconnection_setVhost.phpt
index 94899ae7..f1b109ef 100644
--- a/tests/amqpconnection_setVhost.phpt
+++ b/tests/amqpconnection_setVhost.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setVhost
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
var_dump($cnn->getVhost());
$cnn->setVhost('nonexistent');
var_dump($cnn->getVhost());
diff --git a/tests/amqpconnection_setWriteTimeout_float.phpt b/tests/amqpconnection_setWriteTimeout_float.phpt
index 8254e29e..3a1ac2c9 100644
--- a/tests/amqpconnection_setWriteTimeout_float.phpt
+++ b/tests/amqpconnection_setWriteTimeout_float.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setWriteTimeout float
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setWriteTimeout(.34);
var_dump($cnn->getWriteTimeout());
$cnn->setWriteTimeout(4.7e-2);
diff --git a/tests/amqpconnection_setWriteTimeout_int.phpt b/tests/amqpconnection_setWriteTimeout_int.phpt
index 39d334fb..cc4cd0df 100644
--- a/tests/amqpconnection_setWriteTimeout_int.phpt
+++ b/tests/amqpconnection_setWriteTimeout_int.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setWriteTimeout int
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setWriteTimeout(3);
var_dump($cnn->getWriteTimeout());
?>
diff --git a/tests/amqpconnection_setWriteTimeout_out_of_range.phpt b/tests/amqpconnection_setWriteTimeout_out_of_range.phpt
index 4f6204ac..b0cc4acd 100644
--- a/tests/amqpconnection_setWriteTimeout_out_of_range.phpt
+++ b/tests/amqpconnection_setWriteTimeout_out_of_range.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setWriteTimeout out of range
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
try {
$cnn->setWriteTimeout(-1);
} catch (Exception $e) {
@@ -15,4 +19,4 @@ try {
?>
--EXPECT--
AMQPConnectionException
-Parameter 'write_timeout' must be greater than or equal to zero.
+Parameter 'writeTimeout' must be greater than or equal to zero.
diff --git a/tests/amqpconnection_setWriteTimeout_string.phpt b/tests/amqpconnection_setWriteTimeout_string.phpt
index 0b9f917f..5f6036b7 100644
--- a/tests/amqpconnection_setWriteTimeout_string.phpt
+++ b/tests/amqpconnection_setWriteTimeout_string.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection setWriteTimeout string
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setWriteTimeout(".34");
var_dump($cnn->getWriteTimeout());
$cnn->setWriteTimeout("4.7e-2");
diff --git a/tests/amqpconnection_ssl.phpt b/tests/amqpconnection_ssl.phpt
deleted file mode 100644
index c4d88e0f..00000000
--- a/tests/amqpconnection_ssl.phpt
+++ /dev/null
@@ -1,141 +0,0 @@
---TEST--
-AMQPConnection - ssl support
---SKIPIF--
-
-
---FILE--
- gethostname(), //'vagrant-ubuntu-wily-64',
- 'port' => 5671,
-
- 'verify' => false,
-
- 'cacert' => __DIR__ . "/../provision/test_certs/testca/cacert.pem",
- 'cert' => __DIR__ . "/../provision/test_certs/client/cert.pem",
- 'key' => __DIR__ . "/../provision/test_certs/client/key.pem",
-);
-
-$cnn = new AMQPConnection($credentials);
-
-var_dump($cnn);
-
-$cnn->connect();
-
-echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
-
-echo PHP_EOL;
-
-$cnn = new AMQPConnection();
-$cnn->setPort(5671);
-$cnn->setCACert(__DIR__ . "/../provision/test_certs/testca/cacert.pem");
-$cnn->setCert(__DIR__ . "/../provision/test_certs/client/cert.pem");
-$cnn->setKey(__DIR__ . "/../provision/test_certs/client/key.pem");
-$cnn->setVerify(false);
-var_dump($cnn);
-
-$cnn->connect();
-
-echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
-
-//sleep(100);
-
-?>
---EXPECTF--
-object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5671)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/testca/cacert.pem"
- ["key":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/client/key.pem"
- ["cert":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/client/cert.pem"
- ["verify":"AMQPConnection":private]=>
- bool(false)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
-}
-connected
-
-object(AMQPConnection)#2 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5671)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/testca/cacert.pem"
- ["key":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/client/key.pem"
- ["cert":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/client/cert.pem"
- ["verify":"AMQPConnection":private]=>
- bool(false)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
-}
-connected
diff --git a/tests/amqpconnection_ssl_by_cert.phpt b/tests/amqpconnection_ssl_by_cert.phpt
deleted file mode 100644
index 0a5c39e3..00000000
--- a/tests/amqpconnection_ssl_by_cert.phpt
+++ /dev/null
@@ -1,164 +0,0 @@
---TEST--
-AMQPConnection - ssl support / authentication using certificates
---SKIPIF--
-
-
---FILE--
- hostname must be in same domain
-e.g. rabbitmq.example.org
-if verify = true
-=> you need a /etc/hosts entry, so that the server can resolve the name supplied by the client
-127.0.0.1 rabbitmq.example.org rabbitmq
-CN in client certificate must also match CN scheme
-CN in server is *.example.org
-CN in clients used are e.g.:
- client.example.org
- sasl-client.example.org
-users have to exist with appropriate rights in rabbitmq
-you can validate authentication by looking at /var/log/rabbitmq/rabbit@vagrant-sasl.log
-connection <0.1104.0> (127.0.0.1:48898 -> 127.0.0.1:5671): user 'sasl-client.example.org' authenticated and granted access to vhost '/'
-*/
-$credentials = array(
- 'host' => 'rabbitmq.example.org',
- 'port' => 5671,
-
- 'verify' => true,
-
- 'cacert' => __DIR__ . "/../provision/test_certs/testca/cacert.pem",
- 'cert' => __DIR__ . "/../provision/test_certs/sasl-client/cert.pem",
- 'key' => __DIR__ . "/../provision/test_certs/sasl-client/key.pem",
- 'sasl_method' => 1
-);
-
-$cnn = new AMQPConnection($credentials);
-$cnn->setSaslMethod(1);
-
-var_dump($cnn);
-
-$cnn->connect();
-
-echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
-
-echo PHP_EOL;
-
-$cnn = new AMQPConnection();
-$cnn->setHost('localhost');
-$cnn->setPort(5671);
-$cnn->setCACert(__DIR__ . "/../provision/test_certs/testca/cacert.pem");
-$cnn->setCert(__DIR__ . "/../provision/test_certs/sasl-client/cert.pem");
-$cnn->setKey(__DIR__ . "/../provision/test_certs/sasl-client/key.pem");
-$cnn->setSaslMethod(1);
-$cnn->setVerify(true);
-var_dump($cnn);
-try {
- $cnn->connect();
-} catch(Exception $e) {
- echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL;
-}
-
-echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
-
-//sleep(100);
-
-?>
---EXPECTF--
-object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(20) "rabbitmq.example.org"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5671)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/testca/cacert.pem"
- ["key":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/sasl-client/key.pem"
- ["cert":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/sasl-client/cert.pem"
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(1)
- ["connection_name":"AMQPConnection":private]=>
- NULL
-}
-connected
-
-object(AMQPConnection)#2 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5671)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/testca/cacert.pem"
- ["key":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/sasl-client/key.pem"
- ["cert":"AMQPConnection":private]=>
- string(%d) "%s/provision/test_certs/sasl-client/cert.pem"
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(1)
- ["connection_name":"AMQPConnection":private]=>
- NULL
-}
-AMQPConnectionException(0): Socket error: could not connect to host.
-disconnected
diff --git a/tests/amqpconnection_tls_basic.phpt b/tests/amqpconnection_tls_basic.phpt
new file mode 100644
index 00000000..f4b5e460
--- /dev/null
+++ b/tests/amqpconnection_tls_basic.phpt
@@ -0,0 +1,116 @@
+--TEST--
+AMQPConnection - TLS - CA validation only
+--SKIPIF--
+
+--FILE--
+ 5671,
+ 'host' => getenv('PHP_AMQP_SSL_HOST'),
+ 'cacert' => __DIR__ . "/../infra/tls/certificates/testca/cacert.pem",
+);
+
+$cnn = new AMQPConnection($credentials);
+
+var_dump($cnn);
+
+$cnn->connect();
+
+echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
+
+echo PHP_EOL;
+
+$cnn = new AMQPConnection();
+$cnn->setPort(5671);
+$cnn->setHost(getenv('PHP_AMQP_SSL_HOST'));
+$cnn->setCACert(__DIR__ . "/../infra/tls/certificates/testca/cacert.pem");
+var_dump($cnn);
+
+$cnn->connect();
+
+echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
+?>
+--EXPECTF--
+object(AMQPConnection)#1 (18) {
+ ["login":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["password":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["host":"AMQPConnection":private]=>
+ string(%d) "%s"
+ ["vhost":"AMQPConnection":private]=>
+ string(1) "/"
+ ["port":"AMQPConnection":private]=>
+ int(5671)
+ ["readTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["writeTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["connectTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["rpcTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["frameMax":"AMQPConnection":private]=>
+ int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
+ ["heartbeat":"AMQPConnection":private]=>
+ int(0)
+ ["cacert":"AMQPConnection":private]=>
+ string(%d) "%s/testca/cacert.pem"
+ ["key":"AMQPConnection":private]=>
+ NULL
+ ["cert":"AMQPConnection":private]=>
+ NULL
+ ["verify":"AMQPConnection":private]=>
+ bool(true)
+ ["saslMethod":"AMQPConnection":private]=>
+ int(0)
+ ["connectionName":"AMQPConnection":private]=>
+ NULL
+}
+connected
+
+object(AMQPConnection)#2 (18) {
+ ["login":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["password":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["host":"AMQPConnection":private]=>
+ string(%d) "%s"
+ ["vhost":"AMQPConnection":private]=>
+ string(1) "/"
+ ["port":"AMQPConnection":private]=>
+ int(5671)
+ ["readTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["writeTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["connectTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["rpcTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["frameMax":"AMQPConnection":private]=>
+ int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
+ ["heartbeat":"AMQPConnection":private]=>
+ int(0)
+ ["cacert":"AMQPConnection":private]=>
+ string(%d) "%s/testca/cacert.pem"
+ ["key":"AMQPConnection":private]=>
+ NULL
+ ["cert":"AMQPConnection":private]=>
+ NULL
+ ["verify":"AMQPConnection":private]=>
+ bool(true)
+ ["saslMethod":"AMQPConnection":private]=>
+ int(0)
+ ["connectionName":"AMQPConnection":private]=>
+ NULL
+}
+connected
diff --git a/tests/amqpconnection_tls_mtls.phpt b/tests/amqpconnection_tls_mtls.phpt
new file mode 100644
index 00000000..dad6a3a8
--- /dev/null
+++ b/tests/amqpconnection_tls_mtls.phpt
@@ -0,0 +1,122 @@
+--TEST--
+AMQPConnection - TLS - mTLS support
+--SKIPIF--
+
+--FILE--
+ 5671,
+ 'host' => getenv('PHP_AMQP_SSL_HOST'),
+ 'cacert' => __DIR__ . "/../infra/tls/certificates/testca/cacert.pem",
+ 'cert' => __DIR__ . "/../infra/tls/certificates/client/cert.pem",
+ 'key' => __DIR__ . "/../infra/tls/certificates/client/key.pem",
+);
+
+$cnn = new AMQPConnection($credentials);
+
+var_dump($cnn);
+
+$cnn->connect();
+
+echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
+
+echo PHP_EOL;
+
+$cnn = new AMQPConnection();
+$cnn->setPort(5671);
+$cnn->setHost(getenv('PHP_AMQP_SSL_HOST'));
+$cnn->setCACert(__DIR__ . "/../infra/tls/certificates/testca/cacert.pem");
+$cnn->setCert(__DIR__ . "/../infra/tls/certificates/client/cert.pem");
+$cnn->setKey(__DIR__ . "/../infra/tls/certificates/client/key.pem");
+var_dump($cnn);
+
+$cnn->connect();
+
+echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
+?>
+--EXPECTF--
+object(AMQPConnection)#1 (18) {
+ ["login":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["password":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["host":"AMQPConnection":private]=>
+ string(%d) "%s"
+ ["vhost":"AMQPConnection":private]=>
+ string(1) "/"
+ ["port":"AMQPConnection":private]=>
+ int(5671)
+ ["readTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["writeTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["connectTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["rpcTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["frameMax":"AMQPConnection":private]=>
+ int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
+ ["heartbeat":"AMQPConnection":private]=>
+ int(0)
+ ["cacert":"AMQPConnection":private]=>
+ string(%d) "%s/testca/cacert.pem"
+ ["key":"AMQPConnection":private]=>
+ string(%d) "%s/client/key.pem"
+ ["cert":"AMQPConnection":private]=>
+ string(%d) "%s/client/cert.pem"
+ ["verify":"AMQPConnection":private]=>
+ bool(true)
+ ["saslMethod":"AMQPConnection":private]=>
+ int(0)
+ ["connectionName":"AMQPConnection":private]=>
+ NULL
+}
+connected
+
+object(AMQPConnection)#2 (18) {
+ ["login":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["password":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["host":"AMQPConnection":private]=>
+ string(%d) "%s"
+ ["vhost":"AMQPConnection":private]=>
+ string(1) "/"
+ ["port":"AMQPConnection":private]=>
+ int(5671)
+ ["readTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["writeTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["connectTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["rpcTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["frameMax":"AMQPConnection":private]=>
+ int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
+ ["heartbeat":"AMQPConnection":private]=>
+ int(0)
+ ["cacert":"AMQPConnection":private]=>
+ string(%d) "%s/testca/cacert.pem"
+ ["key":"AMQPConnection":private]=>
+ string(%d) "%s/client/key.pem"
+ ["cert":"AMQPConnection":private]=>
+ string(%d) "%s/client/cert.pem"
+ ["verify":"AMQPConnection":private]=>
+ bool(true)
+ ["saslMethod":"AMQPConnection":private]=>
+ int(0)
+ ["connectionName":"AMQPConnection":private]=>
+ NULL
+}
+connected
diff --git a/tests/amqpconnection_tls_sasl.phpt b/tests/amqpconnection_tls_sasl.phpt
new file mode 100644
index 00000000..728b15d4
--- /dev/null
+++ b/tests/amqpconnection_tls_sasl.phpt
@@ -0,0 +1,126 @@
+--TEST--
+AMQPConnection - TLS - SASL authentication
+--SKIPIF--
+
+--FILE--
+ getenv('PHP_AMQP_SSL_HOST'),
+ 'port' => 5671,
+ 'cacert' => __DIR__ . "/../infra/tls/certificates/testca/cacert.pem",
+ 'cert' => __DIR__ . "/../infra/tls/certificates/sasl-client/cert.pem",
+ 'key' => __DIR__ . "/../infra/tls/certificates/sasl-client/key.pem",
+ 'sasl_method' => AMQP_SASL_METHOD_EXTERNAL,
+);
+
+$cnn = new AMQPConnection($credentials);
+$cnn->setSaslMethod(1);
+
+var_dump($cnn);
+
+$cnn->connect();
+
+echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
+
+echo PHP_EOL;
+
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_SSL_HOST'));
+$cnn->setPort(5671);
+$cnn->setCACert(__DIR__ . "/../infra/tls/certificates/testca/cacert.pem");
+$cnn->setCert(__DIR__ . "/../infra/tls/certificates/sasl-client/cert.pem");
+$cnn->setKey(__DIR__ . "/../infra/tls/certificates/sasl-client/key.pem");
+$cnn->setSaslMethod(AMQP_SASL_METHOD_EXTERNAL);
+
+var_dump($cnn);
+
+$cnn->connect();
+
+echo ($cnn->isConnected() ? 'connected' : 'disconnected'), PHP_EOL;
+?>
+--EXPECTF--
+object(AMQPConnection)#1 (18) {
+ ["login":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["password":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["host":"AMQPConnection":private]=>
+ string(%d) "%s"
+ ["vhost":"AMQPConnection":private]=>
+ string(1) "/"
+ ["port":"AMQPConnection":private]=>
+ int(5671)
+ ["readTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["writeTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["connectTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["rpcTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["frameMax":"AMQPConnection":private]=>
+ int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
+ ["heartbeat":"AMQPConnection":private]=>
+ int(0)
+ ["cacert":"AMQPConnection":private]=>
+ string(%d) "%s/testca/cacert.pem"
+ ["key":"AMQPConnection":private]=>
+ string(%d) "%s/sasl-client/key.pem"
+ ["cert":"AMQPConnection":private]=>
+ string(%d) "%s/sasl-client/cert.pem"
+ ["verify":"AMQPConnection":private]=>
+ bool(true)
+ ["saslMethod":"AMQPConnection":private]=>
+ int(1)
+ ["connectionName":"AMQPConnection":private]=>
+ NULL
+}
+connected
+
+object(AMQPConnection)#2 (18) {
+ ["login":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["password":"AMQPConnection":private]=>
+ string(5) "guest"
+ ["host":"AMQPConnection":private]=>
+ string(%d) "%s"
+ ["vhost":"AMQPConnection":private]=>
+ string(1) "/"
+ ["port":"AMQPConnection":private]=>
+ int(5671)
+ ["readTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["writeTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["connectTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["rpcTimeout":"AMQPConnection":private]=>
+ float(0)
+ ["frameMax":"AMQPConnection":private]=>
+ int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
+ ["heartbeat":"AMQPConnection":private]=>
+ int(0)
+ ["cacert":"AMQPConnection":private]=>
+ string(%d) "%s/testca/cacert.pem"
+ ["key":"AMQPConnection":private]=>
+ string(%d) "%s/sasl-client/key.pem"
+ ["cert":"AMQPConnection":private]=>
+ string(%d) "%s/sasl-client/cert.pem"
+ ["verify":"AMQPConnection":private]=>
+ bool(true)
+ ["saslMethod":"AMQPConnection":private]=>
+ int(1)
+ ["connectionName":"AMQPConnection":private]=>
+ NULL
+}
+connected
diff --git a/tests/amqpconnection_toomanychannels.phpt b/tests/amqpconnection_toomanychannels.phpt
index 910e3326..521c71fc 100644
--- a/tests/amqpconnection_toomanychannels.phpt
+++ b/tests/amqpconnection_toomanychannels.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPConnection too many channels on a connection
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$channels = array();
diff --git a/tests/amqpconnection_validation.phpt b/tests/amqpconnection_validation.phpt
new file mode 100644
index 00000000..4ceb9986
--- /dev/null
+++ b/tests/amqpconnection_validation.phpt
@@ -0,0 +1,112 @@
+--TEST--
+AMQPConnection parameter validation
+--SKIPIF--
+
+--FILE--
+ $value]);
+ echo $getter . " after constructor: ";
+ echo $con1->{$getter}();
+ echo PHP_EOL;
+ } catch (\Throwable $t) {
+ echo get_class($t);
+ echo ": ";
+ echo $t->getMessage();
+ echo PHP_EOL;
+ }
+ if ($setter === null) {
+ continue;
+ }
+ $con2 = new AMQPConnection();
+ try {
+ $con2->{$setter}($value);
+ echo $getter . " after setter: ";
+ echo $con2->{$getter}();
+ echo PHP_EOL;
+ } catch (\Throwable $t) {
+ echo get_class($t);
+ echo ": ";
+ echo $t->getMessage();
+ echo PHP_EOL;
+ }
+ }
+}
+
+?>
+==DONE==
+--EXPECTF--
+AMQPConnectionException: Parameter 'login' exceeds 1024 character limit.
+AMQPConnectionException: Parameter 'login' exceeds 1024 character limit.
+getLogin after constructor: user
+getLogin after setter: user
+AMQPConnectionException: Parameter 'password' exceeds 1024 character limit.
+AMQPConnectionException: Parameter 'password' exceeds 1024 character limit.
+getPassword after constructor: pass
+getPassword after setter: pass
+AMQPConnectionException: Parameter 'host' exceeds 512 character limit.
+AMQPConnectionException: Parameter 'host' exceeds 512 character limit.
+getHost after constructor: host
+getHost after setter: host
+AMQPConnectionException: Parameter 'vhost' exceeds 512 character limit.
+AMQPConnectionException: Parameter 'vhost' exceeds 512 characters limit.
+getVhost after constructor: vhost
+getVhost after setter: vhost
+AMQPConnectionException: Parameter 'port' must be a valid port number between 1 and 65535.
+AMQPConnectionException: Parameter 'port' must be a valid port number between 1 and 65535.
+AMQPConnectionException: Parameter 'port' must be a valid port number between 1 and 65535.
+AMQPConnectionException: Parameter 'port' must be a valid port number between 1 and 65535.
+getPort after constructor: 1234
+getPort after setter: 1234
+
+Deprecated: AMQPConnection::__construct(): Parameter 'timeout' is deprecated; use 'read_timeout' instead in %s on line %d
+AMQPConnectionException: Parameter 'timeout' must be greater than or equal to zero.
+
+Deprecated: AMQPConnection::setTimeout(): AMQPConnection::setTimeout($timeout) method is deprecated; use AMQPConnection::setReadTimeout($timeout) instead in %s on line %d
+AMQPConnectionException: Parameter 'timeout' must be greater than or equal to zero.
+AMQPConnectionException: Parameter 'read_timeout' must be greater than or equal to zero.
+AMQPConnectionException: Parameter 'readTimeout' must be greater than or equal to zero.
+getReadTimeout after constructor: 20
+getReadTimeout after setter: 20
+AMQPConnectionException: Parameter 'write_timeout' must be greater than or equal to zero.
+AMQPConnectionException: Parameter 'writeTimeout' must be greater than or equal to zero.
+getWriteTimeout after constructor: 30
+getWriteTimeout after setter: 30
+AMQPConnectionException: Parameter 'connect_timeout' must be greater than or equal to zero.
+getConnectTimeout after constructor: 40
+AMQPConnectionException: Parameter 'rpc_timeout' must be greater than or equal to zero.
+AMQPConnectionException: Parameter 'rpcTimeout' must be greater than or equal to zero.
+getRpcTimeout after constructor: 50
+getRpcTimeout after setter: 50
+AMQPConnectionException: Parameter 'frame_max' is out of range.%A
+AMQPConnectionException: Parameter 'frame_max' is out of range.
+getMaxFrameSize after constructor: 128
+AMQPConnectionException: Parameter 'channel_max' is out of range.
+AMQPConnectionException: Parameter 'channel_max' is out of range.
+getMaxChannels after constructor: 128
+AMQPConnectionException: Parameter 'heartbeat' is out of range.%A
+AMQPConnectionException: Parameter 'heartbeat' is out of range.
+getHeartbeatInterval after constructor: 250
+getHeartbeatInterval after constructor: 0
+==DONE==
diff --git a/tests/amqpconnection_var_dump.phpt b/tests/amqpconnection_var_dump.phpt
index 0871c110..949dfbea 100644
--- a/tests/amqpconnection_var_dump.phpt
+++ b/tests/amqpconnection_var_dump.phpt
@@ -2,13 +2,13 @@
AMQPConnection var_dump
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
var_dump($cnn->isConnected());
var_dump($cnn);
$cnn->connect();
@@ -21,7 +21,7 @@ $cnn->disconnect();
var_dump($cnn->isConnected());
var_dump($cnn);
?>
---EXPECT--
+--EXPECTF--
bool(false)
object(AMQPConnection)#1 (18) {
["login":"AMQPConnection":private]=>
@@ -29,36 +29,36 @@ object(AMQPConnection)#1 (18) {
["password":"AMQPConnection":private]=>
string(5) "guest"
["host":"AMQPConnection":private]=>
- string(9) "localhost"
+ string(%d) "%s"
["vhost":"AMQPConnection":private]=>
string(1) "/"
["port":"AMQPConnection":private]=>
int(5672)
- ["read_timeout":"AMQPConnection":private]=>
+ ["readTimeout":"AMQPConnection":private]=>
float(0)
- ["write_timeout":"AMQPConnection":private]=>
+ ["writeTimeout":"AMQPConnection":private]=>
float(0)
- ["connect_timeout":"AMQPConnection":private]=>
+ ["connectTimeout":"AMQPConnection":private]=>
float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
+ ["rpcTimeout":"AMQPConnection":private]=>
float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
+ ["frameMax":"AMQPConnection":private]=>
int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
["heartbeat":"AMQPConnection":private]=>
int(0)
["cacert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["key":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["cert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["verify":"AMQPConnection":private]=>
bool(true)
- ["sasl_method":"AMQPConnection":private]=>
+ ["saslMethod":"AMQPConnection":private]=>
int(0)
- ["connection_name":"AMQPConnection":private]=>
+ ["connectionName":"AMQPConnection":private]=>
NULL
}
bool(true)
@@ -69,36 +69,36 @@ object(AMQPConnection)#1 (18) {
["password":"AMQPConnection":private]=>
string(5) "guest"
["host":"AMQPConnection":private]=>
- string(9) "localhost"
+ string(%d) "%s"
["vhost":"AMQPConnection":private]=>
string(1) "/"
["port":"AMQPConnection":private]=>
int(5672)
- ["read_timeout":"AMQPConnection":private]=>
+ ["readTimeout":"AMQPConnection":private]=>
float(0)
- ["write_timeout":"AMQPConnection":private]=>
+ ["writeTimeout":"AMQPConnection":private]=>
float(0)
- ["connect_timeout":"AMQPConnection":private]=>
+ ["connectTimeout":"AMQPConnection":private]=>
float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
+ ["rpcTimeout":"AMQPConnection":private]=>
float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
+ ["frameMax":"AMQPConnection":private]=>
int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
["heartbeat":"AMQPConnection":private]=>
int(0)
["cacert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["key":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["cert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["verify":"AMQPConnection":private]=>
bool(true)
- ["sasl_method":"AMQPConnection":private]=>
+ ["saslMethod":"AMQPConnection":private]=>
int(0)
- ["connection_name":"AMQPConnection":private]=>
+ ["connectionName":"AMQPConnection":private]=>
NULL
}
bool(false)
@@ -108,35 +108,35 @@ object(AMQPConnection)#1 (18) {
["password":"AMQPConnection":private]=>
string(5) "guest"
["host":"AMQPConnection":private]=>
- string(9) "localhost"
+ string(%d) "%s"
["vhost":"AMQPConnection":private]=>
string(1) "/"
["port":"AMQPConnection":private]=>
int(5672)
- ["read_timeout":"AMQPConnection":private]=>
+ ["readTimeout":"AMQPConnection":private]=>
float(0)
- ["write_timeout":"AMQPConnection":private]=>
+ ["writeTimeout":"AMQPConnection":private]=>
float(0)
- ["connect_timeout":"AMQPConnection":private]=>
+ ["connectTimeout":"AMQPConnection":private]=>
float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
+ ["rpcTimeout":"AMQPConnection":private]=>
float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
+ ["frameMax":"AMQPConnection":private]=>
int(131072)
+ ["channelMax":"AMQPConnection":private]=>
+ int(256)
["heartbeat":"AMQPConnection":private]=>
int(0)
["cacert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["key":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["cert":"AMQPConnection":private]=>
- string(0) ""
+ NULL
["verify":"AMQPConnection":private]=>
bool(true)
- ["sasl_method":"AMQPConnection":private]=>
+ ["saslMethod":"AMQPConnection":private]=>
int(0)
- ["connection_name":"AMQPConnection":private]=>
+ ["connectionName":"AMQPConnection":private]=>
NULL
}
diff --git a/tests/amqpdecimal.phpt b/tests/amqpdecimal.phpt
index 4fd79d9a..88fdbc79 100644
--- a/tests/amqpdecimal.phpt
+++ b/tests/amqpdecimal.phpt
@@ -2,15 +2,15 @@
AMQPDecimal
--SKIPIF--
--FILE--
getExponent(), $decimal->getSignificand());
-
+var_dump($decimal === $decimal->toAmqpValue());
+var_dump($decimal instanceof AMQPValue);
try {
new AMQPDecimal(-1, 1);
@@ -50,6 +50,8 @@ var_dump(AMQPDecimal::SIGNIFICAND_MAX);
--EXPECT--
int(1)
int(2)
+bool(true)
+bool(true)
Decimal exponent value must be unsigned.
Decimal significand value must be unsigned.
Decimal exponent value must be less than 255.
diff --git a/tests/amqpenvelope_construct.phpt b/tests/amqpenvelope_construct.phpt
index 6c634d80..90717f18 100644
--- a/tests/amqpenvelope_construct.phpt
+++ b/tests/amqpenvelope_construct.phpt
@@ -2,54 +2,53 @@
AMQPEnvelope construct
--SKIPIF--
--FILE--
--EXPECT--
object(AMQPEnvelope)#1 (20) {
- ["content_type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["content_encoding":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["contentType":"AMQPBasicProperties":private]=>
+ NULL
+ ["contentEncoding":"AMQPBasicProperties":private]=>
+ NULL
["headers":"AMQPBasicProperties":private]=>
array(0) {
}
- ["delivery_mode":"AMQPBasicProperties":private]=>
+ ["deliveryMode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
- ["correlation_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["reply_to":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["correlationId":"AMQPBasicProperties":private]=>
+ NULL
+ ["replyTo":"AMQPBasicProperties":private]=>
+ NULL
["expiration":"AMQPBasicProperties":private]=>
- string(0) ""
- ["message_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["messageId":"AMQPBasicProperties":private]=>
+ NULL
["timestamp":"AMQPBasicProperties":private]=>
- int(0)
+ NULL
["type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["user_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["app_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["cluster_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["body":"AMQPEnvelope":private]=>
NULL
- ["consumer_tag":"AMQPEnvelope":private]=>
+ ["userId":"AMQPBasicProperties":private]=>
+ NULL
+ ["appId":"AMQPBasicProperties":private]=>
NULL
- ["delivery_tag":"AMQPEnvelope":private]=>
+ ["clusterId":"AMQPBasicProperties":private]=>
NULL
- ["is_redelivery":"AMQPEnvelope":private]=>
+ ["body":"AMQPEnvelope":private]=>
+ string(0) ""
+ ["consumerTag":"AMQPEnvelope":private]=>
NULL
- ["exchange_name":"AMQPEnvelope":private]=>
+ ["deliveryTag":"AMQPEnvelope":private]=>
NULL
- ["routing_key":"AMQPEnvelope":private]=>
+ ["isRedelivery":"AMQPEnvelope":private]=>
+ bool(false)
+ ["exchangeName":"AMQPEnvelope":private]=>
NULL
+ ["routingKey":"AMQPEnvelope":private]=>
+ string(0) ""
}
diff --git a/tests/amqpenvelope_get_accessors.phpt b/tests/amqpenvelope_get_accessors.phpt
index af93cf82..9bebdf9c 100644
--- a/tests/amqpenvelope_get_accessors.phpt
+++ b/tests/amqpenvelope_get_accessors.phpt
@@ -1,30 +1,34 @@
--TEST--
AMQPEnvelope test get*() accessors
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-'.microtime(true));
+$ex->setName('exchange-'. bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue1' . microtime(true));
+$q->setName('queue1' . bin2hex(random_bytes(32)));
$q->declareQueue();
// Bind it on the exchange to routing.key
$q->bind($ex->getName(), 'routing.*');
// Publish a message to the exchange with a routing key
-$ex->publish('message', 'routing.1', AMQP_NOPARAM, array('headers' => array('foo' => 'bar')));
+$ex->publish('message', 'routing.1', null, array('headers' => array('foo' => 'bar')));
// Read from the queue
-$msg = $q->get();
+$msg = $q->get(null);
var_dump($msg);
dump_message($msg);
@@ -37,48 +41,48 @@ var_dump($header);
?>
--EXPECTF--
object(AMQPEnvelope)#5 (20) {
- ["content_type":"AMQPBasicProperties":private]=>
+ ["contentType":"AMQPBasicProperties":private]=>
string(10) "text/plain"
- ["content_encoding":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["contentEncoding":"AMQPBasicProperties":private]=>
+ NULL
["headers":"AMQPBasicProperties":private]=>
array(1) {
["foo"]=>
string(3) "bar"
}
- ["delivery_mode":"AMQPBasicProperties":private]=>
+ ["deliveryMode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
- ["correlation_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["reply_to":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["correlationId":"AMQPBasicProperties":private]=>
+ NULL
+ ["replyTo":"AMQPBasicProperties":private]=>
+ NULL
["expiration":"AMQPBasicProperties":private]=>
- string(0) ""
- ["message_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["messageId":"AMQPBasicProperties":private]=>
+ NULL
["timestamp":"AMQPBasicProperties":private]=>
int(0)
["type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["user_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["app_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["cluster_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["userId":"AMQPBasicProperties":private]=>
+ NULL
+ ["appId":"AMQPBasicProperties":private]=>
+ NULL
+ ["clusterId":"AMQPBasicProperties":private]=>
+ NULL
["body":"AMQPEnvelope":private]=>
string(7) "message"
- ["consumer_tag":"AMQPEnvelope":private]=>
+ ["consumerTag":"AMQPEnvelope":private]=>
string(0) ""
- ["delivery_tag":"AMQPEnvelope":private]=>
+ ["deliveryTag":"AMQPEnvelope":private]=>
int(1)
- ["is_redelivery":"AMQPEnvelope":private]=>
+ ["isRedelivery":"AMQPEnvelope":private]=>
bool(false)
- ["exchange_name":"AMQPEnvelope":private]=>
- string(%d) "exchange-%f"
- ["routing_key":"AMQPEnvelope":private]=>
+ ["exchangeName":"AMQPEnvelope":private]=>
+ string(%d) "exchange-%s"
+ ["routingKey":"AMQPEnvelope":private]=>
string(9) "routing.1"
}
AMQPEnvelope
@@ -95,29 +99,29 @@ AMQPEnvelope
getDeliveryMode:
int(1)
getExchangeName:
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
isRedelivery:
bool(false)
getContentEncoding:
- string(0) ""
+ NULL
getType:
- string(0) ""
+ NULL
getTimeStamp:
int(0)
getPriority:
int(0)
getExpiration:
- string(0) ""
+ NULL
getUserId:
- string(0) ""
+ NULL
getAppId:
- string(0) ""
+ NULL
getMessageId:
- string(0) ""
+ NULL
getReplyTo:
- string(0) ""
+ NULL
getCorrelationId:
- string(0) ""
+ NULL
getHeaders:
array(1) {
["foo"]=>
diff --git a/tests/amqpenvelope_var_dump.phpt b/tests/amqpenvelope_var_dump.phpt
index ff1723ff..968acba4 100644
--- a/tests/amqpenvelope_var_dump.phpt
+++ b/tests/amqpenvelope_var_dump.phpt
@@ -2,14 +2,15 @@
AMQPEnvelope var_dump
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
@@ -19,7 +20,7 @@ $ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue1' . microtime(true));
+$q->setName('queue1' . bin2hex(random_bytes(32)));
$q->declareQueue();
// Bind it on the exchange to routing.key
$q->bind($ex->getName(), 'routing.*');
@@ -29,94 +30,94 @@ $ex->publish('message', 'routing.1', AMQP_NOPARAM, array("headers" => array("tes
// Read from the queue
$q->consume("consumeThings");
-$q->consume("consumeThings");
+$q->consume("consumeThings", null);
?>
--EXPECTF--
object(AMQPEnvelope)#5 (20) {
- ["content_type":"AMQPBasicProperties":private]=>
+ ["contentType":"AMQPBasicProperties":private]=>
string(10) "text/plain"
- ["content_encoding":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["contentEncoding":"AMQPBasicProperties":private]=>
+ NULL
["headers":"AMQPBasicProperties":private]=>
array(0) {
}
- ["delivery_mode":"AMQPBasicProperties":private]=>
+ ["deliveryMode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
- ["correlation_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["reply_to":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["correlationId":"AMQPBasicProperties":private]=>
+ NULL
+ ["replyTo":"AMQPBasicProperties":private]=>
+ NULL
["expiration":"AMQPBasicProperties":private]=>
- string(0) ""
- ["message_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["messageId":"AMQPBasicProperties":private]=>
+ NULL
["timestamp":"AMQPBasicProperties":private]=>
int(0)
["type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["user_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["app_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["cluster_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["userId":"AMQPBasicProperties":private]=>
+ NULL
+ ["appId":"AMQPBasicProperties":private]=>
+ NULL
+ ["clusterId":"AMQPBasicProperties":private]=>
+ NULL
["body":"AMQPEnvelope":private]=>
string(7) "message"
- ["consumer_tag":"AMQPEnvelope":private]=>
+ ["consumerTag":"AMQPEnvelope":private]=>
string(31) "amq.ctag-%s"
- ["delivery_tag":"AMQPEnvelope":private]=>
+ ["deliveryTag":"AMQPEnvelope":private]=>
int(1)
- ["is_redelivery":"AMQPEnvelope":private]=>
+ ["isRedelivery":"AMQPEnvelope":private]=>
bool(false)
- ["exchange_name":"AMQPEnvelope":private]=>
+ ["exchangeName":"AMQPEnvelope":private]=>
string(9) "exchange1"
- ["routing_key":"AMQPEnvelope":private]=>
+ ["routingKey":"AMQPEnvelope":private]=>
string(9) "routing.1"
}
object(AMQPEnvelope)#5 (20) {
- ["content_type":"AMQPBasicProperties":private]=>
+ ["contentType":"AMQPBasicProperties":private]=>
string(10) "text/plain"
- ["content_encoding":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["contentEncoding":"AMQPBasicProperties":private]=>
+ NULL
["headers":"AMQPBasicProperties":private]=>
array(1) {
["test"]=>
string(6) "passed"
}
- ["delivery_mode":"AMQPBasicProperties":private]=>
+ ["deliveryMode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
- ["correlation_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["reply_to":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["correlationId":"AMQPBasicProperties":private]=>
+ NULL
+ ["replyTo":"AMQPBasicProperties":private]=>
+ NULL
["expiration":"AMQPBasicProperties":private]=>
- string(0) ""
- ["message_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["messageId":"AMQPBasicProperties":private]=>
+ NULL
["timestamp":"AMQPBasicProperties":private]=>
int(0)
["type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["user_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["app_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["cluster_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["userId":"AMQPBasicProperties":private]=>
+ NULL
+ ["appId":"AMQPBasicProperties":private]=>
+ NULL
+ ["clusterId":"AMQPBasicProperties":private]=>
+ NULL
["body":"AMQPEnvelope":private]=>
string(7) "message"
- ["consumer_tag":"AMQPEnvelope":private]=>
+ ["consumerTag":"AMQPEnvelope":private]=>
string(31) "amq.ctag-%s"
- ["delivery_tag":"AMQPEnvelope":private]=>
+ ["deliveryTag":"AMQPEnvelope":private]=>
int(2)
- ["is_redelivery":"AMQPEnvelope":private]=>
+ ["isRedelivery":"AMQPEnvelope":private]=>
bool(false)
- ["exchange_name":"AMQPEnvelope":private]=>
+ ["exchangeName":"AMQPEnvelope":private]=>
string(9) "exchange1"
- ["routing_key":"AMQPEnvelope":private]=>
+ ["routingKey":"AMQPEnvelope":private]=>
string(9) "routing.1"
}
diff --git a/tests/amqpexchange-declare-segfault.phpt b/tests/amqpexchange-declare-segfault.phpt
index af1d1bde..9095161d 100644
--- a/tests/amqpexchange-declare-segfault.phpt
+++ b/tests/amqpexchange-declare-segfault.phpt
@@ -1,13 +1,17 @@
--TEST--
AMQPExchange
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
-$name = "exchange-" . microtime(true);
+$name = "exchange-" . bin2hex(random_bytes(32));
$ex = new AMQPExchange(new AMQPChannel($cnn));
$ex->setName($name);
diff --git a/tests/amqpexchange_attributes.phpt b/tests/amqpexchange_attributes.phpt
index b92765ea..fe56e2fa 100644
--- a/tests/amqpexchange_attributes.phpt
+++ b/tests/amqpexchange_attributes.phpt
@@ -2,33 +2,42 @@
AMQPExchange attributes
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setArguments($arr = array('existent' => 'value', 'false' => false));
+$ex->setArguments($arr = array('existent' => 'value', 'false' => false, 'null' => null));
echo 'Initial args: ', count($arr), ', exchange args: ', count($ex->getArguments()), PHP_EOL;
$ex->setArgument('foo', 'bar');
echo 'Initial args: ', count($arr), ', exchange args: ', count($ex->getArguments()), PHP_EOL;
-foreach (array('existent', 'false', 'nonexistent') as $key) {
- echo "$key: ", var_export($ex->hasArgument($key), true), ', ', var_export($ex->getArgument($key)), PHP_EOL;
+foreach (array('existent', 'false', 'null', 'nonexistent') as $key) {
+ echo "$key: ";
+ var_export($ex->hasArgument($key));
+ echo ', ';
+ try {
+ var_export($ex->getArgument($key));
+ } catch (AMQPExchangeException $e) {
+ echo "Ex: " . $e->getMessage();
+ }
+ echo PHP_EOL;
}
?>
--EXPECT--
-Initial args: 2, exchange args: 2
-Initial args: 2, exchange args: 3
+Initial args: 3, exchange args: 3
+Initial args: 3, exchange args: 4
existent: true, 'value'
false: true, false
-nonexistent: false, false
+null: true, NULL
+nonexistent: false, Ex: The argument "nonexistent" does not exist
diff --git a/tests/amqpexchange_bind.phpt b/tests/amqpexchange_bind.phpt
index 39b7e77f..c6b3dbd2 100644
--- a/tests/amqpexchange_bind.phpt
+++ b/tests/amqpexchange_bind.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPExchange::bind
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Declare a new exchange
$ex2 = new AMQPExchange($ch);
-$ex2->setName('exchange2-' . microtime(true));
+$ex2->setName('exchange2-' . bin2hex(random_bytes(32)));
$ex2->setType(AMQP_EX_TYPE_FANOUT);
$ex2->declareExchange();
@@ -26,5 +30,5 @@ var_dump($ex->bind($ex2->getName(), 'test-key-1'));
?>
--EXPECT--
-bool(true)
-bool(true)
\ No newline at end of file
+NULL
+NULL
\ No newline at end of file
diff --git a/tests/amqpexchange_bind_with_arguments.phpt b/tests/amqpexchange_bind_with_arguments.phpt
index c3e13618..595a3a27 100644
--- a/tests/amqpexchange_bind_with_arguments.phpt
+++ b/tests/amqpexchange_bind_with_arguments.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPExchange::bind with arguments
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Declare a new exchange
$ex2 = new AMQPExchange($ch);
-$ex2->setName('exchange2-' . microtime(true));
+$ex2->setName('exchange2-' . bin2hex(random_bytes(32)));
$ex2->setType(AMQP_EX_TYPE_FANOUT);
$ex2->declareExchange();
@@ -28,5 +32,5 @@ var_dump($ex->bind($ex2->getName(), 'test', array('test' => 'passed', 'at' => $t
?>
--EXPECT--
-bool(true)
-bool(true)
\ No newline at end of file
+NULL
+NULL
\ No newline at end of file
diff --git a/tests/amqpexchange_bind_without_key.phpt b/tests/amqpexchange_bind_without_key.phpt
index d861e5e7..3f0e063e 100644
--- a/tests/amqpexchange_bind_without_key.phpt
+++ b/tests/amqpexchange_bind_without_key.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPExchange::bind without key
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Declare a new exchange
$ex2 = new AMQPExchange($ch);
-$ex2->setName('exchange2-' . microtime(true));
+$ex2->setName('exchange2-' . bin2hex(random_bytes(32)));
$ex2->setType(AMQP_EX_TYPE_FANOUT);
$ex2->declareExchange();
@@ -27,6 +31,6 @@ var_dump($ex->bind($ex2->getName(), ''));
?>
--EXPECT--
-bool(true)
-bool(true)
-bool(true)
\ No newline at end of file
+NULL
+NULL
+NULL
\ No newline at end of file
diff --git a/tests/amqpexchange_bind_without_key_with_arguments.phpt b/tests/amqpexchange_bind_without_key_with_arguments.phpt
index 6d6f57a8..6ee95985 100644
--- a/tests/amqpexchange_bind_without_key_with_arguments.phpt
+++ b/tests/amqpexchange_bind_without_key_with_arguments.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPExchange::bind without key with arguments
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Declare a new exchange
$ex2 = new AMQPExchange($ch);
-$ex2->setName('exchange2-' . microtime(true));
+$ex2->setName('exchange2-' . bin2hex(random_bytes(32)));
$ex2->setType(AMQP_EX_TYPE_FANOUT);
$ex2->declareExchange();
@@ -28,5 +32,5 @@ var_dump($ex->bind($ex2->getName(), '', array('test' => 'passed', 'at' => $time,
?>
--EXPECT--
-bool(true)
-bool(true)
\ No newline at end of file
+NULL
+NULL
\ No newline at end of file
diff --git a/tests/amqpexchange_channel_refcount.phpt b/tests/amqpexchange_channel_refcount.phpt
index af23e4e9..7261c589 100644
--- a/tests/amqpexchange_channel_refcount.phpt
+++ b/tests/amqpexchange_channel_refcount.phpt
@@ -1,11 +1,15 @@
--TEST--
AMQPExchange channel refcount
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpexchange_construct_basic.phpt b/tests/amqpexchange_construct_basic.phpt
index 6410ea1d..d352c361 100644
--- a/tests/amqpexchange_construct_basic.phpt
+++ b/tests/amqpexchange_construct_basic.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPExchange constructor
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpexchange_declare_basic.phpt b/tests/amqpexchange_declare_basic.phpt
index a1bb4baa..16ccfc3b 100644
--- a/tests/amqpexchange_declare_basic.phpt
+++ b/tests/amqpexchange_declare_basic.phpt
@@ -1,18 +1,24 @@
--TEST--
AMQPExchange
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
-$ex->setType(AMQP_EX_TYPE_FANOUT);
-echo $ex->declareExchange() ? "true" : "false";
+var_dump($ex->setName("exchange-" . bin2hex(random_bytes(32))));
+var_dump($ex->setType(AMQP_EX_TYPE_FANOUT));
+var_dump($ex->declareExchange());
?>
--EXPECT--
-true
+NULL
+NULL
+NULL
diff --git a/tests/amqpexchange_declare_existent.phpt b/tests/amqpexchange_declare_existent.phpt
index f2f04d17..716ee278 100644
--- a/tests/amqpexchange_declare_existent.phpt
+++ b/tests/amqpexchange_declare_existent.phpt
@@ -1,22 +1,26 @@
--TEST--
AMQPExchange
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
echo 'Channel id: ', $ch->getChannelId(), PHP_EOL;
-$exchangge_name = "exchange-" . microtime(true);
+$exchangge_name = "exchange-" . bin2hex(random_bytes(32));
$ex = new AMQPExchange($ch);
$ex->setName($exchangge_name);
$ex->setType(AMQP_EX_TYPE_FANOUT);
-echo "Exchange declared: ", $ex->declareExchange() ? "true" : "false", PHP_EOL;
+echo "Exchange declared: ", var_export($ex->declareExchange(), true), PHP_EOL;
try {
$ex = new AMQPExchange($ch);
@@ -40,8 +44,8 @@ try {
?>
--EXPECTF--
Channel id: 1
-Exchange declared: true
-AMQPExchangeException(406): Server channel error: 406, message: PRECONDITION_FAILED - %s exchange 'exchange-%f' in vhost '/'%s
+Exchange declared: NULL
+AMQPExchangeException(406): Server channel error: 406, message: PRECONDITION_FAILED - %s exchange 'exchange-%s' in vhost '/'%s
Channel connected: false
Connection connected: true
AMQPChannelException(0): Could not create exchange. No channel available.
\ No newline at end of file
diff --git a/tests/amqpexchange_declare_with_stalled_reference.phpt b/tests/amqpexchange_declare_with_stalled_reference.phpt
index d80e18bf..5799cab9 100644
--- a/tests/amqpexchange_declare_with_stalled_reference.phpt
+++ b/tests/amqpexchange_declare_with_stalled_reference.phpt
@@ -1,7 +1,9 @@
--TEST--
AMQPExchange - declare with stalled reference
--SKIPIF--
-
+
--FILE--
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpexchange_declare_without_type.phpt b/tests/amqpexchange_declare_without_type.phpt
index ea77cd04..e534a431 100644
--- a/tests/amqpexchange_declare_without_type.phpt
+++ b/tests/amqpexchange_declare_without_type.phpt
@@ -1,15 +1,19 @@
--TEST--
AMQPExchange::declareExchange() without type set
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
-$exchangge_name = "exchange-" . microtime(true);
+$exchangge_name = "exchange-" . bin2hex(random_bytes(32));
$ex = new AMQPExchange($ch);
$ex->setName($exchangge_name);
diff --git a/tests/amqpexchange_delete_default_exchange.phpt b/tests/amqpexchange_delete_default_exchange.phpt
index 276233f4..8ea80d08 100644
--- a/tests/amqpexchange_delete_default_exchange.phpt
+++ b/tests/amqpexchange_delete_default_exchange.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPExchange::delete()
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpexchange_delete_null_name.phpt b/tests/amqpexchange_delete_null_name.phpt
new file mode 100644
index 00000000..85c9a5e2
--- /dev/null
+++ b/tests/amqpexchange_delete_null_name.phpt
@@ -0,0 +1,29 @@
+--TEST--
+AMQPExchange::delete with explicit null as exchange name
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+$chan = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($chan);
+$ex->setName('test.queue.' . bin2hex(random_bytes(32)));
+$ex->setType(AMQP_EX_TYPE_DIRECT);
+$ex->declareExchange();
+
+$ex->delete(null, null);
+
+// Deleting with explicit null deleted the current exchange, so we should be able to redeclare
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declare();
+$ex->delete();
+?>
+==DONE==
+--EXPECT--
+==DONE==
diff --git a/tests/amqpexchange_get_channel.phpt b/tests/amqpexchange_get_channel.phpt
index f235f2af..92782805 100644
--- a/tests/amqpexchange_get_channel.phpt
+++ b/tests/amqpexchange_get_channel.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPExchange getChannel() test
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpexchange_get_connection.phpt b/tests/amqpexchange_get_connection.phpt
index 7c944814..7c0f73be 100644
--- a/tests/amqpexchange_get_connection.phpt
+++ b/tests/amqpexchange_get_connection.phpt
@@ -2,13 +2,13 @@
AMQPExchange getConnection test
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpexchange_invalid_type.phpt b/tests/amqpexchange_invalid_type.phpt
index 191cebb9..bff0e8cb 100644
--- a/tests/amqpexchange_invalid_type.phpt
+++ b/tests/amqpexchange_invalid_type.phpt
@@ -1,16 +1,20 @@
--TEST--
AMQPExchange
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType("invalid_exchange_type");
echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
@@ -26,9 +30,9 @@ echo "Channel ", $ch->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
?>
---EXPECT--
+--EXPECTF--
Channel connected
Connection connected
-AMQPConnectionException(503): Server connection error: 503, message: COMMAND_INVALID - unknown exchange type 'invalid_exchange_type'
+AMQPExchangeException(%d): %s - unknown exchange type 'invalid_exchange_type'
Channel disconnected
-Connection disconnected
\ No newline at end of file
+Connection connected
diff --git a/tests/amqpexchange_name.phpt b/tests/amqpexchange_name.phpt
new file mode 100644
index 00000000..bd155141
--- /dev/null
+++ b/tests/amqpexchange_name.phpt
@@ -0,0 +1,31 @@
+--TEST--
+AMQPExchange getConnection test
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+var_dump($ex->getName());
+$ex->setName('exchange');
+var_dump($ex->getName());
+$ex->setName('');
+var_dump($ex->getName());
+$ex->setName(null);
+var_dump($ex->getName());
+?>
+==DONE==
+--EXPECT--
+NULL
+string(8) "exchange"
+NULL
+NULL
+==DONE==
\ No newline at end of file
diff --git a/tests/amqpexchange_publish_basic.phpt b/tests/amqpexchange_publish_basic.phpt
index b1b8e559..916ec775 100644
--- a/tests/amqpexchange_publish_basic.phpt
+++ b/tests/amqpexchange_publish_basic.phpt
@@ -1,20 +1,24 @@
--TEST--
AMQPExchange
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
-echo $ex->publish('message', 'routing.key') ? 'true' : 'false';
+var_dump($ex->publish('message', 'routing.key'));
$ex->delete();
?>
--EXPECT--
-true
+NULL
diff --git a/tests/amqpexchange_publish_confirms.phpt b/tests/amqpexchange_publish_confirms.phpt
index 0d736704..8a29f1ac 100644
--- a/tests/amqpexchange_publish_confirms.phpt
+++ b/tests/amqpexchange_publish_confirms.phpt
@@ -1,7 +1,11 @@
--TEST--
AMQPExchange::publish() - publish with confirms
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
//$cnn->setReadTimeout(2);
$cnn->connect();
@@ -30,14 +35,14 @@ try {
$ex1 = new AMQPExchange($ch);
-$ex1->setName("exchange-" . microtime(true));
+$ex1->setName("exchange-" . bin2hex(random_bytes(32)));
$ex1->setType(AMQP_EX_TYPE_FANOUT);
$ex1->setFlags(AMQP_AUTODELETE);
$ex1->declareExchange();
-echo $ex1->publish('message 1', 'routing.key') ? 'true' : 'false', PHP_EOL;
-echo $ex1->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
+var_dump($ex1->publish('message 1', 'routing.key'));
+var_dump($ex1->publish('message 1', 'routing.key', AMQP_MANDATORY));
try {
$ch->waitForConfirm();
@@ -58,8 +63,8 @@ try {
}
-echo $ex1->publish('message 1', 'routing.key') ? 'true' : 'false', PHP_EOL;
-echo $ex1->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
+var_dump($ex1->publish('message 1', 'routing.key'));
+var_dump($ex1->publish('message 1', 'routing.key', AMQP_MANDATORY));
// ack_callback(int $delivery_tag, bool $multiple) : bool;
// nack_callback(int $delivery_tag, bool $multiple, bool $requeue) : bool;
@@ -89,8 +94,8 @@ try {
$ex1->delete();
$ex2 = new AMQPExchange($ch);
-$ex2->setName("exchange-nonexistent-" . microtime(true));
-echo $ex2->publish('message 2', 'routing.key') ? 'true' : 'false', PHP_EOL;
+$ex2->setName("exchange-nonexistent-" . bin2hex(random_bytes(32)));
+var_dump($ex2->publish('message 2', 'routing.key'));
try {
$ch->waitForConfirm(1);
@@ -101,13 +106,13 @@ try {
?>
--EXPECTF--
AMQPQueueException(0): Wait timeout exceed
-true
-true
+NULL
+NULL
Unhandled basic.ack method from server received. Use AMQPChannel::setConfirmCallback() to process it.
Unhandled basic.return method from server received. Use AMQPChannel::setReturnCallback() to process it.
Unhandled basic.ack method from server received. Use AMQPChannel::setConfirmCallback() to process it.
-true
-true
+NULL
+NULL
Message acked
array(2) {
[0]=>
@@ -123,5 +128,5 @@ array(2) {
[1]=>
bool(false)
}
-true
-AMQPChannelException(404): Server channel error: 404, message: NOT_FOUND - no exchange 'exchange-nonexistent-%f' in vhost '/'
+NULL
+AMQPChannelException(404): Server channel error: 404, message: NOT_FOUND - no exchange 'exchange-nonexistent-%s' in vhost '/'
diff --git a/tests/amqpexchange_publish_confirms_consume.phpt b/tests/amqpexchange_publish_confirms_consume.phpt
index 354e8d31..7900a34a 100644
--- a/tests/amqpexchange_publish_confirms_consume.phpt
+++ b/tests/amqpexchange_publish_confirms_consume.phpt
@@ -1,7 +1,11 @@
--TEST--
AMQPExchange::publish() - publish in conform mode and handle conforms with AMQPQueue::consume() method
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setReadTimeout(2);
$cnn->connect();
@@ -21,16 +26,16 @@ $ch = new AMQPChannel($cnn);
$ch->confirmSelect();
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->setFlags(AMQP_AUTODELETE);
$ex->declareExchange();
-echo $ex->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
+var_dump($ex->publish('message 1', 'routing.key', AMQP_MANDATORY));
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->setFlags(AMQP_AUTODELETE);
$q->declareQueue();
@@ -47,7 +52,7 @@ try {
echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL;
}
-echo $ex->publish('message 2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
+var_dump($ex->publish('message 2', 'routing.key', AMQP_MANDATORY));
/* callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body); */
$ch->setReturnCallback(function ($reply_code, $reply_text, $exchange, $routing_key, AMQPBasicProperties $properties, $body) {
@@ -79,13 +84,13 @@ try {
$q->delete();
$ex->delete();
?>
---EXPECTF--
-true
-bool(false)
+--EXPECT--
+NULL
+NULL
Unhandled basic.return method from server received. Use AMQPChannel::setReturnCallback() to process it.
Unhandled basic.ack method from server received. Use AMQPChannel::setConfirmCallback() to process it.
AMQPQueueException(0): Consumer timeout exceed
-true
+NULL
Message returned: NO_ROUTE, message body:message 2
Message acked
array(2) {
diff --git a/tests/amqpexchange_publish_empty_routing_key.phpt b/tests/amqpexchange_publish_empty_routing_key.phpt
index bab006f7..f9bbaf50 100644
--- a/tests/amqpexchange_publish_empty_routing_key.phpt
+++ b/tests/amqpexchange_publish_empty_routing_key.phpt
@@ -1,20 +1,24 @@
--TEST--
AMQPExchange publish with empty routing key
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
-echo $ex->publish('message') ? 'true' : 'false';
+var_dump($ex->publish('message'));
$ex->delete();
?>
--EXPECT--
-true
+NULL
diff --git a/tests/amqpexchange_publish_mandatory.phpt b/tests/amqpexchange_publish_mandatory.phpt
index 3ce304d5..d493f288 100644
--- a/tests/amqpexchange_publish_mandatory.phpt
+++ b/tests/amqpexchange_publish_mandatory.phpt
@@ -1,7 +1,11 @@
--TEST--
AMQPExchange::publish() - publish unroutable mandatory
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
//$cnn->setReadTimeout(2);
$cnn->connect();
@@ -31,17 +36,17 @@ try {
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->setFlags(AMQP_AUTODELETE);
$ex->declareExchange();
-echo $ex->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
-echo $ex->publish('message 2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
+var_dump($ex->publish('message 1', 'routing.key', AMQP_MANDATORY));
+var_dump($ex->publish('message 2', 'routing.key', AMQP_MANDATORY));
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->setFlags(AMQP_AUTODELETE);
$q->declareQueue();
@@ -75,9 +80,9 @@ $ex->delete();
?>
--EXPECTF--
AMQPQueueException(0): Wait timeout exceed
-true
-true
-bool(false)
+NULL
+NULL
+NULL
Unhandled basic.return method from server received. Use AMQPChannel::setReturnCallback() to process it.
Message returned
array(6) {
@@ -86,40 +91,40 @@ array(6) {
[1]=>
string(8) "NO_ROUTE"
[2]=>
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
[3]=>
string(11) "routing.key"
[4]=>
object(AMQPBasicProperties)#7 (14) {
- ["content_type":"AMQPBasicProperties":private]=>
+ ["contentType":"AMQPBasicProperties":private]=>
string(10) "text/plain"
- ["content_encoding":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["contentEncoding":"AMQPBasicProperties":private]=>
+ NULL
["headers":"AMQPBasicProperties":private]=>
array(0) {
}
- ["delivery_mode":"AMQPBasicProperties":private]=>
+ ["deliveryMode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
- ["correlation_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["reply_to":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["correlationId":"AMQPBasicProperties":private]=>
+ NULL
+ ["replyTo":"AMQPBasicProperties":private]=>
+ NULL
["expiration":"AMQPBasicProperties":private]=>
- string(0) ""
- ["message_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["messageId":"AMQPBasicProperties":private]=>
+ NULL
["timestamp":"AMQPBasicProperties":private]=>
int(0)
["type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["user_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["app_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["cluster_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["userId":"AMQPBasicProperties":private]=>
+ NULL
+ ["appId":"AMQPBasicProperties":private]=>
+ NULL
+ ["clusterId":"AMQPBasicProperties":private]=>
+ NULL
}
[5]=>
string(9) "message 2"
diff --git a/tests/amqpexchange_publish_mandatory_consume.phpt b/tests/amqpexchange_publish_mandatory_consume.phpt
index fde04f76..fe8fe4da 100644
--- a/tests/amqpexchange_publish_mandatory_consume.phpt
+++ b/tests/amqpexchange_publish_mandatory_consume.phpt
@@ -1,7 +1,11 @@
--TEST--
AMQPExchange::publish() - publish unroutable with mandatory flag and handle them with AMQPQueue::consume() method
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setReadTimeout(2);
$cnn->connect();
@@ -21,16 +26,16 @@ $cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->setFlags(AMQP_AUTODELETE);
$ex->declareExchange();
-echo $ex->publish('message 1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
+var_dump($ex->publish('message 1', 'routing.key', AMQP_MANDATORY));
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->setFlags(AMQP_AUTODELETE);
$q->declareQueue();
@@ -47,7 +52,7 @@ try {
echo get_class($e), "({$e->getCode()}): ", $e->getMessage(). PHP_EOL;
}
-echo $ex->publish('message 2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
+var_dump($ex->publish('message 2', 'routing.key', AMQP_MANDATORY));
/* callback(int $reply_code, string $reply_text, string $exchange, string $routing_key, AMQPBasicProperties $properties, string $body); */
$ch->setReturnCallback(function ($reply_code, $reply_text, $exchange, $routing_key, AMQPBasicProperties $properties, $body) {
@@ -72,11 +77,11 @@ $q->delete();
$ex->delete();
?>
--EXPECTF--
-true
-bool(false)
+NULL
+NULL
Unhandled basic.return method from server received. Use AMQPChannel::setReturnCallback() to process it.
AMQPQueueException(0): Consumer timeout exceed
-true
+NULL
Message returned
array(6) {
[0]=>
@@ -84,40 +89,40 @@ array(6) {
[1]=>
string(8) "NO_ROUTE"
[2]=>
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
[3]=>
string(11) "routing.key"
[4]=>
object(AMQPBasicProperties)#9 (14) {
- ["content_type":"AMQPBasicProperties":private]=>
+ ["contentType":"AMQPBasicProperties":private]=>
string(10) "text/plain"
- ["content_encoding":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["contentEncoding":"AMQPBasicProperties":private]=>
+ NULL
["headers":"AMQPBasicProperties":private]=>
array(0) {
}
- ["delivery_mode":"AMQPBasicProperties":private]=>
+ ["deliveryMode":"AMQPBasicProperties":private]=>
int(1)
["priority":"AMQPBasicProperties":private]=>
int(0)
- ["correlation_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["reply_to":"AMQPBasicProperties":private]=>
- string(0) ""
+ ["correlationId":"AMQPBasicProperties":private]=>
+ NULL
+ ["replyTo":"AMQPBasicProperties":private]=>
+ NULL
["expiration":"AMQPBasicProperties":private]=>
- string(0) ""
- ["message_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["messageId":"AMQPBasicProperties":private]=>
+ NULL
["timestamp":"AMQPBasicProperties":private]=>
int(0)
["type":"AMQPBasicProperties":private]=>
- string(0) ""
- ["user_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["app_id":"AMQPBasicProperties":private]=>
- string(0) ""
- ["cluster_id":"AMQPBasicProperties":private]=>
- string(0) ""
+ NULL
+ ["userId":"AMQPBasicProperties":private]=>
+ NULL
+ ["appId":"AMQPBasicProperties":private]=>
+ NULL
+ ["clusterId":"AMQPBasicProperties":private]=>
+ NULL
}
[5]=>
string(9) "message 2"
diff --git a/tests/amqpexchange_publish_mandatory_multiple_channels_pitfal.phpt b/tests/amqpexchange_publish_mandatory_multiple_channels_pitfall.phpt
similarity index 71%
rename from tests/amqpexchange_publish_mandatory_multiple_channels_pitfal.phpt
rename to tests/amqpexchange_publish_mandatory_multiple_channels_pitfall.phpt
index 32741a16..0958e367 100644
--- a/tests/amqpexchange_publish_mandatory_multiple_channels_pitfal.phpt
+++ b/tests/amqpexchange_publish_mandatory_multiple_channels_pitfall.phpt
@@ -1,7 +1,11 @@
--TEST--
AMQPExchange::publish() - publish unroutable mandatory on multiple channels pitfall
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
@@ -34,7 +39,7 @@ try {
}
-$exchange_name = "exchange-" . microtime(true);
+$exchange_name = "exchange-" . bin2hex(random_bytes(32));
$ex1 = new AMQPExchange($ch1);
$ex1->setName($exchange_name);
@@ -46,15 +51,12 @@ $ex1->declareExchange();
$ex2 = new AMQPExchange($ch2);
$ex2->setName($exchange_name);
-echo $ex2->publish('message 1-2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
-echo $ex2->publish('message 2-2', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
-
-//echo $ex1->publish('message 1-1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
-//echo $ex1->publish('message 2-1', 'routing.key', AMQP_MANDATORY) ? 'true' : 'false', PHP_EOL;
+var_dump($ex2->publish('message 1-2', 'routing.key', AMQP_MANDATORY));
+var_dump($ex2->publish('message 2-2', 'routing.key', AMQP_MANDATORY));
// Create a new queue
$q = new AMQPQueue($ch1);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->setFlags(AMQP_AUTODELETE);
$q->declareQueue();
@@ -77,8 +79,8 @@ echo 'Connection active: ', ($cnn->isConnected() ? 'yes' : 'no');
--EXPECTF--
AMQPQueueException(0): Wait timeout exceed
AMQPQueueException(0): Wait timeout exceed
-true
-true
-bool(false)
-AMQPException(0): Library error: unexpected method received
+NULL
+NULL
+NULL
+AMQPException(0): unexpected method received
Connection active: no
diff --git a/tests/amqpexchange_publish_null_routing_key.phpt b/tests/amqpexchange_publish_null_routing_key.phpt
index 43cc1f03..a2fb7878 100644
--- a/tests/amqpexchange_publish_null_routing_key.phpt
+++ b/tests/amqpexchange_publish_null_routing_key.phpt
@@ -1,20 +1,24 @@
--TEST--
AMQPExchange publish with null routing key
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
-echo $ex->publish('message', null) ? 'true' : 'false';
+var_dump($ex->publish('message', null));
$ex->delete();
?>
--EXPECT--
-true
+NULL
diff --git a/tests/amqpexchange_publish_timeout.disabled b/tests/amqpexchange_publish_timeout.disabled
index 95529c35..cd41c6ec 100644
--- a/tests/amqpexchange_publish_timeout.disabled
+++ b/tests/amqpexchange_publish_timeout.disabled
@@ -2,17 +2,17 @@
AMQPExchange
--SKIPIF--
--FILE--
$timeout));
-$conn->connect();
+$cnn = new AMQPConnection(array('write_timeout' => $timeout));
+$cnn->connect();
-$chan = new AMQPChannel($conn);
+$chan = new AMQPChannel($cnn);
$ex = new AMQPExchange($chan);
$ex->setName("exchange-pub-timeout-" . time());
diff --git a/tests/amqpexchange_publish_with_decimal_header.phpt b/tests/amqpexchange_publish_with_decimal_header.phpt
index c098de99..5104fd1a 100644
--- a/tests/amqpexchange_publish_with_decimal_header.phpt
+++ b/tests/amqpexchange_publish_with_decimal_header.phpt
@@ -1,23 +1,25 @@
--TEST--
AMQPExchange publish with decimal header
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->declareQueue();
$q->bind($ex->getName());
diff --git a/tests/amqpexchange_publish_with_null.phpt b/tests/amqpexchange_publish_with_null.phpt
index 7032dddd..58d0a95c 100644
Binary files a/tests/amqpexchange_publish_with_null.phpt and b/tests/amqpexchange_publish_with_null.phpt differ
diff --git a/tests/amqpexchange_publish_with_properties.phpt b/tests/amqpexchange_publish_with_properties.phpt
index 19d1a963..cba3b0f8 100644
--- a/tests/amqpexchange_publish_with_properties.phpt
+++ b/tests/amqpexchange_publish_with_properties.phpt
@@ -1,18 +1,22 @@
--TEST--
AMQPExchange publish with properties
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
@@ -53,7 +57,7 @@ $attrs_control = array(
//'headers' => 'not array', // should be array // NOTE: covered in tests/amqpexchange_publish_with_properties_ignore_num_header.phpt
);
-echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs) ? 'true' : 'false', PHP_EOL;
+var_dump($ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs));
//var_dump($attrs, $attrs_control);
@@ -70,7 +74,7 @@ $q->delete();
?>
--EXPECTF--
-true
+NULL
Message attributes are the same
AMQPEnvelope
getBody:
@@ -86,7 +90,7 @@ AMQPEnvelope
getDeliveryMode:
int(1)
getExchangeName:
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
isRedelivery:
bool(false)
getContentEncoding:
@@ -100,7 +104,7 @@ AMQPEnvelope
getExpiration:
string(9) "100000000"
getUserId:
- string(0) ""
+ NULL
getAppId:
string(1) "5"
getMessageId:
diff --git a/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt b/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt
index 2939eb89..c96c0ae5 100644
--- a/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt
+++ b/tests/amqpexchange_publish_with_properties_ignore_num_header.phpt
@@ -1,22 +1,26 @@
--TEST--
AMQPExchange publish with properties - ignore numeric keys in headers
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
-echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => 'ignored')) ? 'true' : 'false', PHP_EOL;
-echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => array(2 => 'ignore_me'))) ? 'true' : 'false', PHP_EOL;
+var_dump($ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => 'ignored')));
+var_dump($ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => array(2 => 'ignore_me'))));
$ex->delete();
@@ -24,7 +28,7 @@ $ex->delete();
?>
--EXPECTF--
Warning: AMQPExchange::publish(): Ignoring non-string header field '0' in %s on line %d
-true
+NULL
Warning: AMQPExchange::publish(): Ignoring non-string header field '2' in %s on line %d
-true
+NULL
diff --git a/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt b/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt
index 792ddd87..9b4a327b 100644
--- a/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt
+++ b/tests/amqpexchange_publish_with_properties_ignore_unsupported_header_values.phpt
@@ -1,16 +1,20 @@
--TEST--
AMQPExchange publish with properties - ignore unsupported header values (NULL, object, resources)
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
@@ -22,7 +26,7 @@ $attrs = array(
),
);
-echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs) ? 'true' : 'false';
+var_dump($ex->publish('message', 'routing.key', AMQP_NOPARAM, $attrs));
$ex->delete();
@@ -32,4 +36,4 @@ $ex->delete();
Warning: AMQPExchange::publish(): Ignoring field 'object' due to unsupported value type (object) in %s on line %d
Warning: AMQPExchange::publish(): Ignoring field 'resource' due to unsupported value type (resource) in %s on line %d
-true
+NULL
diff --git a/tests/amqpexchange_publish_with_properties_nested_header.phpt b/tests/amqpexchange_publish_with_properties_nested_header.phpt
index ccdc7a89..1cc008c5 100644
--- a/tests/amqpexchange_publish_with_properties_nested_header.phpt
+++ b/tests/amqpexchange_publish_with_properties_nested_header.phpt
@@ -1,23 +1,25 @@
--TEST--
AMQPExchange publish with properties - nested header values
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->declareQueue();
$q->bind($ex->getName());
@@ -34,16 +36,17 @@ $headers = array(
$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers));
-$message =$q->get(AMQP_AUTOACK);
+$message = $q->get(AMQP_AUTOACK);
var_dump($message->getHeaders());
var_dump($headers);
echo $message->getHeaders() === $headers ? 'same' : 'differs';
echo PHP_EOL, PHP_EOL;
-$headers = array(
+$originalHeaders = array(
'x-death' => array(
array (
+ 'count' => 1,
'reason' => 'rejected',
'queue' => 'my_queue',
'time' => 1410527691,
@@ -53,12 +56,16 @@ $headers = array(
)
);
-$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $headers));
+$ex->publish('message', 'routing.key', AMQP_NOPARAM, array('headers' => $originalHeaders));
-$message =$q->get(AMQP_AUTOACK);
-var_dump($message->getHeaders());
-var_dump($headers);
-echo $message->getHeaders() === $headers ? 'same' : 'differs';
+$message = $q->get(AMQP_AUTOACK);
+$messageHeaders = $message->getHeaders();
+ksort($messageHeaders);
+var_dump($originalHeaders);
+var_dump($messageHeaders);
+echo $messageHeaders['x-death'][0]['time']->getTimestamp() === (float) $originalHeaders['x-death'][0]['time'] ? "timestamp matches\n" : "timestamp differs\n";
+unset($messageHeaders['x-death'][0]['time'], $originalHeaders['x-death'][0]['time']);
+echo $messageHeaders === $originalHeaders ? "headers (except timestamp) identical\n" : "headers (except timestamp) also differ\n";
echo PHP_EOL, PHP_EOL;
?>
@@ -101,7 +108,9 @@ array(1) {
["x-death"]=>
array(1) {
[0]=>
- array(5) {
+ array(6) {
+ ["count"]=>
+ int(1)
["reason"]=>
string(8) "rejected"
["queue"]=>
@@ -122,13 +131,18 @@ array(1) {
["x-death"]=>
array(1) {
[0]=>
- array(5) {
+ array(6) {
+ ["count"]=>
+ int(1)
["reason"]=>
string(8) "rejected"
["queue"]=>
string(8) "my_queue"
["time"]=>
- int(1410527691)
+ object(AMQPTimestamp)#7 (1) {
+ ["timestamp":"AMQPTimestamp":private]=>
+ float(1410527691)
+ }
["exchange"]=>
string(11) "my_exchange"
["routing-keys"]=>
@@ -139,4 +153,5 @@ array(1) {
}
}
}
-same
\ No newline at end of file
+timestamp matches
+headers (except timestamp) identical
diff --git a/tests/amqpexchange_publish_with_properties_user_id_failure.phpt b/tests/amqpexchange_publish_with_properties_user_id_failure.phpt
index 0c304b7e..fff890c0 100644
--- a/tests/amqpexchange_publish_with_properties_user_id_failure.phpt
+++ b/tests/amqpexchange_publish_with_properties_user_id_failure.phpt
@@ -1,16 +1,20 @@
--TEST--
AMQPExchange publish with properties - user_id failure
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
@@ -19,7 +23,7 @@ echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
try {
// NOTE: basic.publish is asynchronous, so ...
- echo $ex->publish('message', 'routing.key', AMQP_NOPARAM, array('user_id' => 'unknown-' . microtime(true))) ? 'true' : 'false', PHP_EOL;
+ var_dump($ex->publish('message', 'routing.key', AMQP_NOPARAM, array('user_id' => 'unknown-' . bin2hex(random_bytes(32)))));
} catch (AMQPException $e) {
echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL;
}
@@ -46,9 +50,9 @@ echo "Connection ", $cnn->isConnected() ? 'connected' : 'disconnected', PHP_EOL;
--EXPECTF--
Channel connected
Connection connected
-true
+NULL
Channel connected
Connection connected
-AMQPQueueException(406): Server channel error: 406, message: PRECONDITION_FAILED - user_id property set to 'unknown-%f' but authenticated user was 'guest'
+AMQPQueueException(406): Server channel error: 406, message: PRECONDITION_FAILED - user_id property set to 'unknown-%s' but authenticated user was 'guest'
Channel disconnected
Connection connected
\ No newline at end of file
diff --git a/tests/amqpexchange_publish_with_timestamp_header.phpt b/tests/amqpexchange_publish_with_timestamp_header.phpt
index cc435572..169617f8 100644
--- a/tests/amqpexchange_publish_with_timestamp_header.phpt
+++ b/tests/amqpexchange_publish_with_timestamp_header.phpt
@@ -1,23 +1,25 @@
--TEST--
AMQPExchange publish with timestamp header
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->declareQueue();
$q->bind($ex->getName());
@@ -38,14 +40,14 @@ array(1) {
["headerName"]=>
object(AMQPTimestamp)#%d (1) {
["timestamp":"AMQPTimestamp":private]=>
- string(10) "1488578462"
+ float(1488578462)
}
}
array(1) {
["headerName"]=>
object(AMQPTimestamp)#%d (1) {
["timestamp":"AMQPTimestamp":private]=>
- string(10) "1488578462"
+ float(1488578462)
}
}
same
diff --git a/tests/amqpexchange_publish_xdeath.phpt b/tests/amqpexchange_publish_xdeath.phpt
index 91e56048..ee663bae 100644
--- a/tests/amqpexchange_publish_xdeath.phpt
+++ b/tests/amqpexchange_publish_xdeath.phpt
@@ -1,12 +1,14 @@
--TEST--
AMQPExchange publish with properties - nested header values
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
@@ -76,7 +78,7 @@ function assert_xdeath(AMQPEnvelope $envelope, $exchangeName, $queueName) {
return 'unexpected-reason: ' . json_encode($header);
}
- if (!isset($header[0]['time']) || !$header[0]['time'] instanceof AMQPTimestamp) {
+ if (!isset($header[0]['time']) || !$header[0]['time'] instanceof AMQPTimestamp || $header[0]['time']->getTimestamp() < 1690465578) {
return 'unexpected-time: ' . json_encode($header);
}
diff --git a/tests/amqpexchange_setArgument.phpt b/tests/amqpexchange_setArgument.phpt
index 486e16b1..c1def004 100644
--- a/tests/amqpexchange_setArgument.phpt
+++ b/tests/amqpexchange_setArgument.phpt
@@ -1,19 +1,23 @@
--TEST--
AMQPExchange::setArgument() test
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$heartbeat = 10;
-$e_name_ae = 'test.exchange.ae.' . microtime(true);
-$e_name = 'test.exchange.' . microtime(true);
+$e_name_ae = 'test.exchange.ae.' . bin2hex(random_bytes(32));
+$e_name = 'test.exchange.' . bin2hex(random_bytes(32));
$ex_ae = new AMQPExchange($ch);
$ex_ae->setName($e_name_ae);
@@ -35,115 +39,29 @@ $ex->setArgument("alternate-exchange", $e_name_ae);
$ex->setArgument('x-empty-string', '');
$ex->setArgument('x-alternate-exchange-one-more-time', $e_name_ae);
$ex->setArgument('x-numeric-argument', $heartbeat * 10 * 1000);
+$ex->setArgument('x-null-argument', null);
$ex->declareExchange();
var_dump($ex);
-$ex->setArgument('x-alternate-exchange-one-more-time', null); // remov key
+$ex->removeArgument('x-null-argument');
+$ex->removeArgument('x-does-not-exist');
var_dump($ex);
?>
--EXPECTF--
object(AMQPExchange)#3 (9) {
["connection":"AMQPExchange":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
+ %a
["channel":"AMQPExchange":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
- }
- }
+ %a
["name":"AMQPExchange":private]=>
- string(%d) "test.exchange.ae.%f"
+ string(%d) "test.exchange.ae.%s"
["type":"AMQPExchange":private]=>
string(6) "fanout"
["passive":"AMQPExchange":private]=>
bool(false)
["durable":"AMQPExchange":private]=>
bool(false)
- ["auto_delete":"AMQPExchange":private]=>
+ ["autoDelete":"AMQPExchange":private]=>
bool(true)
["internal":"AMQPExchange":private]=>
bool(false)
@@ -153,236 +71,64 @@ object(AMQPExchange)#3 (9) {
}
object(AMQPExchange)#4 (9) {
["connection":"AMQPExchange":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
+ %a
["channel":"AMQPExchange":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
- }
- }
+ %a
["name":"AMQPExchange":private]=>
- string(%d) "test.exchange.%f"
+ string(%d) "test.exchange.%s"
["type":"AMQPExchange":private]=>
string(6) "fanout"
["passive":"AMQPExchange":private]=>
bool(false)
["durable":"AMQPExchange":private]=>
bool(false)
- ["auto_delete":"AMQPExchange":private]=>
+ ["autoDelete":"AMQPExchange":private]=>
bool(true)
["internal":"AMQPExchange":private]=>
bool(false)
["arguments":"AMQPExchange":private]=>
- array(5) {
+ array(6) {
["x-ha-policy"]=>
string(3) "all"
["alternate-exchange"]=>
- string(%d) "test.exchange.ae.%f"
+ string(%d) "test.exchange.ae.%s"
["x-empty-string"]=>
string(0) ""
["x-alternate-exchange-one-more-time"]=>
- string(%d) "test.exchange.ae.%f"
+ string(%d) "test.exchange.ae.%s"
["x-numeric-argument"]=>
int(100000)
+ ["x-null-argument"]=>
+ NULL
}
}
object(AMQPExchange)#4 (9) {
["connection":"AMQPExchange":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
+ %a
["channel":"AMQPExchange":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
- }
- }
+ %a
["name":"AMQPExchange":private]=>
- string(%d) "test.exchange.%f"
+ string(%d) "test.exchange.%s"
["type":"AMQPExchange":private]=>
string(6) "fanout"
["passive":"AMQPExchange":private]=>
bool(false)
["durable":"AMQPExchange":private]=>
bool(false)
- ["auto_delete":"AMQPExchange":private]=>
+ ["autoDelete":"AMQPExchange":private]=>
bool(true)
["internal":"AMQPExchange":private]=>
bool(false)
["arguments":"AMQPExchange":private]=>
- array(4) {
+ array(5) {
["x-ha-policy"]=>
string(3) "all"
["alternate-exchange"]=>
- string(%d) "test.exchange.ae.%f"
+ string(%d) "test.exchange.ae.%s"
["x-empty-string"]=>
string(0) ""
+ ["x-alternate-exchange-one-more-time"]=>
+ string(%d) "test.exchange.ae.%s"
["x-numeric-argument"]=>
int(100000)
}
diff --git a/tests/amqpexchange_set_flag.phpt b/tests/amqpexchange_set_flag.phpt
index 82cdd608..fc2cfaa6 100644
--- a/tests/amqpexchange_set_flag.phpt
+++ b/tests/amqpexchange_set_flag.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPExchange set flag string
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpexchange_set_flags.phpt b/tests/amqpexchange_set_flags.phpt
index 40349876..c95c247f 100644
--- a/tests/amqpexchange_set_flags.phpt
+++ b/tests/amqpexchange_set_flags.phpt
@@ -2,17 +2,18 @@
AMQPExchange setFlags()
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->setArguments(array("x-ha-policy" => "all"));
$ex->setFlags(AMQP_PASSIVE | AMQP_DURABLE | AMQP_AUTODELETE | AMQP_INTERNAL);
@@ -22,106 +23,16 @@ var_dump($ex);
--EXPECTF--
object(AMQPExchange)#3 (9) {
["connection":"AMQPExchange":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["channel":"AMQPExchange":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
- }
- }
+ %a
["name":"AMQPExchange":private]=>
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
["type":"AMQPExchange":private]=>
string(6) "fanout"
["passive":"AMQPExchange":private]=>
bool(true)
["durable":"AMQPExchange":private]=>
bool(true)
- ["auto_delete":"AMQPExchange":private]=>
+ ["autoDelete":"AMQPExchange":private]=>
bool(true)
["internal":"AMQPExchange":private]=>
bool(true)
diff --git a/tests/amqpexchange_type.phpt b/tests/amqpexchange_type.phpt
new file mode 100644
index 00000000..33e1cd02
--- /dev/null
+++ b/tests/amqpexchange_type.phpt
@@ -0,0 +1,34 @@
+--TEST--
+AMQPExchange getConnection test
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+
+$cnn->connect();
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+var_dump($ex->getType());
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+var_dump($ex->getType());
+$ex->setType(null);
+var_dump($ex->getType());
+$ex->setType(AMQP_EX_TYPE_DIRECT);
+var_dump($ex->getType());
+$ex->setType("");
+var_dump($ex->getType());
+?>
+==DONE==
+--EXPECT--
+NULL
+string(6) "fanout"
+NULL
+string(6) "direct"
+NULL
+==DONE==
\ No newline at end of file
diff --git a/tests/amqpexchange_unbind.phpt b/tests/amqpexchange_unbind.phpt
index ced46f7f..ee214c84 100644
--- a/tests/amqpexchange_unbind.phpt
+++ b/tests/amqpexchange_unbind.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPExchange::unbind
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-unbind-' . microtime(true));
+$ex->setName('exchange-unbind-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Declare a new exchange
$ex2 = new AMQPExchange($ch);
-$ex2->setName('exchange2-unbind-' . microtime(true));
+$ex2->setName('exchange2-unbind-' . bin2hex(random_bytes(32)));
$ex2->setType(AMQP_EX_TYPE_FANOUT);
$ex2->declareExchange();
@@ -28,6 +32,6 @@ var_dump($ex->unbind($ex2->getName(), 'test-key-1'));
?>
--EXPECT--
-bool(true)
-bool(true)
-bool(true)
\ No newline at end of file
+NULL
+NULL
+NULL
\ No newline at end of file
diff --git a/tests/amqpexchange_unbind_with_arguments.phpt b/tests/amqpexchange_unbind_with_arguments.phpt
index e95e4b7b..e3b0ac31 100644
--- a/tests/amqpexchange_unbind_with_arguments.phpt
+++ b/tests/amqpexchange_unbind_with_arguments.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPExchange::unbind with arguments
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-unbind-' . microtime(true));
+$ex->setName('exchange-unbind-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Declare a new exchange
$ex2 = new AMQPExchange($ch);
-$ex2->setName('exchange2-exchange-unbind-' . microtime(true));
+$ex2->setName('exchange2-exchange-unbind-' . bin2hex(random_bytes(32)));
$ex2->setType(AMQP_EX_TYPE_FANOUT);
$ex2->declareExchange();
@@ -30,6 +34,6 @@ var_dump($ex->unbind($ex2->getName(), 'test', array('test' => 'passed', 'at' =>
?>
--EXPECT--
-bool(true)
-bool(true)
-bool(true)
\ No newline at end of file
+NULL
+NULL
+NULL
\ No newline at end of file
diff --git a/tests/amqpexchange_unbind_without_key.phpt b/tests/amqpexchange_unbind_without_key.phpt
index d8a4b791..8680d5eb 100644
--- a/tests/amqpexchange_unbind_without_key.phpt
+++ b/tests/amqpexchange_unbind_without_key.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPExchange::unbind without key
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-unbind-' . microtime(true));
+$ex->setName('exchange-unbind-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Declare a new exchange
$ex2 = new AMQPExchange($ch);
-$ex2->setName('exchange2-unbind-' . microtime(true));
+$ex2->setName('exchange2-unbind-' . bin2hex(random_bytes(32)));
$ex2->setType(AMQP_EX_TYPE_FANOUT);
$ex2->declareExchange();
@@ -28,6 +32,6 @@ var_dump($ex->unbind($ex2->getName()));
?>
--EXPECT--
-bool(true)
-bool(true)
-bool(true)
\ No newline at end of file
+NULL
+NULL
+NULL
\ No newline at end of file
diff --git a/tests/amqpexchange_unbind_without_key_with_arguments.phpt b/tests/amqpexchange_unbind_without_key_with_arguments.phpt
index 3db697c7..80b4909b 100644
--- a/tests/amqpexchange_unbind_without_key_with_arguments.phpt
+++ b/tests/amqpexchange_unbind_without_key_with_arguments.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPExchange::unbind without key with arguments
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-unbind-' . microtime(true));
+$ex->setName('exchange-unbind-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Declare a new exchange
$ex2 = new AMQPExchange($ch);
-$ex2->setName('exchange2-unbind-' . microtime(true));
+$ex2->setName('exchange2-unbind-' . bin2hex(random_bytes(32)));
$ex2->setType(AMQP_EX_TYPE_FANOUT);
$ex2->declareExchange();
@@ -33,9 +37,9 @@ var_dump($ex->unbind($ex2->getName(), '', array('test' => 'passed', 'at' => $tim
?>
--EXPECT--
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
-bool(true)
\ No newline at end of file
+NULL
+NULL
+NULL
+NULL
+NULL
+NULL
\ No newline at end of file
diff --git a/tests/amqpexchange_var_dump.phpt b/tests/amqpexchange_var_dump.phpt
index e1249b2d..0ed72df1 100644
--- a/tests/amqpexchange_var_dump.phpt
+++ b/tests/amqpexchange_var_dump.phpt
@@ -2,17 +2,18 @@
AMQPExchange var_dump
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
var_dump($ex);
$ex->setArguments(array("x-ha-policy" => "all"));
@@ -21,106 +22,18 @@ var_dump($ex);
--EXPECTF--
object(AMQPExchange)#3 (9) {
["connection":"AMQPExchange":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
+ %a
["channel":"AMQPExchange":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
- }
- }
+ %a
["name":"AMQPExchange":private]=>
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
["type":"AMQPExchange":private]=>
string(6) "fanout"
["passive":"AMQPExchange":private]=>
bool(false)
["durable":"AMQPExchange":private]=>
bool(false)
- ["auto_delete":"AMQPExchange":private]=>
+ ["autoDelete":"AMQPExchange":private]=>
bool(false)
["internal":"AMQPExchange":private]=>
bool(false)
@@ -130,106 +43,18 @@ object(AMQPExchange)#3 (9) {
}
object(AMQPExchange)#3 (9) {
["connection":"AMQPExchange":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
+ %a
["channel":"AMQPExchange":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
- }
- }
+ %a
["name":"AMQPExchange":private]=>
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
["type":"AMQPExchange":private]=>
string(6) "fanout"
["passive":"AMQPExchange":private]=>
bool(false)
["durable":"AMQPExchange":private]=>
bool(false)
- ["auto_delete":"AMQPExchange":private]=>
+ ["autoDelete":"AMQPExchange":private]=>
bool(false)
["internal":"AMQPExchange":private]=>
bool(false)
diff --git a/tests/amqpqueue-cancel-no-consumers.phpt b/tests/amqpqueue-cancel-no-consumers.phpt
index db55e5f1..cc2cd44a 100644
--- a/tests/amqpqueue-cancel-no-consumers.phpt
+++ b/tests/amqpqueue-cancel-no-consumers.phpt
@@ -1,18 +1,19 @@
--TEST--
AMQPQueue - orphaned envelope
--SKIPIF--
-
+createContext();
-$conn = new AMQPConnection();
-$conn->connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
-$extChannel = new AMQPChannel($conn);
+$extChannel = new AMQPChannel($cnn);
$extChannel->qos(0, 3);
$microtime = microtime('true');
@@ -23,7 +24,7 @@ $exchange_name = 'exchnage-test-.' . $microtime;
$queue_1 = new \AMQPQueue($extChannel);
$queue_1->setName($queue_name);
$queue_1->declareQueue();
-$queue_1->purge();
+var_dump($queue_1->purge());
$exchange = new \AMQPExchange($extChannel);
$exchange->setType(AMQP_EX_TYPE_DIRECT);
@@ -42,4 +43,5 @@ $queue_1->cancel($consumer_tag);
echo "Canceled", PHP_EOL;
--EXPECTF--
+int(0)
Canceled
diff --git a/tests/amqpqueue_attributes.phpt b/tests/amqpqueue_attributes.phpt
index 3bf44905..0b4864b7 100644
--- a/tests/amqpqueue_attributes.phpt
+++ b/tests/amqpqueue_attributes.phpt
@@ -1,30 +1,44 @@
--TEST--
AMQPQueue attributes
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$q = new AMQPQueue($ch);
-$q->setArguments($arr = array('existent' => 'value', 'false' => false));
+var_dump($q->setArguments($arr = array('existent' => 'value', 'false' => false)));
echo 'Initial args: ', count($arr), ', queue args: ', count($q->getArguments()), PHP_EOL;
-$q->setArgument('foo', 'bar');
+var_dump($q->setArgument('foo', 'bar'));
echo 'Initial args: ', count($arr), ', queue args: ', count($q->getArguments()), PHP_EOL;
foreach (array('existent', 'false', 'nonexistent') as $key) {
- echo "$key: ", var_export($q->hasArgument($key), true), ', ', var_export($q->getArgument($key)), PHP_EOL;
+ echo "$key: ";
+ var_export($q->hasArgument($key));
+ echo ', ';
+ try {
+ var_export($q->getArgument($key));
+ } catch (AMQPQueueException $e) {
+ echo 'Ex: ', $e->getMessage();
+ }
+ echo PHP_EOL;
}
?>
--EXPECT--
+NULL
Initial args: 2, queue args: 2
+NULL
Initial args: 2, queue args: 3
existent: true, 'value'
false: true, false
-nonexistent: false, false
+nonexistent: false, Ex: The argument "nonexistent" does not exist
diff --git a/tests/amqpqueue_bind_basic.phpt b/tests/amqpqueue_bind_basic.phpt
index bfa89eb9..6234d78d 100644
--- a/tests/amqpqueue_bind_basic.phpt
+++ b/tests/amqpqueue_bind_basic.phpt
@@ -1,21 +1,25 @@
--TEST--
AMQPQueue
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_DIRECT);
$ex->declareExchange();
$queue = new AMQPQueue($ch);
-$queue->setName("queue-" . microtime(true));
+$queue->setName("queue-" . bin2hex(random_bytes(32)));
$queue->declareQueue();
var_dump($queue->bind($ex->getName(), 'routing.key'));
@@ -23,4 +27,4 @@ $queue->delete();
$ex->delete();
?>
--EXPECT--
-bool(true)
+NULL
diff --git a/tests/amqpqueue_bind_basic_empty_routing_key.phpt b/tests/amqpqueue_bind_basic_empty_routing_key.phpt
index 21fc2449..0c9d2847 100644
--- a/tests/amqpqueue_bind_basic_empty_routing_key.phpt
+++ b/tests/amqpqueue_bind_basic_empty_routing_key.phpt
@@ -1,26 +1,34 @@
--TEST--
AMQPQueue
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_DIRECT);
-$ex->declareExchange();
+var_dump($ex->declareExchange());
$queue = new AMQPQueue($ch);
-$queue->setName("queue-" . microtime(true));
-$queue->declareQueue();
+$queue->setName("queue-" . bin2hex(random_bytes(32)));
+var_dump($queue->declareQueue());
var_dump($queue->bind($ex->getName()));
-$queue->delete();
-$ex->delete();
+var_dump($queue->delete());
+var_dump($ex->delete());
?>
--EXPECT--
-bool(true)
+NULL
+int(0)
+NULL
+int(0)
+NULL
diff --git a/tests/amqpqueue_bind_basic_headers_arguments.phpt b/tests/amqpqueue_bind_basic_headers_arguments.phpt
index dffe3085..4953d11d 100644
--- a/tests/amqpqueue_bind_basic_headers_arguments.phpt
+++ b/tests/amqpqueue_bind_basic_headers_arguments.phpt
@@ -1,28 +1,36 @@
--TEST--
AMQPQueue
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_HEADERS);
-$ex->declareExchange();
+var_dump($ex->declareExchange());
$queue = new AMQPQueue($ch);
-$queue->setName("queue-" . microtime(true));
-$queue->declareQueue();
+$queue->setName("queue-" . bin2hex(random_bytes(32)));
+var_dump($queue->declareQueue());
$arguments = array('x-match' => 'all', 'type' => 'custom');
var_dump($queue->bind($ex->getName(), '', $arguments));
-$queue->delete();
-$ex->delete();
+var_dump($queue->delete());
+var_dump($ex->delete());
?>
--EXPECT--
-bool(true)
+NULL
+int(0)
+NULL
+int(0)
+NULL
diff --git a/tests/amqpqueue_bind_null_routing_key.phpt b/tests/amqpqueue_bind_null_routing_key.phpt
index 758f3840..47b2a607 100644
--- a/tests/amqpqueue_bind_null_routing_key.phpt
+++ b/tests/amqpqueue_bind_null_routing_key.phpt
@@ -1,26 +1,36 @@
--TEST--
-AMQPQueue
+AMQPQueue bind/unbind with explicit null routing key
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_DIRECT);
-$ex->declareExchange();
+var_dump($ex->declareExchange());
$queue = new AMQPQueue($ch);
-$queue->setName("queue-" . microtime(true));
-$queue->declareQueue();
-echo $queue->bind($ex->getName(), null) ? 'true' : 'false';
+$queue->setName("queue-" . bin2hex(random_bytes(32)));
+var_dump($queue->declareQueue());
+var_dump($queue->bind($ex->getName(), null));
+var_dump($queue->unbind($ex->getName(), null));
-$queue->delete();
-$ex->delete();
+var_dump($queue->delete());
+var_dump($ex->delete());
?>
--EXPECT--
-true
+NULL
+int(0)
+NULL
+NULL
+int(0)
+NULL
diff --git a/tests/amqpqueue_cancel.phpt b/tests/amqpqueue_cancel.phpt
index c2e94ecc..8646c538 100644
--- a/tests/amqpqueue_cancel.phpt
+++ b/tests/amqpqueue_cancel.phpt
@@ -1,17 +1,22 @@
--TEST--
AMQPQueue cancel
--SKIPIF--
-
+
--FILE--
connect();
- return $conn;
+ $cnn = new AMQPConnection();
+ $cnn->setHost(getenv('PHP_AMQP_HOST'));
+ $cnn->connect();
+ return $cnn;
}
-function create_channel($connection) {
- $channel = new AMQPChannel($connection);
+function create_channel($cnn) {
+ $channel = new AMQPChannel($cnn);
$channel->setPrefetchCount(1);
return $channel;
}
diff --git a/tests/amqpqueue_construct_basic.phpt b/tests/amqpqueue_construct_basic.phpt
index 57ea772f..cfaeca2d 100644
--- a/tests/amqpqueue_construct_basic.phpt
+++ b/tests/amqpqueue_construct_basic.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPQueue constructor
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpqueue_consume_basic.phpt b/tests/amqpqueue_consume_basic.phpt
index f06891b8..fd140c3a 100644
--- a/tests/amqpqueue_consume_basic.phpt
+++ b/tests/amqpqueue_consume_basic.phpt
@@ -1,25 +1,29 @@
--TEST--
AMQPQueue::consume basic
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->declareQueue();
// Bind it on the exchange to routing.key
@@ -27,7 +31,7 @@ $q->bind($ex->getName(), 'routing.*');
// Publish a message to the exchange with a routing key
$ex->publish('message1', 'routing.1', AMQP_NOPARAM, array('content_type' => 'plain/test', 'headers' => array('foo' => 'bar')));
-$ex->publish('message2', 'routing.2', AMQP_NOPARAM, array('delivery_mode' => AMQP_DURABLE));
+$ex->publish('message2', 'routing.2', AMQP_NOPARAM, array('delivery_mode' => AMQP_DELIVERY_MODE_PERSISTENT));
$ex->publish('message3', 'routing.3', AMQP_DURABLE); // this is wrong way to make messages persistent
$count = 0;
@@ -71,29 +75,29 @@ AMQPEnvelope
getDeliveryMode:
int(1)
getExchangeName:
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
isRedelivery:
bool(false)
getContentEncoding:
- string(0) ""
+ NULL
getType:
- string(0) ""
+ NULL
getTimeStamp:
int(0)
getPriority:
int(0)
getExpiration:
- string(0) ""
+ NULL
getUserId:
- string(0) ""
+ NULL
getAppId:
- string(0) ""
+ NULL
getMessageId:
- string(0) ""
+ NULL
getReplyTo:
- string(0) ""
+ NULL
getCorrelationId:
- string(0) ""
+ NULL
getHeaders:
array(1) {
["foo"]=>
@@ -115,29 +119,29 @@ AMQPEnvelope
getDeliveryMode:
int(2)
getExchangeName:
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
isRedelivery:
bool(false)
getContentEncoding:
- string(0) ""
+ NULL
getType:
- string(0) ""
+ NULL
getTimeStamp:
int(0)
getPriority:
int(0)
getExpiration:
- string(0) ""
+ NULL
getUserId:
- string(0) ""
+ NULL
getAppId:
- string(0) ""
+ NULL
getMessageId:
- string(0) ""
+ NULL
getReplyTo:
- string(0) ""
+ NULL
getCorrelationId:
- string(0) ""
+ NULL
getHeaders:
array(0) {
}
diff --git a/tests/amqpqueue_consume_multiple.phpt b/tests/amqpqueue_consume_multiple.phpt
index e3982814..c8649ba4 100644
--- a/tests/amqpqueue_consume_multiple.phpt
+++ b/tests/amqpqueue_consume_multiple.phpt
@@ -1,12 +1,16 @@
--TEST--
AMQPQueue::consume multiple
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
@@ -15,23 +19,23 @@ $ch3 = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . $time);
+$ex->setName('exchange-' . $id);
$ex->setType(AMQP_EX_TYPE_TOPIC);
$ex->declareExchange();
// Create and bind queues
$q1 = new AMQPQueue($ch);
-$q1->setName('queue-one-' . $time);
+$q1->setName('queue-one-' . $id);
$q1->declareQueue();
$q1->bind($ex->getName(), 'routing.one');
$q2 = new AMQPQueue($ch2);
-$q2->setName('queue-two-' . $time);
+$q2->setName('queue-two-' . $id);
$q2->declareQueue();
$q2->bind($ex->getName(), 'routing.two');
$q3 = new AMQPQueue($ch3);
-$q3->setName('queue-three-' . $time);
+$q3->setName('queue-three-' . $id);
$q3->declareQueue();
$q3->bind($ex->getName(), 'routing.three');
@@ -73,9 +77,9 @@ $q2->cancel();
?>
--EXPECTF--
Message: message1, routing key: routing.one, consumer tag: amq.ctag-%s
-Queue: queue-one-%f, consumer tag: amq.ctag-%s
+Queue: queue-one-%s, consumer tag: amq.ctag-%s
Queue and message consumer tag matches
Message: message2, routing key: routing.two, consumer tag: amq.ctag-%s
-Queue: queue-two-%f, consumer tag: amq.ctag-%s
+Queue: queue-two-%s, consumer tag: amq.ctag-%s
Queue and message consumer tag matches
diff --git a/tests/amqpqueue_consume_multiple_no_doubles.phpt b/tests/amqpqueue_consume_multiple_no_doubles.phpt
index 59790abd..a7539760 100644
--- a/tests/amqpqueue_consume_multiple_no_doubles.phpt
+++ b/tests/amqpqueue_consume_multiple_no_doubles.phpt
@@ -1,19 +1,23 @@
--TEST--
AMQPQueue::consume multiple (no doubles)
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->declareQueue();
var_dump($q->getConsumerTag());
diff --git a/tests/amqpqueue_consume_nonexistent.phpt b/tests/amqpqueue_consume_nonexistent.phpt
index 6ccdf65e..2e49a7a4 100644
--- a/tests/amqpqueue_consume_nonexistent.phpt
+++ b/tests/amqpqueue_consume_nonexistent.phpt
@@ -1,12 +1,16 @@
--TEST--
AMQPQueue::consume from nonexistent queue
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setReadTimeout(10); // both are empirical values that should be far enough to deal with busy RabbitMQ broker
$cnn->setWriteTimeout(10);
$cnn->connect();
@@ -15,13 +19,13 @@ $ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('nonexistent-' . microtime(true));
+$q->setName('nonexistent-' . bin2hex(random_bytes(32)));
try {
$q->consume('noop');
@@ -31,4 +35,4 @@ try {
?>
--EXPECTF--
-AMQPQueueException(404): Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%f' in vhost '/'
+AMQPQueueException(404): Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%s' in vhost '/'
diff --git a/tests/amqpqueue_consume_null_consumer_key.phpt b/tests/amqpqueue_consume_null_consumer_key.phpt
new file mode 100644
index 00000000..bde21714
--- /dev/null
+++ b/tests/amqpqueue_consume_null_consumer_key.phpt
@@ -0,0 +1,50 @@
+--TEST--
+AMQPQueue::consume basic
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+// Declare a new exchange
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+// Create a new queue
+$q = new AMQPQueue($ch);
+$q->setName('queue-' . bin2hex(random_bytes(32)));
+$q->declareQueue();
+
+// Bind it on the exchange to routing.key
+$q->bind($ex->getName());
+
+// Publish a message to the exchange with a routing key
+$ex->publish('message1');
+
+$count = 0;
+
+function consume($message, $queue) {
+ global $count;
+ var_dump($count++);
+ return false;
+}
+
+$q->consume(null, AMQP_AUTOACK, null);
+
+$q->delete();
+$ex->delete();
+?>
+==DONE==
+--EXPECTF--
+==DONE==
\ No newline at end of file
diff --git a/tests/amqpqueue_consume_timeout.phpt b/tests/amqpqueue_consume_timeout.phpt
index 861c911c..b1fdb913 100644
--- a/tests/amqpqueue_consume_timeout.phpt
+++ b/tests/amqpqueue_consume_timeout.phpt
@@ -1,42 +1,46 @@
---TEST--
-AMQPQueue::consume with timeout
---SKIPIF--
-
---FILE--
- $timeout));
-$conn->connect();
-$chan = new AMQPChannel($conn);
-$queue = new AMQPQueue($chan);
-$queue->setFlags(AMQP_EXCLUSIVE);
-$queue->declareQueue();
-$start = microtime(true);
-try {
- $queue->consume('nop');
-} catch (AMQPException $e) {
- echo get_class($e), "({$e->getCode()}): ", $e->getMessage();
- echo PHP_EOL;
-}
-$end = microtime(true);
-$error = $end - $start - $timeout;
-$limit = abs(log10($timeout)); // empirical value
-
-echo 'timeout: ', $timeout, PHP_EOL;
-echo 'takes: ', $end - $start, PHP_EOL;
-echo 'error: ', $error, PHP_EOL;
-echo 'limit: ', $limit, PHP_EOL;
-
-echo abs($error) <= $limit ? 'timings OK' : 'timings failed'; // error should be less than 5% of timeout value
-$queue->delete();
-?>
---EXPECTF--
-AMQPQueueException(0): Consumer timeout exceed
-timeout: %f
-takes: %f
-error: %f
-limit: %f
-timings OK
+--TEST--
+AMQPQueue::consume with timeout
+--SKIPIF--
+
+--FILE--
+ $timeout));
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+$chan = new AMQPChannel($cnn);
+$queue = new AMQPQueue($chan);
+$queue->setFlags(AMQP_EXCLUSIVE);
+$queue->declareQueue();
+$start = microtime(true);
+try {
+ $queue->consume('nop');
+} catch (AMQPException $e) {
+ echo get_class($e), "({$e->getCode()}): ", $e->getMessage();
+ echo PHP_EOL;
+}
+$end = microtime(true);
+$error = $end - $start - $timeout;
+$limit = abs(log10($timeout)); // empirical value
+
+echo 'timeout: ', $timeout, PHP_EOL;
+echo 'takes: ', $end - $start, PHP_EOL;
+echo 'error: ', $error, PHP_EOL;
+echo 'limit: ', $limit, PHP_EOL;
+
+echo abs($error) <= $limit ? 'timings OK' : 'timings failed'; // error should be less than 5% of timeout value
+$queue->delete();
+?>
+--EXPECTF--
+AMQPQueueException(0): Consumer timeout exceed
+timeout: %f
+takes: %f
+error: %f
+limit: %f
+timings OK
diff --git a/tests/amqpqueue_declare_basic.phpt b/tests/amqpqueue_declare_basic.phpt
index 68b98a69..7df6cf2f 100644
--- a/tests/amqpqueue_declare_basic.phpt
+++ b/tests/amqpqueue_declare_basic.phpt
@@ -1,25 +1,33 @@
--TEST--
AMQPQueue
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_DIRECT);
$ex->declareExchange();
$queue = new AMQPQueue($ch);
-$queue->setName("queue-" . microtime(true));
-$queue->declareQueue();
+var_dump($queue->setName("queue-" . bin2hex(random_bytes(32))));
+var_dump($queue->declareQueue());
var_dump($queue->bind($ex->getName(), 'routing.key'));
-$queue->delete();
-$ex->delete();
+var_dump($queue->delete());
+var_dump($ex->delete());
?>
--EXPECT--
-bool(true)
+NULL
+int(0)
+NULL
+int(0)
+NULL
diff --git a/tests/amqpqueue_declare_with_arguments.phpt b/tests/amqpqueue_declare_with_arguments.phpt
index f92ae505..c9052a0b 100644
--- a/tests/amqpqueue_declare_with_arguments.phpt
+++ b/tests/amqpqueue_declare_with_arguments.phpt
@@ -1,29 +1,37 @@
--TEST--
AMQPQueue::declareQueue() - with arguments
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_DIRECT);
$ex->declareExchange();
$queue = new AMQPQueue($ch);
-$queue->setName("queue-" . microtime(true));
-$queue->setArgument('x-dead-letter-exchange', '');
-$queue->setArgument('x-dead-letter-routing-key', 'some key');
-$queue->setArgument('x-message-ttl', 42);
-$queue->setFlags(AMQP_AUTODELETE);
-$res = $queue->declareQueue();
+var_dump($queue->setName("queue-" . bin2hex(random_bytes(32))));
+var_dump($queue->setArgument('x-dead-letter-exchange', ''));
+var_dump($queue->setArgument('x-dead-letter-routing-key', 'some key'));
+var_dump($queue->setArgument('x-message-ttl', 42));
+var_dump($queue->setFlags(AMQP_AUTODELETE));
+var_dump($queue->declareQueue());
-var_dump($res);
-
-$queue->delete();
+var_dump($queue->delete());
?>
--EXPECT--
+NULL
+NULL
+NULL
+NULL
+NULL
+int(0)
int(0)
diff --git a/tests/amqpqueue_declare_with_stalled_reference.phpt b/tests/amqpqueue_declare_with_stalled_reference.phpt
index 0dfdd39c..f10ab3aa 100644
--- a/tests/amqpqueue_declare_with_stalled_reference.phpt
+++ b/tests/amqpqueue_declare_with_stalled_reference.phpt
@@ -1,7 +1,9 @@
--TEST--
AMQPQueue - declare with stalled reference
--SKIPIF--
-
+
--FILE--
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
$queue = new AMQPQueue($ch);
-$queue->setName("queue-" . microtime(true));
+$queue->setName("queue-" . bin2hex(random_bytes(32)));
$queue->declareQueue();
$queue->bind($ex->getName());
var_dump($queue->delete());
-var_dump($queue->delete());
+var_dump($queue->delete(null));
$queue->declareQueue();
$queue->bind($ex->getName());
diff --git a/tests/amqpqueue_empty_name.phpt b/tests/amqpqueue_empty_name.phpt
index 959c3f8d..d19dcf23 100644
--- a/tests/amqpqueue_empty_name.phpt
+++ b/tests/amqpqueue_empty_name.phpt
@@ -1,15 +1,19 @@
--TEST--
AMQPQueue declared with empty name
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_DIRECT);
$ex->declareExchange();
diff --git a/tests/amqpqueue_get_basic.phpt b/tests/amqpqueue_get_basic.phpt
index 759e896d..4b80c9f0 100644
--- a/tests/amqpqueue_get_basic.phpt
+++ b/tests/amqpqueue_get_basic.phpt
@@ -1,25 +1,29 @@
--TEST--
AMQPQueue::get basic
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-'. microtime(true));
+$ex->setName('exchange-'. bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->declareQueue();
// Bind it on the exchange to routing.key
@@ -54,29 +58,29 @@ AMQPEnvelope
getDeliveryMode:
int(1)
getExchangeName:
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
isRedelivery:
bool(false)
getContentEncoding:
- string(0) ""
+ NULL
getType:
- string(0) ""
+ NULL
getTimeStamp:
int(0)
getPriority:
int(0)
getExpiration:
- string(0) ""
+ NULL
getUserId:
- string(0) ""
+ NULL
getAppId:
- string(0) ""
+ NULL
getMessageId:
- string(0) ""
+ NULL
getReplyTo:
- string(0) ""
+ NULL
getCorrelationId:
- string(0) ""
+ NULL
getHeaders:
array(1) {
["foo"]=>
@@ -98,29 +102,29 @@ AMQPEnvelope
getDeliveryMode:
int(1)
getExchangeName:
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
isRedelivery:
bool(false)
getContentEncoding:
- string(0) ""
+ NULL
getType:
- string(0) ""
+ NULL
getTimeStamp:
int(0)
getPriority:
int(0)
getExpiration:
- string(0) ""
+ NULL
getUserId:
- string(0) ""
+ NULL
getAppId:
- string(0) ""
+ NULL
getMessageId:
- string(0) ""
+ NULL
getReplyTo:
- string(0) ""
+ NULL
getCorrelationId:
- string(0) ""
+ NULL
getHeaders:
array(0) {
}
@@ -140,32 +144,32 @@ AMQPEnvelope
getDeliveryMode:
int(1)
getExchangeName:
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
isRedelivery:
bool(false)
getContentEncoding:
- string(0) ""
+ NULL
getType:
- string(0) ""
+ NULL
getTimeStamp:
int(0)
getPriority:
int(0)
getExpiration:
- string(0) ""
+ NULL
getUserId:
- string(0) ""
+ NULL
getAppId:
- string(0) ""
+ NULL
getMessageId:
- string(0) ""
+ NULL
getReplyTo:
- string(0) ""
+ NULL
getCorrelationId:
- string(0) ""
+ NULL
getHeaders:
array(0) {
}
call #3
-bool(false)
+NULL
diff --git a/tests/amqpqueue_get_channel.phpt b/tests/amqpqueue_get_channel.phpt
index 974efe4a..c125083b 100644
--- a/tests/amqpqueue_get_channel.phpt
+++ b/tests/amqpqueue_get_channel.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPQueue getChannel() test
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
diff --git a/tests/amqpqueue_get_connection.phpt b/tests/amqpqueue_get_connection.phpt
index d88c7f76..88190612 100644
--- a/tests/amqpqueue_get_connection.phpt
+++ b/tests/amqpqueue_get_connection.phpt
@@ -2,13 +2,13 @@
AMQPQueue getConnection test
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
diff --git a/tests/amqpqueue_get_empty_body.phpt b/tests/amqpqueue_get_empty_body.phpt
index 89e9ab1f..9220c152 100644
--- a/tests/amqpqueue_get_empty_body.phpt
+++ b/tests/amqpqueue_get_empty_body.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPQueue::get empty body
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange' . microtime(true));
+$ex->setName('exchange' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue1' . microtime(true));
+$q->setName('queue1' . bin2hex(random_bytes(32)));
$q->declareQueue();
// Bind it on the exchange to routing.key
@@ -32,7 +36,7 @@ echo "'" . $msg->getBody() . "'\n";
$msg = $q->get(AMQP_AUTOACK);
-if ($msg === FALSE) {
+if ($msg === null) {
echo "No more messages\n";
}
diff --git a/tests/amqpqueue_get_headers.phpt b/tests/amqpqueue_get_headers.phpt
index a0fe6e0f..a72a68b8 100644
--- a/tests/amqpqueue_get_headers.phpt
+++ b/tests/amqpqueue_get_headers.phpt
@@ -1,23 +1,27 @@
--TEST--
AMQPQueue::get headers
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange' . microtime(true));
+$ex->setName('exchange' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('queue1' . microtime(true));
+$q->setName('queue1' . bin2hex(random_bytes(32)));
$q->declareQueue();
// Bind it on the exchange to routing.key
@@ -59,4 +63,4 @@ bool(true)
one
2
Has nonexistent header: false
-Get nonexistent header: false
+Get nonexistent header: NULL
diff --git a/tests/amqpqueue_get_nonexistent.phpt b/tests/amqpqueue_get_nonexistent.phpt
index 30c661f8..f28d44ac 100644
--- a/tests/amqpqueue_get_nonexistent.phpt
+++ b/tests/amqpqueue_get_nonexistent.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPQueue::get from nonexistent queue
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->setReadTimeout(10); // both are empirical values that should be far enough to deal with busy RabbitMQ broker
$cnn->setWriteTimeout(10);
$cnn->connect();
@@ -13,13 +17,13 @@ $ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('nonexistent-' . microtime(true));
+$q->setName('nonexistent-' . bin2hex(random_bytes(32)));
try {
$q->get();
@@ -29,4 +33,4 @@ try {
?>
--EXPECTF--
-AMQPQueueException(404): Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%f' in vhost '/'
+AMQPQueueException(404): Server channel error: 404, message: NOT_FOUND - no queue 'nonexistent-%s' in vhost '/'
diff --git a/tests/amqpqueue_headers_with_bool.phpt b/tests/amqpqueue_headers_with_bool.phpt
index ac2bd222..e758ab78 100644
--- a/tests/amqpqueue_headers_with_bool.phpt
+++ b/tests/amqpqueue_headers_with_bool.phpt
@@ -1,20 +1,24 @@
--TEST--
AMQPQueue::get headers with bool values
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange' . microtime(true));
+$ex->setName('exchange' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_TOPIC);
$ex->declareExchange();
$q = new AMQPQueue($ch);
-$q->setName('queue1' . microtime(true));
+$q->setName('queue1' . bin2hex(random_bytes(32)));
$q->declareQueue();
$q->bind($ex->getName(), '#');
@@ -33,7 +37,9 @@ $ex->publish(
// Read from the queue
$msg = $q->get(AMQP_AUTOACK);
-var_dump($msg->getHeaders());
+$headers = $msg->getHeaders();
+ksort($headers);
+var_dump($headers);
echo $msg->getHeader('foo') . "\n";
var_dump($msg->hasHeader('true'), $msg->getHeader('true'));
var_dump($msg->hasHeader('false'), $msg->getHeader('false'));
@@ -43,12 +49,12 @@ $q->delete();
?>
--EXPECT--
array(3) {
+ ["false"]=>
+ bool(false)
["foo"]=>
string(3) "bar"
["true"]=>
bool(true)
- ["false"]=>
- bool(false)
}
bar
bool(true)
diff --git a/tests/amqpqueue_headers_with_float.phpt b/tests/amqpqueue_headers_with_float.phpt
index 2a9349fa..f5db8c36 100644
--- a/tests/amqpqueue_headers_with_float.phpt
+++ b/tests/amqpqueue_headers_with_float.phpt
@@ -1,20 +1,24 @@
--TEST--
AMQPQueue::get headers with float values
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange' . microtime(true));
+$ex->setName('exchange' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_TOPIC);
$ex->declareExchange();
$q = new AMQPQueue($ch);
-$q->setName('queue1' . microtime(true));
+$q->setName('queue1' . bin2hex(random_bytes(32)));
$q->declareQueue();
$q->bind($ex->getName(), '#');
@@ -35,7 +39,9 @@ $ex->publish(
// Read from the queue
$msg = $q->get(AMQP_AUTOACK);
-var_dump($msg->getHeaders());
+$headers = $msg->getHeaders();
+ksort($headers);
+var_dump($headers);
echo $msg->getHeader('foo') . "\n";
var_dump($msg->hasHeader('positive'), $msg->getHeader('positive'));
var_dump($msg->hasHeader('negative'), $msg->getHeader('negative'));
@@ -49,10 +55,10 @@ $q->delete();
array(5) {
["foo"]=>
string(3) "bar"
- ["positive"]=>
- float(2.3)
["negative"]=>
float(-1022.123456789)
+ ["positive"]=>
+ float(2.3)
["scientific"]=>
float(1000)
["scientific_big"]=>
diff --git a/tests/amqpqueue_headers_with_null.phpt b/tests/amqpqueue_headers_with_null.phpt
index b1b219a3..dc45012c 100644
--- a/tests/amqpqueue_headers_with_null.phpt
+++ b/tests/amqpqueue_headers_with_null.phpt
@@ -1,20 +1,24 @@
--TEST--
AMQPQueue::get headers
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange' . microtime(true));
+$ex->setName('exchange' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_TOPIC);
$ex->declareExchange();
$q = new AMQPQueue($ch);
-$q->setName('queue1' . microtime(true));
+$q->setName('queue1' . bin2hex(random_bytes(32)));
$q->declareQueue();
$q->bind($ex->getName(), '#');
diff --git a/tests/amqpqueue_nack.phpt b/tests/amqpqueue_nack.phpt
index d6765fba..b55e0e54 100644
--- a/tests/amqpqueue_nack.phpt
+++ b/tests/amqpqueue_nack.phpt
@@ -1,25 +1,29 @@
--TEST--
AMQPQueue::nack
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
$ex = new AMQPExchange($ch);
-$ex->setName('testnack' . microtime(true));
+$ex->setName('testnack' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
$exchangeName = $ex->getName();
// Create a new queue
$q = new AMQPQueue($ch);
-$q->setName('testnack' . microtime(true));
+$q->setName('testnack' . bin2hex(random_bytes(32)));
$q->declareQueue();
$q->bind($exchangeName, '#');
@@ -38,7 +42,7 @@ $q->nack($env->getDeliveryTag(), AMQP_REQUEUE);
// read again
$env2 = $q->get(AMQP_NOPARAM);
if (false !== $env2) {
- $q->ack($env2->getDeliveryTag());
+ $q->ack($env2->getDeliveryTag(), null);
echo $env2->getBody() . PHP_EOL;
echo $env2->isRedelivery() ? 'true' : 'false';
echo PHP_EOL;
diff --git a/tests/amqpqueue_nested_arrays.phpt b/tests/amqpqueue_nested_arrays.phpt
index bbf2e9ea..d056e762 100644
--- a/tests/amqpqueue_nested_arrays.phpt
+++ b/tests/amqpqueue_nested_arrays.phpt
@@ -1,20 +1,24 @@
--TEST--
AMQPQueue::get headers
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange' . microtime(true));
+$ex->setName('exchange' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_TOPIC);
$ex->declareExchange();
$q = new AMQPQueue($ch);
-$q->setName('queue1' . microtime(true));
+$q->setName('queue1' . bin2hex(random_bytes(32)));
$q->declareQueue();
$q->bind($ex->getName(), '#');
@@ -32,7 +36,10 @@ $ex->publish(
// Read from the queue
$msg = $q->get(AMQP_AUTOACK);
-var_dump($msg->getHeaders());
+$headers = $msg->getHeaders();
+ksort($headers);
+
+var_dump($headers);
echo $msg->getHeader('foo') . "\n";
var_dump($msg->getHeader('baz'));
@@ -41,8 +48,6 @@ $q->delete();
?>
--EXPECT--
array(2) {
- ["foo"]=>
- string(3) "bar"
["baz"]=>
array(3) {
[0]=>
@@ -52,6 +57,8 @@ array(2) {
[2]=>
string(3) "def"
}
+ ["foo"]=>
+ string(3) "bar"
}
bar
array(3) {
diff --git a/tests/amqpqueue_nested_headers.phpt b/tests/amqpqueue_nested_headers.phpt
index b24da4d5..8daf4421 100644
--- a/tests/amqpqueue_nested_headers.phpt
+++ b/tests/amqpqueue_nested_headers.phpt
@@ -1,33 +1,37 @@
--TEST--
AMQPQueue::get headers
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// create an error exchange and bind a queue to it:
$errorXchange = new AMQPExchange($ch);
-$errorXchange->setName('errorXchange' . microtime(true));
+$errorXchange->setName('errorXchange' . bin2hex(random_bytes(32)));
$errorXchange->setType(AMQP_EX_TYPE_TOPIC);
$errorXchange->declareExchange();
$errorQ = new AMQPQueue($ch);
-$errorQ->setName('errorQueue' . microtime(true));
+$errorQ->setName('errorQueue' . bin2hex(random_bytes(32)));
$errorQ->declareQueue();
$errorQ->bind($errorXchange->getName(), '#');
// Declare a new exchange and queue using this dead-letter-exchange:
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_TOPIC);
$ex->declareExchange();
$q = new AMQPQueue($ch);
-$q->setName('queue-' . microtime(true));
+$q->setName('queue-' . bin2hex(random_bytes(32)));
$q->setArgument('x-dead-letter-exchange', $errorXchange->getName());
$q->declareQueue();
$q->bind($ex->getName(), '#');
@@ -37,8 +41,10 @@ $q->bind($ex->getName(), '#');
$ex->publish(
'body', 'routing.1', AMQP_NOPARAM, array(
'headers' => array(
- 'foo' => 'bar',
- 'baz' => array('a', 'bc', 'def')
+ 'foo' => 'fval',
+ 'bar' => array(array('aa', 'bb', array('bar_nested' => 'nested'))),
+ 'baz' => array('a', 'bc', 'def', 123, 'g'),
+ 'bla' => array('one' => 2),
)
)
);
@@ -53,37 +59,74 @@ $msg = $errorQ->get(AMQP_AUTOACK);
$header = $msg->getHeader('x-death');
-echo isset($header[0]['count']) ? 'with' : 'without', ' count ', PHP_EOL;
+echo isset($header[0]['count']) ? 'count found' : 'count not found', PHP_EOL;
unset($header[0]['count']);
var_dump($header);
+var_dump($msg->getHeader('foo'));
+var_dump($msg->getHeader('bar'));
+var_dump($msg->getHeader('baz'));
+var_dump($msg->getHeader('bla'));
$ex->delete();
$q->delete();
$errorXchange->delete();
$errorQ->delete();
?>
+==DONE==
--EXPECTF--
-%s
+count %s
array(1) {
[0]=>
array(5) {
["reason"]=>
string(8) "rejected"
["queue"]=>
- string(%d) "queue-%f"
+ string(%d) "queue-%s"
["time"]=>
object(AMQPTimestamp)#%d (1) {
["timestamp":"AMQPTimestamp":private]=>
- string(10) "%s"
+ float(%d)
}
["exchange"]=>
- string(%d) "exchange-%f"
+ string(%d) "exchange-%s"
["routing-keys"]=>
array(1) {
[0]=>
string(9) "routing.1"
}
}
-}
\ No newline at end of file
+}
+string(4) "fval"
+array(1) {
+ [0]=>
+ array(3) {
+ [0]=>
+ string(2) "aa"
+ [1]=>
+ string(2) "bb"
+ [2]=>
+ array(1) {
+ ["bar_nested"]=>
+ string(6) "nested"
+ }
+ }
+}
+array(5) {
+ [0]=>
+ string(1) "a"
+ [1]=>
+ string(2) "bc"
+ [2]=>
+ string(3) "def"
+ [3]=>
+ int(123)
+ [4]=>
+ string(1) "g"
+}
+array(1) {
+ ["one"]=>
+ int(2)
+}
+==DONE==
\ No newline at end of file
diff --git a/tests/amqpqueue_purge_basic.phpt b/tests/amqpqueue_purge_basic.phpt
index 639b34c4..df977d50 100644
--- a/tests/amqpqueue_purge_basic.phpt
+++ b/tests/amqpqueue_purge_basic.phpt
@@ -1,7 +1,9 @@
--TEST--
AMQPQueue
--SKIPIF--
-
+
--FILE--
diff --git a/tests/amqpqueue_recover.phpt b/tests/amqpqueue_recover.phpt
new file mode 100644
index 00000000..e5b5eaf5
--- /dev/null
+++ b/tests/amqpqueue_recover.phpt
@@ -0,0 +1,56 @@
+--TEST--
+AMQPQueue::nack
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('testrecover-' . bin2hex(random_bytes(32)));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+$exchangeName = $ex->getName();
+
+$q = new AMQPQueue($ch);
+$q->setName('testrecover-' . bin2hex(random_bytes(32)));
+$q->declareQueue();
+$q->bind($exchangeName);
+
+$ex->publish('message');
+
+function inspectMessage(AMQPQueue $q) {
+ $msg = $q->get();
+ echo $msg->getBody(), PHP_EOL;
+ echo $msg->isRedelivery() ? 'true' : 'false';
+ echo PHP_EOL;
+}
+
+inspectMessage($q);
+$q->recover();
+
+inspectMessage($q);
+$q->recover(true);
+
+inspectMessage($q);
+
+try {
+ $q->recover(false);
+} catch (AMQPConnectionException $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+--EXPECT--
+message
+false
+message
+true
+message
+true
+Server connection error: 540, message: NOT_IMPLEMENTED - requeue=false
diff --git a/tests/amqpqueue_setArgument.phpt b/tests/amqpqueue_setArgument.phpt
index 1ffc3c5a..c668b8ec 100644
--- a/tests/amqpqueue_setArgument.phpt
+++ b/tests/amqpqueue_setArgument.phpt
@@ -1,19 +1,23 @@
--TEST--
AMQPQueue::setArgument() test
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$heartbeat = 10;
-$q_dead_name = 'test.queue.dead.' . microtime(true);
-$q_name = 'test.queue.' . microtime(true);
+$q_dead_name = 'test.queue.dead.' . bin2hex(random_bytes(32));
+$q_name = 'test.queue.' . bin2hex(random_bytes(32));
$q = new AMQPQueue($ch);
$q->setName($q_name);
@@ -22,116 +26,38 @@ $q->declareQueue();
var_dump($q);
+class MyValue implements AMQPValue {
+ public function toAmqpValue() { return "foo"; }
+}
$q_dead = new AMQPQueue($ch);
$q_dead->setName($q_dead_name);
$q_dead->setArgument('x-dead-letter-exchange', '');
$q_dead->setArgument('x-dead-letter-routing-key', $q_name);
$q_dead->setArgument('x-message-ttl', $heartbeat * 10 * 1000);
+$q_dead->setArgument('x-null', null);
+$q_dead->setArgument('x-array', [0, 3]);
+$q_dead->setArgument('x-hash', ['foo' => 'bar']);
+$q_dead->setArgument('x-timestamp', new AMQPTimestamp(404));
+$q_dead->setArgument('x-decimal', new AMQPDecimal(1, 2));
+$q_dead->setArgument('x-custom-value', new MyValue());
$q_dead->setFlags(AMQP_AUTODELETE);
$q_dead->declareQueue();
var_dump($q_dead);
-$q_dead->setArgument('x-dead-letter-routing-key', null); // removes this key
+$q_dead->removeArgument('x-null');
+$q_dead->removeArgument('x-does-not-exist');
var_dump($q_dead);
?>
--EXPECTF--
-object(AMQPQueue)#3 (9) {
+object(AMQPQueue)#%d (%d) {
["connection":"AMQPQueue":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
+ %a
["channel":"AMQPQueue":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
- }
- }
+ %a
["name":"AMQPQueue":private]=>
- string(%d) "test.queue.%f"
- ["consumer_tag":"AMQPQueue":private]=>
+ string(%d) "test.queue.%s"
+ ["consumerTag":"AMQPQueue":private]=>
NULL
["passive":"AMQPQueue":private]=>
bool(false)
@@ -139,108 +65,20 @@ object(AMQPQueue)#3 (9) {
bool(false)
["exclusive":"AMQPQueue":private]=>
bool(false)
- ["auto_delete":"AMQPQueue":private]=>
+ ["autoDelete":"AMQPQueue":private]=>
bool(true)
["arguments":"AMQPQueue":private]=>
array(0) {
}
}
-object(AMQPQueue)#4 (9) {
+object(AMQPQueue)#%d (%d) {
["connection":"AMQPQueue":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
+ %a
["channel":"AMQPQueue":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
- }
- }
+ %a
["name":"AMQPQueue":private]=>
- string(%d) "test.queue.dead.%f"
- ["consumer_tag":"AMQPQueue":private]=>
+ string(%d) "test.queue.dead.%s"
+ ["consumerTag":"AMQPQueue":private]=>
NULL
["passive":"AMQPQueue":private]=>
bool(false)
@@ -248,114 +86,55 @@ object(AMQPQueue)#4 (9) {
bool(false)
["exclusive":"AMQPQueue":private]=>
bool(false)
- ["auto_delete":"AMQPQueue":private]=>
+ ["autoDelete":"AMQPQueue":private]=>
bool(true)
["arguments":"AMQPQueue":private]=>
- array(3) {
+ array(%d) {
["x-dead-letter-exchange"]=>
string(0) ""
["x-dead-letter-routing-key"]=>
- string(%d) "test.queue.%f"
+ string(%d) "test.queue.%s"
["x-message-ttl"]=>
int(100000)
- }
-}
-object(AMQPQueue)#4 (9) {
- ["connection":"AMQPQueue":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
+ ["x-null"]=>
NULL
- }
- ["channel":"AMQPQueue":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
+ ["x-array"]=>
+ array(2) {
+ [0]=>
int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
+ [1]=>
+ int(3)
+ }
+ ["x-hash"]=>
+ array(1) {
+ ["foo"]=>
+ string(3) "bar"
+ }
+ ["x-timestamp"]=>
+ object(AMQPTimestamp)#%d (%d) {
+ ["timestamp":"AMQPTimestamp":private]=>
+ float(404)
}
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
+ ["x-decimal"]=>
+ object(AMQPDecimal)#%d (%d) {
+ ["exponent":"AMQPDecimal":private]=>
+ int(1)
+ ["significand":"AMQPDecimal":private]=>
+ int(2)
+ }
+ ["x-custom-value"]=>
+ object(MyValue)#%d (%d) {
}
}
+}
+object(AMQPQueue)#%d (%d) {
+ ["connection":"AMQPQueue":private]=>
+ %a
+ ["channel":"AMQPQueue":private]=>
+ %a
["name":"AMQPQueue":private]=>
- string(%d) "test.queue.dead.%f"
- ["consumer_tag":"AMQPQueue":private]=>
+ string(%d) "test.queue.dead.%s"
+ ["consumerTag":"AMQPQueue":private]=>
NULL
["passive":"AMQPQueue":private]=>
bool(false)
@@ -363,13 +142,42 @@ object(AMQPQueue)#4 (9) {
bool(false)
["exclusive":"AMQPQueue":private]=>
bool(false)
- ["auto_delete":"AMQPQueue":private]=>
+ ["autoDelete":"AMQPQueue":private]=>
bool(true)
["arguments":"AMQPQueue":private]=>
- array(2) {
+ array(%d) {
["x-dead-letter-exchange"]=>
string(0) ""
+ ["x-dead-letter-routing-key"]=>
+ string(%d) "test.queue.%s"
["x-message-ttl"]=>
int(100000)
+ ["x-array"]=>
+ array(2) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(3)
+ }
+ ["x-hash"]=>
+ array(1) {
+ ["foo"]=>
+ string(3) "bar"
+ }
+ ["x-timestamp"]=>
+ object(AMQPTimestamp)#%d (%d) {
+ ["timestamp":"AMQPTimestamp":private]=>
+ float(404)
+ }
+ ["x-decimal"]=>
+ object(AMQPDecimal)#%d (%d) {
+ ["exponent":"AMQPDecimal":private]=>
+ int(1)
+ ["significand":"AMQPDecimal":private]=>
+ int(2)
+ }
+ ["x-custom-value"]=>
+ object(MyValue)#%d (%d) {
+ }
}
}
diff --git a/tests/amqpqueue_setFlags.phpt b/tests/amqpqueue_setFlags.phpt
new file mode 100644
index 00000000..1c19f943
--- /dev/null
+++ b/tests/amqpqueue_setFlags.phpt
@@ -0,0 +1,24 @@
+--TEST--
+AMQPQueue::setFlags(null)
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$q = new AMQPQueue($ch);
+$q->setFlags(null);
+var_dump($q->getFlags())
+
+?>
+==DONE==
+--EXPECTF--
+int(0)
+==DONE==
diff --git a/tests/amqpqueue_unbind_basic_empty_routing_key.phpt b/tests/amqpqueue_unbind_basic_empty_routing_key.phpt
index d7861539..91480ad6 100644
--- a/tests/amqpqueue_unbind_basic_empty_routing_key.phpt
+++ b/tests/amqpqueue_unbind_basic_empty_routing_key.phpt
@@ -1,28 +1,37 @@
--TEST--
AMQPQueue
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_DIRECT);
$ex->declareExchange();
$queue = new AMQPQueue($ch);
-$queue->setName("queue-" . microtime(true));
+$queue->setName("queue-" . bin2hex(random_bytes(32)));
$queue->declareQueue();
var_dump($queue->bind($ex->getName()));
var_dump($queue->unbind($ex->getName()));
+var_dump($queue->bind($ex->getName(), null));
+var_dump($queue->unbind($ex->getName(), null));
+
$queue->delete();
$ex->delete();
?>
--EXPECT--
-bool(true)
-bool(true)
+NULL
+NULL
+NULL
+NULL
diff --git a/tests/amqpqueue_unbind_basic_headers_arguments.phpt b/tests/amqpqueue_unbind_basic_headers_arguments.phpt
index a79e705b..44f3c51c 100644
--- a/tests/amqpqueue_unbind_basic_headers_arguments.phpt
+++ b/tests/amqpqueue_unbind_basic_headers_arguments.phpt
@@ -1,21 +1,25 @@
--TEST--
AMQPQueue
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName('exchange-' . microtime(true));
+$ex->setName('exchange-' . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_DIRECT);
$ex->declareExchange();
$queue = new AMQPQueue($ch);
-$queue->setName("queue-" . microtime(true));
+$queue->setName("queue-" . bin2hex(random_bytes(32)));
$queue->declareQueue();
$arguments = array('x-match' => 'all', 'type' => 'custom');
@@ -27,5 +31,5 @@ $queue->delete();
$ex->delete();
?>
--EXPECT--
-bool(true)
-bool(true)
+NULL
+NULL
diff --git a/tests/amqpqueue_var_dump.phpt b/tests/amqpqueue_var_dump.phpt
index 29d428a7..f341e0d0 100644
--- a/tests/amqpqueue_var_dump.phpt
+++ b/tests/amqpqueue_var_dump.phpt
@@ -2,12 +2,13 @@
AMQPQueue var_dump
--SKIPIF--
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
// Declare a new exchange
@@ -21,103 +22,15 @@ $q->setName('queue_var_dump');
$q->declareQueue();
var_dump($q);
?>
---EXPECT--
+--EXPECTF--
object(AMQPQueue)#4 (9) {
["connection":"AMQPQueue":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
+ %a
["channel":"AMQPQueue":private]=>
- object(AMQPChannel)#2 (6) {
- ["connection":"AMQPChannel":private]=>
- object(AMQPConnection)#1 (18) {
- ["login":"AMQPConnection":private]=>
- string(5) "guest"
- ["password":"AMQPConnection":private]=>
- string(5) "guest"
- ["host":"AMQPConnection":private]=>
- string(9) "localhost"
- ["vhost":"AMQPConnection":private]=>
- string(1) "/"
- ["port":"AMQPConnection":private]=>
- int(5672)
- ["read_timeout":"AMQPConnection":private]=>
- float(0)
- ["write_timeout":"AMQPConnection":private]=>
- float(0)
- ["connect_timeout":"AMQPConnection":private]=>
- float(0)
- ["rpc_timeout":"AMQPConnection":private]=>
- float(0)
- ["channel_max":"AMQPConnection":private]=>
- int(256)
- ["frame_max":"AMQPConnection":private]=>
- int(131072)
- ["heartbeat":"AMQPConnection":private]=>
- int(0)
- ["cacert":"AMQPConnection":private]=>
- string(0) ""
- ["key":"AMQPConnection":private]=>
- string(0) ""
- ["cert":"AMQPConnection":private]=>
- string(0) ""
- ["verify":"AMQPConnection":private]=>
- bool(true)
- ["sasl_method":"AMQPConnection":private]=>
- int(0)
- ["connection_name":"AMQPConnection":private]=>
- NULL
- }
- ["prefetch_count":"AMQPChannel":private]=>
- int(3)
- ["prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_count":"AMQPChannel":private]=>
- int(0)
- ["global_prefetch_size":"AMQPChannel":private]=>
- int(0)
- ["consumers":"AMQPChannel":private]=>
- array(0) {
- }
- }
+ %a
["name":"AMQPQueue":private]=>
string(14) "queue_var_dump"
- ["consumer_tag":"AMQPQueue":private]=>
+ ["consumerTag":"AMQPQueue":private]=>
NULL
["passive":"AMQPQueue":private]=>
bool(false)
@@ -125,7 +38,7 @@ object(AMQPQueue)#4 (9) {
bool(false)
["exclusive":"AMQPQueue":private]=>
bool(false)
- ["auto_delete":"AMQPQueue":private]=>
+ ["autoDelete":"AMQPQueue":private]=>
bool(true)
["arguments":"AMQPQueue":private]=>
array(0) {
diff --git a/tests/amqptimestamp.phpt b/tests/amqptimestamp.phpt
index 6424f8b6..193fb06a 100644
--- a/tests/amqptimestamp.phpt
+++ b/tests/amqptimestamp.phpt
@@ -2,22 +2,19 @@
AMQPTimestamp
--SKIPIF--
')) {
- print "skip";
-}
+if (!extension_loaded("amqp")) print "skip AMQP extension is not loaded";
+?>
--FILE--
getTimestamp(), (string) $timestamp);
+var_dump($timestamp === $timestamp->toAmqpValue());
+var_dump($timestamp instanceof AMQPValue);
$timestamp = new AMQPTimestamp(100000.1);
var_dump($timestamp->getTimestamp(), (string) $timestamp);
-new AMQPTimestamp();
-
-new AMQPTimestamp("string");
-
try {
new AMQPTimestamp(AMQPTimestamp::MIN - 1);
} catch (AMQPValueException $e) {
@@ -32,24 +29,22 @@ try {
var_dump((new ReflectionClass("AMQPTimestamp"))->isFinal());
-var_dump(AMQPTimestamp::MAX);
+var_dump(number_format(AMQPTimestamp::MAX, 0, '.', '_'));
var_dump(AMQPTimestamp::MIN);
?>
==END==
--EXPECTF--
+float(100000)
string(6) "100000"
+bool(true)
+bool(true)
+float(100000)
string(6) "100000"
-string(6) "100000"
-string(6) "100000"
-
-Warning: AMQPTimestamp::__construct() expects exactly 1 parameter, 0 given in %s on line %d
-
-Warning: AMQPTimestamp::__construct() expects parameter 1 to be %s, string given in %s on line %d
The timestamp parameter must be greater than 0.
The timestamp parameter must be less than 18446744073709551616.
bool(true)
-string(20) "18446744073709551616"
-string(1) "0"
+string(26) "18_446_744_073_709_551_616"
+float(0)
-==END==
+==END==
\ No newline at end of file
diff --git a/tests/amqptimestamp_php8.phpt b/tests/amqptimestamp_php8.phpt
deleted file mode 100644
index e76102fe..00000000
--- a/tests/amqptimestamp_php8.phpt
+++ /dev/null
@@ -1,60 +0,0 @@
---TEST--
-AMQPTimestamp
---SKIPIF--
-getTimestamp(), (string) $timestamp);
-
-$timestamp = new AMQPTimestamp(100000.1);
-var_dump($timestamp->getTimestamp(), (string) $timestamp);
-
-try {
- new AMQPTimestamp();
-} catch(ArgumentCountError $e) {
- echo $e->getMessage() . "\n";
-}
-try {
- new AMQPTimestamp("string");
-} catch(TypeError $e) {
- echo $e->getMessage() . "\n";
-}
-
-try {
- new AMQPTimestamp(AMQPTimestamp::MIN - 1);
-} catch (AMQPValueException $e) {
- echo $e->getMessage() . "\n";
-}
-
-try {
- new AMQPTimestamp(INF);
-} catch (AMQPValueException $e) {
- echo $e->getMessage() . "\n";
-}
-
-var_dump((new ReflectionClass("AMQPTimestamp"))->isFinal());
-
-var_dump(AMQPTimestamp::MAX);
-var_dump(AMQPTimestamp::MIN);
-?>
-
-==END==
---EXPECTF--
-string(6) "100000"
-string(6) "100000"
-string(6) "100000"
-string(6) "100000"
-AMQPTimestamp::__construct() expects exactly 1 argument, 0 given
-AMQPTimestamp::__construct(): Argument #1 ($timestamp) must be of type float, string given
-The timestamp parameter must be greater than 0.
-The timestamp parameter must be less than 18446744073709551616.
-bool(true)
-string(20) "18446744073709551616"
-string(1) "0"
-
-==END==
diff --git a/tests/bug_17831.phpt b/tests/bug_17831.phpt
index 52e6bd91..5513dd8c 100644
--- a/tests/bug_17831.phpt
+++ b/tests/bug_17831.phpt
@@ -1,16 +1,20 @@
--TEST--
Segfault when publishing to non existent exchange
--SKIPIF--
-
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
-$ch = new AMQPChannel($c);
+$ch = new AMQPChannel($cnn);
$ex = new AMQPExchange($ch);
-$ex->setName("exchange-" . microtime(true));
+$ex->setName("exchange-" . bin2hex(random_bytes(32)));
$ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
try {
diff --git a/tests/bug_19707.phpt b/tests/bug_19707.phpt
index 488b42cf..d2749dbb 100644
--- a/tests/bug_19707.phpt
+++ b/tests/bug_19707.phpt
@@ -1,10 +1,14 @@
--TEST--
AMQPQueue::get() doesn't return the message
--SKIPIF--
-
+
--FILE--
setHost(getenv('PHP_AMQP_HOST'));
$cnn->connect();
$ch = new AMQPChannel($cnn);
@@ -15,7 +19,7 @@ $ex->setType(AMQP_EX_TYPE_FANOUT);
$ex->declareExchange();
$q = new AMQPQueue($ch);
-$q->setName('queue' . microtime(true));
+$q->setName('queue' . bin2hex(random_bytes(32)));
$q->setFlags(AMQP_DURABLE);
$q->declareQueue();
@@ -41,21 +45,21 @@ $ex->delete();
?>
--EXPECT--
message received from get:
-getAppId => ''
+getAppId => NULL
getBody => 'message'
-getContentEncoding => ''
+getContentEncoding => NULL
getContentType => 'text/plain'
-getCorrelationId => ''
+getCorrelationId => NULL
getDeliveryTag => 1
getExchangeName => 'exchange_testing_19707'
-getExpiration => ''
+getExpiration => NULL
getHeaders => array (
)
-getMessageId => ''
+getMessageId => NULL
getPriority => 0
-getReplyTo => ''
+getReplyTo => NULL
getRoutingKey => 'routing.key'
getTimeStamp => 0
-getType => ''
-getUserId => ''
+getType => NULL
+getUserId => NULL
isRedelivery => false
\ No newline at end of file
diff --git a/tests/bug_19840.phpt b/tests/bug_19840.phpt
index 083d8f75..bd0e09ce 100644
--- a/tests/bug_19840.phpt
+++ b/tests/bug_19840.phpt
@@ -1,7 +1,9 @@
--TEST--
Bug 19840: Connection Exception
--SKIPIF--
-
+
--FILE--
connect();
+ $cnn = new AMQPConnection($lServer);
+ $cnn->connect();
echo "No exception thrown\n";
} catch (Exception $e) {
echo get_class($e), "({$e->getCode()}): ", $e->getMessage();
}
?>
--EXPECT--
-AMQPConnectionException(0): Socket error: could not connect to host.
\ No newline at end of file
+AMQPConnectionException(0): Socket error: could not connect to host, hostname lookup failed
\ No newline at end of file
diff --git a/tests/bug_351.phpt b/tests/bug_351.phpt
new file mode 100644
index 00000000..54143b53
--- /dev/null
+++ b/tests/bug_351.phpt
@@ -0,0 +1,51 @@
+--TEST--
+AMQPEnvelope::getBody returns false instead of empty string
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('exchange' . bin2hex(random_bytes(32)));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declareExchange();
+
+$q = new AMQPQueue($ch);
+$q->setName('queue1' . bin2hex(random_bytes(32)));
+$q->declareQueue();
+
+$q->bind($ex->getName(), '*');
+
+$ex->publish('');
+
+$msg = $q->get(AMQP_AUTOACK);
+echo "MSG1\n";
+var_dump($msg->getBody(), $msg->getRoutingKey(), $msg->getConsumerTag(), $msg->getDeliveryTag(), $msg->getExchangeName());
+
+$msg2 = new AMQPEnvelope();
+echo "MSG2\n";
+var_dump($msg2->getBody(), $msg2->getRoutingKey(), $msg2->getConsumerTag(), $msg2->getDeliveryTag(), $msg2->getExchangeName());
+?>
+==DONE==
+--EXPECTF--
+MSG1
+string(0) ""
+string(0) ""
+string(0) ""
+int(%d)
+string(%d) "exchange%s"
+MSG2
+string(0) ""
+string(0) ""
+NULL
+NULL
+NULL
+==DONE==
\ No newline at end of file
diff --git a/tests/bug_385.phpt b/tests/bug_385.phpt
new file mode 100644
index 00000000..4d18d1f7
--- /dev/null
+++ b/tests/bug_385.phpt
@@ -0,0 +1,44 @@
+--TEST--
+#385 Testing consumer cleared on cancel
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+
+$channel = new AMQPChannel($cnn);
+$exchange = new AMQPExchange($channel);
+
+$queue = new AMQPQueue($channel);
+$queue->declareQueue();
+
+// Asynchronously consuming
+$queue->consume(null, AMQP_NOPARAM, 'someid');
+
+// Showing that current consumer tag is from last consume call
+echo $queue->getConsumerTag() ?? 'none';
+
+echo PHP_EOL;
+
+// Cancel by a different consumer tag than the latest one -> expecting the consumer tag to not clear
+$queue->cancel('someotherid');
+
+echo $queue->getConsumerTag() ?? 'none';
+
+echo PHP_EOL;
+
+// Cancel by consumer tag -> expecting the current consumer tag to clear
+$queue->cancel('someid');
+
+// Current consumer tag should be null as consumer has been cancelled
+echo $queue->getConsumerTag() ?? 'none';
+?>
+--EXPECTF--
+someid
+someid
+none
diff --git a/tests/bug_61533.phpt b/tests/bug_61533.phpt
index f53c3159..29716d63 100644
--- a/tests/bug_61533.phpt
+++ b/tests/bug_61533.phpt
@@ -1,12 +1,16 @@
--TEST--
Constructing AMQPQueue with AMQPConnection segfaults
--SKIPIF--
-
+
--FILE--
connect();
-$chan = new AMQPChannel($conn);
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+$chan = new AMQPChannel($cnn);
if (!class_exists('TypeError')) {
class TypeError extends Exception {}
@@ -14,7 +18,7 @@ if (!class_exists('TypeError')) {
try {
error_reporting(error_reporting() & ~E_WARNING);
- $queue = new AMQPQueue($conn);
+ $queue = new AMQPQueue($cnn);
} catch (TypeError $e) {
echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), '.', PHP_EOL; // we pad exception message with dot to make EXPETF be the same on PHP 5 and PHP 7
}
diff --git a/tests/bug_62354.phpt b/tests/bug_62354.phpt
index 6330476c..a92fe7ca 100644
--- a/tests/bug_62354.phpt
+++ b/tests/bug_62354.phpt
@@ -1,7 +1,9 @@
--TEST--
Constructing AMQPQueue with AMQPConnection segfaults
--SKIPIF--
-
+
--FILE--
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
-$channel = new AMQPChannel($connection);
+$channel = new AMQPChannel($cnn);
$channel->setPrefetchCount(2);
$exchange = new AMQPExchange($channel);
diff --git a/tests/bug_gh155_direct_reply_to.phpt b/tests/bug_gh155_direct_reply_to.phpt
index f3a901cb..84f4d8ba 100644
--- a/tests/bug_gh155_direct_reply_to.phpt
+++ b/tests/bug_gh155_direct_reply_to.phpt
@@ -1,15 +1,17 @@
--TEST--
#155 RabbitMQ's Direct reply-to (related to consume multiple)
--SKIPIF--
-
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
-$channel = new AMQPChannel($conn);
+$channel = new AMQPChannel($cnn);
$exchange = new AMQPExchange($channel);
@@ -39,7 +41,7 @@ echo 'Reply-to queue: ', $reply_to, PHP_EOL;
echo 'Prepare response queue...' . PHP_EOL;
-$channel_2 = new AMQPChannel($conn);
+$channel_2 = new AMQPChannel($cnn);
$q_reply = new AMQPQueue($channel_2);
$q_reply->setName($reply_to);
@@ -48,7 +50,7 @@ $q_reply->declareQueue();
echo 'Publishing response...' . PHP_EOL;
-$exchange->publish('response', $reply_to, AMQP_NOPARAM);
+$exchange->publish('response', $reply_to);
echo 'Waiting for reply...' . PHP_EOL;
diff --git a/tests/bug_gh50-1.phpt b/tests/bug_gh50-1.phpt
index 280ff761..46b61031 100644
--- a/tests/bug_gh50-1.phpt
+++ b/tests/bug_gh50-1.phpt
@@ -1,15 +1,19 @@
--TEST--
Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (1)
--SKIPIF--
-
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
for ($i = 0; $i < 3; $i++) {
- $channel = new AMQPChannel($connection);
+ $channel = new AMQPChannel($cnn);
var_dump($channel->getChannelId());
$queue = new AMQPQueue($channel);
@@ -23,5 +27,5 @@ for ($i = 0; $i < 3; $i++) {
--EXPECT--
int(1)
int(2)
-int(1)
+int(3)
==DONE==
diff --git a/tests/bug_gh50-2.phpt b/tests/bug_gh50-2.phpt
index b95b2901..cc814af3 100644
--- a/tests/bug_gh50-2.phpt
+++ b/tests/bug_gh50-2.phpt
@@ -1,15 +1,19 @@
--TEST--
Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (2)
--SKIPIF--
-
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
for ($i = 0; $i < 3; $i++) {
- $channel = new AMQPChannel($connection);
+ $channel = new AMQPChannel($cnn);
var_dump($channel->getChannelId());
$queue = new AMQPQueue($channel);
diff --git a/tests/bug_gh50-3.phpt b/tests/bug_gh50-3.phpt
index f63e3a61..f0c7f1d9 100644
--- a/tests/bug_gh50-3.phpt
+++ b/tests/bug_gh50-3.phpt
@@ -1,15 +1,19 @@
--TEST--
Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (3)
--SKIPIF--
-
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
for ($i = 0; $i < 3; $i++) {
- $channel = new AMQPChannel($connection);
+ $channel = new AMQPChannel($cnn);
var_dump($channel->getChannelId());
$queue = new AMQPQueue($channel);
@@ -19,12 +23,13 @@ for ($i = 0; $i < 3; $i++) {
$queue->delete();
}
-$connection = new AMQPConnection();
-$connection->connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
for ($i = 0; $i < 3; $i++) {
- $channel = new AMQPChannel($connection);
+ $channel = new AMQPChannel($cnn);
var_dump($channel->getChannelId());
$queue = new AMQPQueue($channel);
@@ -40,8 +45,8 @@ for ($i = 0; $i < 3; $i++) {
--EXPECT--
int(1)
int(2)
-int(1)
+int(3)
int(1)
int(2)
-int(1)
+int(3)
==DONE==
diff --git a/tests/bug_gh50-4.phpt b/tests/bug_gh50-4.phpt
index eb3539dc..57477245 100644
--- a/tests/bug_gh50-4.phpt
+++ b/tests/bug_gh50-4.phpt
@@ -1,17 +1,21 @@
--TEST--
Channel creation race condition (https://github.com/pdezwart/php-amqp/issues/50) (4)
--SKIPIF--
-
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
$channels = array();
for ($i = 0; $i < 3; $i++) {
- $channel = $channels[] = new AMQPChannel($connection);
+ $channel = $channels[] = new AMQPChannel($cnn);
var_dump($channel->getChannelId());
$queue = new AMQPQueue($channel);
@@ -21,12 +25,13 @@ for ($i = 0; $i < 3; $i++) {
$queue->delete();
}
-$connection = new AMQPConnection();
-$connection->connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
for ($i = 0; $i < 3; $i++) {
- $channel = $channels[] = new AMQPChannel($connection);
+ $channel = $channels[] = new AMQPChannel($cnn);
var_dump($channel->getChannelId());
$queue = new AMQPQueue($channel);
diff --git a/tests/bug_gh53-2.phpt b/tests/bug_gh53-2.phpt
index 08674a1a..e765c007 100644
--- a/tests/bug_gh53-2.phpt
+++ b/tests/bug_gh53-2.phpt
@@ -1,21 +1,25 @@
--TEST--
Upgrade to RabbitMQ 3.1.0-1: AMQPConnectionException: connection closed unexpectedly (2)
--SKIPIF--
-
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
-$channel = new AMQPChannel($connection);
+$channel = new AMQPChannel($cnn);
$exchange = new AMQPExchange($channel);
-$exchange->setName('exchange' . microtime(true));
+$exchange->setName('exchange' . bin2hex(random_bytes(32)));
$exchange->setType(AMQP_EX_TYPE_TOPIC);
$exchange->declareExchange();
$queue = new AMQPQueue($channel);
-$queue->setName('queue1' . microtime(true));
+$queue->setName('queue1' . bin2hex(random_bytes(32)));
$queue->declareQueue();
$queue->bind($exchange->getName(), '#');
diff --git a/tests/bug_gh53.phpt b/tests/bug_gh53.phpt
index 2ea03575..a4634c5b 100644
--- a/tests/bug_gh53.phpt
+++ b/tests/bug_gh53.phpt
@@ -1,13 +1,17 @@
--TEST--
Upgrade to RabbitMQ 3.1.0-1: AMQPConnectionException: connection closed unexpectedly
--SKIPIF--
-
+
--FILE--
connect();
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
-$channel = new AMQPChannel($connection);
+$channel = new AMQPChannel($cnn);
var_dump($channel->getPrefetchSize());
var_dump($channel->getPrefetchCount());
@@ -23,7 +27,7 @@ try {
echo get_class($e), "({$e->getCode()}): ", $e->getMessage(), PHP_EOL;
}
var_dump($channel->isConnected());
-var_dump($connection->isConnected());
+var_dump($cnn->isConnected());
var_dump($channel->getPrefetchSize());
var_dump($channel->getPrefetchCount());
diff --git a/tests/bug_gh72-1.phpt b/tests/bug_gh72-1.phpt
index d1237585..9673a89b 100644
--- a/tests/bug_gh72-1.phpt
+++ b/tests/bug_gh72-1.phpt
@@ -1,12 +1,16 @@
--TEST--
#72 Publishing to an exchange with an empty name is valid and should not throw an exception (1)
--SKIPIF--
-
+
--FILE--
connect();
-$channel = new AMQPChannel($connection);
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+$channel = new AMQPChannel($cnn);
$exchange = new AMQPExchange($channel);
$exchange->setName('');
diff --git a/tests/bug_gh72-2.phpt b/tests/bug_gh72-2.phpt
index 2abe3d29..b6534c01 100644
--- a/tests/bug_gh72-2.phpt
+++ b/tests/bug_gh72-2.phpt
@@ -1,12 +1,16 @@
--TEST--
#72 Publishing to an exchange with an empty name is valid and should not throw an exception (2)
--SKIPIF--
-
+
--FILE--
connect();
-$channel = new AMQPChannel($connection);
+$cnn = new AMQPConnection();
+$cnn->setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+$channel = new AMQPChannel($cnn);
$exchange = new AMQPExchange($channel);
diff --git a/tests/ini_validation_failure.phpt b/tests/ini_validation_failure.phpt
new file mode 100644
index 00000000..0ad198ee
--- /dev/null
+++ b/tests/ini_validation_failure.phpt
@@ -0,0 +1,64 @@
+--TEST--
+Bad INI settings are rejected
+--SKIPIF--
+
+--INI--
+amqp.host=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+amqp.vhost=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+amqp.port=-1
+amqp.login=00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+amqp.password=00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+amqp.read_timeout=-1
+amqp.write_timeout=-1
+amqp.connect_timeout=-1
+amqp.rpc_timeout=-1
+amqp.timeout=-1
+amqp.prefetch_count=-1
+amqp.prefetch_size=-1
+amqp.global_prefetch_count=-1
+amqp.global_prefetch_size=-1
+amqp.heartbeat=-1
+amqp.channel_max=257
+amqp.frame_max=-1
+--FILE--
+
+==DONE==
+--EXPECT--
+string(9) "localhost"
+string(1) "/"
+string(4) "5672"
+string(5) "guest"
+string(5) "guest"
+string(1) "0"
+string(1) "0"
+string(1) "0"
+string(1) "0"
+string(0) ""
+string(1) "3"
+string(1) "0"
+string(1) "0"
+string(1) "0"
+string(1) "0"
+string(3) "256"
+string(6) "131072"
+==DONE==
\ No newline at end of file
diff --git a/tests/package-version.phpt b/tests/package-version.phpt
index 52ffe0e3..5b12f21e 100644
--- a/tests/package-version.phpt
+++ b/tests/package-version.phpt
@@ -1,7 +1,10 @@
--TEST--
Compare version in package.xml and module
--SKIPIF--
-
+
--FILE--
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('ex-' . bin2hex(random_bytes(32)));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declare();
+
+class RecursiveValue implements AMQPValue {
+ public function toAmqpValue()
+ {
+ return $this;
+ }
+}
+
+class NestedValue implements AMQPValue {
+ private $v;
+
+ public function __construct($v)
+ {
+ $this->v = $v;
+ }
+
+ public function toAmqpValue()
+ {
+ return $this->v;
+ }
+}
+
+try {
+ $ex->publish('msg', null, null, ['headers' => ['x-val' => new RecursiveValue()]]);
+} catch (AMQPException $e) {
+ var_dump($e->getMessage());
+}
+$ex->publish('msg', null, null, ['headers' => ['x-val' => new NestedValue(new stdClass())]]);
+
+$ex->publish('msg', null, null, ['headers' => ['x-val' => new NestedValue(new NestedValue(new stdClass()))]]);
+
+?>
+==DONE==
+--EXPECTF--
+string(%d) "Maximum serialization depth of 128 reached while serializing value"
+
+Warning: AMQPExchange::publish(): Ignoring field 'x-val' due to unsupported value type (object) in %s on line %d
+
+Warning: AMQPExchange::publish(): Ignoring field 'x-val' due to unsupported value type (object) in %s on line %d
+==DONE==
\ No newline at end of file
diff --git a/tests/serialize-custom-amqpvalue.phpt b/tests/serialize-custom-amqpvalue.phpt
new file mode 100644
index 00000000..0d91bc5d
--- /dev/null
+++ b/tests/serialize-custom-amqpvalue.phpt
@@ -0,0 +1,80 @@
+--TEST--
+Serialize custom AMQP value
+--SKIPIF--
+
+--FILE--
+setHost(getenv('PHP_AMQP_HOST'));
+$cnn->connect();
+
+$ch = new AMQPChannel($cnn);
+
+$ex = new AMQPExchange($ch);
+$ex->setName('ex-' . bin2hex(random_bytes(32)));
+$ex->setType(AMQP_EX_TYPE_FANOUT);
+$ex->declare();
+
+$q = new AMQPQueue($ch);
+$q->setName('q-' . bin2hex(random_bytes(32)));
+$q->declare();
+$q->bind($ex->getName());
+
+class MyAmqpValue implements AMQPValue {
+ public function toAmqpValue()
+ {
+ return 'foo';
+ }
+}
+
+class MyNestedAmqpValue implements AMQPValue {
+ private $val;
+ public function __construct($val) {
+ $this->val = $val;
+ }
+
+ public function toAmqpValue() {
+ return $this->val;
+ }
+}
+
+$ex->publish('msg', null, null, ['headers' => [
+ 'x-val' => new MyAmqpValue(),
+ 'x-nested' => new MyNestedAmqpValue(new MyAmqpValue()),
+ 'x-array' => [new MyNestedAmqpValue(new MyAmqpValue())],
+ 'x-array-nested' => new MyNestedAmqpValue([new MyNestedAmqpValue(1), 2]),
+ 'x-nested-decimal' => new MyNestedAmqpValue(new AMQPDecimal(1, 2345)),
+ 'x-nested-timestamp' => new MyNestedAmqpValue(new AMQPTimestamp(987))
+]]);
+
+$msg = $q->get(AMQP_AUTOACK);
+
+var_dump($msg->getHeader('x-val'));
+var_dump($msg->getHeader('x-nested'));
+var_dump($msg->getHeader('x-array'));
+var_dump($msg->getHeader('x-array-nested'));
+var_dump($msg->getHeader('x-nested-decimal')->getExponent());
+var_dump($msg->getHeader('x-nested-decimal')->getSignificand());
+var_dump($msg->getHeader('x-nested-timestamp')->getTimestamp());
+?>
+==DONE==
+--EXPECT--
+string(3) "foo"
+string(3) "foo"
+array(1) {
+ [0]=>
+ string(3) "foo"
+}
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ int(2)
+}
+int(1)
+int(2345)
+float(987)
+==DONE==
\ No newline at end of file
diff --git a/tests/testtest.phpt b/tests/testtest.phpt
new file mode 100644
index 00000000..d364cf24
--- /dev/null
+++ b/tests/testtest.phpt
@@ -0,0 +1,57 @@
+--TEST--
+Test the tests
+--FILE--
+.*?)--[A-Z]+--/s', $content, $matches)) {
+ printf("%s TEST section cannot be parsed\n", basename($test));
+ continue;
+ }
+ ['testCode' => $testCode] = $matches;
+
+ if (!preg_match('/--SKIPIF--(?P.*?)--[A-Z]+--/s', $content, $matches)) {
+ printf("%s SKIPIF section cannot be parsed\n", basename($test));
+ continue;
+ }
+
+ ['skipCode' => $skipCode] = $matches;
+
+ if (!preg_match('/if\s*\(!extension_loaded\("amqp"\)\)\s*\{?\s*print "skip AMQP extension is not loaded";/', $skipCode)) {
+ printf("%s --SKIP-- does not check for the extension being present\n", basename($test));
+ continue;
+ }
+
+ $hostVars = ['PHP_AMQP_HOST', 'PHP_AMQP_SSL_HOST'];
+ foreach ($hostVars as $hostVar) {
+ if (strpos($testCode, $hostVar) !== false && !preg_match('/!getenv\(["\']' . $hostVar . '/', $skipCode)) {
+ printf("%s --TEST-- contains reference to %s but --SKIP-- does not check for it\n", basename($test), $hostVar);
+ continue 2;
+ }
+
+ if (strpos($testCode, $hostVar) === false && strpos($skipCode, $hostVar) !== false) {
+ printf("%s --TEST-- contains no reference to %s but --SKIP-- checks for reference\n", basename($test), $hostVar);
+ continue 2;
+ }
+ }
+}
+?>
+==DONE==
+--EXPECT--
+
+==DONE==
\ No newline at end of file