*.DS_Store
composer.lock
-vendor
phpunit.xml
tests/log
build
--- /dev/null
+*.DS_Store
+composer.lock
+vendor
+phpunit.xml
+tests/log
+build
+phplog
+
+# Ignore eclipse project files
+.buildpath
+.project
+.settings
--- /dev/null
+[submodule "sample-code-php"]
+ path = sample-code-php
+ url = https://github.com/AuthorizeNet/sample-code-php.git
+ branch = master
--- /dev/null
+checks:
+ php:
+ code_rating: true
+ duplication: true
+
+tools:
+ php_mess_detector: true
+ php_code_sniffer: true
+ sensiolabs_security_checker: true
+ php_cpd: true
+ php_loc: true
+ php_pdepend: true
+ external_code_coverage:
+ timeout: 1500 #15 min
+filter:
+ paths:
+ - lib/*
\ No newline at end of file
--- /dev/null
+language: php
+
+sudo: false
+
+env:
+ - TEST_SUITE=samples
+
+php:
+ - 5.6
+ - 7.0
+ - 7.1
+
+before_install:
+ # execute all of the commands which need to be executed
+ # before installing dependencies
+ - composer validate # make sure that our composer.json file is valid for packaging
+
+install:
+ # install all of the dependencies we need here
+ - pecl install xmldiff
+ - composer install --prefer-dist
+
+before_script:
+ # execute all of the commands which need to be executed
+ # before running actual tests
+ - git submodule update --remote --recursive
+
+script:
+ # execute all of the tests or other commands to determine
+ # whether the build will pass or fail
+ - if [[ "$TEST_SUITE" == "samples" ]]; then phpenv config-rm xdebug.ini; cp -R lib sample-code-php/; cp -R vendor sample-code-php/; cd sample-code-php; vendor/phpunit/phpunit/phpunit test-runner.php .; cat testslog; fi
+
+after_script:
+# - if [[ "$TEST_SUITE" == "coverage" ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
+# - if [[ "$TEST_SUITE" == "coverage" ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
--- /dev/null
+SDK LICENSE AGREEMENT\r
+This Software Development Kit (“SDK”) License Agreement (“Agreement”) is between you (both the individual downloading the SDK and any legal entity on behalf of which such individual is acting) (“You” or “Your”) and Authorize.Net LLC (“Authorize.Net’).\r
+IT IS IMPORTANT THAT YOU READ CAREFULLY AND UNDERSTAND THIS AGREEMENT. BY CLICKING THE “I ACCEPT” BUTTON OR AN EQUIVALENT INDICATOR OR BY DOWNLOADING, INSTALLING OR USING THE SDK OR THE DOCUMENTATION, YOU AGREE TO BE BOUND BY THIS AGREEMENT. \r
+\r
+1. DEFINITIONS\r
+ 1.1 “Application(s)” means software programs that You develop to operate with the Gateway using components of the Software.\r
+ 1.2 “Documentation” means the materials made available to You in connection with the Software by or on behalf of Authorize.Net pursuant to this Agreement. \r
+ 1.3 “Gateway” means any electronic payment platform maintained and operated by Authorize.Net and any of its affiliates.\r
+ 1.4 “Software” means all of the software included in the software development kit made available to You by or on behalf of Authorize.Net pursuant to this Agreement, including but not limited to sample source code, code snippets, software tools, code libraries, sample applications, Documentation and any upgrades, modified versions, updates, and/or additions thereto, if any, made available to You by or on behalf of Authorize.Net pursuant to this Agreement. \r
+2. GRANT OF LICENSE; RESTRICTIONS\r
+ 2.1 Limited License. Subject to and conditioned upon Your compliance with the terms of this Agreement, Authorize.Net hereby grants to You a limited, revocable, non-exclusive, non-transferable, royalty-free license during the term of this Agreement to: (a) in any country worldwide, use, reproduce, modify, and create derivative works of the components of the Software solely for the purpose of developing, testing and manufacturing Applications; (b) distribute, sell or otherwise provide Your Applications that include components of the Software to Your end users; and (c) use the Documentation in connection with the foregoing activities. The license to distribute Applications that include components of the Software as set forth in subsection (b) above includes the right to grant sublicenses to Your end users to use such components of the Software as incorporated into such Applications, subject to the limitations and restrictions set forth in this Agreement. \r
+ 2.2 Restrictions. You shall not (and shall have no right to): (a) make or distribute copies of the Software or the Documentation, in whole or in part, except as expressly permitted pursuant to Section 2.1; (b) alter or remove any copyright, trademark, trade name or other proprietary notices, legends, symbols or labels appearing on or in the Software or Documentation; (c) sublicense (or purport to sublicense) the Software or the Documentation, in whole or in part, to any third party except as expressly permitted pursuant to Section 2.1; (d) engage in any activity with the Software, including the development or distribution of an Application, that interferes with, disrupts, damages, or accesses in an unauthorized manner the Gateway or platform, servers, or systems of Authorize.Net, any of its affiliates, or any third party; (e) make any statements that Your Application is “certified” or otherwise endorsed, or that its performance is guaranteed, by Authorize.Net or any of its affiliates; or (f) otherwise use or exploit the Software or the Documentation for any purpose other than to develop and distribute Applications as expressly permitted by this Agreement. \r
+ 2.3 Ownership. You shall retain ownership of Your Applications developed in accordance with this Agreement, subject to Authorize.Net’s ownership of the Software and Documentation (including Authorize.Net’s ownership of any portion of the Software or Documentation incorporated in Your Applications). You acknowledge and agree that all right, title and interest in and to the Software and Documentation shall, at all times, be and remain the exclusive property of Authorize.Net and that You do not have or acquire any rights, express or implied, in the Software or Documentation except those rights expressly granted under this Agreement. \r
+ 2.4 No Support. Authorize.Net has no obligation to provide support, maintenance, upgrades, modifications or new releases of the Software.\r
+ 2.5 Open Source Software. You hereby acknowledge that the Software may contain software that is distributed under “open source” license terms (“Open Source Software”). You shall review the Documentation in order to determine which portions of the Software are Open Source Software and are licensed under such Open Source Software license terms. To the extent any such license requires that Authorize.Net provide You any rights with respect to such Open Source Software that are inconsistent with the limited rights granted to You in this Agreement, then such rights in the applicable Open Source Software license shall take precedence over the rights and restrictions granted in this Agreement, but solely with respect to such Open Source Software. You acknowledge that the Open Source Software license is solely between You and the applicable licensor of the Open Source Software and that Your use, reproduction and distribution of Open Source Software shall be in compliance with applicable Open Source Software license. You understand and agree that Authorize.Net is not liable for any loss or damage that You may experience as a result of Your use of Open Source Software and that You will look solely to the licensor of the Open Source Software in the event of any such loss or damage. \r
+ 2.6 License to Authorize.Net. In the event You choose to submit any suggestions, feedback or other information or materials related to the Software or Documentation or Your use thereof (collectively, “Feedback”) to Authorize.Net, You hereby grant to Authorize.Net a worldwide, non-exclusive, royalty-free, transferable, sublicensable, perpetual and irrevocable license to use and otherwise exploit such Feedback in connection with the Software, Documentation, and other products and services. \r
+ 2.7 Use. \r
+ (a) You represent, warrant and agree to use the Software and write Applications only for purposes permitted by (i) this Agreement; (ii) applicable law and regulation, including, without limitation, the Payment Card Industry Data Security Standard (PCI DSS); and (iii) generally accepted practices or guidelines in the relevant jurisdictions. You represent, warrant and agree that if You use the Software to develop Applications for general public end users, that You will protect the privacy and legal rights of those users. If the Application receives or stores personal or sensitive information provided by end users, it must do so securely and in compliance with all applicable laws and regulations, including card association regulations. If the Application receives Authorize.Net account information, the Application may only use that information to access the end user's Authorize.Net account. You represent, warrant and agree that You are solely responsible for (and that neither Authorize.Net nor its affiliates have any responsibility to You or to any third party for): (i) any data, content, or resources that You obtain, transmit or display through the Application; and (ii) any breach of Your obligations under this Agreement, any applicable third party license, or any applicable law or regulation, and for the consequences of any such breach. \r
+ 3. WARRANTY DISCLAIMER; LIMITATION OF LIABILITY\r
+ 3.1 Disclaimer. THE SOFTWARE AND THE DOCUMENTATION ARE PROVIDED ON AN “AS IS” AND “AS AVAILABLE” BASIS WITH NO WARRANTY. YOU AGREE THAT YOUR USE OF THE SOFTWARE AND THE DOCUMENTATION IS AT YOUR SOLE RISK AND YOU ARE SOLELY RESPONSIBLE FOR ANY DAMAGE TO YOUR COMPUTER SYSTEM OR OTHER DEVICE OR LOSS OF DATA THAT RESULTS FROM SUCH USE. TO THE FULLEST EXTENT PERMISSIBLE UNDER APPLICABLE LAW, AUTHORIZE.NET AND ITS AFFILIATES EXPRESSLY DISCLAIM ALL WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, WITH RESPECT TO THE SOFTWARE AND THE DOCUMENTATION, INCLUDING ALL WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, SATISFACTORY QUALITY, ACCURACY, TITLE AND NON-INFRINGEMENT, AND ANY WARRANTIES THAT MAY ARISE OUT OF COURSE OF PERFORMANCE, COURSE OF DEALING OR USAGE OF TRADE. NEITHER AUTHORIZE.NET NOR ITS AFFILIATES WARRANT THAT THE FUNCTIONS OR INFORMATION CONTAINED IN THE SOFTWARE OR THE DOCUMENTATION WILL MEET ANY REQUIREMENTS OR NEEDS YOU MAY HAVE, OR THAT THE SOFTWARE OR DOCUMENTATION WILL OPERATE ERROR FREE, OR THAT THE SOFTWARE OR DOCUMENTATION IS COMPATIBLE WITH ANY PARTICULAR OPERATING SYSTEM. \r
+ 3.2 Limitation of Liability. IN NO EVENT SHALL AUTHORIZE.NET AND ITS AFFILIATES BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR PUNITIVE DAMAGES, OR DAMAGES FOR LOSS OF PROFITS, REVENUE, BUSINESS, SAVINGS, DATA, USE OR COST OF SUBSTITUTE PROCUREMENT, INCURRED BY YOU OR ANY THIRD PARTY, WHETHER IN AN ACTION IN CONTRACT OR TORT, EVEN IF AUTHORIZE.NET HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR IF SUCH DAMAGES ARE FORESEEABLE. IN NO EVENT SHALL THE ENTIRE LIABILITY OF AUTHORIZE.NET AND AFFILIATES ARISING FROM OR RELATING TO THIS AGREEMENT OR THE SUBJECT MATTER HEREOF EXCEED ONE HUNDRED U.S. DOLLARS ($100). THE PARTIES ACKNOWLEDGE THAT THE LIMITATIONS OF LIABILITY IN THIS SECTION 3.2 AND IN THE OTHER PROVISIONS OF THIS AGREEMENT AND THE ALLOCATION OF RISK HEREIN ARE AN ESSENTIAL ELEMENT OF THE BARGAIN BETWEEN THE PARTIES, WITHOUT WHICH AUTHORIZE.NET WOULD NOT HAVE ENTERED INTO THIS AGREEMENT. \r
+ 4. INDEMNIFICATION. You shall indemnify, hold harmless and, at Authorize.Net’s request, defend Authorize.Net and its affiliates and their officers, directors, employees, and agents from and against any claim, suit or proceeding, and any associated liabilities, costs, damages and expenses, including reasonable attorneys’ fees, that arise out of relate to: (i) Your Applications or the use or distribution thereof and Your use or distribution of the Software or the Documentation (or any portion thereof including Open Source Software), including, but not limited to, any allegation that any such Application or any such use or distribution infringes, misappropriates or otherwise violates any intellectual property (including, without limitation, copyright, patent, and trademark), privacy, publicity or other rights of any third party, or has caused the death or injury of any person or damage to any property; (ii) Your alleged or actual breach of this Agreement; (iii) the alleged or actual breach of this Agreement by any party to whom you have provided Your Applications, the Software or the Documentation or (iii) Your alleged or actual violation of or non-compliance with any applicable laws, legislation, policies, rules, regulations or governmental requirements (including, without limitation, any laws, legislation, policies, rules, regulations or governmental requirements related to privacy and data collection).\r
+ 5. TERMINATION. This Agreement and the licenses granted to you herein are effective until terminated. Authorize.Net may terminate this Agreement and the licenses granted to You at any time. Upon termination of this Agreement, You shall cease all use of the Software and the Documentation, return to Authorize.Net or destroy all copies of the Software and Documentation and related materials in Your possession, and so certify to Authorize.Net. Except for the license to You granted herein, the terms of this Agreement shall survive termination.\r
+ 6. CONFIDENTIAL INFORMATION\r
+ a. You hereby agree (i) to hold Authorize.Net’s Confidential Information in strict confidence and to take reasonable precautions to protect such Confidential Information (including, without limitation, all precautions You employ with respect to Your own confidential materials), (ii) not to divulge any such Confidential Information to any third person; (iii) not to make any use whatsoever at any time of such Confidential Information except as strictly licensed hereunder, (iv) not to remove or export from the United States or re-export any such Confidential Information or any direct product thereof, except in compliance with, and with all licenses and approvals required under applicable U.S. and foreign export laws and regulations, including, without limitation, those of the U.S. Department of Commerce. \r
+ b. “Confidential Information” shall mean any data or information, oral or written, treated as confidential that relates to Authorize.Net’s past, present, or future research, development or business activities, including without limitation any unannounced products and services, any information relating to services, developments, inventions, processes, plans, financial information, customer data, revenue, transaction volume, forecasts, projections, application programming interfaces, Software and Documentation. \r
+ 7. General Terms\r
+ 7.1 Law. This Agreement and all matters arising out of or relating to this Agreement shall be governed by the internal laws of the State of California without giving effect to any choice of law rule. This Agreement shall not be governed by the United Nations Convention on Contracts for the International Sales of Goods, the application of which is expressly excluded. In the event of any controversy, claim or dispute between the parties arising out of or relating to this Agreement, such controversy, claim or dispute shall be resolved in the state or federal courts in Santa Clara County, California, and the parties hereby irrevocably consent to the jurisdiction and venue of such courts. \r
+ 7.2 Logo License. Authorize.Net hereby grants to You the right to use, reproduce, publish, perform and display Authorize.Net logo solely in accordance with the current Authorize.Net brand guidelines.\r
+ 7.3 Severability and Waiver. If any provision of this Agreement is held to be illegal, invalid or otherwise unenforceable, such provision shall be enforced to the extent possible consistent with the stated intention of the parties, or, if incapable of such enforcement, shall be deemed to be severed and deleted from this Agreement, while the remainder of this Agreement shall continue in full force and effect. The waiver by either party of any default or breach of this Agreement shall not constitute a waiver of any other or subsequent default or breach. \r
+ 7.4 No Assignment. You may not assign, sell, transfer, delegate or otherwise dispose of, whether voluntarily or involuntarily, by operation of law or otherwise, this Agreement or any rights or obligations under this Agreement without the prior written consent of Authorize.Net, which may be withheld in Authorize.Net’s sole discretion. Any purported assignment, transfer or delegation by You shall be null and void. Subject to the foregoing, this Agreement shall be binding upon and shall inure to the benefit of the parties and their respective successors and assigns.\r
+ 7.5 Government Rights. If You (or any person or entity to whom you provide the Software or Documentation) are an agency or instrumentality of the United States Government, the Software and Documentation are “commercial computer software” and “commercial computer software documentation,” and pursuant to FAR 12.212 or DFARS 227.7202, and their successors, as applicable, use, reproduction and disclosure of the Software and Documentation are governed by the terms of this Agreement. \r
+ 7.6 Export Administration. You shall comply fully with all relevant export laws and regulations of the United States, including, without limitation, the U.S. Export Administration Regulations (collectively “Export Controls”). Without limiting the generality of the foregoing, You shall not, and You shall require Your representatives not to, export, direct or transfer the Software or the Documentation, or any direct product thereof, to any destination, person or entity restricted or prohibited by the Export Controls. \r
+ 7.7 Privacy. In order to continually innovate and improve the Software, Licensee understands and agrees that Authorize.Net may collect certain usage statistics including but not limited to a unique identifier, associated IP address, version number of software, and information on which tools and/or services in the Software are being used and how they are being used.\r
+ 7.8 Entire Agreement; Amendments. This Agreement constitutes the entire agreement between the parties and supersedes all prior or contemporaneous agreements or representations, written or oral, concerning the subject matter of this Agreement. Authorize.Net may make changes to this Agreement, Software or Documentation in its sole discretion. When these changes are made, Authorize.Net will make a new version of the Agreement, Software or Documentation available on the website where the Software is available. This Agreement may not be modified or amended by You except in a writing signed by a duly authorized representative of each party. You acknowledge and agree that\r
+Authorize.Net has not made any representations, warranties or agreements of any kind, except as expressly set forth herein.\r
+\r
+\r
+Authorize.Net Software Development Kit (SDK) License Agreement \r
+v. February 1, 2017\r
+1\r
--- /dev/null
+# Authorize.Net PHP SDK
+
+[](https://travis-ci.org/AuthorizeNet/sdk-php)
+[](https://scrutinizer-ci.com/g/AuthorizeNet/sdk-php/?branch=master)
+[](https://packagist.org/packages/authorizenet/authorizenet)
+
+
+## Requirements
+* PHP 5.6+
+* cURL PHP Extension
+* JSON PHP Extension
+* An Authorize.Net account (see _Registration & Configuration_ section below)
+* TLS 1.2 capable versions of libcurl and OpenSSL (or its equivalent)
+
+### TLS 1.2
+The Authorize.Net APIs only support connections using the TLS 1.2 security protocol. This SDK communicates with the Authorize.Net API using `libcurl` and `OpenSSL` (or equivalent crypto library). It's important to make sure you have new enough versions of these components to support TLS 1.2. Additionally, it's very important to keep these components up to date going forward to mitigate the risk of any security flaws that may be discovered in these libraries.
+
+To test whether your current installation is capable of communicating to our servers using TLS 1.2, run the following PHP code and examine the output for the TLS version:
+```php
+<?php
+ $ch = curl_init('https://apitest.authorize.net/xml/v1/request.api');
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($ch, CURLOPT_VERBOSE, true);
+ $data = curl_exec($ch);
+ curl_close($ch);
+```
+
+If curl is unable to connect to our URL (as given in the previous sample), it's likely that your system is not able to connect using TLS 1.2, or does not have a supported cipher installed. To verify what TLS version your connection _does_ support, run the following PHP code:
+```php
+<?php
+$ch = curl_init('https://www.howsmyssl.com/a/check');
+curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
+$data = curl_exec($ch);
+curl_close($ch);
+
+$json = json_decode($data);
+echo "Connection uses " . $json->tls_version ."\n";
+```
+
+
+## Installation
+
+### Composer
+We recommend using [`Composer`](http://getcomposer.org). *(Note: we never recommend you
+override the new secure-http default setting)*.
+*Update your composer.json file as per the example below and then run
+`composer update`.*
+
+```json
+{
+ "require": {
+ "php": ">=5.6",
+ "authorizenet/authorizenet": "~1.9.6"
+ }
+}
+```
+
+After installation through Composer,
+don't forget to require its autoloader in your script or bootstrap file:
+```php
+require 'vendor/autoload.php';
+```
+
+### Custom SPL Autoloader
+Alternatively, we provide a custom `SPL` autoloader for you to reference from within your PHP file:
+```php
+require 'path/to/anet_php_sdk/autoload.php';
+```
+This autoloader still requires the `vendor` directory and all of its dependencies to exist.
+However, this is a possible solution for cases where composer can't be run on a given system.
+You can run composer locally or on another system to build the directory, then copy the
+`vendor` directory to the desired system.
+
+
+## Registration & Configuration
+Use of this SDK and the Authorize.Net APIs requires having an account on our system. You can find these details in the Settings section.
+If you don't currently have a production Authorize.Net account and need a sandbox account for testing, you can easily sign up for one [here](https://developer.authorize.net/sandbox/).
+
+### Authentication
+To authenticate with the Authorize.Net API you will need to use your account's API Login ID and Transaction Key. If you don't have these values, you can obtain them from our Merchant Interface site. Access the Merchant Interface for production accounts at (https://account.authorize.net/) or sandbox accounts at (https://sandbox.authorize.net).
+
+Once you have your keys simply load them into the appropriate variables in your code, as per the below sample code dealing with the authentication part of the API request.
+
+#### To set your API credentials for an API request:
+...
+```php
+use net\authorize\api\contract\v1 as AnetAPI;
+```
+...
+
+```php
+$merchantAuthentication = new AnetAPI\MerchantAuthenticationType();
+$merchantAuthentication->setName("YOURLOGIN");
+$merchantAuthentication->setTransactionKey("YOURKEY");
+```
+...
+
+```php
+$request = new AnetAPI\CreateTransactionRequest();
+$request->setMerchantAuthentication($merchantAuthentication);
+```
+...
+
+You should never include your Login ID and Transaction Key directly in a PHP file that's in a publically accessible portion of your website. A better practice would be to define these in a constants file, and then reference those constants in the appropriate place in your code.
+
+### Switching between the sandbox environment and the production environment
+Authorize.Net maintains a complete sandbox environment for testing and development purposes. This sandbox environment is an exact duplicate of our production environment with the transaction authorization and settlement process simulated. By default, this SDK is configured to communicate with the sandbox environment. To switch to the production environment, replace the environment constant in the execute method. For example:
+```php
+// For PRODUCTION use
+$response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::PRODUCTION);
+```
+
+API credentials are different for each environment, so be sure to switch to the appropriate credentials when switching environments.
+
+
+## SDK Usage Examples and Sample Code
+To get started using this SDK, it's highly recommended to download our sample code repository:
+* [Authorize.Net PHP Sample Code Repository (on GitHub)](https://github.com/AuthorizeNet/sample-code-php)
+
+In that respository, we have comprehensive sample code for all common uses of our API:
+
+Additionally, you can find details and examples of how our API is structured in our API Reference Guide:
+* [Developer Center API Reference](http://developer.authorize.net/api/reference/index.html)
+
+The API Reference Guide provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK.
+
+
+## Building & Testing the SDK
+Integration tests for the AuthorizeNet SDK are in the `tests` directory. These tests
+are mainly for SDK development. However, you can also browse through them to find
+more usage examples for the various APIs.
+
+- Run `composer update --dev` to load the `PHPUnit` test library.
+- Copy the `phpunit.xml.dist` file to `phpunit.xml` and enter your merchant
+ credentials in the constant fields.
+- Run `vendor/bin/phpunit` to run the test suite.
+
+*You'll probably want to disable emails on your sandbox account.*
+
+### Testing Guide
+For additional help in testing your own code, Authorize.Net maintains a [comprehensive testing guide](http://developer.authorize.net/hello_world/testing_guide/) that includes test credit card numbers to use and special triggers to generate certain responses from the sandbox environment.
+
+
+## Logging
+The SDK generates a log with masking for sensitive data like credit card, expiration dates. The provided levels for logging are
+ `debug`, `info`, `warn`, `error`. Add ````use \net\authorize\util\LogFactory;````. Logger can be initialized using `$logger = LogFactory::getLog(get_class($this));`
+The default log file `phplog` gets generated in the current folder. The subsequent logs are appended to the same file, unless the execution folder is changed, and a new log file is generated.
+
+### Usage Examples
+- Logging a string message `$logger->debug("Sending 'XML' Request type");`
+- Logging xml strings `$logger->debug($xmlRequest);`
+- Logging using formatting `$logger->debugFormat("Integer: %d, Float: %f, Xml-Request: %s\n", array(100, 1.29f, $xmlRequest));`
+
+### Customizing Sensitive Tags
+A local copy of [AuthorizedNetSensitiveTagsConfig.json](/lib/net/authorize/util/ANetSensitiveFields.php) gets generated when code invoking the logger first gets executed. The local file can later be edited by developer to re-configure what is masked and what is visible. (*Do not edit the JSON in the SDK*).
+- For each element of the `sensitiveTags` array,
+ - `tagName` field corresponds to the name of the property in object, or xml-tag that should be hidden entirely ( *XXXX* shown if no replacement specified ) or masked (e.g. showing the last 4 digits of credit card number).
+ - `pattern`[<sup>[Note]</sup>](#regex-note) and `replacement`[<sup>[Note]</sup>](#regex-note) can be left `""`, if the default is to be used (as defined in [Log.php](/lib/net/authorize/util/Log.php)). `pattern` gives the regex to identify, while `replacement` defines the visible part.
+ - `disableMask` can be set to *true* to allow the log to fully display that property in an object, or tag in a xml string.
+- `sensitiveStringRegexes`[<sup>[Note]</sup>](#regex-note) has list of credit-card regexes. So if credit-card number is not already masked, it would get entirely masked.
+- Take care of non-ascii characters (refer [manual](http://php.net/manual/en/regexp.reference.unicode.php)) while defining the regex, e.g. use
+`"pattern": "(\\p{N}+)(\\p{N}{4})"` instead of `"pattern": "(\\d+)(\\d{4})"`. Also note `\\` escape sequence is used.
+
+**<a name="regex-note">Note</a>:**
+**For any regex, no starting or ending '/' or any other delimiter should be defined. The '/' delimiter and unicode flag is added in the code.**
+
+
+## License
+This repository is distributed under a proprietary license. See the provided [`LICENSE.txt`](/LICENSE.txt) file.
--- /dev/null
+<?php
+/**
+ * Custom SPL autoloader for the AuthorizeNet SDK
+ *
+ * @package AuthorizeNet
+ */
+
+spl_autoload_register(function($className) {
+ static $classMap;
+
+ if (!isset($classMap)) {
+ $classMap = require __DIR__ . DIRECTORY_SEPARATOR . 'classmap.php';
+ }
+
+ if (isset($classMap[$className])) {
+ include $classMap[$className];
+ }
+});
--- /dev/null
+<?php
+spl_autoload_extensions(".php"); // comma-separated list
+spl_autoload_register();
+
+/**
+ * A map of classname => filename for SPL autoloading.
+ *
+ * @package AuthorizeNet
+ */
+
+$baseDir = __DIR__ ;
+$libDir = $baseDir . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR;
+$sharedDir = $libDir . 'shared' . DIRECTORY_SEPARATOR;
+$vendorDir = $baseDir . '/vendor';
+
+return array(
+
+ 'Doctrine\Common\Annotations\Annotation' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation.php',
+ 'Doctrine\Common\Annotations\AnnotationException' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php',
+ 'Doctrine\Common\Annotations\AnnotationReader' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php',
+ 'Doctrine\Common\Annotations\AnnotationRegistry' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php',
+ 'Doctrine\Common\Annotations\Annotation\Attribute' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attribute.php',
+ 'Doctrine\Common\Annotations\Annotation\Attributes' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Attributes.php',
+ 'Doctrine\Common\Annotations\Annotation\Enum' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Enum.php',
+ 'Doctrine\Common\Annotations\Annotation\IgnoreAnnotation' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/IgnoreAnnotation.php',
+ 'Doctrine\Common\Annotations\Annotation\Required' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Required.php',
+ 'Doctrine\Common\Annotations\Annotation\Target' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php',
+ 'Doctrine\Common\Annotations\CachedReader' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/CachedReader.php',
+ 'Doctrine\Common\Annotations\DocLexer' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/DocLexer.php',
+ 'Doctrine\Common\Annotations\DocParser' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php',
+ 'Doctrine\Common\Annotations\FileCacheReader' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/FileCacheReader.php',
+ 'Doctrine\Common\Annotations\IndexedReader' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/IndexedReader.php',
+ 'Doctrine\Common\Annotations\PhpParser' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/PhpParser.php',
+ 'Doctrine\Common\Annotations\Reader' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/Reader.php',
+ 'Doctrine\Common\Annotations\SimpleAnnotationReader' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php',
+ 'Doctrine\Common\Annotations\TokenParser' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php',
+ 'Doctrine\Common\Lexer\AbstractLexer' => $vendorDir . '/doctrine/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php',
+ 'Doctrine\Instantiator\Instantiator' => $vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php',
+ 'Doctrine\Instantiator\InstantiatorInterface' => $vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator/InstantiatorInterface.php',
+ 'GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler\BaseTypesHandler' => $vendorDir . '/goetas-webservices/xsd2php-runtime/src/Jms/Handler/BaseTypesHandler.php',
+ 'GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler\XmlSchemaDateHandler' => $vendorDir . '/goetas-webservices/xsd2php-runtime/src/Jms/Handler/XmlSchemaDateHandler.php',
+ 'JMS\Parser\AbstractLexer' => $vendorDir . '/jms/parser-lib/src/JMS/Parser/AbstractLexer.php',
+ 'JMS\Parser\AbstractParser' => $vendorDir . '/jms/parser-lib/src/JMS/Parser/AbstractParser.php',
+ 'JMS\Parser\SimpleLexer' => $vendorDir . '/jms/parser-lib/src/JMS/Parser/SimpleLexer.php',
+ 'JMS\Parser\SyntaxErrorException' => $vendorDir . '/jms/parser-lib/src/JMS/Parser/SyntaxErrorException.php',
+ 'JMS\Serializer\AbstractVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/AbstractVisitor.php',
+ 'JMS\Serializer\ArrayTransformerInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ArrayTransformerInterface.php',
+ 'JMS\Serializer\Context' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Context.php',
+ 'JMS\Serializer\ContextFactory\CallableContextFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/CallableContextFactory.php',
+ 'JMS\Serializer\ContextFactory\CallableDeserializationContextFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/CallableDeserializationContextFactory.php',
+ 'JMS\Serializer\ContextFactory\CallableSerializationContextFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/CallableSerializationContextFactory.php',
+ 'JMS\Serializer\ContextFactory\DefaultDeserializationContextFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/DefaultDeserializationContextFactory.php',
+ 'JMS\Serializer\ContextFactory\DefaultSerializationContextFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/DefaultSerializationContextFactory.php',
+ 'JMS\Serializer\ContextFactory\DeserializationContextFactoryInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/DeserializationContextFactoryInterface.php',
+'JMS\Serializer\ContextFactory\SerializationContextFactoryInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/ContextFactory/SerializationContextFactoryInterface.php',
+ 'JMS\Serializer\DeserializationContext' => $vendorDir . '/jms/serializer/src/JMS/Serializer/DeserializationContext.php',
+ 'JMS\Serializer\GenericDeserializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/GenericDeserializationVisitor.php',
+ 'JMS\Serializer\GenericSerializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/GenericSerializationVisitor.php',
+ 'JMS\Serializer\GraphNavigator' => $vendorDir . '/jms/serializer/src/JMS/Serializer/GraphNavigator.php',
+ 'JMS\Serializer\JsonDeserializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/JsonDeserializationVisitor.php',
+ 'JMS\Serializer\JsonSerializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/JsonSerializationVisitor.php',
+ 'JMS\Serializer\SerializationContext' => $vendorDir . '/jms/serializer/src/JMS/Serializer/SerializationContext.php',
+ 'JMS\Serializer\Serializer' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Serializer.php',
+ 'JMS\Serializer\SerializerBuilder' => $vendorDir . '/jms/serializer/src/JMS/Serializer/SerializerBuilder.php',
+ 'JMS\Serializer\SerializerInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/SerializerInterface.php',
+ 'JMS\Serializer\TypeParser' => $vendorDir . '/jms/serializer/src/JMS/Serializer/TypeParser.php',
+ 'JMS\Serializer\VisitorInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/VisitorInterface.php',
+ 'JMS\Serializer\XmlDeserializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/XmlDeserializationVisitor.php',
+ 'JMS\Serializer\XmlSerializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/XmlSerializationVisitor.php',
+ 'JMS\Serializer\YamlSerializationVisitor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/YamlSerializationVisitor.php',
+ 'JMS\Serializer\Annotation\Accessor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Accessor.php',
+ 'JMS\Serializer\Annotation\AccessorOrder' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/AccessorOrder.php',
+ 'JMS\Serializer\Annotation\AccessType' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/AccessType.php',
+ 'JMS\Serializer\Annotation\Discriminator' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Discriminator.php',
+ 'JMS\Serializer\Annotation\Exclude' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Exclude.php',
+ 'JMS\Serializer\Annotation\ExclusionPolicy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/ExclusionPolicy.php',
+ 'JMS\Serializer\Annotation\Expose' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Expose.php',
+ 'JMS\Serializer\Annotation\Groups' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Groups.php',
+ 'JMS\Serializer\Annotation\HandlerCallback' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/HandlerCallback.php',
+ 'JMS\Serializer\Annotation\Inline' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Inline.php',
+ 'JMS\Serializer\Annotation\MaxDepth' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/MaxDepth.php',
+ 'JMS\Serializer\Annotation\PostDeserialize' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/PostDeserialize.php',
+ 'JMS\Serializer\Annotation\PostSerialize' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/PostSerialize.php',
+ 'JMS\Serializer\Annotation\PreSerialize' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/PreSerialize.php',
+ 'JMS\Serializer\Annotation\ReadOnly' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/ReadOnly.php',
+ 'JMS\Serializer\Annotation\SerializedName' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/SerializedName.php',
+ 'JMS\Serializer\Annotation\Since' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Since.php',
+ 'JMS\Serializer\Annotation\Type' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Type.php',
+ 'JMS\Serializer\Annotation\Until' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Until.php',
+ 'JMS\Serializer\Annotation\Version' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/Version.php',
+ 'JMS\Serializer\Annotation\VirtualProperty' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/VirtualProperty.php',
+ 'JMS\Serializer\Annotation\XmlAttribute' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlAttribute.php',
+ 'JMS\Serializer\Annotation\XmlAttributeMap' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlAttributeMap.php',
+ 'JMS\Serializer\Annotation\XmlCollection' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlCollection.php',
+ 'JMS\Serializer\Annotation\XmlElement' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlElement.php',
+ 'JMS\Serializer\Annotation\XmlKeyValuePairs' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlKeyValuePairs.php',
+ 'JMS\Serializer\Annotation\XmlList' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlList.php',
+ 'JMS\Serializer\Annotation\XmlMap' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlMap.php',
+ 'JMS\Serializer\Annotation\XmlNamespace' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlNamespace.php',
+ 'JMS\Serializer\Annotation\XmlRoot' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlRoot.php',
+ 'JMS\Serializer\Annotation\XmlValue' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Annotation/XmlValue.php',
+ 'JMS\Serializer\Builder\CallbackDriverFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Builder/CallbackDriverFactory.php',
+ 'JMS\Serializer\Builder\DefaultDriverFactory' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Builder/DefaultDriverFactory.php',
+ 'JMS\Serializer\Builder\DriverFactoryInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Builder/DriverFactoryInterface.php',
+ 'JMS\Serializer\Construction\DoctrineObjectConstructor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Construction/DoctrineObjectConstructor.php',
+ 'JMS\Serializer\Construction\ObjectConstructorInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Construction/ObjectConstructorInterface.php',
+ 'JMS\Serializer\Construction\UnserializeObjectConstructor' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Construction/UnserializeObjectConstructor.php',
+ 'JMS\Serializer\EventDispatcher\Event' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/Event.php',
+ 'JMS\Serializer\EventDispatcher\EventDispatcher' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/EventDispatcher.php',
+ 'JMS\Serializer\EventDispatcher\EventDispatcherInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/EventDispatcherInterface.php',
+ 'JMS\Serializer\EventDispatcher\Events' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/Events.php',
+ 'JMS\Serializer\EventDispatcher\EventSubscriberInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/EventSubscriberInterface.php',
+ 'JMS\Serializer\EventDispatcher\LazyEventDispatcher' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/LazyEventDispatcher.php',
+ 'JMS\Serializer\EventDispatcher\ObjectEvent' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/ObjectEvent.php',
+ 'JMS\Serializer\EventDispatcher\PreDeserializeEvent' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/PreDeserializeEvent.php',
+ 'JMS\Serializer\EventDispatcher\PreSerializeEvent' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/PreSerializeEvent.php',
+ 'JMS\Serializer\EventDispatcher\Subscriber\DoctrineProxySubscriber' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/Subscriber/DoctrineProxySubscriber.php',
+ 'JMS\Serializer\EventDispatcher\Subscriber\SymfonyValidatorSubscriber' => $vendorDir . '/jms/serializer/src/JMS/Serializer/EventDispatcher/Subscriber/SymfonyValidatorSubscriber.php',
+ 'JMS\Serializer\Exception\Exception' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exception/Exception.php',
+ 'JMS\Serializer\Exception\InvalidArgumentException' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exception/InvalidArgumentException.php',
+ 'JMS\Serializer\Exception\LogicException' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exception/LogicException.php',
+ 'JMS\Serializer\Exception\RuntimeException' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exception/RuntimeException.php',
+ 'JMS\Serializer\Exception\UnsupportedFormatException' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exception/UnsupportedFormatException.php',
+ 'JMS\Serializer\Exception\ValidationFailedException' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exception/ValidationFailedException.php',
+ 'JMS\Serializer\Exception\XmlErrorException' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exception/XmlErrorException.php',
+ 'JMS\Serializer\Exclusion\DepthExclusionStrategy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exclusion/DepthExclusionStrategy.php',
+ 'JMS\Serializer\Exclusion\DisjunctExclusionStrategy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exclusion/DisjunctExclusionStrategy.php',
+ 'JMS\Serializer\Exclusion\ExclusionStrategyInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exclusion/ExclusionStrategyInterface.php',
+ 'JMS\Serializer\Exclusion\GroupsExclusionStrategy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exclusion/GroupsExclusionStrategy.php',
+ 'JMS\Serializer\Exclusion\VersionExclusionStrategy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Exclusion/VersionExclusionStrategy.php',
+ 'JMS\Serializer\Handler\ArrayCollectionHandler' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/ArrayCollectionHandler.php',
+ 'JMS\Serializer\Handler\ConstraintViolationHandler' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/ConstraintViolationHandler.php',
+ 'JMS\Serializer\Handler\DateHandler' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/DateHandler.php',
+ 'JMS\Serializer\Handler\FormErrorHandler' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/FormErrorHandler.php',
+ 'JMS\Serializer\Handler\HandlerRegistry' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/HandlerRegistry.php',
+ 'JMS\Serializer\Handler\HandlerRegistryInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/HandlerRegistryInterface.php',
+ 'JMS\Serializer\Handler\LazyHandlerRegistry' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/LazyHandlerRegistry.php',
+ 'JMS\Serializer\Handler\PhpCollectionHandler' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/PhpCollectionHandler.php',
+ 'JMS\Serializer\Handler\PropelCollectionHandler' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/PropelCollectionHandler.php',
+ 'JMS\Serializer\Handler\SubscribingHandlerInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Handler/SubscribingHandlerInterface.php',
+ 'JMS\Serializer\Metadata\ClassMetadata' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/ClassMetadata.php',
+ 'JMS\Serializer\Metadata\PropertyMetadata' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/PropertyMetadata.php',
+ 'JMS\Serializer\Metadata\StaticPropertyMetadata' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/StaticPropertyMetadata.php',
+ 'JMS\Serializer\Metadata\VirtualPropertyMetadata' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/VirtualPropertyMetadata.php',
+ 'JMS\Serializer\Metadata\Driver\AbstractDoctrineTypeDriver' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/Driver/AbstractDoctrineTypeDriver.php',
+ 'JMS\Serializer\Metadata\Driver\AnnotationDriver' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/Driver/AnnotationDriver.php',
+ 'JMS\Serializer\Metadata\Driver\DoctrinePHPCRTypeDriver' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/Driver/DoctrinePHPCRTypeDriver.php',
+ 'JMS\Serializer\Metadata\Driver\DoctrineTypeDriver' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/Driver/DoctrineTypeDriver.php',
+ 'JMS\Serializer\Metadata\Driver\PhpDriver' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/Driver/PhpDriver.php',
+ 'JMS\Serializer\Metadata\Driver\XmlDriver' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/Driver/XmlDriver.php',
+ 'JMS\Serializer\Metadata\Driver\YamlDriver' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Metadata/Driver/YamlDriver.php',
+ 'JMS\Serializer\Naming\CacheNamingStrategy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Naming/CacheNamingStrategy.php',
+ 'JMS\Serializer\Naming\CamelCaseNamingStrategy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Naming/CamelCaseNamingStrategy.php',
+ 'JMS\Serializer\Naming\IdenticalPropertyNamingStrategy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Naming/IdenticalPropertyNamingStrategy.php',
+ 'JMS\Serializer\Naming\PropertyNamingStrategyInterface' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Naming/PropertyNamingStrategyInterface.php',
+ 'JMS\Serializer\Naming\SerializedNameAnnotationStrategy' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Naming/SerializedNameAnnotationStrategy.php',
+ 'JMS\Serializer\Twig\SerializerExtension' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Twig/SerializerExtension.php',
+ 'JMS\Serializer\Util\Writer' => $vendorDir . '/jms/serializer/src/JMS/Serializer/Util/Writer.php',
+ 'Metadata\Cache\CacheInterface' => $vendorDir . '/jms/metadata/src/Metadata/Cache/CacheInterface.php',
+ 'Metadata\Cache\DoctrineCacheAdapter' => $vendorDir . '/jms/metadata/src/Metadata/Cache/DoctrineCacheAdapter.php',
+ 'Metadata\Cache\FileCache' => $vendorDir . '/jms/metadata/src/Metadata/Cache/FileCache.php',
+ 'Metadata\ClassHierarchyMetadata' => $vendorDir . '/jms/metadata/src/Metadata/ClassHierarchyMetadata.php',
+ 'Metadata\ClassMetadata' => $vendorDir . '/jms/metadata/src/Metadata/ClassMetadata.php',
+ 'Metadata\Driver\AbstractFileDriver' => $vendorDir . '/jms/metadata/src/Metadata/Driver/AbstractFileDriver.php',
+ 'Metadata\Driver\AdvancedDriverInterface' => $vendorDir . '/jms/metadata/src/Metadata/Driver/AdvancedDriverInterface.php',
+ 'Metadata\Driver\AdvancedFileLocatorInterface' => $vendorDir . '/jms/metadata/src/Metadata/Driver/AdvancedFileLocatorInterface.php',
+ 'Metadata\Driver\DriverChain' => $vendorDir . '/jms/metadata/src/Metadata/Driver/DriverChain.php',
+ 'Metadata\Driver\DriverInterface' => $vendorDir . '/jms/metadata/src/Metadata/Driver/DriverInterface.php',
+ 'Metadata\Driver\FileLocator' => $vendorDir . '/jms/metadata/src/Metadata/Driver/FileLocator.php',
+ 'Metadata\Driver\FileLocatorInterface' => $vendorDir . '/jms/metadata/src/Metadata/Driver/FileLocatorInterface.php',
+ 'Metadata\Driver\LazyLoadingDriver' => $vendorDir . '/jms/metadata/src/Metadata/Driver/LazyLoadingDriver.php',
+ 'Metadata\AdvancedMetadataFactoryInterface' => $vendorDir . '/jms/metadata/src/Metadata/AdvancedMetadataFactoryInterface.php',
+ 'Metadata\MergeableClassMetadata' => $vendorDir . '/jms/metadata/src/Metadata/MergeableClassMetadata.php',
+ 'Metadata\MergeableInterface' => $vendorDir . '/jms/metadata/src/Metadata/MergeableInterface.php',
+ 'Metadata\MetadataFactory' => $vendorDir . '/jms/metadata/src/Metadata/MetadataFactory.php',
+ 'Metadata\MetadataFactoryInterface' => $vendorDir . '/jms/metadata/src/Metadata/MetadataFactoryInterface.php',
+ 'Metadata\MethodMetadata' => $vendorDir . '/jms/metadata/src/Metadata/MethodMetadata.php',
+ 'Metadata\NullMetadata' => $vendorDir . '/jms/metadata/src/Metadata/NullMetadata.php',
+ 'Metadata\PropertyMetadata' => $vendorDir . '/jms/metadata/src/Metadata/PropertyMetadata.php',
+ 'Metadata\Version' => $vendorDir . '/jms/metadata/src/Metadata/Version.php',
+ 'PhpCollection\AbstractCollection' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/AbstractCollection.php',
+ 'PhpCollection\AbstractMap' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/AbstractMap.php',
+ 'PhpCollection\AbstractSequence' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/AbstractSequence.php',
+ 'PhpCollection\CollectionInterface' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/CollectionInterface.php',
+ 'PhpCollection\Map' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/Map.php',
+ 'PhpCollection\MapInterface' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/MapInterface.php',
+ 'PhpCollection\Sequence' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/Sequence.php',
+ 'PhpCollection\SequenceInterface' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/SequenceInterface.php',
+ 'PhpCollection\SortableInterface' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/SortableInterface.php',
+ 'PhpCollection\SortedSequence' => $vendorDir . '/phpcollection/phpcollection/src/PhpCollection/SortedSequence.php',
+ 'PhpOption\LazyOption' => $vendorDir . '/phpoption/phpoption/src/PhpOption/LazyOption.php',
+ 'PhpOption\None' => $vendorDir . '/phpoption/phpoption/src/PhpOption/None.php',
+ 'PhpOption\Option' => $vendorDir . '/phpoption/phpoption/src/PhpOption/Option.php',
+ 'PhpOption\Some' => $vendorDir . '/phpoption/phpoption/src/PhpOption/Some.php',
+ 'Symfony\Component\Yaml\Yaml' => $vendorDir . '/symfony/yaml/Yaml.php',
+ 'Symfony\Component\Yaml\Parser' => $vendorDir . '/symfony/yaml/Parser.php',
+ 'Symfony\Component\Yaml\Inline' => $vendorDir . '/symfony/yaml/Inline.php',
+
+ 'AuthorizeNetAIM' => $libDir . 'AuthorizeNetAIM.php',
+ 'AuthorizeNetAIM_Response' => $libDir . 'AuthorizeNetAIM.php',
+ 'AuthorizeNetARB' => $libDir . 'AuthorizeNetARB.php',
+ 'AuthorizeNetARB_Response' => $libDir . 'AuthorizeNetARB.php',
+ 'AuthorizeNetAddress' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetBankAccount' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetCIM' => $libDir . 'AuthorizeNetCIM.php',
+ 'AuthorizeNetCIM_Response' => $libDir . 'AuthorizeNetCIM.php',
+ 'AuthorizeNetCP' => $libDir . 'AuthorizeNetCP.php',
+ 'AuthorizeNetCP_Response' => $libDir . 'AuthorizeNetCP.php',
+ 'AuthorizeNetCreditCard' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetCustomer' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetDPM' => $libDir . 'AuthorizeNetDPM.php',
+ 'AuthorizeNetException' => $sharedDir . 'AuthorizeNetException.php',
+ 'AuthorizeNetLineItem' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetPayment' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetPaymentProfile' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetRequest' => $sharedDir . 'AuthorizeNetRequest.php',
+ 'AuthorizeNetResponse' => $sharedDir . 'AuthorizeNetResponse.php',
+ 'AuthorizeNetSIM' => $libDir . 'AuthorizeNetSIM.php',
+ 'AuthorizeNetSIM_Form' => $libDir . 'AuthorizeNetSIM.php',
+ 'AuthorizeNetSOAP' => $libDir . 'AuthorizeNetSOAP.php',
+ 'AuthorizeNetTD' => $libDir . 'AuthorizeNetTD.php',
+ 'AuthorizeNetTD_Response' => $libDir . 'AuthorizeNetTD.php',
+ 'AuthorizeNetTransaction' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetXMLResponse' => $sharedDir . 'AuthorizeNetXMLResponse.php',
+ 'AuthorizeNet_Subscription' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetGetSubscriptionList' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetSubscriptionListSorting' => $sharedDir . 'AuthorizeNetTypes.php',
+ 'AuthorizeNetSubscriptionListPaging' => $sharedDir . 'AuthorizeNetTypes.php',
+
+ // Following section contains the new controller model classes needed
+ //Utils
+ //'net\authorize\util\ObjectToXml' => $libDir . 'net/authorize/util/ObjectToXml.php',
+ 'net\authorize\util\HttpClient' => $libDir . 'net/authorize/util/HttpClient.php',
+ 'net\authorize\util\Helpers' => $libDir . 'net/authorize/util/Helpers.php',
+ 'net\authorize\util\Log' => $libDir . 'net/authorize/util/Log.php',
+ 'net\authorize\util\LogFactory' => $libDir . 'net/authorize/util/LogFactory.php',
+ 'net\authorize\util\ANetSensitiveFields' => $libDir . 'net/authorize/util/ANetSensitiveFields.php',
+ 'net\authorize\util\SensitiveTag' => $libDir . 'net/authorize/util/SensitiveTag.php',
+ 'net\authorize\util\SensitiveDataConfigType' => $libDir . 'net/authorize/util/SensitiveDataConfigType.php',
+
+ //constants
+ 'net\authorize\api\constants\ANetEnvironment' => $libDir . 'net/authorize/api/constants/ANetEnvironment.php',
+
+ //base classes
+ 'net\authorize\api\controller\base\IApiOperation' => $libDir . 'net/authorize/api/controller/base/IApiOperation.php',
+ 'net\authorize\api\controller\base\ApiOperationBase' => $libDir . 'net/authorize/api/controller/base/ApiOperationBase.php',
+
+ //following are generated class mappings
+ 'net\authorize\api\contract\v1\ANetApiRequestType' => $libDir . 'net/authorize/api/contract/v1/ANetApiRequestType.php',
+ 'net\authorize\api\contract\v1\ANetApiResponseType' => $libDir . 'net/authorize/api/contract/v1/ANetApiResponseType.php',
+ 'net\authorize\api\contract\v1\ARBCancelSubscriptionRequest' => $libDir . 'net/authorize/api/contract/v1/ARBCancelSubscriptionRequest.php',
+ 'net\authorize\api\contract\v1\ARBCancelSubscriptionResponse' => $libDir . 'net/authorize/api/contract/v1/ARBCancelSubscriptionResponse.php',
+ 'net\authorize\api\contract\v1\ARBCreateSubscriptionRequest' => $libDir . 'net/authorize/api/contract/v1/ARBCreateSubscriptionRequest.php',
+ 'net\authorize\api\contract\v1\ARBCreateSubscriptionResponse' => $libDir . 'net/authorize/api/contract/v1/ARBCreateSubscriptionResponse.php',
+ 'net\authorize\api\contract\v1\ARBGetSubscriptionListRequest' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionListRequest.php',
+ 'net\authorize\api\contract\v1\ARBGetSubscriptionListResponse' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionListResponse.php',
+ 'net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionListSortingType.php',
+ 'net\authorize\api\contract\v1\ARBGetSubscriptionRequest' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionRequest.php',
+ 'net\authorize\api\contract\v1\ARBGetSubscriptionResponse' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionResponse.php',
+ 'net\authorize\api\contract\v1\ARBGetSubscriptionStatusRequest' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionStatusRequest.php',
+ 'net\authorize\api\contract\v1\ARBGetSubscriptionStatusResponse' => $libDir . 'net/authorize/api/contract/v1/ARBGetSubscriptionStatusResponse.php',
+ 'net\authorize\api\contract\v1\ARBSubscriptionMaskedType' => $libDir . 'net/authorize/api/contract/v1/ARBSubscriptionMaskedType.php',
+ 'net\authorize\api\contract\v1\ARBSubscriptionType' => $libDir . 'net/authorize/api/contract/v1/ARBSubscriptionType.php',
+ 'net\authorize\api\contract\v1\ArbTransactionType' => $libDir . 'net/authorize/api/contract/v1/ArbTransactionType.php',
+ 'net\authorize\api\contract\v1\ARBUpdateSubscriptionRequest' => $libDir . 'net/authorize/api/contract/v1/ARBUpdateSubscriptionRequest.php',
+ 'net\authorize\api\contract\v1\ARBUpdateSubscriptionResponse' => $libDir . 'net/authorize/api/contract/v1/ARBUpdateSubscriptionResponse.php',
+ 'net\authorize\api\contract\v1\ArrayOfSettingType' => $libDir . 'net/authorize/api/contract/v1/ArrayOfSettingType.php',
+ 'net\authorize\api\contract\v1\AuthenticateTestRequest' => $libDir . 'net/authorize/api/contract/v1/AuthenticateTestRequest.php',
+ 'net\authorize\api\contract\v1\AuthenticateTestResponse' => $libDir . 'net/authorize/api/contract/v1/AuthenticateTestResponse.php',
+ 'net\authorize\api\contract\v1\BankAccountMaskedType' => $libDir . 'net/authorize/api/contract/v1/BankAccountMaskedType.php',
+ 'net\authorize\api\contract\v1\BankAccountType' => $libDir . 'net/authorize/api/contract/v1/BankAccountType.php',
+ 'net\authorize\api\contract\v1\BatchDetailsType' => $libDir . 'net/authorize/api/contract/v1/BatchDetailsType.php',
+ 'net\authorize\api\contract\v1\BatchStatisticType' => $libDir . 'net/authorize/api/contract/v1/BatchStatisticType.php',
+ 'net\authorize\api\contract\v1\CardArtType' => $libDir . 'net/authorize/api/contract/v1/CardArtType.php',
+ 'net\authorize\api\contract\v1\CcAuthenticationType' => $libDir . 'net/authorize/api/contract/v1/CcAuthenticationType.php',
+ 'net\authorize\api\contract\v1\CreateCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerPaymentProfileRequest.php',
+ 'net\authorize\api\contract\v1\CreateCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerPaymentProfileResponse.php',
+ 'net\authorize\api\contract\v1\CreateCustomerProfileFromTransactionRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileFromTransactionRequest.php',
+ 'net\authorize\api\contract\v1\CreateCustomerProfileRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileRequest.php',
+ 'net\authorize\api\contract\v1\CreateCustomerProfileResponse' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileResponse.php',
+ 'net\authorize\api\contract\v1\CreateCustomerProfileTransactionRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileTransactionRequest.php',
+ 'net\authorize\api\contract\v1\CreateCustomerProfileTransactionResponse' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerProfileTransactionResponse.php',
+ 'net\authorize\api\contract\v1\CreateCustomerShippingAddressRequest' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerShippingAddressRequest.php',
+ 'net\authorize\api\contract\v1\CreateCustomerShippingAddressResponse' => $libDir . 'net/authorize/api/contract/v1/CreateCustomerShippingAddressResponse.php',
+ 'net\authorize\api\contract\v1\CreateProfileResponseType' => $libDir . 'net/authorize/api/contract/v1/CreateProfileResponseType.php',
+ 'net\authorize\api\contract\v1\CreateTransactionRequest' => $libDir . 'net/authorize/api/contract/v1/CreateTransactionRequest.php',
+ 'net\authorize\api\contract\v1\CreateTransactionResponse' => $libDir . 'net/authorize/api/contract/v1/CreateTransactionResponse.php',
+ 'net\authorize\api\contract\v1\CreditCardMaskedType' => $libDir . 'net/authorize/api/contract/v1/CreditCardMaskedType.php',
+ 'net\authorize\api\contract\v1\CreditCardSimpleType' => $libDir . 'net/authorize/api/contract/v1/CreditCardSimpleType.php',
+ 'net\authorize\api\contract\v1\CreditCardTrackType' => $libDir . 'net/authorize/api/contract/v1/CreditCardTrackType.php',
+ 'net\authorize\api\contract\v1\CreditCardType' => $libDir . 'net/authorize/api/contract/v1/CreditCardType.php',
+ 'net\authorize\api\contract\v1\CustomerAddressExType' => $libDir . 'net/authorize/api/contract/v1/CustomerAddressExType.php',
+ 'net\authorize\api\contract\v1\CustomerAddressType' => $libDir . 'net/authorize/api/contract/v1/CustomerAddressType.php',
+ 'net\authorize\api\contract\v1\CustomerDataType' => $libDir . 'net/authorize/api/contract/v1/CustomerDataType.php',
+ 'net\authorize\api\contract\v1\CustomerProfileIdType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileIdType.php',
+ 'net\authorize\api\contract\v1\CustomerPaymentProfileBaseType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileBaseType.php',
+ 'net\authorize\api\contract\v1\CustomerPaymentProfileExType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileExType.php',
+ 'net\authorize\api\contract\v1\CustomerPaymentProfileListItemType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileListItemType.php',
+ 'net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileMaskedType.php',
+ 'net\authorize\api\contract\v1\CustomerPaymentProfileSortingType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileSortingType.php',
+ 'net\authorize\api\contract\v1\CustomerPaymentProfileType' => $libDir . 'net/authorize/api/contract/v1/CustomerPaymentProfileType.php',
+ 'net\authorize\api\contract\v1\CustomerProfileBaseType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileBaseType.php',
+ 'net\authorize\api\contract\v1\CustomerProfileExType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileExType.php',
+ 'net\authorize\api\contract\v1\CustomerProfileMaskedType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileMaskedType.php',
+ 'net\authorize\api\contract\v1\CustomerProfilePaymentType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfilePaymentType.php',
+ 'net\authorize\api\contract\v1\CustomerProfileSummaryType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileSummaryType.php',
+ 'net\authorize\api\contract\v1\CustomerProfileType' => $libDir . 'net/authorize/api/contract/v1/CustomerProfileType.php',
+ 'net\authorize\api\contract\v1\CustomerType' => $libDir . 'net/authorize/api/contract/v1/CustomerType.php',
+ 'net\authorize\api\contract\v1\DecryptPaymentDataRequest' => $libDir . 'net/authorize/api/contract/v1/DecryptPaymentDataRequest.php',
+ 'net\authorize\api\contract\v1\DecryptPaymentDataResponse' => $libDir . 'net/authorize/api/contract/v1/DecryptPaymentDataResponse.php',
+ 'net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerPaymentProfileRequest.php',
+ 'net\authorize\api\contract\v1\DeleteCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerPaymentProfileResponse.php',
+ 'net\authorize\api\contract\v1\DeleteCustomerProfileRequest' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerProfileRequest.php',
+ 'net\authorize\api\contract\v1\DeleteCustomerProfileResponse' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerProfileResponse.php',
+ 'net\authorize\api\contract\v1\DeleteCustomerShippingAddressRequest' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerShippingAddressRequest.php',
+ 'net\authorize\api\contract\v1\DeleteCustomerShippingAddressResponse' => $libDir . 'net/authorize/api/contract/v1/DeleteCustomerShippingAddressResponse.php',
+ 'net\authorize\api\contract\v1\DriversLicenseMaskedType' => $libDir . 'net/authorize/api/contract/v1/DriversLicenseMaskedType.php',
+ 'net\authorize\api\contract\v1\DriversLicenseType' => $libDir . 'net/authorize/api/contract/v1/DriversLicenseType.php',
+ 'net\authorize\api\contract\v1\EmailSettingsType' => $libDir . 'net/authorize/api/contract/v1/EmailSettingsType.php',
+ 'net\authorize\api\contract\v1\EncryptedTrackDataType' => $libDir . 'net/authorize/api/contract/v1/EncryptedTrackDataType.php',
+ 'net\authorize\api\contract\v1\EnumCollection' => $libDir . 'net/authorize/api/contract/v1/EnumCollection.php',
+ 'net\authorize\api\contract\v1\ErrorResponse' => $libDir . 'net/authorize/api/contract/v1/ErrorResponse.php',
+ 'net\authorize\api\contract\v1\ExtendedAmountType' => $libDir . 'net/authorize/api/contract/v1/ExtendedAmountType.php',
+ 'net\authorize\api\contract\v1\FDSFilterType' => $libDir . 'net/authorize/api/contract/v1/FDSFilterType.php',
+ 'net\authorize\api\contract\v1\FingerPrintType' => $libDir . 'net/authorize/api/contract/v1/FingerPrintType.php',
+ 'net\authorize\api\contract\v1\FraudInformationType.php' => $libDir . 'net/authorize/api/contract/v1/FraudInformationType.php',
+ 'net\authorize\api\contract\v1\GetBatchStatisticsRequest' => $libDir . 'net/authorize/api/contract/v1/GetBatchStatisticsRequest.php',
+ 'net\authorize\api\contract\v1\GetBatchStatisticsResponse' => $libDir . 'net/authorize/api/contract/v1/GetBatchStatisticsResponse.php',
+ 'net\authorize\api\contract\v1\GetCustomerPaymentProfileListRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerPaymentProfileListRequest.php',
+ 'net\authorize\api\contract\v1\GetCustomerPaymentProfileListResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerPaymentProfileListResponse.php',
+ 'net\authorize\api\contract\v1\GetCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerPaymentProfileRequest.php',
+ 'net\authorize\api\contract\v1\GetCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerPaymentProfileResponse.php',
+ 'net\authorize\api\contract\v1\GetCustomerProfileIdsRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerProfileIdsRequest.php',
+ 'net\authorize\api\contract\v1\GetCustomerProfileIdsResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerProfileIdsResponse.php',
+ 'net\authorize\api\contract\v1\GetCustomerProfileRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerProfileRequest.php',
+ 'net\authorize\api\contract\v1\GetCustomerProfileResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerProfileResponse.php',
+ 'net\authorize\api\contract\v1\GetCustomerShippingAddressRequest' => $libDir . 'net/authorize/api/contract/v1/GetCustomerShippingAddressRequest.php',
+ 'net\authorize\api\contract\v1\GetCustomerShippingAddressResponse' => $libDir . 'net/authorize/api/contract/v1/GetCustomerShippingAddressResponse.php',
+ 'net\authorize\api\contract\v1\GetHostedPaymentPageRequest.php' => $libDir . 'net/authorize/api/contract/v1/GetHostedPaymentPageRequest.php',
+ 'net\authorize\api\contract\v1\GetHostedPaymentPageResponse.php' => $libDir . 'net/authorize/api/contract/v1/GetHostedPaymentPageResponse.php',
+ 'net\authorize\api\contract\v1\GetHostedProfilePageRequest' => $libDir . 'net/authorize/api/contract/v1/GetHostedProfilePageRequest.php',
+ 'net\authorize\api\contract\v1\GetHostedProfilePageResponse' => $libDir . 'net/authorize/api/contract/v1/GetHostedProfilePageResponse.php',
+ 'net\authorize\api\contract\v1\GetMerchantDetailsRequest.php' => $libDir . 'net/authorize/api/contract/v1/GetMerchantDetailsRequest.php',
+ 'net\authorize\api\contract\v1\GetMerchantDetailsResponse.php' => $libDir . 'net/authorize/api/contract/v1/GetMerchantDetailsResponse.php',
+ 'net\authorize\api\contract\v1\GetSettledBatchListRequest' => $libDir . 'net/authorize/api/contract/v1/GetSettledBatchListRequest.php',
+ 'net\authorize\api\contract\v1\GetSettledBatchListResponse' => $libDir . 'net/authorize/api/contract/v1/GetSettledBatchListResponse.php',
+ 'net\authorize\api\contract\v1\GetTransactionDetailsRequest' => $libDir . 'net/authorize/api/contract/v1/GetTransactionDetailsRequest.php',
+ 'net\authorize\api\contract\v1\GetTransactionDetailsResponse' => $libDir . 'net/authorize/api/contract/v1/GetTransactionDetailsResponse.php',
+ 'net\authorize\api\contract\v1\GetTransactionListRequest' => $libDir . 'net/authorize/api/contract/v1/GetTransactionListRequest.php',
+ 'net\authorize\api\contract\v1\GetTransactionListResponse' => $libDir . 'net/authorize/api/contract/v1/GetTransactionListResponse.php',
+ 'net\authorize\api\contract\v1\GetUnsettledTransactionListRequest' => $libDir . 'net/authorize/api/contract/v1/GetUnsettledTransactionListRequest.php',
+ 'net\authorize\api\contract\v1\GetUnsettledTransactionListResponse' => $libDir . 'net/authorize/api/contract/v1/GetUnsettledTransactionListResponse.php',
+ 'net\authorize\api\contract\v1\HeldTransactionRequestType.php' => $libDir . 'net/authorize/api/contract/v1/HeldTransactionRequestType.php',
+ 'net\authorize\api\contract\v1\ImpersonationAuthenticationType' => $libDir . 'net/authorize/api/contract/v1/ImpersonationAuthenticationType.php',
+ 'net\authorize\api\contract\v1\IsAliveRequest' => $libDir . 'net/authorize/api/contract/v1/IsAliveRequest.php',
+ 'net\authorize\api\contract\v1\IsAliveResponse' => $libDir . 'net/authorize/api/contract/v1/IsAliveResponse.php',
+ 'net\authorize\api\contract\v1\KeyBlockType' => $libDir . 'net/authorize/api/contract/v1/KeyBlockType.php',
+ 'net\authorize\api\contract\v1\KeyManagementSchemeType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType.php',
+ 'net\authorize\api\contract\v1\KeyValueType' => $libDir . 'net/authorize/api/contract/v1/KeyValueType.php',
+ 'net\authorize\api\contract\v1\LineItemType' => $libDir . 'net/authorize/api/contract/v1/LineItemType.php',
+ 'net\authorize\api\contract\v1\LogoutRequest' => $libDir . 'net/authorize/api/contract/v1/LogoutRequest.php',
+ 'net\authorize\api\contract\v1\LogoutResponse' => $libDir . 'net/authorize/api/contract/v1/LogoutResponse.php',
+ 'net\authorize\api\contract\v1\MerchantAuthenticationType' => $libDir . 'net/authorize/api/contract/v1/MerchantAuthenticationType.php',
+ 'net\authorize\api\contract\v1\MerchantContactType' => $libDir . 'net/authorize/api/contract/v1/MerchantContactType.php',
+ 'net\authorize\api\contract\v1\MessagesType' => $libDir . 'net/authorize/api/contract/v1/MessagesType.php',
+ 'net\authorize\api\contract\v1\MobileDeviceLoginRequest' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceLoginRequest.php',
+ 'net\authorize\api\contract\v1\MobileDeviceLoginResponse' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceLoginResponse.php',
+ 'net\authorize\api\contract\v1\MobileDeviceRegistrationRequest' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceRegistrationRequest.php',
+ 'net\authorize\api\contract\v1\MobileDeviceRegistrationResponse' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceRegistrationResponse.php',
+ 'net\authorize\api\contract\v1\MobileDeviceType' => $libDir . 'net/authorize/api/contract/v1/MobileDeviceType.php',
+ 'net\authorize\api\contract\v1\NameAndAddressType' => $libDir . 'net/authorize/api/contract/v1/NameAndAddressType.php',
+ 'net\authorize\api\contract\v1\OpaqueDataType' => $libDir . 'net/authorize/api/contract/v1/OpaqueDataType.php',
+ 'net\authorize\api\contract\v1\OrderExType' => $libDir . 'net/authorize/api/contract/v1/OrderExType.php',
+ 'net\authorize\api\contract\v1\OrderType' => $libDir . 'net/authorize/api/contract/v1/OrderType.php',
+ 'net\authorize\api\contract\v1\PagingType' => $libDir . 'net/authorize/api/contract/v1/PagingType.php',
+ 'net\authorize\api\contract\v1\PaymentDetailsType' => $libDir . 'net/authorize/api/contract/v1/PaymentDetailsType.php',
+ 'net\authorize\api\contract\v1\PaymentMaskedType' => $libDir . 'net/authorize/api/contract/v1/PaymentMaskedType.php',
+ 'net\authorize\api\contract\v1\PaymentProfileType' => $libDir . 'net/authorize/api/contract/v1/PaymentProfileType.php',
+ 'net\authorize\api\contract\v1\PaymentScheduleType' => $libDir . 'net/authorize/api/contract/v1/PaymentScheduleType.php',
+ 'net\authorize\api\contract\v1\PaymentSimpleType' => $libDir . 'net/authorize/api/contract/v1/PaymentSimpleType.php',
+ 'net\authorize\api\contract\v1\PaymentType' => $libDir . 'net/authorize/api/contract/v1/PaymentType.php',
+ 'net\authorize\api\contract\v1\PayPalType' => $libDir . 'net/authorize/api/contract/v1/PayPalType.php',
+ 'net\authorize\api\contract\v1\PermissionType' => $libDir . 'net/authorize/api/contract/v1/PermissionType.php',
+ 'net\authorize\api\contract\v1\ProcessorType.php' => $libDir . 'net/authorize/api/contract/v1/ProcessorType.php',
+ 'net\authorize\api\contract\v1\ProfileTransactionType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransactionType.php',
+ 'net\authorize\api\contract\v1\ProfileTransAmountType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransAmountType.php',
+ 'net\authorize\api\contract\v1\ProfileTransAuthCaptureType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransAuthCaptureType.php',
+ 'net\authorize\api\contract\v1\ProfileTransAuthOnlyType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransAuthOnlyType.php',
+ 'net\authorize\api\contract\v1\ProfileTransCaptureOnlyType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransCaptureOnlyType.php',
+ 'net\authorize\api\contract\v1\ProfileTransOrderType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransOrderType.php',
+ 'net\authorize\api\contract\v1\ProfileTransPriorAuthCaptureType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransPriorAuthCaptureType.php',
+ 'net\authorize\api\contract\v1\ProfileTransRefundType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransRefundType.php',
+ 'net\authorize\api\contract\v1\ProfileTransVoidType' => $libDir . 'net/authorize/api/contract/v1/ProfileTransVoidType.php',
+ 'net\authorize\api\contract\v1\ReturnedItemType' => $libDir . 'net/authorize/api/contract/v1/ReturnedItemType.php',
+ 'net\authorize\api\contract\v1\SearchCriteriaCustomerProfileType' => $libDir . 'net/authorize/api/contract/v1/SearchCriteriaCustomerProfileType.php',
+ 'net\authorize\api\contract\v1\SecurePaymentContainerErrorType' => $libDir . 'net/authorize/api/contract/v1/SecurePaymentContainerErrorType.php',
+ 'net\authorize\api\contract\v1\SecurePaymentContainerRequest' => $libDir . 'net/authorize/api/contract/v1/SecurePaymentContainerRequest.php',
+ 'net\authorize\api\contract\v1\SecurePaymentContainerResponse' => $libDir . 'net/authorize/api/contract/v1/SecurePaymentContainerResponse.php',
+ 'net\authorize\api\contract\v1\SendCustomerTransactionReceiptRequest' => $libDir . 'net/authorize/api/contract/v1/SendCustomerTransactionReceiptRequest.php',
+ 'net\authorize\api\contract\v1\SendCustomerTransactionReceiptResponse' => $libDir . 'net/authorize/api/contract/v1/SendCustomerTransactionReceiptResponse.php',
+ 'net\authorize\api\contract\v1\SettingType' => $libDir . 'net/authorize/api/contract/v1/SettingType.php',
+ 'net\authorize\api\contract\v1\SolutionType' => $libDir . 'net/authorize/api/contract/v1/SolutionType.php',
+ 'net\authorize\api\contract\v1\SubMerchantType' => $libDir . 'net/authorize/api/contract/v1/SubMerchantType.php',
+ 'net\authorize\api\contract\v1\SubscriptionCustomerProfileType' => $libDir . 'net/authorize/api/contract/v1/SubscriptionCustomerProfileType.php',
+ 'net\authorize\api\contract\v1\SubscriptionDetailType' => $libDir . 'net/authorize/api/contract/v1/SubscriptionDetailType.php',
+ 'net\authorize\api\contract\v1\SubscriptionPaymentType' => $libDir . 'net/authorize/api/contract/v1/SubscriptionPaymentType.php',
+ 'net\authorize\api\contract\v1\TokenMaskedType' => $libDir . 'net/authorize/api/contract/v1/TokenMaskedType.php',
+ 'net\authorize\api\contract\v1\TransactionDetailsType' => $libDir . 'net/authorize/api/contract/v1/TransactionDetailsType.php',
+ 'net\authorize\api\contract\v1\TransactionListSortingType.php' => $libDir . 'net/authorize/api/contract/v1/TransactionListSortingType.php',
+ 'net\authorize\api\contract\v1\TransactionRequestType' => $libDir . 'net/authorize/api/contract/v1/TransactionRequestType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType.php',
+ 'net\authorize\api\contract\v1\TransactionSummaryType' => $libDir . 'net/authorize/api/contract/v1/TransactionSummaryType.php',
+ 'net\authorize\api\contract\v1\TransRetailInfoType' => $libDir . 'net/authorize/api/contract/v1/TransRetailInfoType.php',
+ 'net\authorize\api\contract\v1\UpdateCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerPaymentProfileRequest.php',
+ 'net\authorize\api\contract\v1\UpdateCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerPaymentProfileResponse.php',
+ 'net\authorize\api\contract\v1\UpdateCustomerProfileRequest' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerProfileRequest.php',
+ 'net\authorize\api\contract\v1\UpdateCustomerProfileResponse' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerProfileResponse.php',
+ 'net\authorize\api\contract\v1\UpdateCustomerShippingAddressRequest' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerShippingAddressRequest.php',
+ 'net\authorize\api\contract\v1\UpdateCustomerShippingAddressResponse' => $libDir . 'net/authorize/api/contract/v1/UpdateCustomerShippingAddressResponse.php',
+ 'net\authorize\api\contract\v1\UpdateHeldTransactionRequest.php' => $libDir . 'net/authorize/api/contract/v1/UpdateHeldTransactionRequest.php',
+ 'net\authorize\api\contract\v1\UpdateHeldTransactionResponse.php' => $libDir . 'net/authorize/api/contract/v1/UpdateHeldTransactionResponse.php',
+ 'net\authorize\api\contract\v1\UpdateSplitTenderGroupRequest' => $libDir . 'net/authorize/api/contract/v1/UpdateSplitTenderGroupRequest.php',
+ 'net\authorize\api\contract\v1\UpdateSplitTenderGroupResponse' => $libDir . 'net/authorize/api/contract/v1/UpdateSplitTenderGroupResponse.php',
+ 'net\authorize\api\contract\v1\UserFieldType' => $libDir . 'net/authorize/api/contract/v1/UserFieldType.php',
+ 'net\authorize\api\contract\v1\ValidateCustomerPaymentProfileRequest' => $libDir . 'net/authorize/api/contract/v1/ValidateCustomerPaymentProfileRequest.php',
+ 'net\authorize\api\contract\v1\ValidateCustomerPaymentProfileResponse' => $libDir . 'net/authorize/api/contract/v1/ValidateCustomerPaymentProfileResponse.php',
+ 'net\authorize\api\contract\v1\WebCheckOutDataType' => $libDir . 'net/authorize/api/contract/v1/WebCheckOutDataType.php',
+ 'net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType.php',
+ 'net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\DeviceInfoAType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType/DeviceInfoAType.php',
+ 'net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\EncryptedDataAType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType/EncryptedDataAType.php',
+ 'net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\ModeAType' => $libDir . 'net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType/ModeAType.php',
+ 'net\authorize\api\contract\v1\MessagesType\MessageAType' => $libDir . 'net/authorize/api/contract/v1/MessagesType/MessageAType.php',
+ 'net\authorize\api\contract\v1\PaymentScheduleType\IntervalAType' => $libDir . 'net/authorize/api/contract/v1/PaymentScheduleType/IntervalAType.php',
+ 'net\authorize\api\contract\v1\TransactionRequestType\UserFieldsAType' => $libDir . 'net/authorize/api/contract/v1/TransactionRequestType/UserFieldsAType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/ErrorsAType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType\MessagesAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/MessagesAType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType\PrePaidCardAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/PrePaidCardAType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType\SecureAcceptanceAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/SecureAcceptanceAType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/SplitTenderPaymentsAType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType\UserFieldsAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/UserFieldsAType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/ErrorsAType/ErrorAType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/MessagesAType/MessageAType.php',
+ 'net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType' => $libDir . 'net/authorize/api/contract/v1/TransactionResponseType/SplitTenderPaymentsAType/SplitTenderPaymentAType.php',
+ 'net\authorize\api\contract\v1\WebCheckOutDataType\TokenAType' => $libDir . 'net/authorize/api/contract/v1/WebCheckOutDataType/TokenAType.php',
+
+ 'net\authorize\api\contract\v1\GetAUJobSummaryRequest' => $libDir . 'net/authorize/api/contract/v1/getAUJobSummaryRequest.php',
+ 'net\authorize\api\contract\v1\GetAUJobSummaryResponse' => $libDir . 'net/authorize/api/contract/v1/GetAUJobSummaryResponse.php',
+ 'net\authorize\api\contract\v1\GetAUJobDetailsRequest' => $libDir . 'net/authorize/api/contract/v1/GetAUJobDetailsRequest.php',
+ 'net\authorize\api\contract\v1\GetAUJobDetailsResponse' => $libDir . 'net/authorize/api/contract/v1/GetAUJobDetailsResponse.php',
+
+ 'net\authorize\api\contract\v1\AuDeleteType' => $libDir . 'net/authorize/api/contract/v1/AuDeleteType.php',
+ 'net\authorize\api\contract\v1\AuDetailsType' => $libDir . 'net/authorize/api/contract/v1/AuDetailsType.php',
+ 'net\authorize\api\contract\v1\AuResponseType' => $libDir . 'net/authorize/api/contract/v1/AuResponseType.php',
+ 'net\authorize\api\contract\v1\AuUpdateType' => $libDir . 'net/authorize/api/contract/v1/AuUpdateType.php',
+
+ 'net\authorize\api\contract\v1\ListOfAUDetailsType' => $libDir . 'net/authorize/api/contract/v1/ListOfAUDetailsType.php',
+ 'net\authorize\api\contract\v1\EmvTagType' => $libDir . 'net/authorize/api/contract/v1/EmvTagType.php',
+ 'net\authorize\api\contract\v1\PaymentEmvType' => $libDir . 'net/authorize/api/contract/v1/PaymentEmvType.php',
+
+
+ //Controllers
+ 'net\authorize\api\controller\ARBCancelSubscriptionController' => $libDir . 'net/authorize/api/controller/ARBCancelSubscriptionController.php',
+ 'net\authorize\api\controller\ARBCreateSubscriptionController' => $libDir . 'net/authorize/api/controller/ARBCreateSubscriptionController.php',
+ 'net\authorize\api\controller\ARBGetSubscriptionController' => $libDir . 'net/authorize/api/controller/ARBGetSubscriptionController.php',
+ 'net\authorize\api\controller\ARBGetSubscriptionListController' => $libDir . 'net/authorize/api/controller/ARBGetSubscriptionListController.php',
+ 'net\authorize\api\controller\ARBGetSubscriptionStatusController' => $libDir . 'net/authorize/api/controller/ARBGetSubscriptionStatusController.php',
+ 'net\authorize\api\controller\ARBUpdateSubscriptionController' => $libDir . 'net/authorize/api/controller/ARBUpdateSubscriptionController.php',
+ 'net\authorize\api\controller\AuthenticateTestController' => $libDir . 'net/authorize/api/controller/AuthenticateTestController.php',
+ 'net\authorize\api\controller\CreateCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/CreateCustomerPaymentProfileController.php',
+ 'net\authorize\api\controller\CreateCustomerProfileController' => $libDir . 'net/authorize/api/controller/CreateCustomerProfileController.php',
+ 'net\authorize\api\controller\CreateCustomerProfileFromTransactionController' => $libDir . 'net/authorize/api/controller/CreateCustomerProfileFromTransactionController.php',
+ 'net\authorize\api\controller\CreateCustomerProfileTransactionController' => $libDir . 'net/authorize/api/controller/CreateCustomerProfileTransactionController.php',
+ 'net\authorize\api\controller\CreateCustomerShippingAddressController' => $libDir . 'net/authorize/api/controller/CreateCustomerShippingAddressController.php',
+ 'net\authorize\api\controller\CreateTransactionController' => $libDir . 'net/authorize/api/controller/CreateTransactionController.php',
+ 'net\authorize\api\controller\DecryptPaymentDataController' => $libDir . 'net/authorize/api/controller/DecryptPaymentDataController.php',
+ 'net\authorize\api\controller\DeleteCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/DeleteCustomerPaymentProfileController.php',
+ 'net\authorize\api\controller\DeleteCustomerProfileController' => $libDir . 'net/authorize/api/controller/DeleteCustomerProfileController.php',
+ 'net\authorize\api\controller\DeleteCustomerShippingAddressController' => $libDir . 'net/authorize/api/controller/DeleteCustomerShippingAddressController.php',
+ 'net\authorize\api\controller\GetBatchStatisticsController' => $libDir . 'net/authorize/api/controller/GetBatchStatisticsController.php',
+ 'net\authorize\api\controller\GetCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/GetCustomerPaymentProfileController.php',
+ 'net\authorize\api\controller\GetCustomerPaymentProfileListController' => $libDir . 'net/authorize/api/controller/GetCustomerPaymentProfileListController.php',
+ 'net\authorize\api\controller\GetCustomerProfileController' => $libDir . 'net/authorize/api/controller/GetCustomerProfileController.php',
+ 'net\authorize\api\controller\GetCustomerProfileIdsController' => $libDir . 'net/authorize/api/controller/GetCustomerProfileIdsController.php',
+ 'net\authorize\api\controller\GetCustomerShippingAddressController' => $libDir . 'net/authorize/api/controller/GetCustomerShippingAddressController.php',
+ 'net\authorize\api\controller\GetHostedPaymentPageController' => $libDir . 'net/authorize/api/controller/GetHostedPaymentPageController.php',
+ 'net\authorize\api\controller\GetHostedProfilePageController' => $libDir . 'net/authorize/api/controller/GetHostedProfilePageController.php',
+ 'net\authorize\api\controller\GetMerchantDetailsController' => $libDir . 'net/authorize/api/controller/GetMerchantDetailsController.php',
+ 'net\authorize\api\controller\GetSettledBatchListController' => $libDir . 'net/authorize/api/controller/GetSettledBatchListController.php',
+ 'net\authorize\api\controller\GetTransactionDetailsController' => $libDir . 'net/authorize/api/controller/GetTransactionDetailsController.php',
+ 'net\authorize\api\controller\GetTransactionListController' => $libDir . 'net/authorize/api/controller/GetTransactionListController.php',
+ 'net\authorize\api\controller\GetUnsettledTransactionListController' => $libDir . 'net/authorize/api/controller/GetUnsettledTransactionListController.php',
+ 'net\authorize\api\controller\IsAliveController' => $libDir . 'net/authorize/api/controller/IsAliveController.php',
+ 'net\authorize\api\controller\LogoutController' => $libDir . 'net/authorize/api/controller/LogoutController.php',
+ 'net\authorize\api\controller\MobileDeviceLoginController' => $libDir . 'net/authorize/api/controller/MobileDeviceLoginController.php',
+ 'net\authorize\api\controller\MobileDeviceRegistrationController' => $libDir . 'net/authorize/api/controller/MobileDeviceRegistrationController.php',
+ 'net\authorize\api\controller\SecurePaymentContainerController' => $libDir . 'net/authorize/api/controller/SecurePaymentContainerController.php',
+ 'net\authorize\api\controller\SendCustomerTransactionReceiptController' => $libDir . 'net/authorize/api/controller/SendCustomerTransactionReceiptController.php',
+ 'net\authorize\api\controller\UpdateCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/UpdateCustomerPaymentProfileController.php',
+ 'net\authorize\api\controller\UpdateCustomerProfileController' => $libDir . 'net/authorize/api/controller/UpdateCustomerProfileController.php',
+ 'net\authorize\api\controller\UpdateCustomerShippingAddressController' => $libDir . 'net/authorize/api/controller/UpdateCustomerShippingAddressController.php',
+ 'net\authorize\api\controller\UpdateHeldTransactionController' => $libDir . 'net/authorize/api/controller/UpdateHeldTransactionController.php',
+ 'net\authorize\api\controller\UpdateSplitTenderGroupController' => $libDir . 'net/authorize/api/controller/UpdateSplitTenderGroupController.php',
+ 'net\authorize\api\controller\ValidateCustomerPaymentProfileController' => $libDir . 'net/authorize/api/controller/ValidateCustomerPaymentProfileController.php',
+
+ 'net\authorize\api\controller\GetAUJobDetailsController' => $libDir . 'net/authorize/api/controller/GetAUJobDetailsController.php',
+ 'net\authorize\api\controller\GetAUJobSummaryController' => $libDir . 'net/authorize/api/controller/GetAUJobSummaryController.php'
+
+);
--- /dev/null
+{
+ "name": "authorizenet/authorizenet",
+ "type": "library",
+ "description": "Official PHP SDK for Authorize.Net",
+ "keywords": ["authorizenet", "authorize.net", "payment", "ecommerce"],
+ "license": "proprietary",
+ "homepage": "http://developer.authorize.net",
+ "require": {
+ "php": ">=5.6",
+ "ext-curl": "*",
+ "ext-json": "*",
+ "ext-simplexml": "*",
+ "ext-xmlwriter": "*",
+ "goetas-webservices/xsd2php-runtime":"^0.2.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.0",
+ "phpmd/phpmd": "~2.0"
+ },
+ "autoload": {
+ "classmap": ["lib"]
+ },
+ "autoload-dev": {
+ "classmap": ["tests"]
+ }
+}
--- /dev/null
+Advanced Integration Method
+===========================
+
+Basic Overview
+--------------
+
+The AuthorizeNetAIM class creates a request object for submitting transactions
+to the AuthorizeNetAIM API. To use, create an instance of the class, set the fields
+for your transaction, call the method you want to use (Authorize Only, Authorize &
+Capture, etc.) and you'll receive an AuthorizeNetAIM response object providing easy access
+to the results of the transaction.
+
+Autoloading
+-----------------
+
+```PHP
+require 'vendor/autoload.php';
+```
+
+Setting Merchant Credentials
+----------------------------
+The easiest way to set credentials is to define constants which the SDK uses:
+
+```PHP
+define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
+define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
+```
+
+You can also set credentials manually per request like so:
+
+```PHP
+$sale = new AuthorizeNetAIM("YOUR_API_LOGIN_ID","YOUR_TRANSACTION_KEY");
+```
+
+Setting the Transaction Post Location
+-------------------------------------
+
+To post transactions to the live Authorize.Net gateway:
+
+```PHP
+define("AUTHORIZENET_SANDBOX", false);
+```
+
+To post transactions to the Authorize.Net test server:
+
+```PHP
+define("AUTHORIZENET_SANDBOX", true);
+```
+
+You can also set the location manually per request:
+
+```PHP
+$sale->setSandbox(false);
+```
+
+Setting Fields
+--------------
+
+An Authorize.Net AIM request is simply a set of name/value pairs. The PHP SDK
+allows you to set these fields in a few different ways depending on your
+preference.
+
+Note: to make things easier on the developer, the "x_" prefix attached to each
+field in the AIM API has been removed. Thus, instead of setting `$sale->x_card_num`,
+set `$sale->card_num` instead.
+
+1.) By Setting Fields Directly:
+
+```PHP
+$sale = new AuthorizeNetAIM;
+$sale->amount = "1999.99";
+$sale->card_num = '6011000000000012';
+$sale->exp_date = '04/15';
+$response = $sale->authorizeAndCapture();
+```
+
+2.) By Setting Multiple Fields at Once:
+
+```PHP
+$sale = new AuthorizeNetAIM;
+$sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0415'
+ )
+);
+```
+
+3.) By Setting Special Items
+
+To add line items or set custom fields use the respective functions:
+
+Line Items:
+
+```PHP
+$sale->addLineItem(
+ 'item1', // Item Id
+ 'Golf tees', // Item Name
+ 'Blue tees', // Item Description
+ '2', // Item Quantity
+ '5.00', // Item Unit Price
+ 'N' // Item taxable
+ );
+```
+
+Custom Fields:
+
+```PHP
+$sale->setCustomField("coupon_code", "SAVE2011");
+```
+
+4.) By Passing in Objects
+
+Each property will be copied from the object to the AIM request.
+
+```PHP
+$sale = new AuthorizeNetAIM;
+$customer = (object)array();
+$customer->first_name = "Jane";
+$customer->last_name = "Smith";
+$customer->company = "Jane Smith Enterprises Inc.";
+$customer->address = "20 Main Street";
+$customer->city = "San Francisco";
+$customer->state = "CA";
+$customer->zip = "94110";
+$customer->country = "US";
+$customer->phone = "415-555-5557";
+$customer->fax = "415-555-5556";
+$customer->email = "foo@example.com";
+$customer->cust_id = "55";
+$customer->customer_ip = "98.5.5.5";
+$sale->setFields($customer);
+```
+
+Submitting Transactions
+-----------------------
+To submit a transaction call one of the 7 methods:
+
+```PHP
+AuthorizeNetAIM::authorizeAndCapture()
+AuthorizeNetAIM::authorizeOnly()
+AuthorizeNetAIM::priorAuthCapture()
+AuthorizeNetAIM::void()
+AuthorizeNetAIM::captureOnly()
+AuthorizeNetAIM::credit()
+```
+
+Each method has optional parameters which highlight the fields required by the
+Authorize.Net API for that transaction type.
+
+
+eCheck
+------
+To submit an electronic check transaction you can set the required fields individually
+or simply use the setECheck method:
+
+```PHP
+$sale = new AuthorizeNetAIM;
+$sale->amount = "45.00";
+$sale->setECheck(
+ '121042882', // bank_aba_code
+ '123456789123', // bank_acct_num
+ 'CHECKING', // bank_acct_type
+ 'Bank of Earth', // bank_name
+ 'Jane Doe', // bank_acct_name
+ 'WEB' // echeck_type
+);
+$response = $sale->authorizeAndCapture();
+```
+
+Partial Authorization Transactions
+----------------------------------
+To enable partial authorization transactions set the partial_auth flag
+to true:
+
+```PHP
+$sale->allow_partial_auth = true;
+```
+
+You should receive a split tender id in the response if a partial auth
+is made:
+
+```PHP
+$split_tender_id = $response->split_tender_id;
+```
+
+Itemized Order Information
+--------------------------
+To add itemized order information use the addLineItem method:
+
+```PHP
+$auth->addLineItem(
+ 'item1', // Item Id
+ 'Golf tees', // Item Name
+ 'Blue tees', // Item Description
+ '2', // Item Quantity
+ '5.00', // Item Unit Price
+ 'N' // Item taxable
+ );
+```
+
+Merchant Defined Fields
+-----------------------
+You can use the setCustomField method to set any custom merchant defined field(s):
+
+```PHP
+$sale->setCustomField("entrance_source", "Search Engine");
+$sale->setCustomField("coupon_code", "SAVE2011");
+```
+
+Transaction Response
+--------------------
+When you submit an AIM transaction you receive an AuthorizeNetAIM_Response
+object in return. You can access each name/value pair in the response as
+you would normally expect:
+
+```PHP
+$response = $sale->authorizeAndCapture();
+$response->response_code;
+$response->response_subcode;
+$response->response_reason_code;
+$response->transaction_id;
+```
--- /dev/null
+ARB API
+=======
+
+Basic Overview
+--------------
+
+The AuthorizeNetARB class creates a request object for submitting transactions
+to the AuthorizeNetARB API.
+
+
+Creating/Updating Subscriptions
+-------------------------------
+
+To create or update a subscription first create a subscription object:
+
+```PHP
+$subscription = new AuthorizeNet_Subscription;
+$subscription->name = "Short subscription";
+$subscription->intervalLength = "1";
+$subscription->intervalUnit = "months";
+$subscription->startDate = "2011-03-12";
+$subscription->totalOccurrences = "14";
+$subscription->amount = rand(1,100);
+$subscription->creditCardCardNumber = "6011000000000012";
+$subscription->creditCardExpirationDate = "2018-10";
+$subscription->creditCardCardCode = "123";
+$subscription->billToFirstName = "john";
+$subscription->billToLastName = "doe";
+```
+
+Then create an AuthorizeNetARB object and call the appropriate method
+passing in your subscription object:
+
+```PHP
+$request = new AuthorizeNetARB;
+$response = $request->createSubscription($subscription);
+```
+
+or for updating a subscription:
+
+```PHP
+$response = $request->updateSubscription($subscription_id, $subscription);
+```
+
+Getting Subscription Status
+---------------------------
+
+Create a new AuthorizeNetARB object and call the getSubscriptionStatus
+method with the subscription_id you want the status of as the parameter:
+
+```PHP
+$status_request = new AuthorizeNetARB;
+$status_response = $status_request->getSubscriptionStatus($subscription_id);
+```
+
+Canceling a Subscription
+------------------------
+
+```PHP
+$cancellation = new AuthorizeNetARB;
+$cancel_response = $cancellation->cancelSubscription($subscription_id);
+```
--- /dev/null
+CIM API
+=======
+
+Basic Overview
+--------------
+
+The AuthorizeNetCIM class creates a request object for submitting transactions
+to the Authorize.Net CIM API.
+
+
+Creating a Customer Profile
+---------------------------
+
+To create a new cusomter profile, first create a new AuthorizeNetCustomer
+object.
+
+```PHP
+$customerProfile = new AuthorizeNetCustomer;
+$customerProfile->description = "Description of customer";
+$customerProfile->merchantCustomerId = 123;
+$customerProfile->email = "user@domain.com";
+```
+You can then create an add payment profiles and addresses to this
+customer object.
+
+```PHP
+// Add payment profile.
+$paymentProfile = new AuthorizeNetPaymentProfile;
+$paymentProfile->customerType = "individual";
+$paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
+$paymentProfile->payment->creditCard->expirationDate = "2015-10";
+$customerProfile->paymentProfiles[] = $paymentProfile;
+
+// Add another payment profile.
+$paymentProfile2 = new AuthorizeNetPaymentProfile;
+$paymentProfile2->customerType = "business";
+$paymentProfile2->payment->bankAccount->accountType = "businessChecking";
+$paymentProfile2->payment->bankAccount->routingNumber = "121042882";
+$paymentProfile2->payment->bankAccount->accountNumber = "123456789123";
+$paymentProfile2->payment->bankAccount->nameOnAccount = "Jane Doe";
+$paymentProfile2->payment->bankAccount->echeckType = "WEB";
+$paymentProfile2->payment->bankAccount->bankName = "Pandora Bank";
+$customerProfile->paymentProfiles[] = $paymentProfile2;
+
+// Add shipping address.
+$address = new AuthorizeNetAddress;
+$address->firstName = "john";
+$address->lastName = "Doe";
+$address->company = "John Doe Company";
+$address->address = "1 Main Street";
+$address->city = "Boston";
+$address->state = "MA";
+$address->zip = "02412";
+$address->country = "USA";
+$address->phoneNumber = "555-555-5555";
+$address->faxNumber = "555-555-5556";
+$customerProfile->shipToList[] = $address;
+
+// Add another shipping address.
+$address2 = new AuthorizeNetAddress;
+$address2->firstName = "jane";
+$address2->lastName = "Doe";
+$address2->address = "11 Main Street";
+$address2->city = "Boston";
+$address2->state = "MA";
+$address2->zip = "02412";
+$address2->country = "USA";
+$address2->phoneNumber = "555-512-5555";
+$address2->faxNumber = "555-523-5556";
+$customerProfile->shipToList[] = $address2;
+```
+
+Next, create an AuthorizeNetCIM object:
+
+```PHP
+$request = new AuthorizeNetCIM;
+```
+
+Finally, call the createCustomerProfile method and pass in your
+customer object:
+
+```PHP
+$response = $request->createCustomerProfile($customerProfile);
+```
+
+The response object provides some helper methods for easy access to the
+results of the transaction:
+
+```PHP
+$new_customer_id = $response->getCustomerProfileId();
+```
+
+The response object also stores the XML response as a SimpleXml element
+which you can access like so:
+
+```PHP
+$new_customer_id = $response->xml->customerProfileId
+```
+
+You can also run xpath queries against the result:
+
+```PHP
+$array = $response->xpath('customerProfileId');
+$new_customer_id = $array[0];
+```
+
+Deleting a Customer Profile
+---------------------------
+
+To delete a customer profile first create a new AuthorizeNetCIM object:
+
+```PHP
+$request = new AuthorizeNetCIM;
+```
+
+Then call the deleteCustomerProfile method:
+
+```PHP
+request->deleteCustomerProfile($customer_id);
+```
+
+
+Retrieving a Customer Profile
+-----------------------------
+
+To retrieve a customer profile call the getCustomerProfile method:
+
+```PHP
+$response = $request->getCustomerProfile($customerProfileId);
+```
+
+Validation Mode
+---------------
+
+Validation mode allows you to generate a test transaction at the time you create a customer profile. In Test Mode, only field validation is performed. In Live Mode, a transaction is generated and submitted to the processor with the amount of $0.00 or $0.01. If successful, the transaction is immediately voided.
+
+To create a customer profile with Validation mode, simply pass in the
+a value for the validation mode parameter on the createCustomerProfile method:
+
+```PHP
+$response = $request->createCustomerProfile($customerProfile, "testMode");
+```
+
+You can access the validation response for each payment profile via xpath,
+the SimpleXML element or the getValidationResponses method:
+
+```PHP
+$validationResponses = $response->getValidationResponses();
+ foreach ($validationResponses as $vr) {
+ echo $vr->approved;
+}
+```
+
+Updating a Customer Profile
+---------------------------
+
+Call the updateCustomerProfile method with the customerProfileId and customerProfile
+parameters:
+
+```PHP
+$response = $request->updateCustomerProfile($customerProfileId, $customerProfile);
+```
+
+Adding a Payment Profile
+------------------------
+
+```PHP
+$paymentProfile = new AuthorizeNetPaymentProfile;
+$paymentProfile->customerType = "individual";
+$paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
+$paymentProfile->payment->creditCard->expirationDate = "2015-10";
+$response = $request->createCustomerPaymentProfile($customerProfileId, $paymentProfile);
+```
+
+Updating a Payment Profile
+--------------------------
+
+```PHP
+$paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
+$paymentProfile->payment->creditCard->expirationDate = "2017-11";
+$response = $request->updateCustomerPaymentProfile($customerProfileId,$paymentProfileId, $paymentProfile);
+```
+
+Adding a Shipping Address
+-------------------------
+
+```PHP
+$address = new AuthorizeNetAddress;
+$address->firstName = "john";
+$address->lastName = "Doe";
+$address->company = "John Doe Company";
+$address->address = "1 Main Street";
+$address->city = "Boston";
+$address->state = "MA";
+$address->zip = "02412";
+$address->country = "USA";
+$address->phoneNumber = "555-555-5555";
+$address->faxNumber = "555-555-5556";
+$response = $request->createCustomerShippingAddress($customerProfileId, $address);
+$customerAddressId = $response->getCustomerAddressId();
+```
+
+Updating a Shipping Address
+---------------------------
+
+```PHP
+// Update shipping address.
+$address->address = "2 First Street";
+$response = $request->updateCustomerShippingAddress($customerProfileId, $customerAddressId, $address);
+```
+
+Creating Transactions
+---------------------
+
+```PHP
+// Create Auth & Capture Transaction
+$transaction = new AuthorizeNetTransaction;
+$transaction->amount = "9.79";
+$transaction->customerProfileId = $customerProfileId;
+$transaction->customerPaymentProfileId = $paymentProfileId;
+$transaction->customerShippingAddressId = $customerAddressId;
+
+$lineItem = new AuthorizeNetLineItem;
+$lineItem->itemId = "4";
+$lineItem->name = "Cookies";
+$lineItem->description = "Chocolate Chip";
+$lineItem->quantity = "4";
+$lineItem->unitPrice = "1.00";
+$lineItem->taxable = "true";
+
+$lineItem2 = new AuthorizeNetLineItem;
+$lineItem2->itemId = "4";
+$lineItem2->name = "Cookies";
+$lineItem2->description= "Peanut Butter";
+$lineItem2->quantity = "4";
+$lineItem2->unitPrice = "1.00";
+$lineItem2->taxable = "true";
+
+$transaction->lineItems[] = $lineItem;
+$transaction->lineItems[] = $lineItem2;
+
+$response = $request->createCustomerProfileTransaction("AuthCapture", $transaction);
+$transactionResponse = $response->getTransactionResponse();
+$transactionId = $transactionResponse->transaction_id;
+```
+
+Voiding a Transaction
+---------------------
+
+```PHP
+$transaction = new AuthorizeNetTransaction;
+$transaction->transId = $transactionId;
+$response = $request->createCustomerProfileTransaction("Void", $transaction);
+```
+
+Deleting a Shipping Address
+---------------------------
+
+```PHP
+$response = $request->deleteCustomerShippingAddress($customerProfileId, $customerAddressId);
+```
+
+Deleting a Payment Profile
+--------------------------
+
+```PHP
+$response = $request->deleteCustomerPaymentProfile($customerProfileId, $paymentProfileId);
+```
+
+Getting Customer Profile IDs
+----------------------------
+
+```PHP
+$response = $request->getCustomerProfileIds();
+```
--- /dev/null
+Card Present API
+================
+
+Basic Overview
+--------------
+
+The AuthorizeNetCP class creates a request object for submitting transactions
+to the AuthorizeNetCP API. The AuthorizeNetCP class extends the AuthorizeNetAIM
+class. See the AIM.markdown for help with the basics. This document contains
+information regarding the special features of the AuthorizeNetCP class.
+
+
+Merchant Credentials
+--------------------
+
+Please note that if you are using both the CNP and CP APIs your merchant
+credentials will be different.
+
+Setting Track Data
+------------------
+
+To set Track 1 and/or Track 2 data, use the respective methods like so:
+
+```PHP
+$sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+$sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'device_type' => '4',
+ )
+);
+$sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?');
+$response = $sale->authorizeAndCapture();
+
+$sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+$sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'device_type' => '4',
+ )
+);
+$sale->setTrack2Data('4111111111111111=1803101000020000831?');
+$response = $sale->authorizeAndCapture();
+```
--- /dev/null
+Direct Post Method
+==================
+
+Basic Overview
+--------------
+
+The Authorize.Net PHP SDK includes a class that demonstrates one way
+of implementing the Direct Post Method.
+
+While it is not necessary to use the AuthorizeNetDPM class to implement
+DPM, it may serve as a handy reference.
+
+The AuthorizeNetDPM class extends the AuthorizeNetSIM_Form class.
+See the SIM.markdown for additional documentation.
+
+Relay Response Snippet
+----------------------
+
+The AuthorizeNetDPM class contains a `getRelayResponseSnippet($redirect_url)`
+which generates a snippet of HTML that will redirect a user back to your
+site after submitting a checkout form using DPM/SIM.
+
+Use this method(or just grab the html) if you want to create a checkout
+experience where the user only interacts with pages on your site.
--- /dev/null
+# This documentation and the objects it documents have been deprecated
+
+For the README for this repository, see README.md in the root level of the repository. For examples of how to interact with the current Authorize.Net API, see our new sample code GitHub repository at https://github.com/AuthorizeNet/sample-code-php.
--- /dev/null
+Server Integration Method
+=========================
+
+Basic Overview
+--------------
+
+The Authorize.Net PHP SDK includes classes that can speed up implementing
+a Server Integration Method solution.
+
+
+Hosted Order/Receipt Page
+-------------------------
+
+The `AuthorizeNetSIM_Form` class aims to make it easier to setup the hidden
+fields necessary for creating a SIM experience. While it is not necessary
+to use the `AuthorizeNetSIM_Form` class to implement SIM, it may be handy for
+reference.
+
+The code below will generate a buy now button that leads to a hosted order page:
+
+```PHP
+<form method="post" action="https://test.authorize.net/gateway/transact.dll">
+<?php
+$amount = "9.99";
+$fp_sequence = "123";
+$time = time();
+
+$fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $time);
+$sim = new AuthorizeNetSIM_Form(
+ array(
+ 'x_amount' => $amount,
+ 'x_fp_sequence' => $fp_sequence,
+ 'x_fp_hash' => $fingerprint,
+ 'x_fp_timestamp' => $time,
+ 'x_relay_response'=> "FALSE",
+ 'x_login' => $api_login_id,
+ )
+);
+echo $sim->getHiddenFieldString();?>
+<input type="submit" value="Buy Now">
+</form>
+```
+
+Fingerprint Generation
+----------------------
+
+To generate the fingerprint needed for a SIM transaction call the `getFingerprint` method:
+
+```PHP
+$fingerprint = AuthorizeNetSIM_Form::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp);
+```
+
+Relay Response
+--------------
+
+The PHP SDK includes a `AuthorizeNetSIM` class for handling a relay response from
+Authorize.Net.
+
+To receive a relay response from Authorize.Net you can either configure the
+url in the Merchant Interface or specify the url when submitting a transaction
+with SIM using the "x_relay_url" field.
+
+When a transaction occurs, Authorize.Net will post the transaction details to
+this url. You can then create a page on your server at a url such as
+http://yourdomain.com/response_handler.php and execute any logic you want
+when a transaction occurs. The AuthorizeNetSIM class makes it easy to verify
+the transaction came from Authorize.Net and parse the response:
+
+```PHP
+$response = new AuthorizeNetSIM;
+if ($response->isAuthorizeNet())
+{
+ if ($response->approved)
+ {
+ // Activate magazine subscription
+ magazine_subscription_activate($response->cust_id);
+ }
+}
+```
--- /dev/null
+SOAP
+====
+
+Basic Overview
+--------------
+
+The AuthorizeNetSOAP class provides a very basic wrapper to PHP's bundled
+SoapClient class. The AuthorizeNetSOAP class merely contains the WSDL,
+Sandbox, and Live Production server urls to make it easier to connect
+to the Authorize.Net SOAP API.
\ No newline at end of file
--- /dev/null
+Transaction Details API
+=======================
+
+Basic Overview
+--------------
+
+The AuthorizeNetTD class creates a request object for submitting requests
+to the Authorize.Net Transaction Details API.
+
+The AuthorizeNetTD class returns a response that uses PHP's bundled SimpleXML
+class for accessing it's members.
+
+The AuthorizeNetTD response provides two ways to access response elements:
+
+1.) A SimpleXml object:
+
+```PHP
+$response->xml->transaction->payment->creditCard->cardType
+```
+
+2.) Xpath:
+
+```PHP
+$batches = $response->xpath("batchList/batch");
+```
+
+3.) AuthorizeNet Objects (todo)
+
+
+
+Get Transaction Details
+-----------------------
+
+```PHP
+$request = new AuthorizeNetTD;
+$response = $request->getTransactionDetails($transId);
+echo "Amount: {$response->xml->transaction->authAmount}";
+```
+
+Get Settled Batch List
+----------------------
+
+```PHP
+$request = new AuthorizeNetTD;
+$response = $request->getSettledBatchList();
+$batches = $response->xpath("batchList/batch");
+echo "Batch 1: {$batches[0]->batchId}";
+```
+
+Get Transaction List
+--------------------
+
+```PHP
+$request = new AuthorizeNetTD;
+$response = $request->getTransactionList($batch_id);
+$transactions = $response->xpath("transactions/transaction")
+```
+
+There are two additional helper methods in the PHP SDK which
+will make multiple calls to retrieve a day's worth of
+transactions or a month's worth of batches:
+
+```PHP
+getTransactionsForDay($month, $day, $year = false)
+getSettledBatchListForMonth($month , $year)
+```
+
+If you don't pass parameters into these methods they will default
+to the current day/month.
--- /dev/null
+#!/bin/bash
+
+# sudo apt-get install php5-curl
+# composer install
+
+#create directories that do not exist
+apidir=lib/net/authorize/api/contract/v1
+#net.authorize.api.contract.v1.
+if [ -d "$apidir" ]; then
+ rm -r "$apidir"
+fi
+mkdir -p "$apidir"
+echo Make sure the ns-dest uses destination as: $apidir
+logfile=./xsdgen.log
+echo `date` > $logfile
+echo Generating PHP Classes >> $logfile
+vendor/goetas/xsd2php/bin/xsd2php convert:php \
+ --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/contract/v1' \
+ --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \
+ --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \
+ ./AnetApiSchema.xsd >> $logfile 2>> $logfile
+echo Generation of PHP Classes complete >> $logfile
+
+jmsdir=lib/net/authorize/api/yml/v1
+if [ -d "$jmsdir" ]; then
+ rm -r "$jmsdir"
+fi
+mkdir -p "$jmsdir"
+echo Generating Serializers for Classes >> $logfile
+vendor/goetas/xsd2php/bin/xsd2php convert:jms-yaml \
+ --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/yml/v1' \
+ --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \
+ --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \
+ ./AnetApiSchema.xsd >> $logfile
+echo Generator output is in file: $logfile
+
+#GOOD
+# vendor/goetas/xsd2php/bin/xsd2php.php convert:php \
+ # --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/contract/v1' \
+ # --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \
+ # --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \
+ # /home/ramittal/AnetApiSchema.xsd >> $logfile
+#Old good
+# vendor/goetas/xsd2php/bin/xsd2php.php convert:php \
+ # --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/contract/v1' \
+ # --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \
+ # --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \
+ # /home/ramittal/AnetApiSchema.xsd
+#
+# jmsdir=lib/net/authorize/api/jms/v1
+# mkdir -p $jmsdir
+# rm -r $jmsdir\*
+# Do not want JMS serializer
+# echo Generating Serializers for Classes >> $logfile
+# vendor/goetas/xsd2php/bin/xsd2php.php convert:jms-yaml \
+ # --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/jms/v1' \
+ # --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \
+ # --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \
+ # /home/ramittal/AnetApiSchema.xsd >> $logfile
+#DOOG
+
+
+#--alias-map='Vendor/Project/CustomDateClass; http://www.opentravel.org/OTA/2003/05#CustomOTADateTimeFormat'
+
+# symfony/console suggests installing symfony/event-dispatcher ()
+# symfony/console suggests installing psr/log (For using the console logger)
+# phpunit/php-code-coverage suggests installing ext-xdebug (>=2.2.1)
+# phpunit/phpunit suggests installing phpunit/php-invoker (~1.1)
+# symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them)
+
+# ----------------
+# zendframework/zend-stdlib suggests installing zendframework/zend-serializer (Zend\Serializer component)
+# zendframework/zend-stdlib suggests installing zendframework/zend-servicemanager (To support hydrator plugin manager usage)
+# zendframework/zend-code suggests installing doctrine/common (Doctrine\Common >=2.1 for annotation features)
+# symfony/console suggests installing symfony/event-dispatcher ()
+# symfony/console suggests installing psr/log (For using the console logger)
--- /dev/null
+<?php
+/**
+ * Easily interact with the Authorize.Net AIM API.
+ *
+ *
+ * Example Authorize and Capture Transaction against the Sandbox:
+ * <code>
+ * <?php require_once 'AuthorizeNet.php'
+ * $sale = new AuthorizeNetAIM;
+ * $sale->setFields(
+ * array(
+ * 'amount' => '4.99',
+ * 'card_num' => '411111111111111',
+ * 'exp_date' => '0515'
+ * )
+ * );
+ * $response = $sale->authorizeAndCapture();
+ * if ($response->approved) {
+ * echo "Sale successful!"; } else {
+ * echo $response->error_message;
+ * }
+ * ?>
+ * </code>
+ *
+ * Note: To send requests to the live gateway, either define this:
+ * define("AUTHORIZENET_SANDBOX", false);
+ * -- OR --
+ * $sale = new AuthorizeNetAIM;
+ * $sale->setSandbox(false);
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetAIM
+ * @link http://www.authorize.net/support/AIM_guide.pdf AIM Guide
+ */
+
+
+/**
+ * Builds and sends an AuthorizeNet AIM Request.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetAIM
+ */
+class AuthorizeNetAIM extends AuthorizeNetRequest
+{
+
+ const LIVE_URL = 'https://secure2.authorize.net/gateway/transact.dll';
+ const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
+
+ /**
+ * Holds all the x_* name/values that will be posted in the request.
+ * Default values are provided for best practice fields.
+ */
+ protected $_x_post_fields = array(
+ "version" => "3.1",
+ "delim_char" => ",",
+ "delim_data" => "TRUE",
+ "relay_response" => "FALSE",
+ "encap_char" => "|",
+ );
+
+ /**
+ * Only used if merchant wants to send multiple line items about the charge.
+ */
+ private $_additional_line_items = array();
+
+ /**
+ * Only used if merchant wants to send custom fields.
+ */
+ private $_custom_fields = array();
+
+ /**
+ * Checks to make sure a field is actually in the API before setting.
+ * Set to false to skip this check.
+ */
+ public $verify_x_fields = true;
+
+ /**
+ * A list of all fields in the AIM API.
+ * Used to warn user if they try to set a field not offered in the API.
+ */
+ private $_all_aim_fields = array("address","allow_partial_auth","amount",
+ "auth_code","authentication_indicator", "bank_aba_code","bank_acct_name",
+ "bank_acct_num","bank_acct_type","bank_check_number","bank_name",
+ "card_code","card_num","cardholder_authentication_value","city","company",
+ "country","cust_id","customer_ip","delim_char","delim_data","description",
+ "duplicate_window","duty","echeck_type","email","email_customer",
+ "encap_char","exp_date","fax","first_name","footer_email_receipt",
+ "freight","header_email_receipt","invoice_num","last_name","line_item",
+ "login","method","phone","po_num","recurring_billing","relay_response",
+ "ship_to_address","ship_to_city","ship_to_company","ship_to_country",
+ "ship_to_first_name","ship_to_last_name","ship_to_state","ship_to_zip",
+ "split_tender_id","state","tax","tax_exempt","test_request","tran_key",
+ "trans_id","type","version","zip"
+ );
+
+ /**
+ * Do an AUTH_CAPTURE transaction.
+ *
+ * Required "x_" fields: card_num, exp_date, amount
+ *
+ * @param string $amount The dollar amount to charge
+ * @param string $card_num The credit card number
+ * @param string $exp_date CC expiration date
+ *
+ * @return AuthorizeNetAIM_Response
+ */
+ public function authorizeAndCapture($amount = false, $card_num = false, $exp_date = false)
+ {
+ ($amount ? $this->amount = $amount : null);
+ ($card_num ? $this->card_num = $card_num : null);
+ ($exp_date ? $this->exp_date = $exp_date : null);
+ $this->type = "AUTH_CAPTURE";
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Do a PRIOR_AUTH_CAPTURE transaction.
+ *
+ * Required "x_" field: trans_id(The transaction id of the prior auth, unless split
+ * tender, then set x_split_tender_id manually.)
+ * amount (only if lesser than original auth)
+ *
+ * @param string $trans_id Transaction id to charge
+ * @param string $amount Dollar amount to charge if lesser than auth
+ *
+ * @return AuthorizeNetAIM_Response
+ */
+ public function priorAuthCapture($trans_id = false, $amount = false)
+ {
+ ($trans_id ? $this->trans_id = $trans_id : null);
+ ($amount ? $this->amount = $amount : null);
+ $this->type = "PRIOR_AUTH_CAPTURE";
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Do an AUTH_ONLY transaction.
+ *
+ * Required "x_" fields: card_num, exp_date, amount
+ *
+ * @param string $amount The dollar amount to charge
+ * @param string $card_num The credit card number
+ * @param string $exp_date CC expiration date
+ *
+ * @return AuthorizeNetAIM_Response
+ */
+ public function authorizeOnly($amount = false, $card_num = false, $exp_date = false)
+ {
+ ($amount ? $this->amount = $amount : null);
+ ($card_num ? $this->card_num = $card_num : null);
+ ($exp_date ? $this->exp_date = $exp_date : null);
+ $this->type = "AUTH_ONLY";
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Do a VOID transaction.
+ *
+ * Required "x_" field: trans_id(The transaction id of the prior auth, unless split
+ * tender, then set x_split_tender_id manually.)
+ *
+ * @param string $trans_id Transaction id to void
+ *
+ * @return AuthorizeNetAIM_Response
+ */
+ public function void($trans_id = false)
+ {
+ ($trans_id ? $this->trans_id = $trans_id : null);
+ $this->type = "VOID";
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Do a CAPTURE_ONLY transaction.
+ *
+ * Required "x_" fields: auth_code, amount, card_num , exp_date
+ *
+ * @param string $auth_code The auth code
+ * @param string $amount The dollar amount to charge
+ * @param string $card_num The last 4 of credit card number
+ * @param string $exp_date CC expiration date
+ *
+ * @return AuthorizeNetAIM_Response
+ */
+ public function captureOnly($auth_code = false, $amount = false, $card_num = false, $exp_date = false)
+ {
+ ($auth_code ? $this->auth_code = $auth_code : null);
+ ($amount ? $this->amount = $amount : null);
+ ($card_num ? $this->card_num = $card_num : null);
+ ($exp_date ? $this->exp_date = $exp_date : null);
+ $this->type = "CAPTURE_ONLY";
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Do a CREDIT transaction.
+ *
+ * Required "x_" fields: trans_id, amount, card_num (just the last 4)
+ *
+ * @param string $trans_id Transaction id to credit
+ * @param string $amount The dollar amount to credit
+ * @param string $card_num The last 4 of credit card number
+ *
+ * @return AuthorizeNetAIM_Response
+ */
+ public function credit($trans_id = false, $amount = false, $card_num = false)
+ {
+ ($trans_id ? $this->trans_id = $trans_id : null);
+ ($amount ? $this->amount = $amount : null);
+ ($card_num ? $this->card_num = $card_num : null);
+ $this->type = "CREDIT";
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Alternative syntax for setting x_ fields.
+ *
+ * Usage: $sale->method = "echeck";
+ *
+ * @param string $name
+ * @param string $value
+ */
+ public function __set($name, $value)
+ {
+ $this->setField($name, $value);
+ }
+
+ /**
+ * Quickly set multiple fields.
+ *
+ * Note: The prefix x_ will be added to all fields. If you want to set a
+ * custom field without the x_ prefix, use setCustomField or setCustomFields.
+ *
+ * @param array $fields Takes an array or object.
+ */
+ public function setFields($fields)
+ {
+ $array = (array)$fields;
+ foreach ($array as $key => $value) {
+ $this->setField($key, $value);
+ }
+ }
+
+ /**
+ * Quickly set multiple custom fields.
+ *
+ * @param array $fields
+ */
+ public function setCustomFields($fields)
+ {
+ $array = (array)$fields;
+ foreach ($array as $key => $value) {
+ $this->setCustomField($key, $value);
+ }
+ }
+
+ /**
+ * Add a line item.
+ *
+ * @param string $item_id
+ * @param string $item_name
+ * @param string $item_description
+ * @param string $item_quantity
+ * @param string $item_unit_price
+ * @param string $item_taxable
+ */
+ public function addLineItem($item_id, $item_name, $item_description, $item_quantity, $item_unit_price, $item_taxable)
+ {
+ $line_item = "";
+ $delimiter = "";
+ foreach (func_get_args() as $key => $value) {
+ $line_item .= $delimiter . preg_replace('/|/', '_', $value);
+ $delimiter = "<|>";
+ }
+ $this->_additional_line_items[] = $line_item;
+ }
+
+ /**
+ * Use ECHECK as payment type.
+ */
+ public function setECheck($bank_aba_code, $bank_acct_num, $bank_acct_type, $bank_name, $bank_acct_name, $echeck_type = 'WEB')
+ {
+ $this->setFields(
+ array(
+ 'method' => 'echeck',
+ 'bank_aba_code' => $bank_aba_code,
+ 'bank_acct_num' => $bank_acct_num,
+ 'bank_acct_type' => $bank_acct_type,
+ 'bank_name' => $bank_name,
+ 'bank_acct_name' => $bank_acct_name,
+ 'echeck_type' => $echeck_type,
+ )
+ );
+ }
+
+ /**
+ * Set an individual name/value pair. This will append x_ to the name
+ * before posting.
+ *
+ * @param string $name
+ * @param string $value
+ */
+ public function setField($name, $value)
+ {
+ if ($this->verify_x_fields) {
+ if (in_array($name, $this->_all_aim_fields)) {
+ $this->_x_post_fields[$name] = $value;
+ } else {
+ throw new AuthorizeNetException("Error: no field $name exists in the AIM API.
+ To set a custom field use setCustomField('field','value') instead.");
+ }
+ } else {
+ $this->_x_post_fields[$name] = $value;
+ }
+ }
+
+ /**
+ * Set a custom field. Note: the x_ prefix will not be added to
+ * your custom field if you use this method.
+ *
+ * @param string $name
+ * @param string $value
+ */
+ public function setCustomField($name, $value)
+ {
+ $this->_custom_fields[$name] = $value;
+ }
+
+ /**
+ * Unset an x_ field.
+ *
+ * @param string $name Field to unset.
+ */
+ public function unsetField($name)
+ {
+ unset($this->_x_post_fields[$name]);
+ }
+
+ /**
+ *
+ *
+ * @param string $response
+ *
+ * @return AuthorizeNetAIM_Response
+ */
+ protected function _handleResponse($response)
+ {
+ return new AuthorizeNetAIM_Response($response, $this->_x_post_fields['delim_char'], $this->_x_post_fields['encap_char'], $this->_custom_fields);
+ }
+
+ /**
+ * @return string
+ */
+ protected function _getPostUrl()
+ {
+ return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL);
+ }
+
+ /**
+ * Converts the x_post_fields array into a string suitable for posting.
+ */
+ protected function _setPostString()
+ {
+ $this->_x_post_fields['login'] = $this->_api_login;
+ $this->_x_post_fields['tran_key'] = $this->_transaction_key;
+ $this->_post_string = "";
+ foreach ($this->_x_post_fields as $key => $value) {
+ $this->_post_string .= "x_$key=" . urlencode($value) . "&";
+ }
+ // Add line items
+ foreach ($this->_additional_line_items as $key => $value) {
+ $this->_post_string .= "x_line_item=" . urlencode($value) . "&";
+ }
+ // Add custom fields
+ foreach ($this->_custom_fields as $key => $value) {
+ $this->_post_string .= "$key=" . urlencode($value) . "&";
+ }
+ $this->_post_string = rtrim($this->_post_string, "& ");
+ }
+}
+
+/**
+ * Parses an AuthorizeNet AIM Response.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetAIM
+ */
+class AuthorizeNetAIM_Response extends AuthorizeNetResponse
+{
+ private $_response_array = array(); // An array with the split response.
+
+ /**
+ * Constructor. Parses the AuthorizeNet response string.
+ *
+ * @param string $response The response from the AuthNet server.
+ * @param string $delimiter The delimiter used (default is ",")
+ * @param string $encap_char The encap_char used (default is "|")
+ * @param array $custom_fields Any custom fields set in the request.
+ */
+ public function __construct($response, $delimiter, $encap_char, $custom_fields)
+ {
+ if ($response) {
+
+ // Split Array
+ $this->response = $response;
+ if ($encap_char) {
+ $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
+ } else {
+ $this->_response_array = explode($delimiter, $response);
+ }
+
+ /**
+ * If AuthorizeNet doesn't return a delimited response.
+ */
+ if (count($this->_response_array) < 10) {
+ $this->approved = false;
+ $this->error = true;
+ $this->error_message = "Unrecognized response from AuthorizeNet: $response";
+ return;
+ }
+
+
+
+ // Set all fields
+ $this->response_code = $this->_response_array[0];
+ $this->response_subcode = $this->_response_array[1];
+ $this->response_reason_code = $this->_response_array[2];
+ $this->response_reason_text = $this->_response_array[3];
+ $this->authorization_code = $this->_response_array[4];
+ $this->avs_response = $this->_response_array[5];
+ $this->transaction_id = $this->_response_array[6];
+ $this->invoice_number = $this->_response_array[7];
+ $this->description = $this->_response_array[8];
+ $this->amount = $this->_response_array[9];
+ $this->method = $this->_response_array[10];
+ $this->transaction_type = $this->_response_array[11];
+ $this->customer_id = $this->_response_array[12];
+ $this->first_name = $this->_response_array[13];
+ $this->last_name = $this->_response_array[14];
+ $this->company = $this->_response_array[15];
+ $this->address = $this->_response_array[16];
+ $this->city = $this->_response_array[17];
+ $this->state = $this->_response_array[18];
+ $this->zip_code = $this->_response_array[19];
+ $this->country = $this->_response_array[20];
+ $this->phone = $this->_response_array[21];
+ $this->fax = $this->_response_array[22];
+ $this->email_address = $this->_response_array[23];
+ $this->ship_to_first_name = $this->_response_array[24];
+ $this->ship_to_last_name = $this->_response_array[25];
+ $this->ship_to_company = $this->_response_array[26];
+ $this->ship_to_address = $this->_response_array[27];
+ $this->ship_to_city = $this->_response_array[28];
+ $this->ship_to_state = $this->_response_array[29];
+ $this->ship_to_zip_code = $this->_response_array[30];
+ $this->ship_to_country = $this->_response_array[31];
+ $this->tax = $this->_response_array[32];
+ $this->duty = $this->_response_array[33];
+ $this->freight = $this->_response_array[34];
+ $this->tax_exempt = $this->_response_array[35];
+ $this->purchase_order_number= $this->_response_array[36];
+ $this->md5_hash = $this->_response_array[37];
+ $this->card_code_response = $this->_response_array[38];
+ $this->cavv_response = $this->_response_array[39];
+ $this->account_number = $this->_response_array[50];
+ $this->card_type = $this->_response_array[51];
+ $this->split_tender_id = $this->_response_array[52];
+ $this->requested_amount = $this->_response_array[53];
+ $this->balance_on_card = $this->_response_array[54];
+
+ $this->approved = ($this->response_code == self::APPROVED);
+ $this->declined = ($this->response_code == self::DECLINED);
+ $this->error = ($this->response_code == self::ERROR);
+ $this->held = ($this->response_code == self::HELD);
+
+ // Set custom fields
+ if ($count = count($custom_fields)) {
+ $custom_fields_response = array_slice($this->_response_array, -$count-1, $count);
+ $i = 0;
+ foreach ($custom_fields as $key => $value) {
+ $this->$key = $custom_fields_response[$i];
+ $i++;
+ }
+ }
+
+ if ($this->error) {
+ $this->error_message = "AuthorizeNet Error:
+ Response Code: ".$this->response_code."
+ Response Subcode: ".$this->response_subcode."
+ Response Reason Code: ".$this->response_reason_code."
+ Response Reason Text: ".$this->response_reason_text."
+ ";
+ }
+ } else {
+ $this->approved = false;
+ $this->error = true;
+ $this->error_message = "Error connecting to AuthorizeNet";
+ }
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Easily interact with the Authorize.Net ARB XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetARB
+ * @link http://www.authorize.net/support/ARB_guide.pdf ARB Guide
+ */
+
+
+/**
+ * A class to send a request to the ARB XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetARB
+ */
+class AuthorizeNetARB extends AuthorizeNetRequest
+{
+ const LIVE_URL = "https://api2.authorize.net/xml/v1/request.api";
+ const SANDBOX_URL = "https://apitest.authorize.net/xml/v1/request.api";
+
+ private $_request_type;
+ private $_request_payload;
+
+ /**
+ * Optional. Used if the merchant wants to set a reference ID.
+ *
+ * @param string $refId
+ */
+ public function setRefId($refId)
+ {
+ $this->_request_payload = ($refId ? "<refId>$refId</refId>" : "");
+ }
+
+ /**
+ * Create an ARB subscription
+ *
+ * @param AuthorizeNet_Subscription $subscription
+ *
+ * @return AuthorizeNetARB_Response
+ */
+ public function createSubscription(AuthorizeNet_Subscription $subscription)
+ {
+ $this->_request_type = "CreateSubscriptionRequest";
+ $this->_request_payload .= $subscription->getXml();
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Update an ARB subscription
+ *
+ * @param int $subscriptionId
+ * @param AuthorizeNet_Subscription $subscription
+ *
+ * @return AuthorizeNetARB_Response
+ */
+ public function updateSubscription($subscriptionId, AuthorizeNet_Subscription $subscription)
+ {
+ $this->_request_type = "UpdateSubscriptionRequest";
+ $this->_request_payload .= "<subscriptionId>$subscriptionId</subscriptionId>";
+ $this->_request_payload .= $subscription->getXml();
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Get status of a subscription
+ *
+ * @param int $subscriptionId
+ *
+ * @return AuthorizeNetARB_Response
+ */
+ public function getSubscriptionStatus($subscriptionId)
+ {
+ $this->_request_type = "GetSubscriptionStatusRequest";
+ $this->_request_payload .= "<subscriptionId>$subscriptionId</subscriptionId>";
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Cancel a subscription
+ *
+ * @param int $subscriptionId
+ *
+ * @return AuthorizeNetARB_Response
+ */
+ public function cancelSubscription($subscriptionId)
+ {
+ $this->_request_type = "CancelSubscriptionRequest";
+ $this->_request_payload .= "<subscriptionId>$subscriptionId</subscriptionId>";
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Create an ARB subscription
+ *
+ * @param AuthorizeNet_Subscription $subscription
+ *
+ * @return AuthorizeNetARB_Response
+ */
+ public function getSubscriptionList(AuthorizeNetGetSubscriptionList $subscriptionList)
+ {
+ $this->_request_type = "GetSubscriptionListRequest";
+ $this->_request_payload .= $subscriptionList->getXml();
+ return $this->_sendRequest();
+ }
+
+ /**
+ *
+ *
+ * @param string $response
+ *
+ * @return AuthorizeNetARB_Response
+ */
+ protected function _handleResponse($response)
+ {
+ return new AuthorizeNetARB_Response($response);
+ }
+
+ /**
+ * @return string
+ */
+ protected function _getPostUrl()
+ {
+ return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL);
+ }
+
+ /**
+ * Prepare the XML document for posting.
+ */
+ protected function _setPostString()
+ {
+ $this->_post_string =<<<XML
+<?xml version="1.0" encoding="utf-8"?>
+<ARB{$this->_request_type} xmlns= "AnetApi/xml/v1/schema/AnetApiSchema.xsd">
+ <merchantAuthentication>
+ <name>{$this->_api_login}</name>
+ <transactionKey>{$this->_transaction_key}</transactionKey>
+ </merchantAuthentication>
+ {$this->_request_payload}
+</ARB{$this->_request_type}>
+XML;
+ }
+
+}
+
+
+/**
+ * A class to parse a response from the ARB XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetARB
+ */
+class AuthorizeNetARB_Response extends AuthorizeNetXMLResponse
+{
+
+ /**
+ * @return int
+ */
+ public function getSubscriptionId()
+ {
+ return $this->_getElementContents("subscriptionId");
+ }
+
+ /**
+ * @return string
+ */
+ public function getSubscriptionStatus()
+ {
+ return $this->_getElementContents("status");
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Easily interact with the Authorize.Net CIM XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ * @link http://www.authorize.net/support/CIM_XML_guide.pdf CIM XML Guide
+ */
+
+
+
+/**
+ * A class to send a request to the CIM XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetCIM extends AuthorizeNetRequest
+{
+
+ const LIVE_URL = "https://api2.authorize.net/xml/v1/request.api";
+ const SANDBOX_URL = "https://apitest.authorize.net/xml/v1/request.api";
+
+
+ private $_xml;
+ private $_refId = false;
+ private $_validationMode = "none"; // "none","testMode","liveMode"
+ private $_extraOptions;
+ private $_transactionTypes = array(
+ 'AuthOnly',
+ 'AuthCapture',
+ 'CaptureOnly',
+ 'PriorAuthCapture',
+ 'Refund',
+ 'Void',
+ );
+
+ /**
+ * Optional. Used if the merchant wants to set a reference ID.
+ *
+ * @param string $refId
+ */
+ public function setRefId($refId)
+ {
+ $this->_refId = $refId;
+ }
+
+ /**
+ * Create a customer profile.
+ *
+ * @param AuthorizeNetCustomer $customerProfile
+ * @param string $validationMode
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function createCustomerProfile($customerProfile, $validationMode = "none")
+ {
+ $this->_validationMode = $validationMode;
+ $this->_constructXml("createCustomerProfileRequest");
+ $profile = $this->_xml->addChild("profile");
+ $this->_addObject($profile, $customerProfile);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Create a customer payment profile.
+ *
+ * @param int $customerProfileId
+ * @param AuthorizeNetPaymentProfile $paymentProfile
+ * @param string $validationMode
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function createCustomerPaymentProfile($customerProfileId, $paymentProfile, $validationMode = "none")
+ {
+ $this->_validationMode = $validationMode;
+ $this->_constructXml("createCustomerPaymentProfileRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ $profile = $this->_xml->addChild("paymentProfile");
+ $this->_addObject($profile, $paymentProfile);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Create a shipping address.
+ *
+ * @param int $customerProfileId
+ * @param AuthorizeNetAddress $shippingAddress
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function createCustomerShippingAddress($customerProfileId, $shippingAddress)
+ {
+ $this->_constructXml("createCustomerShippingAddressRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ $address = $this->_xml->addChild("address");
+ $this->_addObject($address, $shippingAddress);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Create a transaction.
+ *
+ * @param string $transactionType
+ * @param AuthorizeNetTransaction $transaction
+ * @param string $extraOptionsString
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function createCustomerProfileTransaction($transactionType, $transaction, $extraOptionsString = "")
+ {
+ $this->_constructXml("createCustomerProfileTransactionRequest");
+ $transactionParent = $this->_xml->addChild("transaction");
+ $transactionChild = $transactionParent->addChild("profileTrans" . $transactionType);
+ $this->_addObject($transactionChild, $transaction);
+ $this->_extraOptions = $extraOptionsString . "x_encap_char=|";
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Delete a customer profile.
+ *
+ * @param int $customerProfileId
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function deleteCustomerProfile($customerProfileId)
+ {
+ $this->_constructXml("deleteCustomerProfileRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Delete a payment profile.
+ *
+ * @param int $customerProfileId
+ * @param int $customerPaymentProfileId
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function deleteCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId)
+ {
+ $this->_constructXml("deleteCustomerPaymentProfileRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ $this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Delete a shipping address.
+ *
+ * @param int $customerProfileId
+ * @param int $customerAddressId
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function deleteCustomerShippingAddress($customerProfileId, $customerAddressId)
+ {
+ $this->_constructXml("deleteCustomerShippingAddressRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ $this->_xml->addChild("customerAddressId", $customerAddressId);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Get all customer profile ids.
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function getCustomerProfileIds()
+ {
+ $this->_constructXml("getCustomerProfileIdsRequest");
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Get a customer profile.
+ *
+ * @param int $customerProfileId
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function getCustomerProfile($customerProfileId)
+ {
+ $this->_constructXml("getCustomerProfileRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Get a payment profile.
+ *
+ * @param int $customerProfileId
+ * @param int $customerPaymentProfileId
+ * @param boolean $unmaskExpirationDate
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function getCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId, $unmaskExpirationDate = false)
+ {
+ $this->_constructXml("getCustomerPaymentProfileRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ $this->_xml->addChild("customerPaymentProfileId", $customerPaymentProfileId);
+ if ( $unmaskExpirationDate ) {
+ $this->_xml->addChild("unmaskExpirationDate", true);
+ }
+
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Get a shipping address.
+ *
+ * @param int $customerProfileId
+ * @param int $customerAddressId
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function getCustomerShippingAddress($customerProfileId, $customerAddressId)
+ {
+ $this->_constructXml("getCustomerShippingAddressRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ $this->_xml->addChild("customerAddressId", $customerAddressId);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Update a profile.
+ *
+ * @param int $customerProfileId
+ * @param AuthorizeNetCustomer $customerProfile
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function updateCustomerProfile($customerProfileId, $customerProfile)
+ {
+ $this->_constructXml("updateCustomerProfileRequest");
+ $customerProfile->customerProfileId = $customerProfileId;
+ $profile = $this->_xml->addChild("profile");
+ $this->_addObject($profile, $customerProfile);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Update a payment profile.
+ *
+ * @param int $customerProfileId
+ * @param int $customerPaymentProfileId
+ * @param AuthorizeNetPaymentProfile $paymentProfile
+ * @param string $validationMode
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function updateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId, $paymentProfile, $validationMode = "none")
+ {
+ $this->_validationMode = $validationMode;
+ $this->_constructXml("updateCustomerPaymentProfileRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ $paymentProfile->customerPaymentProfileId = $customerPaymentProfileId;
+ $profile = $this->_xml->addChild("paymentProfile");
+ $this->_addObject($profile, $paymentProfile);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Update a shipping address.
+ *
+ * @param int $customerProfileId
+ * @param int $customerShippingAddressId
+ * @param AuthorizeNetAddress $shippingAddress
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function updateCustomerShippingAddress($customerProfileId, $customerShippingAddressId, $shippingAddress)
+ {
+
+ $this->_constructXml("updateCustomerShippingAddressRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+ $shippingAddress->customerAddressId = $customerShippingAddressId;
+ $sa = $this->_xml->addChild("address");
+ $this->_addObject($sa, $shippingAddress);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Update the status of an existing order that contains multiple transactions with the same splitTenderId.
+ *
+ * @param int $splitTenderId
+ * @param string $splitTenderStatus
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function updateSplitTenderGroup($splitTenderId, $splitTenderStatus)
+ {
+ $this->_constructXml("updateSplitTenderGroupRequest");
+ $this->_xml->addChild("splitTenderId", $splitTenderId);
+ $this->_xml->addChild("splitTenderStatus", $splitTenderStatus);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Validate a customer payment profile.
+ *
+ * @param int $customerProfileId
+ * @param int $customerPaymentProfileId
+ * @param int $customerShippingAddressId
+ * @param int $cardCode
+ * @param string $validationMode
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function validateCustomerPaymentProfile($customerProfileId, $customerPaymentProfileId, $customerShippingAddressId, $cardCode, $validationMode = "testMode")
+ {
+ $this->_validationMode = $validationMode;
+ $this->_constructXml("validateCustomerPaymentProfileRequest");
+ $this->_xml->addChild("customerProfileId",$customerProfileId);
+ $this->_xml->addChild("customerPaymentProfileId",$customerPaymentProfileId);
+ $this->_xml->addChild("customerShippingAddressId",$customerShippingAddressId);
+ $this->_xml->addChild("cardCode",$cardCode);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Get hosted profile page request token
+ *
+ * @param string $customerProfileId
+ * @param mixed $settings
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ public function getHostedProfilePageRequest($customerProfileId, $settings=0)
+ {
+ $this->_constructXml("getHostedProfilePageRequest");
+ $this->_xml->addChild("customerProfileId", $customerProfileId);
+
+ if (!empty($settings)) {
+ $hostedSettings = $this->_xml->addChild("hostedProfileSettings");
+ foreach ($settings as $key => $val) {
+ $setting = $hostedSettings->addChild("setting");
+ $setting->addChild("settingName", $key);
+ $setting->addChild("settingValue", $val);
+ }
+ }
+
+ return $this->_sendRequest();
+ }
+
+ /**
+ * @return string
+ */
+ protected function _getPostUrl()
+ {
+ return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL);
+ }
+
+ /**
+ *
+ *
+ * @param string $response
+ *
+ * @return AuthorizeNetCIM_Response
+ */
+ protected function _handleResponse($response)
+ {
+ return new AuthorizeNetCIM_Response($response);
+ }
+
+ /**
+ * Prepare the XML post string.
+ */
+ protected function _setPostString()
+ {
+ ($this->_validationMode != "none" ? $this->_xml->addChild('validationMode',$this->_validationMode) : "");
+ $this->_post_string = $this->_xml->asXML();
+
+ // Add extraOptions CDATA
+ if ($this->_extraOptions) {
+ $this->_xml->addChild("extraOptions");
+ $this->_post_string = str_replace(array("<extraOptions></extraOptions>","<extraOptions/>"),'<extraOptions><![CDATA[' . $this->_extraOptions . ']]></extraOptions>', $this->_xml->asXML());
+ $this->_extraOptions = false;
+ }
+ // Blank out our validation mode, so that we don't include it in calls that
+ // don't use it.
+ $this->_validationMode = "none";
+ }
+
+ /**
+ * Start the SimpleXMLElement that will be posted.
+ *
+ * @param string $request_type The action to be performed.
+ */
+ private function _constructXml($request_type)
+ {
+ $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>';
+ $this->_xml = @new SimpleXMLElement($string);
+ $merchant = $this->_xml->addChild('merchantAuthentication');
+ $merchant->addChild('name',$this->_api_login);
+ $merchant->addChild('transactionKey',$this->_transaction_key);
+ ($this->_refId ? $this->_xml->addChild('refId',$this->_refId) : "");
+ }
+
+ /**
+ * Add an object to an SimpleXMLElement parent element.
+ *
+ * @param SimpleXMLElement $destination The parent element.
+ * @param Object $object An object, array or value.
+ */
+ private function _addObject($destination, $object)
+ {
+ $array = (array)$object;
+ foreach ($array as $key => $value) {
+ if ($value && !is_object($value)) {
+ if (is_array($value) && count($value)) {
+ foreach ($value as $index => $item) {
+ $items = $destination->addChild($key);
+ $this->_addObject($items, $item);
+ }
+ } else {
+ $destination->addChild($key,$value);
+ }
+ } elseif (is_object($value) && self::_notEmpty($value)) {
+ $dest = $destination->addChild($key);
+ $this->_addObject($dest, $value);
+ }
+ }
+ }
+
+ /**
+ * Checks whether an array or object contains any values.
+ *
+ * @param Object $object
+ *
+ * @return bool
+ */
+ private static function _notEmpty($object)
+ {
+ $array = (array)$object;
+ foreach ($array as $key => $value) {
+ if ($value && !is_object($value)) {
+ return true;
+ } elseif (is_object($value)) {
+ if (self::_notEmpty($value)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+}
+
+/**
+ * A class to parse a response from the CIM XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetCIM_Response extends AuthorizeNetXMLResponse
+{
+ /**
+ * @return AuthorizeNetAIM_Response
+ */
+ public function getTransactionResponse()
+ {
+ return new AuthorizeNetAIM_Response($this->_getElementContents("directResponse"), ",", "|", array());
+ }
+
+ /**
+ * @return array Array of AuthorizeNetAIM_Response objects for each payment profile.
+ */
+ public function getValidationResponses()
+ {
+ $responses = (array)$this->xml->validationDirectResponseList;
+ $return = array();
+ foreach ((array)$responses["string"] as $response) {
+ $return[] = new AuthorizeNetAIM_Response($response, ",", "", array());
+ }
+ return $return;
+ }
+
+ /**
+ * @return AuthorizeNetAIM_Response
+ */
+ public function getValidationResponse()
+ {
+ return new AuthorizeNetAIM_Response($this->_getElementContents("validationDirectResponse"), ",", "|", array());
+ }
+
+ /**
+ * @return array
+ */
+ public function getCustomerProfileIds()
+ {
+ $ids = (array)$this->xml->ids;
+ if(!empty($ids))
+ return $ids["numericString"];
+ else
+ return $ids;
+ }
+
+ /**
+ * @return array
+ */
+ public function getCustomerPaymentProfileIds()
+ {
+ $ids = (array)$this->xml->customerPaymentProfileIdList;
+ if(!empty($ids))
+ return $ids["numericString"];
+ else
+ return $ids;
+ }
+
+ /**
+ * @return array
+ */
+ public function getCustomerShippingAddressIds()
+ {
+ $ids = (array)$this->xml->customerShippingAddressIdList;
+ if(!empty($ids))
+ return $ids["numericString"];
+ else
+ return $ids;
+ }
+
+ /**
+ * @return string
+ */
+ public function getCustomerAddressId()
+ {
+ return $this->_getElementContents("customerAddressId");
+ }
+
+ /**
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->_getElementContents("customerProfileId");
+ }
+
+ /**
+ * @return string
+ */
+ public function getPaymentProfileId()
+ {
+ return $this->_getElementContents("customerPaymentProfileId");
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Easily interact with the Authorize.Net Card Present API.
+ *
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCP
+ * @link http://www.authorize.net/support/CP_guide.pdf Card Present Guide
+ */
+
+
+/**
+ * Builds and sends an AuthorizeNet CP Request.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCP
+ */
+class AuthorizeNetCP extends AuthorizeNetAIM
+{
+
+ const LIVE_URL = 'https://cardpresent.authorize.net/gateway/transact.dll';
+
+ public $verify_x_fields = false;
+
+ /**
+ * Holds all the x_* name/values that will be posted in the request.
+ * Default values are provided for best practice fields.
+ */
+ protected $_x_post_fields = array(
+ "cpversion" => "1.0",
+ "delim_char" => ",",
+ "encap_char" => "|",
+ "market_type" => "2",
+ "response_format" => "1", // 0 - XML, 1 - NVP
+ );
+
+ /**
+ * Device Types (x_device_type)
+ * 1 = Unknown
+ * 2 = Unattended Terminal
+ * 3 = Self Service Terminal
+ * 4 = Electronic Cash Register
+ * 5 = Personal Computer- Based Terminal
+ * 6 = AirPay
+ * 7 = Wireless POS
+ * 8 = Website
+ * 9 = Dial Terminal
+ * 10 = Virtual Terminal
+ */
+
+ /**
+ * Only used if merchant wants to send custom fields.
+ */
+ private $_custom_fields = array();
+
+ /**
+ * Strip sentinels and set track1 field.
+ *
+ * @param string $track1data
+ */
+ public function setTrack1Data($track1data) {
+ if (preg_match('/^%.*\?$/', $track1data)) {
+ $this->track1 = substr($track1data, 1, -1);
+ } else {
+ $this->track1 = $track1data;
+ }
+ }
+
+ /**
+ * Strip sentinels and set track2 field.
+ *
+ * @param string $track2data
+ */
+ public function setTrack2Data($track2data) {
+ if (preg_match('/^;.*\?$/', $track2data)) {
+ $this->track2 = substr($track2data, 1, -1);
+ } else {
+ $this->track2 = $track2data;
+ }
+ }
+
+ /**
+ *
+ *
+ * @param string $response
+ *
+ * @return AuthorizeNetAIM_Response
+ */
+ protected function _handleResponse($response)
+ {
+ return new AuthorizeNetCP_Response($response, $this->_x_post_fields['delim_char'], $this->_x_post_fields['encap_char'], $this->_custom_fields);
+ }
+
+}
+
+
+/**
+ * Parses an AuthorizeNet Card Present Response.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCP
+ */
+class AuthorizeNetCP_Response extends AuthorizeNetResponse
+{
+ private $_response_array = array(); // An array with the split response.
+
+ /**
+ * Constructor. Parses the AuthorizeNet response string.
+ *
+ * @param string $response The response from the AuthNet server.
+ * @param string $delimiter The delimiter used (default is ",")
+ * @param string $encap_char The encap_char used (default is "|")
+ * @param array $custom_fields Any custom fields set in the request.
+ */
+ public function __construct($response, $delimiter, $encap_char, $custom_fields)
+ {
+ if ($response) {
+
+ // If it's an XML response
+ if (substr($response, 0, 5) == "<?xml") {
+
+ $this->xml = @simplexml_load_string($response);
+ // Set all fields
+ $this->version = array_pop(array_slice(explode('"', $response), 1,1));
+ $this->response_code = (string)$this->xml->ResponseCode;
+
+ if ($this->response_code == 1) {
+ $this->response_reason_code = (string)$this->xml->Messages->Message->Code;
+ $this->response_reason_text = (string)$this->xml->Messages->Message->Description;
+ } else {
+ $this->response_reason_code = (string)$this->xml->Errors->Error->ErrorCode;
+ $this->response_reason_text = (string)$this->xml->Errors->Error->ErrorText;
+ }
+
+ $this->authorization_code = (string)$this->xml->AuthCode;
+ $this->avs_code = (string)$this->xml->AVSResultCode;
+ $this->card_code_response = (string)$this->xml->CVVResultCode;
+ $this->transaction_id = (string)$this->xml->TransID;
+ $this->md5_hash = (string)$this->xml->TransHash;
+ $this->user_ref = (string)$this->xml->UserRef;
+ $this->card_num = (string)$this->xml->AccountNumber;
+ $this->card_type = (string)$this->xml->AccountType;
+ $this->test_mode = (string)$this->xml->TestMode;
+ $this->ref_trans_id = (string)$this->xml->RefTransID;
+
+
+ } else { // If it's an NVP response
+
+ // Split Array
+ $this->response = $response;
+ if ($encap_char) {
+ $this->_response_array = explode($encap_char.$delimiter.$encap_char, substr($response, 1, -1));
+ } else {
+ $this->_response_array = explode($delimiter, $response);
+ }
+
+ /**
+ * If AuthorizeNet doesn't return a delimited response.
+ */
+ if (count($this->_response_array) < 10) {
+ $this->approved = false;
+ $this->error = true;
+ $this->error_message = "Unrecognized response from AuthorizeNet: $response";
+ return;
+ }
+
+
+
+ // Set all fields
+ $this->version = $this->_response_array[0];
+ $this->response_code = $this->_response_array[1];
+ $this->response_reason_code = $this->_response_array[2];
+ $this->response_reason_text = $this->_response_array[3];
+ $this->authorization_code = $this->_response_array[4];
+ $this->avs_code = $this->_response_array[5];
+ $this->card_code_response = $this->_response_array[6];
+ $this->transaction_id = $this->_response_array[7];
+ $this->md5_hash = $this->_response_array[8];
+ $this->user_ref = $this->_response_array[9];
+ $this->card_num = $this->_response_array[20];
+ $this->card_type = $this->_response_array[21];
+ $this->split_tender_id = isset($this->_response_array[22]) ? $this->_response_array[22] : NULL;
+ $this->requested_amount = isset($this->_response_array[23]) ? $this->_response_array[23] : NULL;
+ $this->approved_amount = isset($this->_response_array[24]) ? $this->_response_array[24] : NULL;
+ $this->card_balance = isset($this->_response_array[25]) ? $this->_response_array[25] : NULL;
+
+
+
+ }
+ $this->approved = ($this->response_code == self::APPROVED);
+ $this->declined = ($this->response_code == self::DECLINED);
+ $this->error = ($this->response_code == self::ERROR);
+ $this->held = ($this->response_code == self::HELD);
+
+
+ if ($this->error) {
+ $this->error_message = "AuthorizeNet Error:
+ Response Code: ".$this->response_code."
+ Response Reason Code: ".$this->response_reason_code."
+ Response Reason Text: ".$this->response_reason_text."
+ ";
+ }
+
+ } else {
+ $this->approved = false;
+ $this->error = true;
+ $this->error_message = "Error connecting to AuthorizeNet";
+ }
+ }
+
+ /**
+ * Is the MD5 provided correct?
+ *
+ * @param string $api_login_id
+ * @param string $md5_setting
+ * @return bool
+ */
+ public function isAuthorizeNet($api_login_id = false, $md5_setting = false)
+ {
+ $amount = ($this->amount ? $this->amount : '0.00');
+ $api_login_id = ($api_login_id ? $api_login_id : AUTHORIZENET_API_LOGIN_ID);
+ $md5_setting = ($md5_setting ? $md5_setting : AUTHORIZENET_MD5_SETTING);
+ return ($this->md5_hash == strtoupper(md5($md5_setting . $api_login_id . $this->transaction_id . $amount)));
+ }
+
+}
+
--- /dev/null
+<?php
+/**
+ * Demonstrates the Direct Post Method.
+ *
+ * To implement the Direct Post Method you need to implement 3 steps:
+ *
+ * Step 1: Add necessary hidden fields to your checkout form and make your form is set to post to AuthorizeNet.
+ *
+ * Step 2: Receive a response from AuthorizeNet, do your business logic, and return
+ * a relay response snippet with a url to redirect the customer to.
+ *
+ * Step 3: Show a receipt page to your customer.
+ *
+ * This class is more for demonstration purposes than actual production use.
+ *
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetDPM
+ */
+
+/**
+ * A class that demonstrates the DPM method.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetDPM
+ */
+class AuthorizeNetDPM extends AuthorizeNetSIM_Form
+{
+
+ const LIVE_URL = 'https://secure2.authorize.net/gateway/transact.dll';
+ const SANDBOX_URL = 'https://test.authorize.net/gateway/transact.dll';
+
+ /**
+ * Implements all 3 steps of the Direct Post Method for demonstration
+ * purposes.
+ */
+ public static function directPostDemo($url, $api_login_id, $transaction_key, $amount = "0.00", $md5_setting = "")
+ {
+
+ // Step 1: Show checkout form to customer.
+ if (!count($_POST) && !count($_GET))
+ {
+ $fp_sequence = time(); // Any sequential number like an invoice number.
+ echo AuthorizeNetDPM::getCreditCardForm($amount, $fp_sequence, $url, $api_login_id, $transaction_key);
+ }
+ // Step 2: Handle AuthorizeNet Transaction Result & return snippet.
+ elseif (count($_POST))
+ {
+ $response = new AuthorizeNetSIM($api_login_id, $md5_setting);
+ if ($response->isAuthorizeNet())
+ {
+ if ($response->approved)
+ {
+ // Do your processing here.
+ $redirect_url = $url . '?response_code=1&transaction_id=' . $response->transaction_id;
+ }
+ else
+ {
+ // Redirect to error page.
+ $redirect_url = $url . '?response_code='.$response->response_code . '&response_reason_text=' . $response->response_reason_text;
+ }
+ // Send the Javascript back to AuthorizeNet, which will redirect user back to your site.
+ echo AuthorizeNetDPM::getRelayResponseSnippet($redirect_url);
+ }
+ else
+ {
+ echo "Error -- not AuthorizeNet. Check your MD5 Setting.";
+ }
+ }
+ // Step 3: Show receipt page to customer.
+ elseif (!count($_POST) && count($_GET))
+ {
+ if ($_GET['response_code'] == 1)
+ {
+ echo "Thank you for your purchase! Transaction id: " . htmlentities($_GET['transaction_id']);
+ }
+ else
+ {
+ echo "Sorry, an error occurred: " . htmlentities($_GET['response_reason_text']);
+ }
+ }
+ }
+
+ /**
+ * A snippet to send to AuthorizeNet to redirect the user back to the
+ * merchant's server. Use this on your relay response page.
+ *
+ * @param string $redirect_url Where to redirect the user.
+ *
+ * @return string
+ */
+ public static function getRelayResponseSnippet($redirect_url)
+ {
+ return "<html><head><script language=\"javascript\">
+ <!--
+ window.location=\"{$redirect_url}\";
+ //-->
+ </script>
+ </head><body><noscript><meta http-equiv=\"refresh\" content=\"1;url={$redirect_url}\"></noscript></body></html>";
+ }
+
+ /**
+ * Generate a sample form for use in a demo Direct Post implementation.
+ *
+ * @param string $amount Amount of the transaction.
+ * @param string $fp_sequence Sequential number(ie. Invoice #)
+ * @param string $relay_response_url The Relay Response URL
+ * @param string $api_login_id Your API Login ID
+ * @param string $transaction_key Your API Tran Key.
+ * @param bool $test_mode Use the sandbox?
+ * @param bool $prefill Prefill sample values(for test purposes).
+ *
+ * @return string
+ */
+ public static function getCreditCardForm($amount, $fp_sequence, $relay_response_url, $api_login_id, $transaction_key, $test_mode = true, $prefill = true)
+ {
+ $time = time();
+ $fp = self::getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $time);
+ $sim = new AuthorizeNetSIM_Form(
+ array(
+ 'x_amount' => $amount,
+ 'x_fp_sequence' => $fp_sequence,
+ 'x_fp_hash' => $fp,
+ 'x_fp_timestamp' => $time,
+ 'x_relay_response'=> "TRUE",
+ 'x_relay_url' => $relay_response_url,
+ 'x_login' => $api_login_id,
+ )
+ );
+ $hidden_fields = $sim->getHiddenFieldString();
+ $post_url = ($test_mode ? self::SANDBOX_URL : self::LIVE_URL);
+
+ $form = '
+ <style>
+ fieldset {
+ overflow: auto;
+ border: 0;
+ margin: 0;
+ padding: 0; }
+
+ fieldset div {
+ float: left; }
+
+ fieldset.centered div {
+ text-align: center; }
+
+ label {
+ color: #183b55;
+ display: block;
+ margin-bottom: 5px; }
+
+ label img {
+ display: block;
+ margin-bottom: 5px; }
+
+ input.text {
+ border: 1px solid #bfbab4;
+ margin: 0 4px 8px 0;
+ padding: 6px;
+ color: #1e1e1e;
+ -webkit-border-radius: 5px;
+ -moz-border-radius: 5px;
+ border-radius: 5px;
+ -webkit-box-shadow: inset 0px 5px 5px #eee;
+ -moz-box-shadow: inset 0px 5px 5px #eee;
+ box-shadow: inset 0px 5px 5px #eee; }
+ .submit {
+ display: block;
+ background-color: #76b2d7;
+ border: 1px solid #766056;
+ color: #3a2014;
+ margin: 13px 0;
+ padding: 8px 16px;
+ -webkit-border-radius: 12px;
+ -moz-border-radius: 12px;
+ border-radius: 12px;
+ font-size: 14px;
+ -webkit-box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75);
+ -moz-box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75);
+ box-shadow: inset 3px -3px 3px rgba(0,0,0,.5), inset 0 3px 3px rgba(255,255,255,.5), inset -3px 0 3px rgba(255,255,255,.75); }
+ </style>
+ <form method="post" action="'.$post_url.'">
+ '.$hidden_fields.'
+ <fieldset>
+ <div>
+ <label>Credit Card Number</label>
+ <input type="text" class="text" size="15" name="x_card_num" value="'.($prefill ? '6011000000000012' : '').'"></input>
+ </div>
+ <div>
+ <label>Exp.</label>
+ <input type="text" class="text" size="4" name="x_exp_date" value="'.($prefill ? '04/17' : '').'"></input>
+ </div>
+ <div>
+ <label>CCV</label>
+ <input type="text" class="text" size="4" name="x_card_code" value="'.($prefill ? '782' : '').'"></input>
+ </div>
+ </fieldset>
+ <fieldset>
+ <div>
+ <label>First Name</label>
+ <input type="text" class="text" size="15" name="x_first_name" value="'.($prefill ? 'John' : '').'"></input>
+ </div>
+ <div>
+ <label>Last Name</label>
+ <input type="text" class="text" size="14" name="x_last_name" value="'.($prefill ? 'Doe' : '').'"></input>
+ </div>
+ </fieldset>
+ <fieldset>
+ <div>
+ <label>Address</label>
+ <input type="text" class="text" size="26" name="x_address" value="'.($prefill ? '123 Main Street' : '').'"></input>
+ </div>
+ <div>
+ <label>City</label>
+ <input type="text" class="text" size="15" name="x_city" value="'.($prefill ? 'Boston' : '').'"></input>
+ </div>
+ </fieldset>
+ <fieldset>
+ <div>
+ <label>State</label>
+ <input type="text" class="text" size="4" name="x_state" value="'.($prefill ? 'MA' : '').'"></input>
+ </div>
+ <div>
+ <label>Zip Code</label>
+ <input type="text" class="text" size="9" name="x_zip" value="'.($prefill ? '02142' : '').'"></input>
+ </div>
+ <div>
+ <label>Country</label>
+ <input type="text" class="text" size="22" name="x_country" value="'.($prefill ? 'US' : '').'"></input>
+ </div>
+ </fieldset>
+ <input type="submit" value="BUY" class="submit buy">
+ </form>';
+ return $form;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Easily use the Authorize.Net Server Integration Method(SIM).
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetSIM
+ * @link http://www.authorize.net/support/SIM_guide.pdf SIM Guide
+ */
+
+/**
+ * Easily parse an AuthorizeNet SIM Response.
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetSIM
+ */
+class AuthorizeNetSIM extends AuthorizeNetResponse
+{
+
+ // For ARB transactions
+ public $subscription_id;
+ public $subscription_paynum;
+
+ /**
+ * Constructor.
+ *
+ * @param string $api_login_id
+ * @param string $md5_setting For verifying an Authorize.Net message.
+ */
+ public function __construct($api_login_id = false, $md5_setting = false)
+ {
+ $this->api_login_id = ($api_login_id ? $api_login_id : (defined('AUTHORIZENET_API_LOGIN_ID') ? AUTHORIZENET_API_LOGIN_ID : ""));
+ $this->md5_setting = ($md5_setting ? $md5_setting : (defined('AUTHORIZENET_MD5_SETTING') ? AUTHORIZENET_MD5_SETTING : ""));
+ $this->response = $_POST;
+
+ // Set fields without x_ prefix
+ foreach ($_POST as $key => $value) {
+ $name = substr($key, 2);
+ $this->$name = $value;
+ }
+
+ // Set some human readable fields
+ $map = array(
+ 'invoice_number' => 'x_invoice_num',
+ 'transaction_type' => 'x_type',
+ 'zip_code' => 'x_zip',
+ 'email_address' => 'x_email',
+ 'ship_to_zip_code' => 'x_ship_to_zip',
+ 'account_number' => 'x_account_number',
+ 'avs_response' => 'x_avs_code',
+ 'authorization_code' => 'x_auth_code',
+ 'transaction_id' => 'x_trans_id',
+ 'customer_id' => 'x_cust_id',
+ 'md5_hash' => 'x_MD5_Hash',
+ 'card_code_response' => 'x_cvv2_resp_code',
+ 'cavv_response' => 'x_cavv_response',
+ );
+ foreach ($map as $key => $value) {
+ $this->$key = (isset($_POST[$value]) ? $_POST[$value] : "");
+ }
+
+ $this->approved = ($this->response_code == self::APPROVED);
+ $this->declined = ($this->response_code == self::DECLINED);
+ $this->error = ($this->response_code == self::ERROR);
+ $this->held = ($this->response_code == self::HELD);
+ }
+
+ /**
+ * Verify the request is AuthorizeNet.
+ *
+ * @return bool
+ */
+ public function isAuthorizeNet()
+ {
+ return count($_POST) && $this->md5_hash && ($this->generateHash() == $this->md5_hash);
+ }
+
+ /**
+ * Generates an Md5 hash to compare against Authorize.Net's.
+ *
+ * @return string Hash
+ */
+ public function generateHash()
+ {
+ $amount = ($this->amount ? $this->amount : "0.00");
+ return strtoupper(md5($this->md5_setting . $this->api_login_id . $this->transaction_id . $amount));
+ }
+
+}
+
+/**
+ * A helper class for using hosted order page.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetSIM
+ */
+class AuthorizeNetSIM_Form
+{
+ public $x_address;
+ public $x_amount;
+ public $x_background_url;
+ public $x_card_num;
+ public $x_city;
+ public $x_color_background;
+ public $x_color_link;
+ public $x_color_text;
+ public $x_company;
+ public $x_country;
+ public $x_cust_id;
+ public $x_customer_ip;
+ public $x_description;
+ public $x_delim_data;
+ public $x_duplicate_window;
+ public $x_duty;
+ public $x_email;
+ public $x_email_customer;
+ public $x_fax;
+ public $x_first_name;
+ public $x_footer_email_receipt;
+ public $x_footer_html_payment_form;
+ public $x_footer_html_receipt;
+ public $x_fp_hash;
+ public $x_fp_sequence;
+ public $x_fp_timestamp;
+ public $x_freight;
+ public $x_header_email_receipt;
+ public $x_header_html_payment_form;
+ public $x_header_html_receipt;
+ public $x_invoice_num;
+ public $x_last_name;
+ public $x_line_item;
+ public $x_login;
+ public $x_logo_url;
+ public $x_method;
+ public $x_phone;
+ public $x_po_num;
+ public $x_receipt_link_method;
+ public $x_receipt_link_text;
+ public $x_receipt_link_url;
+ public $x_recurring_billing;
+ public $x_relay_response;
+ public $x_relay_url;
+ public $x_rename;
+ public $x_ship_to_address;
+ public $x_ship_to_company;
+ public $x_ship_to_country;
+ public $x_ship_to_city;
+ public $x_ship_to_first_name;
+ public $x_ship_to_last_name;
+ public $x_ship_to_state;
+ public $x_ship_to_zip;
+ public $x_show_form;
+ public $x_state;
+ public $x_tax;
+ public $x_tax_exempt;
+ public $x_test_request;
+ public $x_trans_id;
+ public $x_type;
+ public $x_version;
+ public $x_zip;
+
+ /**
+ * Constructor
+ *
+ * @param array $fields Fields to set.
+ */
+ public function __construct($fields = false)
+ {
+ // Set some best practice fields
+ $this->x_relay_response = "FALSE";
+ $this->x_version = "3.1";
+ $this->x_delim_char = ",";
+ $this->x_delim_data = "TRUE";
+
+ if ($fields) {
+ foreach ($fields as $key => $value) {
+ $this->$key = $value;
+ }
+ }
+ }
+
+ /**
+ * Get a string of HTML hidden fields for use in a form.
+ *
+ * @return string
+ */
+ public function getHiddenFieldString()
+ {
+ $array = (array)$this;
+ $string = "";
+ foreach ($array as $key => $value) {
+ if ($value) {
+ $string .= '<input type="hidden" name="'.$key.'" value="'.$value.'">';
+ }
+ }
+ return $string;
+ }
+
+ /**
+ * Generates a fingerprint needed for a hosted order form or DPM.
+ *
+ * @param string $api_login_id Login ID.
+ * @param string $transaction_key API key.
+ * @param string $amount Amount of transaction.
+ * @param string $fp_sequence An invoice number or random number.
+ * @param string $fp_timestamp Timestamp.
+ * @param string $fp_currency_code Currency Code
+ *
+ * @return string The fingerprint.
+ */
+ public static function getFingerprint($api_login_id, $transaction_key, $amount, $fp_sequence, $fp_timestamp, $fp_currency_code = '')
+ {
+ $api_login_id = ($api_login_id ? $api_login_id : (defined('AUTHORIZENET_API_LOGIN_ID') ? AUTHORIZENET_API_LOGIN_ID : ""));
+ $transaction_key = ($transaction_key ? $transaction_key : (defined('AUTHORIZENET_TRANSACTION_KEY') ? AUTHORIZENET_TRANSACTION_KEY : ""));
+ if (function_exists('hash_hmac')) {
+ return hash_hmac("md5", $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^" . $fp_currency_code, $transaction_key);
+ }
+ return bin2hex(mhash(MHASH_MD5, $api_login_id . "^" . $fp_sequence . "^" . $fp_timestamp . "^" . $amount . "^" . $fp_currency_code, $transaction_key));
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * A simple wrapper for the SOAP API as well as a helper function
+ * to generate a documentation file from the WSDL.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetSoap
+ */
+
+/**
+ * A simple wrapper for the SOAP API as well as a helper function
+ * to generate a documentation file from the WSDL.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetSoap
+ * @todo Make the doc file a usable class.
+ */
+class AuthorizeNetSOAP extends SoapClient
+{
+ const WSDL_URL = "https://api2.authorize.net/soap/v1/Service.asmx?WSDL";
+ const LIVE_URL = "https://api2.authorize.net/soap/v1/Service.asmx";
+ const SANDBOX_URL = "https://apitest.authorize.net/soap/v1/Service.asmx";
+
+ public $sandbox;
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ parent::__construct(self::WSDL_URL);
+ $this->__setLocation(self::SANDBOX_URL);
+ }
+
+ /**
+ * Switch between the sandbox or production gateway.
+ *
+ * @param bool
+ */
+ public function setSandbox($bool)
+ {
+ $this->__setLocation(($bool ? self::SANDBOX_URL : self::LIVE_URL));
+ }
+
+ /**
+ * Get all types as PHP Code.
+ * @return string
+ */
+ public function getSoapTypes()
+ {
+ $string = "";
+ $types = $this->__getTypes();
+ foreach ($types as $type) {
+ if (preg_match("/struct /",$type)) {
+ $type = preg_replace("/struct /","class ",$type);
+ $type = preg_replace("/ (\w+) (\w+);/"," // $1\n public \$$2;",$type);
+ $string .= $type ."\n";
+ }
+ }
+ return $string;
+ }
+
+ /**
+ * Get all methods as PHP Code.
+ * @return string
+ */
+ public function getSoapMethods()
+ {
+ $string = "";
+ $functions = array();
+ $methods = $this->__getFunctions();
+ foreach ($methods as $index => $method) {
+ $sig = explode(" ", $method, 2);
+ if (!isset($functions[$sig[1]])) {
+ $string .= " /**\n * @return {$sig[0]}\n */\n public function {$sig[1]} {}\n\n";
+ $functions[$sig[1]] = true;
+ }
+ }
+ return $string;
+ }
+
+ /**
+ * Create a file from the WSDL for reference.
+ */
+ public function saveSoapDocumentation($path)
+ {
+ $string = "<?php\n";
+ $string .= "/**\n";
+ $string .= " * Auto generated documentation for the AuthorizeNetSOAP API.\n";
+ $string .= " * Generated " . date("m/d/Y") . "\n";
+ $string .= " */\n";
+ $string .= "class AuthorizeNetSOAP\n";
+ $string .= "{\n" . $this->getSoapMethods() . "\n}\n\n" . $this->getSoapTypes() ."\n\n ?>";
+ return file_put_contents($path, $string);
+ }
+
+
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * Easily interact with the Authorize.Net Transaction Details XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetTD
+ * @link http://www.authorize.net/support/ReportingGuide_XML.pdf Transaction Details XML Guide
+ */
+
+
+/**
+ * A class to send a request to the Transaction Details XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetTD
+ */
+class AuthorizeNetTD extends AuthorizeNetRequest
+{
+
+ const LIVE_URL = "https://api2.authorize.net/xml/v1/request.api";
+ const SANDBOX_URL = "https://apitest.authorize.net/xml/v1/request.api";
+
+ private $_xml;
+
+ /**
+ * This function returns information about a settled batch: Batch ID, Settlement Time, &
+ * Settlement State. If you specify includeStatistics, you also receive batch statistics
+ * by payment type.
+ *
+ *
+ * The detault date range is one day (the previous 24 hour period). The maximum date range is 31
+ * days. The merchant time zone is taken into consideration when calculating the batch date range,
+ * unless the Z is specified in the first and last settlement date
+ *
+ * @param bool $includeStatistics
+ * @param string $firstSettlementDate // yyyy-mmddTHH:MM:SS
+ * @param string $lastSettlementDate // yyyy-mmddTHH:MM:SS
+ * @param bool $utc // Use UTC instead of merchant time zone setting
+ *
+ * @return AuthorizeNetTD_Response
+ */
+ public function getSettledBatchList($includeStatistics = false, $firstSettlementDate = false, $lastSettlementDate = false, $utc = true)
+ {
+ $utc = ($utc ? "Z" : "");
+ $this->_constructXml("getSettledBatchListRequest");
+ ($includeStatistics ?
+ $this->_xml->addChild("includeStatistics", $includeStatistics) : null);
+ ($firstSettlementDate ?
+ $this->_xml->addChild("firstSettlementDate", $firstSettlementDate . $utc) : null);
+ ($lastSettlementDate ?
+ $this->_xml->addChild("lastSettlementDate", $lastSettlementDate . $utc) : null);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Return all settled batches for a certain month.
+ *
+ * @param int $month
+ * @param int $year
+ *
+ * @return AuthorizeNetTD_Response
+ */
+ public function getSettledBatchListForMonth($month = false, $year = false)
+ {
+ $month = ($month ? $month : date('m'));
+ $year = ($year ? $year : date('Y'));
+ $firstSettlementDate = substr(date('c',mktime(0, 0, 0, $month, 1, $year)),0,-6);
+ $lastSettlementDate = substr(date('c',mktime(0, 0, 0, $month+1, 0, $year)),0,-6);
+ return $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate);
+ }
+
+ /**
+ * This function returns limited transaction details for a specified batch ID
+ *
+ * @param int $batchId
+ *
+ * @return AuthorizeNetTD_Response
+ */
+ public function getTransactionList($batchId)
+ {
+ $this->_constructXml("getTransactionListRequest");
+ $this->_xml->addChild("batchId", $batchId);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * Return all transactions for a certain day.
+ *
+ * @param int $month
+ * @param int $day
+ * @param int $year
+ *
+ * @return array Array of SimpleXMLElments
+ */
+ public function getTransactionsForDay($month = false, $day = false, $year = false)
+ {
+ $transactions = array();
+ $month = ($month ? $month : date('m'));
+ $day = ($day ? $day : date('d'));
+ $year = ($year ? $year : date('Y'));
+ $firstSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6);
+ $lastSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6);
+ $response = $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate);
+ $batches = $response->xpath("batchList/batch");
+ foreach ($batches as $batch) {
+ $batch_id = (string)$batch->batchId;
+ $request = new AuthorizeNetTD;
+ $tran_list = $request->getTransactionList($batch_id);
+ $transactions = array_merge($transactions, $tran_list->xpath("transactions/transaction"));
+ }
+ return $transactions;
+ }
+
+ /**
+ * This function returns full transaction details for a specified transaction ID.
+ *
+ * @param int $transId
+ *
+ * @return AuthorizeNetTD_Response
+ */
+ public function getTransactionDetails($transId)
+ {
+ $this->_constructXml("getTransactionDetailsRequest");
+ $this->_xml->addChild("transId", $transId);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * This function returns statistics about the settled batch specified by $batchId.
+ *
+ * @param int $batchId
+ *
+ * @return AuthorizeNetTD_Response
+ */
+ public function getBatchStatistics($batchId)
+ {
+ $this->_constructXml("getBatchStatisticsRequest");
+ $this->_xml->addChild("batchId", $batchId);
+ return $this->_sendRequest();
+ }
+
+ /**
+ * This function returns the last 1000 unsettled transactions.
+ *
+ *
+ * @return AuthorizeNetTD_Response
+ */
+ public function getUnsettledTransactionList()
+ {
+ $this->_constructXml("getUnsettledTransactionListRequest");
+ return $this->_sendRequest();
+ }
+
+ /**
+ * @return string
+ */
+ protected function _getPostUrl()
+ {
+ return ($this->_sandbox ? self::SANDBOX_URL : self::LIVE_URL);
+ }
+
+ /**
+ *
+ *
+ * @param string $response
+ *
+ * @return AuthorizeNetTransactionDetails_Response
+ */
+ protected function _handleResponse($response)
+ {
+ return new AuthorizeNetTD_Response($response);
+ }
+
+ /**
+ * Prepare the XML post string.
+ */
+ protected function _setPostString()
+ {
+ $this->_post_string = $this->_xml->asXML();
+
+ }
+
+ /**
+ * Start the SimpleXMLElement that will be posted.
+ *
+ * @param string $request_type The action to be performed.
+ */
+ private function _constructXml($request_type)
+ {
+ $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>';
+ $this->_xml = @new SimpleXMLElement($string);
+ $merchant = $this->_xml->addChild('merchantAuthentication');
+ $merchant->addChild('name',$this->_api_login);
+ $merchant->addChild('transactionKey',$this->_transaction_key);
+ }
+
+}
+
+/**
+ * A class to parse a response from the Transaction Details XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetTD
+ */
+class AuthorizeNetTD_Response extends AuthorizeNetXMLResponse
+{
+
+
+}
--- /dev/null
+Old Usage Examples (Of Deprecated SDK Functionality)
+=======================================
+
+# This documentation in this directoary and the objects it documents have been deprecated
+
+**For the README for this repository, see `[README.md]`(/README.md) in the root level of the repository. For examples of how to interact with the current Authorize.Net API, see our new sample code GitHub repository at https://github.com/AuthorizeNet/sample-code-php.**
+
+**What follows is the old README pertaining to this deprecated functionality:**
+
+## Requirements
+
+- PHP 5.3+ *(>=5.3.10 recommended)*
+- cURL PHP Extension
+- JSON PHP Extension
+- SimpleXML PHP Extension
+- An Authorize.Net Merchant Account or Sandbox Account. You can get a
+ free sandbox account at http://developer.authorize.net/sandbox/
+
+## Autoloading
+
+[`Composer`](http://getcomposer.org) currently has a [MITM](https://github.com/composer/composer/issues/1074)
+security vulnerability. However, if you wish to use it, require its autoloader in
+your script or bootstrap file:
+```php
+require 'vendor/autoload.php';
+```
+*Note: you'll need a composer.json file with the following require section and to run
+`composer update`.*
+```json
+"require": {
+ "authorizenet/authorizenet": "~1.8"
+}
+```
+
+Alternatively, we provide a custom `SPL` autoloader:
+```php
+require 'path/to/anet_php_sdk/autoload.php';
+```
+
+## Authentication
+To authenticate with the Authorize.Net API you will need to retrieve your API Login ID and Transaction Key from the [`Merchant Interface`](https://account.authorize.net/). You can find these details in the Settings section.
+If you need a sandbox account you can sign up for one really easily [`here`](https://developer.authorize.net/sandbox/).
+
+Once you have your keys simply plug them into the appropriate variables as per the samples below.
+
+````php
+define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
+define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
+````
+
+## Usage Examples
+
+See below for basic usage examples. View the `tests/` folder for more examples of
+each API. Additional documentation is in the `docs/` folder.
+
+### AuthorizeNetAIM.php Quick Usage Example
+
+```php
+define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
+define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
+define("AUTHORIZENET_SANDBOX", true);
+$sale = new AuthorizeNetAIM;
+$sale->amount = "5.99";
+$sale->card_num = '6011000000000012';
+$sale->exp_date = '04/15';
+$response = $sale->authorizeAndCapture();
+if ($response->approved) {
+ $transaction_id = $response->transaction_id;
+}
+```
+
+### AuthorizeNetAIM.php Advanced Usage Example
+
+```php
+define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
+define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
+define("AUTHORIZENET_SANDBOX", true);
+$auth = new AuthorizeNetAIM;
+$auth->amount = "45.00";
+
+// Use eCheck:
+$auth->setECheck(
+ '121042882',
+ '123456789123',
+ 'CHECKING',
+ 'Bank of Earth',
+ 'Jane Doe',
+ 'WEB'
+);
+
+// Set multiple line items:
+$auth->addLineItem('item1', 'Golf tees', 'Blue tees', '2', '5.00', 'N');
+$auth->addLineItem('item2', 'Golf shirt', 'XL', '1', '40.00', 'N');
+
+// Set Invoice Number:
+$auth->invoice_num = time();
+
+// Set a Merchant Defined Field:
+$auth->setCustomField("entrance_source", "Search Engine");
+
+// Authorize Only:
+$response = $auth->authorizeOnly();
+
+if ($response->approved) {
+ $auth_code = $response->transaction_id;
+
+ // Now capture:
+ $capture = new AuthorizeNetAIM;
+ $capture_response = $capture->priorAuthCapture($auth_code);
+
+ // Now void:
+ $void = new AuthorizeNetAIM;
+ $void_response = $void->void($capture_response->transaction_id);
+}
+```
+
+### AuthorizeNetARB.php Usage Example
+
+```php
+define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
+define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
+$subscription = new AuthorizeNet_Subscription;
+$subscription->name = "PHP Monthly Magazine";
+$subscription->intervalLength = "1";
+$subscription->intervalUnit = "months";
+$subscription->startDate = "2011-03-12";
+$subscription->totalOccurrences = "12";
+$subscription->amount = "12.99";
+$subscription->creditCardCardNumber = "6011000000000012";
+$subscription->creditCardExpirationDate= "2018-10";
+$subscription->creditCardCardCode = "123";
+$subscription->billToFirstName = "Rasmus";
+$subscription->billToLastName = "Doe";
+
+// Create the subscription.
+$request = new AuthorizeNetARB;
+$response = $request->createSubscription($subscription);
+$subscription_id = $response->getSubscriptionId();
+```
+
+### AuthorizeNetCIM.php Usage Example
+
+```php
+define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
+define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
+$request = new AuthorizeNetCIM;
+// Create new customer profile
+$customerProfile = new AuthorizeNetCustomer;
+$customerProfile->description = "Description of customer";
+$customerProfile->merchantCustomerId = time();
+$customerProfile->email = "test@domain.com";
+$response = $request->createCustomerProfile($customerProfile);
+if ($response->isOk()) {
+ $customerProfileId = $response->getCustomerProfileId();
+}
+```
+
+### AuthorizeNetSIM.php Usage Example
+
+```php
+define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
+define("AUTHORIZENET_MD5_SETTING", "");
+$message = new AuthorizeNetSIM;
+if ($message->isAuthorizeNet()) {
+ $transactionId = $message->transaction_id;
+}
+```
+
+### AuthorizeNetDPM.php Usage Example
+
+```php
+$url = "http://YOUR_DOMAIN.com/direct_post.php";
+$api_login_id = 'YOUR_API_LOGIN_ID';
+$transaction_key = 'YOUR_TRANSACTION_KEY';
+$md5_setting = 'YOUR_MD5_SETTING'; // Your MD5 Setting
+$amount = "5.99";
+AuthorizeNetDPM::directPostDemo($url, $api_login_id, $transaction_key, $amount, $md5_setting);
+```
+
+### AuthorizeNetCP.php Usage Example
+
+```php
+define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
+define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
+define("AUTHORIZENET_MD5_SETTING", "");
+$sale = new AuthorizeNetCP;
+$sale->amount = '59.99';
+$sale->device_type = '4';
+$sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?');
+$response = $sale->authorizeAndCapture();
+$trans_id = $response->transaction_id;
+```
+
+### AuthorizeNetTD.php Usage Example
+
+```php
+define("AUTHORIZENET_API_LOGIN_ID", "YOURLOGIN");
+define("AUTHORIZENET_TRANSACTION_KEY", "YOURKEY");
+$request = new AuthorizeNetTD;
+$response = $request->getTransactionDetails("12345");
+echo $response->xml->transaction->transactionStatus;
+```
--- /dev/null
+<?php
+namespace net\authorize\api\constants;
+
+class ANetEnvironment
+{
+ const CUSTOM = "http://wwww.myendpoint.com";
+ const SANDBOX = "https://apitest.authorize.net";
+ const PRODUCTION = "https://api2.authorize.net";
+
+ const VERSION = "1.9.6";
+}
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ANetApiRequestType
+ *
+ *
+ * XSD Type: ANetApiRequest
+ */
+class ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\MerchantAuthenticationType
+ * $merchantAuthentication
+ */
+ private $merchantAuthentication = null;
+
+ /**
+ * @property string $clientId
+ */
+ private $clientId = null;
+
+ /**
+ * @property string $refId
+ */
+ private $refId = null;
+
+ /**
+ * Gets as merchantAuthentication
+ *
+ * @return \net\authorize\api\contract\v1\MerchantAuthenticationType
+ */
+ public function getMerchantAuthentication()
+ {
+ return $this->merchantAuthentication;
+ }
+
+ /**
+ * Sets a new merchantAuthentication
+ *
+ * @param \net\authorize\api\contract\v1\MerchantAuthenticationType
+ * $merchantAuthentication
+ * @return self
+ */
+ public function setMerchantAuthentication(\net\authorize\api\contract\v1\MerchantAuthenticationType $merchantAuthentication)
+ {
+ $this->merchantAuthentication = $merchantAuthentication;
+ return $this;
+ }
+
+ /**
+ * Gets as clientId
+ *
+ * @return string
+ */
+ public function getClientId()
+ {
+ return $this->clientId;
+ }
+
+ /**
+ * Sets a new clientId
+ *
+ * @param string $clientId
+ * @return self
+ */
+ public function setClientId($clientId)
+ {
+ $this->clientId = $clientId;
+ return $this;
+ }
+
+ /**
+ * Gets as refId
+ *
+ * @return string
+ */
+ public function getRefId()
+ {
+ return $this->refId;
+ }
+
+ /**
+ * Sets a new refId
+ *
+ * @param string $refId
+ * @return self
+ */
+ public function setRefId($refId)
+ {
+ $this->refId = $refId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ANetApiResponseType
+ *
+ *
+ * XSD Type: ANetApiResponse
+ */
+class ANetApiResponseType
+{
+
+ /**
+ * @property string $refId
+ */
+ private $refId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\MessagesType $messages
+ */
+ private $messages = null;
+
+ /**
+ * @property string $sessionToken
+ */
+ private $sessionToken = null;
+
+ /**
+ * Gets as refId
+ *
+ * @return string
+ */
+ public function getRefId()
+ {
+ return $this->refId;
+ }
+
+ /**
+ * Sets a new refId
+ *
+ * @param string $refId
+ * @return self
+ */
+ public function setRefId($refId)
+ {
+ $this->refId = $refId;
+ return $this;
+ }
+
+ /**
+ * Gets as messages
+ *
+ * @return \net\authorize\api\contract\v1\MessagesType
+ */
+ public function getMessages()
+ {
+ return $this->messages;
+ }
+
+ /**
+ * Sets a new messages
+ *
+ * @param \net\authorize\api\contract\v1\MessagesType $messages
+ * @return self
+ */
+ public function setMessages(\net\authorize\api\contract\v1\MessagesType $messages)
+ {
+ $this->messages = $messages;
+ return $this;
+ }
+
+ /**
+ * Gets as sessionToken
+ *
+ * @return string
+ */
+ public function getSessionToken()
+ {
+ return $this->sessionToken;
+ }
+
+ /**
+ * Sets a new sessionToken
+ *
+ * @param string $sessionToken
+ * @return self
+ */
+ public function setSessionToken($sessionToken)
+ {
+ $this->sessionToken = $sessionToken;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBCancelSubscriptionRequest
+ */
+class ARBCancelSubscriptionRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $subscriptionId
+ */
+ private $subscriptionId = null;
+
+ /**
+ * Gets as subscriptionId
+ *
+ * @return string
+ */
+ public function getSubscriptionId()
+ {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * Sets a new subscriptionId
+ *
+ * @param string $subscriptionId
+ * @return self
+ */
+ public function setSubscriptionId($subscriptionId)
+ {
+ $this->subscriptionId = $subscriptionId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBCancelSubscriptionResponse
+ */
+class ARBCancelSubscriptionResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBCreateSubscriptionRequest
+ */
+class ARBCreateSubscriptionRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\ARBSubscriptionType $subscription
+ */
+ private $subscription = null;
+
+ /**
+ * Gets as subscription
+ *
+ * @return \net\authorize\api\contract\v1\ARBSubscriptionType
+ */
+ public function getSubscription()
+ {
+ return $this->subscription;
+ }
+
+ /**
+ * Sets a new subscription
+ *
+ * @param \net\authorize\api\contract\v1\ARBSubscriptionType $subscription
+ * @return self
+ */
+ public function setSubscription(\net\authorize\api\contract\v1\ARBSubscriptionType $subscription)
+ {
+ $this->subscription = $subscription;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBCreateSubscriptionResponse
+ */
+class ARBCreateSubscriptionResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string $subscriptionId
+ */
+ private $subscriptionId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ */
+ private $profile = null;
+
+ /**
+ * Gets as subscriptionId
+ *
+ * @return string
+ */
+ public function getSubscriptionId()
+ {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * Sets a new subscriptionId
+ *
+ * @param string $subscriptionId
+ * @return self
+ */
+ public function setSubscriptionId($subscriptionId)
+ {
+ $this->subscriptionId = $subscriptionId;
+ return $this;
+ }
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileIdType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfileIdType $profile)
+ {
+ $this->profile = $profile;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBGetSubscriptionListRequest
+ */
+class ARBGetSubscriptionListRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $searchType
+ */
+ private $searchType = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType
+ * $sorting
+ */
+ private $sorting = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PagingType $paging
+ */
+ private $paging = null;
+
+ /**
+ * Gets as searchType
+ *
+ * @return string
+ */
+ public function getSearchType()
+ {
+ return $this->searchType;
+ }
+
+ /**
+ * Sets a new searchType
+ *
+ * @param string $searchType
+ * @return self
+ */
+ public function setSearchType($searchType)
+ {
+ $this->searchType = $searchType;
+ return $this;
+ }
+
+ /**
+ * Gets as sorting
+ *
+ * @return \net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType
+ */
+ public function getSorting()
+ {
+ return $this->sorting;
+ }
+
+ /**
+ * Sets a new sorting
+ *
+ * @param \net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType $sorting
+ * @return self
+ */
+ public function setSorting(\net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType $sorting)
+ {
+ $this->sorting = $sorting;
+ return $this;
+ }
+
+ /**
+ * Gets as paging
+ *
+ * @return \net\authorize\api\contract\v1\PagingType
+ */
+ public function getPaging()
+ {
+ return $this->paging;
+ }
+
+ /**
+ * Sets a new paging
+ *
+ * @param \net\authorize\api\contract\v1\PagingType $paging
+ * @return self
+ */
+ public function setPaging(\net\authorize\api\contract\v1\PagingType $paging)
+ {
+ $this->paging = $paging;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBGetSubscriptionListResponse
+ */
+class ARBGetSubscriptionListResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property integer $totalNumInResultSet
+ */
+ private $totalNumInResultSet = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\SubscriptionDetailType[]
+ * $subscriptionDetails
+ */
+ private $subscriptionDetails = null;
+
+ /**
+ * Gets as totalNumInResultSet
+ *
+ * @return integer
+ */
+ public function getTotalNumInResultSet()
+ {
+ return $this->totalNumInResultSet;
+ }
+
+ /**
+ * Sets a new totalNumInResultSet
+ *
+ * @param integer $totalNumInResultSet
+ * @return self
+ */
+ public function setTotalNumInResultSet($totalNumInResultSet)
+ {
+ $this->totalNumInResultSet = $totalNumInResultSet;
+ return $this;
+ }
+
+ /**
+ * Adds as subscriptionDetail
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\SubscriptionDetailType $subscriptionDetail
+ */
+ public function addToSubscriptionDetails(\net\authorize\api\contract\v1\SubscriptionDetailType $subscriptionDetail)
+ {
+ $this->subscriptionDetails[] = $subscriptionDetail;
+ return $this;
+ }
+
+ /**
+ * isset subscriptionDetails
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetSubscriptionDetails($index)
+ {
+ return isset($this->subscriptionDetails[$index]);
+ }
+
+ /**
+ * unset subscriptionDetails
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetSubscriptionDetails($index)
+ {
+ unset($this->subscriptionDetails[$index]);
+ }
+
+ /**
+ * Gets as subscriptionDetails
+ *
+ * @return \net\authorize\api\contract\v1\SubscriptionDetailType[]
+ */
+ public function getSubscriptionDetails()
+ {
+ return $this->subscriptionDetails;
+ }
+
+ /**
+ * Sets a new subscriptionDetails
+ *
+ * @param \net\authorize\api\contract\v1\SubscriptionDetailType[]
+ * $subscriptionDetails
+ * @return self
+ */
+ public function setSubscriptionDetails(array $subscriptionDetails)
+ {
+ $this->subscriptionDetails = $subscriptionDetails;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBGetSubscriptionListSortingType
+ *
+ *
+ * XSD Type: ARBGetSubscriptionListSorting
+ */
+class ARBGetSubscriptionListSortingType
+{
+
+ /**
+ * @property string $orderBy
+ */
+ private $orderBy = null;
+
+ /**
+ * @property boolean $orderDescending
+ */
+ private $orderDescending = null;
+
+ /**
+ * Gets as orderBy
+ *
+ * @return string
+ */
+ public function getOrderBy()
+ {
+ return $this->orderBy;
+ }
+
+ /**
+ * Sets a new orderBy
+ *
+ * @param string $orderBy
+ * @return self
+ */
+ public function setOrderBy($orderBy)
+ {
+ $this->orderBy = $orderBy;
+ return $this;
+ }
+
+ /**
+ * Gets as orderDescending
+ *
+ * @return boolean
+ */
+ public function getOrderDescending()
+ {
+ return $this->orderDescending;
+ }
+
+ /**
+ * Sets a new orderDescending
+ *
+ * @param boolean $orderDescending
+ * @return self
+ */
+ public function setOrderDescending($orderDescending)
+ {
+ $this->orderDescending = $orderDescending;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBGetSubscriptionRequest
+ */
+class ARBGetSubscriptionRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $subscriptionId
+ */
+ private $subscriptionId = null;
+
+ /**
+ * @property boolean $includeTransactions
+ */
+ private $includeTransactions = null;
+
+ /**
+ * Gets as subscriptionId
+ *
+ * @return string
+ */
+ public function getSubscriptionId()
+ {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * Sets a new subscriptionId
+ *
+ * @param string $subscriptionId
+ * @return self
+ */
+ public function setSubscriptionId($subscriptionId)
+ {
+ $this->subscriptionId = $subscriptionId;
+ return $this;
+ }
+
+ /**
+ * Gets as includeTransactions
+ *
+ * @return boolean
+ */
+ public function getIncludeTransactions()
+ {
+ return $this->includeTransactions;
+ }
+
+ /**
+ * Sets a new includeTransactions
+ *
+ * @param boolean $includeTransactions
+ * @return self
+ */
+ public function setIncludeTransactions($includeTransactions)
+ {
+ $this->includeTransactions = $includeTransactions;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBGetSubscriptionResponse
+ */
+class ARBGetSubscriptionResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\ARBSubscriptionMaskedType $subscription
+ */
+ private $subscription = null;
+
+ /**
+ * Gets as subscription
+ *
+ * @return \net\authorize\api\contract\v1\ARBSubscriptionMaskedType
+ */
+ public function getSubscription()
+ {
+ return $this->subscription;
+ }
+
+ /**
+ * Sets a new subscription
+ *
+ * @param \net\authorize\api\contract\v1\ARBSubscriptionMaskedType $subscription
+ * @return self
+ */
+ public function setSubscription(\net\authorize\api\contract\v1\ARBSubscriptionMaskedType $subscription)
+ {
+ $this->subscription = $subscription;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBGetSubscriptionStatusRequest
+ */
+class ARBGetSubscriptionStatusRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $subscriptionId
+ */
+ private $subscriptionId = null;
+
+ /**
+ * Gets as subscriptionId
+ *
+ * @return string
+ */
+ public function getSubscriptionId()
+ {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * Sets a new subscriptionId
+ *
+ * @param string $subscriptionId
+ * @return self
+ */
+ public function setSubscriptionId($subscriptionId)
+ {
+ $this->subscriptionId = $subscriptionId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBGetSubscriptionStatusResponse
+ */
+class ARBGetSubscriptionStatusResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string $status
+ */
+ private $status = null;
+
+ /**
+ * Gets as status
+ *
+ * @return string
+ */
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ /**
+ * Sets a new status
+ *
+ * @param string $status
+ * @return self
+ */
+ public function setStatus($status)
+ {
+ $this->status = $status;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBSubscriptionMaskedType
+ *
+ *
+ * XSD Type: ARBSubscriptionMaskedType
+ */
+class ARBSubscriptionMaskedType
+{
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentScheduleType $paymentSchedule
+ */
+ private $paymentSchedule = null;
+
+ /**
+ * @property float $amount
+ */
+ private $amount = null;
+
+ /**
+ * @property float $trialAmount
+ */
+ private $trialAmount = null;
+
+ /**
+ * @property string $status
+ */
+ private $status = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\SubscriptionCustomerProfileType
+ * $profile
+ */
+ private $profile = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\OrderType $order
+ */
+ private $order = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ArbTransactionType[] $arbTransactions
+ */
+ private $arbTransactions = null;
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Gets as paymentSchedule
+ *
+ * @return \net\authorize\api\contract\v1\PaymentScheduleType
+ */
+ public function getPaymentSchedule()
+ {
+ return $this->paymentSchedule;
+ }
+
+ /**
+ * Sets a new paymentSchedule
+ *
+ * @param \net\authorize\api\contract\v1\PaymentScheduleType $paymentSchedule
+ * @return self
+ */
+ public function setPaymentSchedule(\net\authorize\api\contract\v1\PaymentScheduleType $paymentSchedule)
+ {
+ $this->paymentSchedule = $paymentSchedule;
+ return $this;
+ }
+
+ /**
+ * Gets as amount
+ *
+ * @return float
+ */
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ /**
+ * Sets a new amount
+ *
+ * @param float $amount
+ * @return self
+ */
+ public function setAmount($amount)
+ {
+ $this->amount = $amount;
+ return $this;
+ }
+
+ /**
+ * Gets as trialAmount
+ *
+ * @return float
+ */
+ public function getTrialAmount()
+ {
+ return $this->trialAmount;
+ }
+
+ /**
+ * Sets a new trialAmount
+ *
+ * @param float $trialAmount
+ * @return self
+ */
+ public function setTrialAmount($trialAmount)
+ {
+ $this->trialAmount = $trialAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as status
+ *
+ * @return string
+ */
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ /**
+ * Sets a new status
+ *
+ * @param string $status
+ * @return self
+ */
+ public function setStatus($status)
+ {
+ $this->status = $status;
+ return $this;
+ }
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\SubscriptionCustomerProfileType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\SubscriptionCustomerProfileType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\SubscriptionCustomerProfileType $profile)
+ {
+ $this->profile = $profile;
+ return $this;
+ }
+
+ /**
+ * Gets as order
+ *
+ * @return \net\authorize\api\contract\v1\OrderType
+ */
+ public function getOrder()
+ {
+ return $this->order;
+ }
+
+ /**
+ * Sets a new order
+ *
+ * @param \net\authorize\api\contract\v1\OrderType $order
+ * @return self
+ */
+ public function setOrder(\net\authorize\api\contract\v1\OrderType $order)
+ {
+ $this->order = $order;
+ return $this;
+ }
+
+ /**
+ * Adds as arbTransaction
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\ArbTransactionType $arbTransaction
+ */
+ public function addToArbTransactions(\net\authorize\api\contract\v1\ArbTransactionType $arbTransaction)
+ {
+ $this->arbTransactions[] = $arbTransaction;
+ return $this;
+ }
+
+ /**
+ * isset arbTransactions
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetArbTransactions($index)
+ {
+ return isset($this->arbTransactions[$index]);
+ }
+
+ /**
+ * unset arbTransactions
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetArbTransactions($index)
+ {
+ unset($this->arbTransactions[$index]);
+ }
+
+ /**
+ * Gets as arbTransactions
+ *
+ * @return \net\authorize\api\contract\v1\ArbTransactionType[]
+ */
+ public function getArbTransactions()
+ {
+ return $this->arbTransactions;
+ }
+
+ /**
+ * Sets a new arbTransactions
+ *
+ * @param \net\authorize\api\contract\v1\ArbTransactionType[] $arbTransactions
+ * @return self
+ */
+ public function setArbTransactions(array $arbTransactions)
+ {
+ $this->arbTransactions = $arbTransactions;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBSubscriptionType
+ *
+ *
+ * XSD Type: ARBSubscriptionType
+ */
+class ARBSubscriptionType
+{
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentScheduleType $paymentSchedule
+ */
+ private $paymentSchedule = null;
+
+ /**
+ * @property float $amount
+ */
+ private $amount = null;
+
+ /**
+ * @property float $trialAmount
+ */
+ private $trialAmount = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentType $payment
+ */
+ private $payment = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\OrderType $order
+ */
+ private $order = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerType $customer
+ */
+ private $customer = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\NameAndAddressType $billTo
+ */
+ private $billTo = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\NameAndAddressType $shipTo
+ */
+ private $shipTo = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ */
+ private $profile = null;
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Gets as paymentSchedule
+ *
+ * @return \net\authorize\api\contract\v1\PaymentScheduleType
+ */
+ public function getPaymentSchedule()
+ {
+ return $this->paymentSchedule;
+ }
+
+ /**
+ * Sets a new paymentSchedule
+ *
+ * @param \net\authorize\api\contract\v1\PaymentScheduleType $paymentSchedule
+ * @return self
+ */
+ public function setPaymentSchedule(\net\authorize\api\contract\v1\PaymentScheduleType $paymentSchedule)
+ {
+ $this->paymentSchedule = $paymentSchedule;
+ return $this;
+ }
+
+ /**
+ * Gets as amount
+ *
+ * @return float
+ */
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ /**
+ * Sets a new amount
+ *
+ * @param float $amount
+ * @return self
+ */
+ public function setAmount($amount)
+ {
+ $this->amount = $amount;
+ return $this;
+ }
+
+ /**
+ * Gets as trialAmount
+ *
+ * @return float
+ */
+ public function getTrialAmount()
+ {
+ return $this->trialAmount;
+ }
+
+ /**
+ * Sets a new trialAmount
+ *
+ * @param float $trialAmount
+ * @return self
+ */
+ public function setTrialAmount($trialAmount)
+ {
+ $this->trialAmount = $trialAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as payment
+ *
+ * @return \net\authorize\api\contract\v1\PaymentType
+ */
+ public function getPayment()
+ {
+ return $this->payment;
+ }
+
+ /**
+ * Sets a new payment
+ *
+ * @param \net\authorize\api\contract\v1\PaymentType $payment
+ * @return self
+ */
+ public function setPayment(\net\authorize\api\contract\v1\PaymentType $payment)
+ {
+ $this->payment = $payment;
+ return $this;
+ }
+
+ /**
+ * Gets as order
+ *
+ * @return \net\authorize\api\contract\v1\OrderType
+ */
+ public function getOrder()
+ {
+ return $this->order;
+ }
+
+ /**
+ * Sets a new order
+ *
+ * @param \net\authorize\api\contract\v1\OrderType $order
+ * @return self
+ */
+ public function setOrder(\net\authorize\api\contract\v1\OrderType $order)
+ {
+ $this->order = $order;
+ return $this;
+ }
+
+ /**
+ * Gets as customer
+ *
+ * @return \net\authorize\api\contract\v1\CustomerType
+ */
+ public function getCustomer()
+ {
+ return $this->customer;
+ }
+
+ /**
+ * Sets a new customer
+ *
+ * @param \net\authorize\api\contract\v1\CustomerType $customer
+ * @return self
+ */
+ public function setCustomer(\net\authorize\api\contract\v1\CustomerType $customer)
+ {
+ $this->customer = $customer;
+ return $this;
+ }
+
+ /**
+ * Gets as billTo
+ *
+ * @return \net\authorize\api\contract\v1\NameAndAddressType
+ */
+ public function getBillTo()
+ {
+ return $this->billTo;
+ }
+
+ /**
+ * Sets a new billTo
+ *
+ * @param \net\authorize\api\contract\v1\NameAndAddressType $billTo
+ * @return self
+ */
+ public function setBillTo(\net\authorize\api\contract\v1\NameAndAddressType $billTo)
+ {
+ $this->billTo = $billTo;
+ return $this;
+ }
+
+ /**
+ * Gets as shipTo
+ *
+ * @return \net\authorize\api\contract\v1\NameAndAddressType
+ */
+ public function getShipTo()
+ {
+ return $this->shipTo;
+ }
+
+ /**
+ * Sets a new shipTo
+ *
+ * @param \net\authorize\api\contract\v1\NameAndAddressType $shipTo
+ * @return self
+ */
+ public function setShipTo(\net\authorize\api\contract\v1\NameAndAddressType $shipTo)
+ {
+ $this->shipTo = $shipTo;
+ return $this;
+ }
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileIdType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfileIdType $profile)
+ {
+ $this->profile = $profile;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBUpdateSubscriptionRequest
+ */
+class ARBUpdateSubscriptionRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $subscriptionId
+ */
+ private $subscriptionId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ARBSubscriptionType $subscription
+ */
+ private $subscription = null;
+
+ /**
+ * Gets as subscriptionId
+ *
+ * @return string
+ */
+ public function getSubscriptionId()
+ {
+ return $this->subscriptionId;
+ }
+
+ /**
+ * Sets a new subscriptionId
+ *
+ * @param string $subscriptionId
+ * @return self
+ */
+ public function setSubscriptionId($subscriptionId)
+ {
+ $this->subscriptionId = $subscriptionId;
+ return $this;
+ }
+
+ /**
+ * Gets as subscription
+ *
+ * @return \net\authorize\api\contract\v1\ARBSubscriptionType
+ */
+ public function getSubscription()
+ {
+ return $this->subscription;
+ }
+
+ /**
+ * Sets a new subscription
+ *
+ * @param \net\authorize\api\contract\v1\ARBSubscriptionType $subscription
+ * @return self
+ */
+ public function setSubscription(\net\authorize\api\contract\v1\ARBSubscriptionType $subscription)
+ {
+ $this->subscription = $subscription;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ARBUpdateSubscriptionResponse
+ */
+class ARBUpdateSubscriptionResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ */
+ private $profile = null;
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileIdType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfileIdType $profile)
+ {
+ $this->profile = $profile;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ArbTransactionType
+ *
+ *
+ * XSD Type: arbTransaction
+ */
+class ArbTransactionType
+{
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * @property string $response
+ */
+ private $response = null;
+
+ /**
+ * @property \DateTime $submitTimeUTC
+ */
+ private $submitTimeUTC = null;
+
+ /**
+ * @property integer $payNum
+ */
+ private $payNum = null;
+
+ /**
+ * @property integer $attemptNum
+ */
+ private $attemptNum = null;
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;
+ return $this;
+ }
+
+ /**
+ * Gets as response
+ *
+ * @return string
+ */
+ public function getResponse()
+ {
+ return $this->response;
+ }
+
+ /**
+ * Sets a new response
+ *
+ * @param string $response
+ * @return self
+ */
+ public function setResponse($response)
+ {
+ $this->response = $response;
+ return $this;
+ }
+
+ /**
+ * Gets as submitTimeUTC
+ *
+ * @return \DateTime
+ */
+ public function getSubmitTimeUTC()
+ {
+ return $this->submitTimeUTC;
+ }
+
+ /**
+ * Sets a new submitTimeUTC
+ *
+ * @param \DateTime $submitTimeUTC
+ * @return self
+ */
+ public function setSubmitTimeUTC(\DateTime $submitTimeUTC)
+ {
+ $this->submitTimeUTC = $submitTimeUTC;
+ return $this;
+ }
+
+ /**
+ * Gets as payNum
+ *
+ * @return integer
+ */
+ public function getPayNum()
+ {
+ return $this->payNum;
+ }
+
+ /**
+ * Sets a new payNum
+ *
+ * @param integer $payNum
+ * @return self
+ */
+ public function setPayNum($payNum)
+ {
+ $this->payNum = $payNum;
+ return $this;
+ }
+
+ /**
+ * Gets as attemptNum
+ *
+ * @return integer
+ */
+ public function getAttemptNum()
+ {
+ return $this->attemptNum;
+ }
+
+ /**
+ * Sets a new attemptNum
+ *
+ * @param integer $attemptNum
+ * @return self
+ */
+ public function setAttemptNum($attemptNum)
+ {
+ $this->attemptNum = $attemptNum;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ArrayOfSettingType
+ *
+ *
+ * XSD Type: ArrayOfSetting
+ */
+class ArrayOfSettingType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\SettingType[] $setting
+ */
+ private $setting = null;
+
+ /**
+ * Adds as setting
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\SettingType $setting
+ */
+ public function addToSetting(\net\authorize\api\contract\v1\SettingType $setting)
+ {
+ $this->setting[] = $setting;
+ return $this;
+ }
+
+ /**
+ * isset setting
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetSetting($index)
+ {
+ return isset($this->setting[$index]);
+ }
+
+ /**
+ * unset setting
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetSetting($index)
+ {
+ unset($this->setting[$index]);
+ }
+
+ /**
+ * Gets as setting
+ *
+ * @return \net\authorize\api\contract\v1\SettingType[]
+ */
+ public function getSetting()
+ {
+ return $this->setting;
+ }
+
+ /**
+ * Sets a new setting
+ *
+ * @param \net\authorize\api\contract\v1\SettingType[] $setting
+ * @return self
+ */
+ public function setSetting(array $setting)
+ {
+ $this->setting = $setting;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing AuDeleteType
+ *
+ *
+ * XSD Type: auDeleteType
+ */
+class AuDeleteType extends AuDetailsType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CreditCardMaskedType $creditCard
+ */
+ private $creditCard = null;
+
+ /**
+ * Gets as creditCard
+ *
+ * @return \net\authorize\api\contract\v1\CreditCardMaskedType
+ */
+ public function getCreditCard()
+ {
+ return $this->creditCard;
+ }
+
+ /**
+ * Sets a new creditCard
+ *
+ * @param \net\authorize\api\contract\v1\CreditCardMaskedType $creditCard
+ * @return self
+ */
+ public function setCreditCard(\net\authorize\api\contract\v1\CreditCardMaskedType $creditCard)
+ {
+ $this->creditCard = $creditCard;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing AuDetailsType
+ *
+ *
+ * XSD Type: auDetailsType
+ */
+class AuDetailsType
+{
+
+ /**
+ * @property integer $customerProfileID
+ */
+ private $customerProfileID = null;
+
+ /**
+ * @property integer $customerPaymentProfileID
+ */
+ private $customerPaymentProfileID = null;
+
+ /**
+ * @property string $firstName
+ */
+ private $firstName = null;
+
+ /**
+ * @property string $lastName
+ */
+ private $lastName = null;
+
+ /**
+ * @property string $updateTimeUTC
+ */
+ private $updateTimeUTC = null;
+
+ /**
+ * @property string $auReasonCode
+ */
+ private $auReasonCode = null;
+
+ /**
+ * @property string $reasonDescription
+ */
+ private $reasonDescription = null;
+
+ /**
+ * Gets as customerProfileID
+ *
+ * @return integer
+ */
+ public function getCustomerProfileID()
+ {
+ return $this->customerProfileID;
+ }
+
+ /**
+ * Sets a new customerProfileID
+ *
+ * @param integer $customerProfileID
+ * @return self
+ */
+ public function setCustomerProfileID($customerProfileID)
+ {
+ $this->customerProfileID = $customerProfileID;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileID
+ *
+ * @return integer
+ */
+ public function getCustomerPaymentProfileID()
+ {
+ return $this->customerPaymentProfileID;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileID
+ *
+ * @param integer $customerPaymentProfileID
+ * @return self
+ */
+ public function setCustomerPaymentProfileID($customerPaymentProfileID)
+ {
+ $this->customerPaymentProfileID = $customerPaymentProfileID;
+ return $this;
+ }
+
+ /**
+ * Gets as firstName
+ *
+ * @return string
+ */
+ public function getFirstName()
+ {
+ return $this->firstName;
+ }
+
+ /**
+ * Sets a new firstName
+ *
+ * @param string $firstName
+ * @return self
+ */
+ public function setFirstName($firstName)
+ {
+ $this->firstName = $firstName;
+ return $this;
+ }
+
+ /**
+ * Gets as lastName
+ *
+ * @return string
+ */
+ public function getLastName()
+ {
+ return $this->lastName;
+ }
+
+ /**
+ * Sets a new lastName
+ *
+ * @param string $lastName
+ * @return self
+ */
+ public function setLastName($lastName)
+ {
+ $this->lastName = $lastName;
+ return $this;
+ }
+
+ /**
+ * Gets as updateTimeUTC
+ *
+ * @return string
+ */
+ public function getUpdateTimeUTC()
+ {
+ return $this->updateTimeUTC;
+ }
+
+ /**
+ * Sets a new updateTimeUTC
+ *
+ * @param string $updateTimeUTC
+ * @return self
+ */
+ public function setUpdateTimeUTC($updateTimeUTC)
+ {
+ $this->updateTimeUTC = $updateTimeUTC;
+ return $this;
+ }
+
+ /**
+ * Gets as auReasonCode
+ *
+ * @return string
+ */
+ public function getAuReasonCode()
+ {
+ return $this->auReasonCode;
+ }
+
+ /**
+ * Sets a new auReasonCode
+ *
+ * @param string $auReasonCode
+ * @return self
+ */
+ public function setAuReasonCode($auReasonCode)
+ {
+ $this->auReasonCode = $auReasonCode;
+ return $this;
+ }
+
+ /**
+ * Gets as reasonDescription
+ *
+ * @return string
+ */
+ public function getReasonDescription()
+ {
+ return $this->reasonDescription;
+ }
+
+ /**
+ * Sets a new reasonDescription
+ *
+ * @param string $reasonDescription
+ * @return self
+ */
+ public function setReasonDescription($reasonDescription)
+ {
+ $this->reasonDescription = $reasonDescription;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing AuResponseType
+ *
+ *
+ * XSD Type: auResponseType
+ */
+class AuResponseType
+{
+
+ /**
+ * @property string $auReasonCode
+ */
+ private $auReasonCode = null;
+
+ /**
+ * @property integer $profileCount
+ */
+ private $profileCount = null;
+
+ /**
+ * @property string $reasonDescription
+ */
+ private $reasonDescription = null;
+
+ /**
+ * Gets as auReasonCode
+ *
+ * @return string
+ */
+ public function getAuReasonCode()
+ {
+ return $this->auReasonCode;
+ }
+
+ /**
+ * Sets a new auReasonCode
+ *
+ * @param string $auReasonCode
+ * @return self
+ */
+ public function setAuReasonCode($auReasonCode)
+ {
+ $this->auReasonCode = $auReasonCode;
+ return $this;
+ }
+
+ /**
+ * Gets as profileCount
+ *
+ * @return integer
+ */
+ public function getProfileCount()
+ {
+ return $this->profileCount;
+ }
+
+ /**
+ * Sets a new profileCount
+ *
+ * @param integer $profileCount
+ * @return self
+ */
+ public function setProfileCount($profileCount)
+ {
+ $this->profileCount = $profileCount;
+ return $this;
+ }
+
+ /**
+ * Gets as reasonDescription
+ *
+ * @return string
+ */
+ public function getReasonDescription()
+ {
+ return $this->reasonDescription;
+ }
+
+ /**
+ * Sets a new reasonDescription
+ *
+ * @param string $reasonDescription
+ * @return self
+ */
+ public function setReasonDescription($reasonDescription)
+ {
+ $this->reasonDescription = $reasonDescription;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing AuUpdateType
+ *
+ *
+ * XSD Type: auUpdateType
+ */
+class AuUpdateType extends AuDetailsType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CreditCardMaskedType $newCreditCard
+ */
+ private $newCreditCard = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CreditCardMaskedType $oldCreditCard
+ */
+ private $oldCreditCard = null;
+
+ /**
+ * Gets as newCreditCard
+ *
+ * @return \net\authorize\api\contract\v1\CreditCardMaskedType
+ */
+ public function getNewCreditCard()
+ {
+ return $this->newCreditCard;
+ }
+
+ /**
+ * Sets a new newCreditCard
+ *
+ * @param \net\authorize\api\contract\v1\CreditCardMaskedType $newCreditCard
+ * @return self
+ */
+ public function setNewCreditCard(\net\authorize\api\contract\v1\CreditCardMaskedType $newCreditCard)
+ {
+ $this->newCreditCard = $newCreditCard;
+ return $this;
+ }
+
+ /**
+ * Gets as oldCreditCard
+ *
+ * @return \net\authorize\api\contract\v1\CreditCardMaskedType
+ */
+ public function getOldCreditCard()
+ {
+ return $this->oldCreditCard;
+ }
+
+ /**
+ * Sets a new oldCreditCard
+ *
+ * @param \net\authorize\api\contract\v1\CreditCardMaskedType $oldCreditCard
+ * @return self
+ */
+ public function setOldCreditCard(\net\authorize\api\contract\v1\CreditCardMaskedType $oldCreditCard)
+ {
+ $this->oldCreditCard = $oldCreditCard;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing AuthenticateTestRequest
+ */
+class AuthenticateTestRequest extends ANetApiRequestType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing AuthenticateTestResponse
+ */
+class AuthenticateTestResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing BankAccountMaskedType
+ *
+ *
+ * XSD Type: bankAccountMaskedType
+ */
+class BankAccountMaskedType
+{
+
+ /**
+ * @property string $accountType
+ */
+ private $accountType = null;
+
+ /**
+ * @property string $routingNumber
+ */
+ private $routingNumber = null;
+
+ /**
+ * @property string $accountNumber
+ */
+ private $accountNumber = null;
+
+ /**
+ * @property string $nameOnAccount
+ */
+ private $nameOnAccount = null;
+
+ /**
+ * @property string $echeckType
+ */
+ private $echeckType = null;
+
+ /**
+ * @property string $bankName
+ */
+ private $bankName = null;
+
+ /**
+ * Gets as accountType
+ *
+ * @return string
+ */
+ public function getAccountType()
+ {
+ return $this->accountType;
+ }
+
+ /**
+ * Sets a new accountType
+ *
+ * @param string $accountType
+ * @return self
+ */
+ public function setAccountType($accountType)
+ {
+ $this->accountType = $accountType;
+ return $this;
+ }
+
+ /**
+ * Gets as routingNumber
+ *
+ * @return string
+ */
+ public function getRoutingNumber()
+ {
+ return $this->routingNumber;
+ }
+
+ /**
+ * Sets a new routingNumber
+ *
+ * @param string $routingNumber
+ * @return self
+ */
+ public function setRoutingNumber($routingNumber)
+ {
+ $this->routingNumber = $routingNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as accountNumber
+ *
+ * @return string
+ */
+ public function getAccountNumber()
+ {
+ return $this->accountNumber;
+ }
+
+ /**
+ * Sets a new accountNumber
+ *
+ * @param string $accountNumber
+ * @return self
+ */
+ public function setAccountNumber($accountNumber)
+ {
+ $this->accountNumber = $accountNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as nameOnAccount
+ *
+ * @return string
+ */
+ public function getNameOnAccount()
+ {
+ return $this->nameOnAccount;
+ }
+
+ /**
+ * Sets a new nameOnAccount
+ *
+ * @param string $nameOnAccount
+ * @return self
+ */
+ public function setNameOnAccount($nameOnAccount)
+ {
+ $this->nameOnAccount = $nameOnAccount;
+ return $this;
+ }
+
+ /**
+ * Gets as echeckType
+ *
+ * @return string
+ */
+ public function getEcheckType()
+ {
+ return $this->echeckType;
+ }
+
+ /**
+ * Sets a new echeckType
+ *
+ * @param string $echeckType
+ * @return self
+ */
+ public function setEcheckType($echeckType)
+ {
+ $this->echeckType = $echeckType;
+ return $this;
+ }
+
+ /**
+ * Gets as bankName
+ *
+ * @return string
+ */
+ public function getBankName()
+ {
+ return $this->bankName;
+ }
+
+ /**
+ * Sets a new bankName
+ *
+ * @param string $bankName
+ * @return self
+ */
+ public function setBankName($bankName)
+ {
+ $this->bankName = $bankName;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing BankAccountType
+ *
+ *
+ * XSD Type: bankAccountType
+ */
+class BankAccountType
+{
+
+ /**
+ * @property string $accountType
+ */
+ private $accountType = null;
+
+ /**
+ * @property string $routingNumber
+ */
+ private $routingNumber = null;
+
+ /**
+ * @property string $accountNumber
+ */
+ private $accountNumber = null;
+
+ /**
+ * @property string $nameOnAccount
+ */
+ private $nameOnAccount = null;
+
+ /**
+ * @property string $echeckType
+ */
+ private $echeckType = null;
+
+ /**
+ * @property string $bankName
+ */
+ private $bankName = null;
+
+ /**
+ * @property string $checkNumber
+ */
+ private $checkNumber = null;
+
+ /**
+ * Gets as accountType
+ *
+ * @return string
+ */
+ public function getAccountType()
+ {
+ return $this->accountType;
+ }
+
+ /**
+ * Sets a new accountType
+ *
+ * @param string $accountType
+ * @return self
+ */
+ public function setAccountType($accountType)
+ {
+ $this->accountType = $accountType;
+ return $this;
+ }
+
+ /**
+ * Gets as routingNumber
+ *
+ * @return string
+ */
+ public function getRoutingNumber()
+ {
+ return $this->routingNumber;
+ }
+
+ /**
+ * Sets a new routingNumber
+ *
+ * @param string $routingNumber
+ * @return self
+ */
+ public function setRoutingNumber($routingNumber)
+ {
+ $this->routingNumber = $routingNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as accountNumber
+ *
+ * @return string
+ */
+ public function getAccountNumber()
+ {
+ return $this->accountNumber;
+ }
+
+ /**
+ * Sets a new accountNumber
+ *
+ * @param string $accountNumber
+ * @return self
+ */
+ public function setAccountNumber($accountNumber)
+ {
+ $this->accountNumber = $accountNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as nameOnAccount
+ *
+ * @return string
+ */
+ public function getNameOnAccount()
+ {
+ return $this->nameOnAccount;
+ }
+
+ /**
+ * Sets a new nameOnAccount
+ *
+ * @param string $nameOnAccount
+ * @return self
+ */
+ public function setNameOnAccount($nameOnAccount)
+ {
+ $this->nameOnAccount = $nameOnAccount;
+ return $this;
+ }
+
+ /**
+ * Gets as echeckType
+ *
+ * @return string
+ */
+ public function getEcheckType()
+ {
+ return $this->echeckType;
+ }
+
+ /**
+ * Sets a new echeckType
+ *
+ * @param string $echeckType
+ * @return self
+ */
+ public function setEcheckType($echeckType)
+ {
+ $this->echeckType = $echeckType;
+ return $this;
+ }
+
+ /**
+ * Gets as bankName
+ *
+ * @return string
+ */
+ public function getBankName()
+ {
+ return $this->bankName;
+ }
+
+ /**
+ * Sets a new bankName
+ *
+ * @param string $bankName
+ * @return self
+ */
+ public function setBankName($bankName)
+ {
+ $this->bankName = $bankName;
+ return $this;
+ }
+
+ /**
+ * Gets as checkNumber
+ *
+ * @return string
+ */
+ public function getCheckNumber()
+ {
+ return $this->checkNumber;
+ }
+
+ /**
+ * Sets a new checkNumber
+ *
+ * @param string $checkNumber
+ * @return self
+ */
+ public function setCheckNumber($checkNumber)
+ {
+ $this->checkNumber = $checkNumber;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing BatchDetailsType
+ *
+ *
+ * XSD Type: batchDetailsType
+ */
+class BatchDetailsType
+{
+
+ /**
+ * @property string $batchId
+ */
+ private $batchId = null;
+
+ /**
+ * @property \DateTime $settlementTimeUTC
+ */
+ private $settlementTimeUTC = null;
+
+ /**
+ * @property \DateTime $settlementTimeLocal
+ */
+ private $settlementTimeLocal = null;
+
+ /**
+ * @property string $settlementState
+ */
+ private $settlementState = null;
+
+ /**
+ * @property string $paymentMethod
+ */
+ private $paymentMethod = null;
+
+ /**
+ * @property string $marketType
+ */
+ private $marketType = null;
+
+ /**
+ * @property string $product
+ */
+ private $product = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\BatchStatisticType[] $statistics
+ */
+ private $statistics = null;
+
+ /**
+ * Gets as batchId
+ *
+ * @return string
+ */
+ public function getBatchId()
+ {
+ return $this->batchId;
+ }
+
+ /**
+ * Sets a new batchId
+ *
+ * @param string $batchId
+ * @return self
+ */
+ public function setBatchId($batchId)
+ {
+ $this->batchId = $batchId;
+ return $this;
+ }
+
+ /**
+ * Gets as settlementTimeUTC
+ *
+ * @return \DateTime
+ */
+ public function getSettlementTimeUTC()
+ {
+ return $this->settlementTimeUTC;
+ }
+
+ /**
+ * Sets a new settlementTimeUTC
+ *
+ * @param \DateTime $settlementTimeUTC
+ * @return self
+ */
+ public function setSettlementTimeUTC(\DateTime $settlementTimeUTC)
+ {
+ $this->settlementTimeUTC = $settlementTimeUTC;
+ return $this;
+ }
+
+ /**
+ * Gets as settlementTimeLocal
+ *
+ * @return \DateTime
+ */
+ public function getSettlementTimeLocal()
+ {
+ return $this->settlementTimeLocal;
+ }
+
+ /**
+ * Sets a new settlementTimeLocal
+ *
+ * @param \DateTime $settlementTimeLocal
+ * @return self
+ */
+ public function setSettlementTimeLocal(\DateTime $settlementTimeLocal)
+ {
+ $this->settlementTimeLocal = $settlementTimeLocal;
+ return $this;
+ }
+
+ /**
+ * Gets as settlementState
+ *
+ * @return string
+ */
+ public function getSettlementState()
+ {
+ return $this->settlementState;
+ }
+
+ /**
+ * Sets a new settlementState
+ *
+ * @param string $settlementState
+ * @return self
+ */
+ public function setSettlementState($settlementState)
+ {
+ $this->settlementState = $settlementState;
+ return $this;
+ }
+
+ /**
+ * Gets as paymentMethod
+ *
+ * @return string
+ */
+ public function getPaymentMethod()
+ {
+ return $this->paymentMethod;
+ }
+
+ /**
+ * Sets a new paymentMethod
+ *
+ * @param string $paymentMethod
+ * @return self
+ */
+ public function setPaymentMethod($paymentMethod)
+ {
+ $this->paymentMethod = $paymentMethod;
+ return $this;
+ }
+
+ /**
+ * Gets as marketType
+ *
+ * @return string
+ */
+ public function getMarketType()
+ {
+ return $this->marketType;
+ }
+
+ /**
+ * Sets a new marketType
+ *
+ * @param string $marketType
+ * @return self
+ */
+ public function setMarketType($marketType)
+ {
+ $this->marketType = $marketType;
+ return $this;
+ }
+
+ /**
+ * Gets as product
+ *
+ * @return string
+ */
+ public function getProduct()
+ {
+ return $this->product;
+ }
+
+ /**
+ * Sets a new product
+ *
+ * @param string $product
+ * @return self
+ */
+ public function setProduct($product)
+ {
+ $this->product = $product;
+ return $this;
+ }
+
+ /**
+ * Adds as statistic
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\BatchStatisticType $statistic
+ */
+ public function addToStatistics(\net\authorize\api\contract\v1\BatchStatisticType $statistic)
+ {
+ $this->statistics[] = $statistic;
+ return $this;
+ }
+
+ /**
+ * isset statistics
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetStatistics($index)
+ {
+ return isset($this->statistics[$index]);
+ }
+
+ /**
+ * unset statistics
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetStatistics($index)
+ {
+ unset($this->statistics[$index]);
+ }
+
+ /**
+ * Gets as statistics
+ *
+ * @return \net\authorize\api\contract\v1\BatchStatisticType[]
+ */
+ public function getStatistics()
+ {
+ return $this->statistics;
+ }
+
+ /**
+ * Sets a new statistics
+ *
+ * @param \net\authorize\api\contract\v1\BatchStatisticType[] $statistics
+ * @return self
+ */
+ public function setStatistics(array $statistics)
+ {
+ $this->statistics = $statistics;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing BatchStatisticType
+ *
+ *
+ * XSD Type: batchStatisticType
+ */
+class BatchStatisticType
+{
+
+ /**
+ * @property string $accountType
+ */
+ private $accountType = null;
+
+ /**
+ * @property float $chargeAmount
+ */
+ private $chargeAmount = null;
+
+ /**
+ * @property integer $chargeCount
+ */
+ private $chargeCount = null;
+
+ /**
+ * @property float $refundAmount
+ */
+ private $refundAmount = null;
+
+ /**
+ * @property integer $refundCount
+ */
+ private $refundCount = null;
+
+ /**
+ * @property integer $voidCount
+ */
+ private $voidCount = null;
+
+ /**
+ * @property integer $declineCount
+ */
+ private $declineCount = null;
+
+ /**
+ * @property integer $errorCount
+ */
+ private $errorCount = null;
+
+ /**
+ * @property float $returnedItemAmount
+ */
+ private $returnedItemAmount = null;
+
+ /**
+ * @property integer $returnedItemCount
+ */
+ private $returnedItemCount = null;
+
+ /**
+ * @property float $chargebackAmount
+ */
+ private $chargebackAmount = null;
+
+ /**
+ * @property integer $chargebackCount
+ */
+ private $chargebackCount = null;
+
+ /**
+ * @property integer $correctionNoticeCount
+ */
+ private $correctionNoticeCount = null;
+
+ /**
+ * @property float $chargeChargeBackAmount
+ */
+ private $chargeChargeBackAmount = null;
+
+ /**
+ * @property integer $chargeChargeBackCount
+ */
+ private $chargeChargeBackCount = null;
+
+ /**
+ * @property float $refundChargeBackAmount
+ */
+ private $refundChargeBackAmount = null;
+
+ /**
+ * @property integer $refundChargeBackCount
+ */
+ private $refundChargeBackCount = null;
+
+ /**
+ * @property float $chargeReturnedItemsAmount
+ */
+ private $chargeReturnedItemsAmount = null;
+
+ /**
+ * @property integer $chargeReturnedItemsCount
+ */
+ private $chargeReturnedItemsCount = null;
+
+ /**
+ * @property float $refundReturnedItemsAmount
+ */
+ private $refundReturnedItemsAmount = null;
+
+ /**
+ * @property integer $refundReturnedItemsCount
+ */
+ private $refundReturnedItemsCount = null;
+
+ /**
+ * Gets as accountType
+ *
+ * @return string
+ */
+ public function getAccountType()
+ {
+ return $this->accountType;
+ }
+
+ /**
+ * Sets a new accountType
+ *
+ * @param string $accountType
+ * @return self
+ */
+ public function setAccountType($accountType)
+ {
+ $this->accountType = $accountType;
+ return $this;
+ }
+
+ /**
+ * Gets as chargeAmount
+ *
+ * @return float
+ */
+ public function getChargeAmount()
+ {
+ return $this->chargeAmount;
+ }
+
+ /**
+ * Sets a new chargeAmount
+ *
+ * @param float $chargeAmount
+ * @return self
+ */
+ public function setChargeAmount($chargeAmount)
+ {
+ $this->chargeAmount = $chargeAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as chargeCount
+ *
+ * @return integer
+ */
+ public function getChargeCount()
+ {
+ return $this->chargeCount;
+ }
+
+ /**
+ * Sets a new chargeCount
+ *
+ * @param integer $chargeCount
+ * @return self
+ */
+ public function setChargeCount($chargeCount)
+ {
+ $this->chargeCount = $chargeCount;
+ return $this;
+ }
+
+ /**
+ * Gets as refundAmount
+ *
+ * @return float
+ */
+ public function getRefundAmount()
+ {
+ return $this->refundAmount;
+ }
+
+ /**
+ * Sets a new refundAmount
+ *
+ * @param float $refundAmount
+ * @return self
+ */
+ public function setRefundAmount($refundAmount)
+ {
+ $this->refundAmount = $refundAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as refundCount
+ *
+ * @return integer
+ */
+ public function getRefundCount()
+ {
+ return $this->refundCount;
+ }
+
+ /**
+ * Sets a new refundCount
+ *
+ * @param integer $refundCount
+ * @return self
+ */
+ public function setRefundCount($refundCount)
+ {
+ $this->refundCount = $refundCount;
+ return $this;
+ }
+
+ /**
+ * Gets as voidCount
+ *
+ * @return integer
+ */
+ public function getVoidCount()
+ {
+ return $this->voidCount;
+ }
+
+ /**
+ * Sets a new voidCount
+ *
+ * @param integer $voidCount
+ * @return self
+ */
+ public function setVoidCount($voidCount)
+ {
+ $this->voidCount = $voidCount;
+ return $this;
+ }
+
+ /**
+ * Gets as declineCount
+ *
+ * @return integer
+ */
+ public function getDeclineCount()
+ {
+ return $this->declineCount;
+ }
+
+ /**
+ * Sets a new declineCount
+ *
+ * @param integer $declineCount
+ * @return self
+ */
+ public function setDeclineCount($declineCount)
+ {
+ $this->declineCount = $declineCount;
+ return $this;
+ }
+
+ /**
+ * Gets as errorCount
+ *
+ * @return integer
+ */
+ public function getErrorCount()
+ {
+ return $this->errorCount;
+ }
+
+ /**
+ * Sets a new errorCount
+ *
+ * @param integer $errorCount
+ * @return self
+ */
+ public function setErrorCount($errorCount)
+ {
+ $this->errorCount = $errorCount;
+ return $this;
+ }
+
+ /**
+ * Gets as returnedItemAmount
+ *
+ * @return float
+ */
+ public function getReturnedItemAmount()
+ {
+ return $this->returnedItemAmount;
+ }
+
+ /**
+ * Sets a new returnedItemAmount
+ *
+ * @param float $returnedItemAmount
+ * @return self
+ */
+ public function setReturnedItemAmount($returnedItemAmount)
+ {
+ $this->returnedItemAmount = $returnedItemAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as returnedItemCount
+ *
+ * @return integer
+ */
+ public function getReturnedItemCount()
+ {
+ return $this->returnedItemCount;
+ }
+
+ /**
+ * Sets a new returnedItemCount
+ *
+ * @param integer $returnedItemCount
+ * @return self
+ */
+ public function setReturnedItemCount($returnedItemCount)
+ {
+ $this->returnedItemCount = $returnedItemCount;
+ return $this;
+ }
+
+ /**
+ * Gets as chargebackAmount
+ *
+ * @return float
+ */
+ public function getChargebackAmount()
+ {
+ return $this->chargebackAmount;
+ }
+
+ /**
+ * Sets a new chargebackAmount
+ *
+ * @param float $chargebackAmount
+ * @return self
+ */
+ public function setChargebackAmount($chargebackAmount)
+ {
+ $this->chargebackAmount = $chargebackAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as chargebackCount
+ *
+ * @return integer
+ */
+ public function getChargebackCount()
+ {
+ return $this->chargebackCount;
+ }
+
+ /**
+ * Sets a new chargebackCount
+ *
+ * @param integer $chargebackCount
+ * @return self
+ */
+ public function setChargebackCount($chargebackCount)
+ {
+ $this->chargebackCount = $chargebackCount;
+ return $this;
+ }
+
+ /**
+ * Gets as correctionNoticeCount
+ *
+ * @return integer
+ */
+ public function getCorrectionNoticeCount()
+ {
+ return $this->correctionNoticeCount;
+ }
+
+ /**
+ * Sets a new correctionNoticeCount
+ *
+ * @param integer $correctionNoticeCount
+ * @return self
+ */
+ public function setCorrectionNoticeCount($correctionNoticeCount)
+ {
+ $this->correctionNoticeCount = $correctionNoticeCount;
+ return $this;
+ }
+
+ /**
+ * Gets as chargeChargeBackAmount
+ *
+ * @return float
+ */
+ public function getChargeChargeBackAmount()
+ {
+ return $this->chargeChargeBackAmount;
+ }
+
+ /**
+ * Sets a new chargeChargeBackAmount
+ *
+ * @param float $chargeChargeBackAmount
+ * @return self
+ */
+ public function setChargeChargeBackAmount($chargeChargeBackAmount)
+ {
+ $this->chargeChargeBackAmount = $chargeChargeBackAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as chargeChargeBackCount
+ *
+ * @return integer
+ */
+ public function getChargeChargeBackCount()
+ {
+ return $this->chargeChargeBackCount;
+ }
+
+ /**
+ * Sets a new chargeChargeBackCount
+ *
+ * @param integer $chargeChargeBackCount
+ * @return self
+ */
+ public function setChargeChargeBackCount($chargeChargeBackCount)
+ {
+ $this->chargeChargeBackCount = $chargeChargeBackCount;
+ return $this;
+ }
+
+ /**
+ * Gets as refundChargeBackAmount
+ *
+ * @return float
+ */
+ public function getRefundChargeBackAmount()
+ {
+ return $this->refundChargeBackAmount;
+ }
+
+ /**
+ * Sets a new refundChargeBackAmount
+ *
+ * @param float $refundChargeBackAmount
+ * @return self
+ */
+ public function setRefundChargeBackAmount($refundChargeBackAmount)
+ {
+ $this->refundChargeBackAmount = $refundChargeBackAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as refundChargeBackCount
+ *
+ * @return integer
+ */
+ public function getRefundChargeBackCount()
+ {
+ return $this->refundChargeBackCount;
+ }
+
+ /**
+ * Sets a new refundChargeBackCount
+ *
+ * @param integer $refundChargeBackCount
+ * @return self
+ */
+ public function setRefundChargeBackCount($refundChargeBackCount)
+ {
+ $this->refundChargeBackCount = $refundChargeBackCount;
+ return $this;
+ }
+
+ /**
+ * Gets as chargeReturnedItemsAmount
+ *
+ * @return float
+ */
+ public function getChargeReturnedItemsAmount()
+ {
+ return $this->chargeReturnedItemsAmount;
+ }
+
+ /**
+ * Sets a new chargeReturnedItemsAmount
+ *
+ * @param float $chargeReturnedItemsAmount
+ * @return self
+ */
+ public function setChargeReturnedItemsAmount($chargeReturnedItemsAmount)
+ {
+ $this->chargeReturnedItemsAmount = $chargeReturnedItemsAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as chargeReturnedItemsCount
+ *
+ * @return integer
+ */
+ public function getChargeReturnedItemsCount()
+ {
+ return $this->chargeReturnedItemsCount;
+ }
+
+ /**
+ * Sets a new chargeReturnedItemsCount
+ *
+ * @param integer $chargeReturnedItemsCount
+ * @return self
+ */
+ public function setChargeReturnedItemsCount($chargeReturnedItemsCount)
+ {
+ $this->chargeReturnedItemsCount = $chargeReturnedItemsCount;
+ return $this;
+ }
+
+ /**
+ * Gets as refundReturnedItemsAmount
+ *
+ * @return float
+ */
+ public function getRefundReturnedItemsAmount()
+ {
+ return $this->refundReturnedItemsAmount;
+ }
+
+ /**
+ * Sets a new refundReturnedItemsAmount
+ *
+ * @param float $refundReturnedItemsAmount
+ * @return self
+ */
+ public function setRefundReturnedItemsAmount($refundReturnedItemsAmount)
+ {
+ $this->refundReturnedItemsAmount = $refundReturnedItemsAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as refundReturnedItemsCount
+ *
+ * @return integer
+ */
+ public function getRefundReturnedItemsCount()
+ {
+ return $this->refundReturnedItemsCount;
+ }
+
+ /**
+ * Sets a new refundReturnedItemsCount
+ *
+ * @param integer $refundReturnedItemsCount
+ * @return self
+ */
+ public function setRefundReturnedItemsCount($refundReturnedItemsCount)
+ {
+ $this->refundReturnedItemsCount = $refundReturnedItemsCount;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CardArtType
+ *
+ *
+ * XSD Type: cardArt
+ */
+class CardArtType
+{
+
+ /**
+ * @property string $cardBrand
+ */
+ private $cardBrand = null;
+
+ /**
+ * @property string $cardImageHeight
+ */
+ private $cardImageHeight = null;
+
+ /**
+ * @property string $cardImageUrl
+ */
+ private $cardImageUrl = null;
+
+ /**
+ * @property string $cardImageWidth
+ */
+ private $cardImageWidth = null;
+
+ /**
+ * @property string $cardType
+ */
+ private $cardType = null;
+
+ /**
+ * Gets as cardBrand
+ *
+ * @return string
+ */
+ public function getCardBrand()
+ {
+ return $this->cardBrand;
+ }
+
+ /**
+ * Sets a new cardBrand
+ *
+ * @param string $cardBrand
+ * @return self
+ */
+ public function setCardBrand($cardBrand)
+ {
+ $this->cardBrand = $cardBrand;
+ return $this;
+ }
+
+ /**
+ * Gets as cardImageHeight
+ *
+ * @return string
+ */
+ public function getCardImageHeight()
+ {
+ return $this->cardImageHeight;
+ }
+
+ /**
+ * Sets a new cardImageHeight
+ *
+ * @param string $cardImageHeight
+ * @return self
+ */
+ public function setCardImageHeight($cardImageHeight)
+ {
+ $this->cardImageHeight = $cardImageHeight;
+ return $this;
+ }
+
+ /**
+ * Gets as cardImageUrl
+ *
+ * @return string
+ */
+ public function getCardImageUrl()
+ {
+ return $this->cardImageUrl;
+ }
+
+ /**
+ * Sets a new cardImageUrl
+ *
+ * @param string $cardImageUrl
+ * @return self
+ */
+ public function setCardImageUrl($cardImageUrl)
+ {
+ $this->cardImageUrl = $cardImageUrl;
+ return $this;
+ }
+
+ /**
+ * Gets as cardImageWidth
+ *
+ * @return string
+ */
+ public function getCardImageWidth()
+ {
+ return $this->cardImageWidth;
+ }
+
+ /**
+ * Sets a new cardImageWidth
+ *
+ * @param string $cardImageWidth
+ * @return self
+ */
+ public function setCardImageWidth($cardImageWidth)
+ {
+ $this->cardImageWidth = $cardImageWidth;
+ return $this;
+ }
+
+ /**
+ * Gets as cardType
+ *
+ * @return string
+ */
+ public function getCardType()
+ {
+ return $this->cardType;
+ }
+
+ /**
+ * Sets a new cardType
+ *
+ * @param string $cardType
+ * @return self
+ */
+ public function setCardType($cardType)
+ {
+ $this->cardType = $cardType;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CcAuthenticationType
+ *
+ *
+ * XSD Type: ccAuthenticationType
+ */
+class CcAuthenticationType
+{
+
+ /**
+ * @property string $authenticationIndicator
+ */
+ private $authenticationIndicator = null;
+
+ /**
+ * @property string $cardholderAuthenticationValue
+ */
+ private $cardholderAuthenticationValue = null;
+
+ /**
+ * Gets as authenticationIndicator
+ *
+ * @return string
+ */
+ public function getAuthenticationIndicator()
+ {
+ return $this->authenticationIndicator;
+ }
+
+ /**
+ * Sets a new authenticationIndicator
+ *
+ * @param string $authenticationIndicator
+ * @return self
+ */
+ public function setAuthenticationIndicator($authenticationIndicator)
+ {
+ $this->authenticationIndicator = $authenticationIndicator;
+ return $this;
+ }
+
+ /**
+ * Gets as cardholderAuthenticationValue
+ *
+ * @return string
+ */
+ public function getCardholderAuthenticationValue()
+ {
+ return $this->cardholderAuthenticationValue;
+ }
+
+ /**
+ * Sets a new cardholderAuthenticationValue
+ *
+ * @param string $cardholderAuthenticationValue
+ * @return self
+ */
+ public function setCardholderAuthenticationValue($cardholderAuthenticationValue)
+ {
+ $this->cardholderAuthenticationValue = $cardholderAuthenticationValue;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateCustomerPaymentProfileRequest
+ */
+class CreateCustomerPaymentProfileRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerPaymentProfileType
+ * $paymentProfile
+ */
+ private $paymentProfile = null;
+
+ /**
+ * @property string $validationMode
+ */
+ private $validationMode = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as paymentProfile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerPaymentProfileType
+ */
+ public function getPaymentProfile()
+ {
+ return $this->paymentProfile;
+ }
+
+ /**
+ * Sets a new paymentProfile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileType $paymentProfile
+ * @return self
+ */
+ public function setPaymentProfile(\net\authorize\api\contract\v1\CustomerPaymentProfileType $paymentProfile)
+ {
+ $this->paymentProfile = $paymentProfile;
+ return $this;
+ }
+
+ /**
+ * Gets as validationMode
+ *
+ * @return string
+ */
+ public function getValidationMode()
+ {
+ return $this->validationMode;
+ }
+
+ /**
+ * Sets a new validationMode
+ *
+ * @param string $validationMode
+ * @return self
+ */
+ public function setValidationMode($validationMode)
+ {
+ $this->validationMode = $validationMode;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateCustomerPaymentProfileResponse
+ */
+class CreateCustomerPaymentProfileResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property string $validationDirectResponse
+ */
+ private $validationDirectResponse = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as validationDirectResponse
+ *
+ * @return string
+ */
+ public function getValidationDirectResponse()
+ {
+ return $this->validationDirectResponse;
+ }
+
+ /**
+ * Sets a new validationDirectResponse
+ *
+ * @param string $validationDirectResponse
+ * @return self
+ */
+ public function setValidationDirectResponse($validationDirectResponse)
+ {
+ $this->validationDirectResponse = $validationDirectResponse;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateCustomerProfileFromTransactionRequest
+ */
+class CreateCustomerProfileFromTransactionRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileBaseType $customer
+ */
+ private $customer = null;
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property boolean $defaultPaymentProfile
+ */
+ private $defaultPaymentProfile = null;
+
+ /**
+ * @property boolean $defaultShippingAddress
+ */
+ private $defaultShippingAddress = null;
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;
+ return $this;
+ }
+
+ /**
+ * Gets as customer
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileBaseType
+ */
+ public function getCustomer()
+ {
+ return $this->customer;
+ }
+
+ /**
+ * Sets a new customer
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileBaseType $customer
+ * @return self
+ */
+ public function setCustomer(\net\authorize\api\contract\v1\CustomerProfileBaseType $customer)
+ {
+ $this->customer = $customer;
+ return $this;
+ }
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as defaultPaymentProfile
+ *
+ * @return boolean
+ */
+ public function getDefaultPaymentProfile()
+ {
+ return $this->defaultPaymentProfile;
+ }
+
+ /**
+ * Sets a new defaultPaymentProfile
+ *
+ * @param boolean $defaultPaymentProfile
+ * @return self
+ */
+ public function setDefaultPaymentProfile($defaultPaymentProfile)
+ {
+ $this->defaultPaymentProfile = $defaultPaymentProfile;
+ return $this;
+ }
+
+ /**
+ * Gets as defaultShippingAddress
+ *
+ * @return boolean
+ */
+ public function getDefaultShippingAddress()
+ {
+ return $this->defaultShippingAddress;
+ }
+
+ /**
+ * Sets a new defaultShippingAddress
+ *
+ * @param boolean $defaultShippingAddress
+ * @return self
+ */
+ public function setDefaultShippingAddress($defaultShippingAddress)
+ {
+ $this->defaultShippingAddress = $defaultShippingAddress;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateCustomerProfileRequest
+ */
+class CreateCustomerProfileRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileType $profile
+ */
+ private $profile = null;
+
+ /**
+ * @property string $validationMode
+ */
+ private $validationMode = null;
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfileType $profile)
+ {
+ $this->profile = $profile;
+ return $this;
+ }
+
+ /**
+ * Gets as validationMode
+ *
+ * @return string
+ */
+ public function getValidationMode()
+ {
+ return $this->validationMode;
+ }
+
+ /**
+ * Sets a new validationMode
+ *
+ * @param string $validationMode
+ * @return self
+ */
+ public function setValidationMode($validationMode)
+ {
+ $this->validationMode = $validationMode;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateCustomerProfileResponse
+ */
+class CreateCustomerProfileResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string[] $customerPaymentProfileIdList
+ */
+ private $customerPaymentProfileIdList = null;
+
+ /**
+ * @property string[] $customerShippingAddressIdList
+ */
+ private $customerShippingAddressIdList = null;
+
+ /**
+ * @property string[] $validationDirectResponseList
+ */
+ private $validationDirectResponseList = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Adds as numericString
+ *
+ * @return self
+ * @param string $numericString
+ */
+ public function addToCustomerPaymentProfileIdList($numericString)
+ {
+ $this->customerPaymentProfileIdList[] = $numericString;
+ return $this;
+ }
+
+ /**
+ * isset customerPaymentProfileIdList
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetCustomerPaymentProfileIdList($index)
+ {
+ return isset($this->customerPaymentProfileIdList[$index]);
+ }
+
+ /**
+ * unset customerPaymentProfileIdList
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetCustomerPaymentProfileIdList($index)
+ {
+ unset($this->customerPaymentProfileIdList[$index]);
+ }
+
+ /**
+ * Gets as customerPaymentProfileIdList
+ *
+ * @return string[]
+ */
+ public function getCustomerPaymentProfileIdList()
+ {
+ return $this->customerPaymentProfileIdList;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileIdList
+ *
+ * @param string $customerPaymentProfileIdList
+ * @return self
+ */
+ public function setCustomerPaymentProfileIdList(array $customerPaymentProfileIdList)
+ {
+ $this->customerPaymentProfileIdList = $customerPaymentProfileIdList;
+ return $this;
+ }
+
+ /**
+ * Adds as numericString
+ *
+ * @return self
+ * @param string $numericString
+ */
+ public function addToCustomerShippingAddressIdList($numericString)
+ {
+ $this->customerShippingAddressIdList[] = $numericString;
+ return $this;
+ }
+
+ /**
+ * isset customerShippingAddressIdList
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetCustomerShippingAddressIdList($index)
+ {
+ return isset($this->customerShippingAddressIdList[$index]);
+ }
+
+ /**
+ * unset customerShippingAddressIdList
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetCustomerShippingAddressIdList($index)
+ {
+ unset($this->customerShippingAddressIdList[$index]);
+ }
+
+ /**
+ * Gets as customerShippingAddressIdList
+ *
+ * @return string[]
+ */
+ public function getCustomerShippingAddressIdList()
+ {
+ return $this->customerShippingAddressIdList;
+ }
+
+ /**
+ * Sets a new customerShippingAddressIdList
+ *
+ * @param string $customerShippingAddressIdList
+ * @return self
+ */
+ public function setCustomerShippingAddressIdList(array $customerShippingAddressIdList)
+ {
+ $this->customerShippingAddressIdList = $customerShippingAddressIdList;
+ return $this;
+ }
+
+ /**
+ * Adds as string
+ *
+ * @return self
+ * @param string $string
+ */
+ public function addToValidationDirectResponseList($string)
+ {
+ $this->validationDirectResponseList[] = $string;
+ return $this;
+ }
+
+ /**
+ * isset validationDirectResponseList
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetValidationDirectResponseList($index)
+ {
+ return isset($this->validationDirectResponseList[$index]);
+ }
+
+ /**
+ * unset validationDirectResponseList
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetValidationDirectResponseList($index)
+ {
+ unset($this->validationDirectResponseList[$index]);
+ }
+
+ /**
+ * Gets as validationDirectResponseList
+ *
+ * @return string[]
+ */
+ public function getValidationDirectResponseList()
+ {
+ return $this->validationDirectResponseList;
+ }
+
+ /**
+ * Sets a new validationDirectResponseList
+ *
+ * @param string[] $validationDirectResponseList
+ * @return self
+ */
+ public function setValidationDirectResponseList(array $validationDirectResponseList)
+ {
+ $this->validationDirectResponseList = $validationDirectResponseList;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateCustomerProfileTransactionRequest
+ */
+class CreateCustomerProfileTransactionRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\ProfileTransactionType $transaction
+ */
+ private $transaction = null;
+
+ /**
+ * @property string $extraOptions
+ */
+ private $extraOptions = null;
+
+ /**
+ * Gets as transaction
+ *
+ * @return \net\authorize\api\contract\v1\ProfileTransactionType
+ */
+ public function getTransaction()
+ {
+ return $this->transaction;
+ }
+
+ /**
+ * Sets a new transaction
+ *
+ * @param \net\authorize\api\contract\v1\ProfileTransactionType $transaction
+ * @return self
+ */
+ public function setTransaction(\net\authorize\api\contract\v1\ProfileTransactionType $transaction)
+ {
+ $this->transaction = $transaction;
+ return $this;
+ }
+
+ /**
+ * Gets as extraOptions
+ *
+ * @return string
+ */
+ public function getExtraOptions()
+ {
+ return $this->extraOptions;
+ }
+
+ /**
+ * Sets a new extraOptions
+ *
+ * @param string $extraOptions
+ * @return self
+ */
+ public function setExtraOptions($extraOptions)
+ {
+ $this->extraOptions = $extraOptions;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateCustomerProfileTransactionResponse
+ */
+class CreateCustomerProfileTransactionResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionResponseType
+ * $transactionResponse
+ */
+ private $transactionResponse = null;
+
+ /**
+ * @property string $directResponse
+ */
+ private $directResponse = null;
+
+ /**
+ * Gets as transactionResponse
+ *
+ * @return \net\authorize\api\contract\v1\TransactionResponseType
+ */
+ public function getTransactionResponse()
+ {
+ return $this->transactionResponse;
+ }
+
+ /**
+ * Sets a new transactionResponse
+ *
+ * @param \net\authorize\api\contract\v1\TransactionResponseType
+ * $transactionResponse
+ * @return self
+ */
+ public function setTransactionResponse(\net\authorize\api\contract\v1\TransactionResponseType $transactionResponse)
+ {
+ $this->transactionResponse = $transactionResponse;
+ return $this;
+ }
+
+ /**
+ * Gets as directResponse
+ *
+ * @return string
+ */
+ public function getDirectResponse()
+ {
+ return $this->directResponse;
+ }
+
+ /**
+ * Sets a new directResponse
+ *
+ * @param string $directResponse
+ * @return self
+ */
+ public function setDirectResponse($directResponse)
+ {
+ $this->directResponse = $directResponse;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateCustomerShippingAddressRequest
+ */
+class CreateCustomerShippingAddressRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressType $address
+ */
+ private $address = null;
+
+ /**
+ * @property boolean $defaultShippingAddress
+ */
+ private $defaultShippingAddress = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as address
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressType
+ */
+ public function getAddress()
+ {
+ return $this->address;
+ }
+
+ /**
+ * Sets a new address
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressType $address
+ * @return self
+ */
+ public function setAddress(\net\authorize\api\contract\v1\CustomerAddressType $address)
+ {
+ $this->address = $address;
+ return $this;
+ }
+
+ /**
+ * Gets as defaultShippingAddress
+ *
+ * @return boolean
+ */
+ public function getDefaultShippingAddress()
+ {
+ return $this->defaultShippingAddress;
+ }
+
+ /**
+ * Sets a new defaultShippingAddress
+ *
+ * @param boolean $defaultShippingAddress
+ * @return self
+ */
+ public function setDefaultShippingAddress($defaultShippingAddress)
+ {
+ $this->defaultShippingAddress = $defaultShippingAddress;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateCustomerShippingAddressResponse
+ */
+class CreateCustomerShippingAddressResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerAddressId
+ */
+ private $customerAddressId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerAddressId
+ *
+ * @return string
+ */
+ public function getCustomerAddressId()
+ {
+ return $this->customerAddressId;
+ }
+
+ /**
+ * Sets a new customerAddressId
+ *
+ * @param string $customerAddressId
+ * @return self
+ */
+ public function setCustomerAddressId($customerAddressId)
+ {
+ $this->customerAddressId = $customerAddressId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateProfileResponseType
+ *
+ *
+ * XSD Type: createProfileResponse
+ */
+class CreateProfileResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\MessagesType $messages
+ */
+ private $messages = null;
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string[] $customerPaymentProfileIdList
+ */
+ private $customerPaymentProfileIdList = null;
+
+ /**
+ * @property string[] $customerShippingAddressIdList
+ */
+ private $customerShippingAddressIdList = null;
+
+ /**
+ * Gets as messages
+ *
+ * @return \net\authorize\api\contract\v1\MessagesType
+ */
+ public function getMessages()
+ {
+ return $this->messages;
+ }
+
+ /**
+ * Sets a new messages
+ *
+ * @param \net\authorize\api\contract\v1\MessagesType $messages
+ * @return self
+ */
+ public function setMessages(\net\authorize\api\contract\v1\MessagesType $messages)
+ {
+ $this->messages = $messages;
+ return $this;
+ }
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Adds as numericString
+ *
+ * @return self
+ * @param string $numericString
+ */
+ public function addToCustomerPaymentProfileIdList($numericString)
+ {
+ $this->customerPaymentProfileIdList[] = $numericString;
+ return $this;
+ }
+
+ /**
+ * isset customerPaymentProfileIdList
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetCustomerPaymentProfileIdList($index)
+ {
+ return isset($this->customerPaymentProfileIdList[$index]);
+ }
+
+ /**
+ * unset customerPaymentProfileIdList
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetCustomerPaymentProfileIdList($index)
+ {
+ unset($this->customerPaymentProfileIdList[$index]);
+ }
+
+ /**
+ * Gets as customerPaymentProfileIdList
+ *
+ * @return string[]
+ */
+ public function getCustomerPaymentProfileIdList()
+ {
+ return $this->customerPaymentProfileIdList;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileIdList
+ *
+ * @param string $customerPaymentProfileIdList
+ * @return self
+ */
+ public function setCustomerPaymentProfileIdList(array $customerPaymentProfileIdList)
+ {
+ $this->customerPaymentProfileIdList = $customerPaymentProfileIdList;
+ return $this;
+ }
+
+ /**
+ * Adds as numericString
+ *
+ * @return self
+ * @param string $numericString
+ */
+ public function addToCustomerShippingAddressIdList($numericString)
+ {
+ $this->customerShippingAddressIdList[] = $numericString;
+ return $this;
+ }
+
+ /**
+ * isset customerShippingAddressIdList
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetCustomerShippingAddressIdList($index)
+ {
+ return isset($this->customerShippingAddressIdList[$index]);
+ }
+
+ /**
+ * unset customerShippingAddressIdList
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetCustomerShippingAddressIdList($index)
+ {
+ unset($this->customerShippingAddressIdList[$index]);
+ }
+
+ /**
+ * Gets as customerShippingAddressIdList
+ *
+ * @return string[]
+ */
+ public function getCustomerShippingAddressIdList()
+ {
+ return $this->customerShippingAddressIdList;
+ }
+
+ /**
+ * Sets a new customerShippingAddressIdList
+ *
+ * @param string $customerShippingAddressIdList
+ * @return self
+ */
+ public function setCustomerShippingAddressIdList(array $customerShippingAddressIdList)
+ {
+ $this->customerShippingAddressIdList = $customerShippingAddressIdList;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateTransactionRequest
+ */
+class CreateTransactionRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionRequestType
+ * $transactionRequest
+ */
+ private $transactionRequest = null;
+
+ /**
+ * Gets as transactionRequest
+ *
+ * @return \net\authorize\api\contract\v1\TransactionRequestType
+ */
+ public function getTransactionRequest()
+ {
+ return $this->transactionRequest;
+ }
+
+ /**
+ * Sets a new transactionRequest
+ *
+ * @param \net\authorize\api\contract\v1\TransactionRequestType $transactionRequest
+ * @return self
+ */
+ public function setTransactionRequest(\net\authorize\api\contract\v1\TransactionRequestType $transactionRequest)
+ {
+ $this->transactionRequest = $transactionRequest;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreateTransactionResponse
+ */
+class CreateTransactionResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionResponseType
+ * $transactionResponse
+ */
+ private $transactionResponse = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CreateProfileResponseType
+ * $profileResponse
+ */
+ private $profileResponse = null;
+
+ /**
+ * Gets as transactionResponse
+ *
+ * @return \net\authorize\api\contract\v1\TransactionResponseType
+ */
+ public function getTransactionResponse()
+ {
+ return $this->transactionResponse;
+ }
+
+ /**
+ * Sets a new transactionResponse
+ *
+ * @param \net\authorize\api\contract\v1\TransactionResponseType
+ * $transactionResponse
+ * @return self
+ */
+ public function setTransactionResponse(\net\authorize\api\contract\v1\TransactionResponseType $transactionResponse)
+ {
+ $this->transactionResponse = $transactionResponse;
+ return $this;
+ }
+
+ /**
+ * Gets as profileResponse
+ *
+ * @return \net\authorize\api\contract\v1\CreateProfileResponseType
+ */
+ public function getProfileResponse()
+ {
+ return $this->profileResponse;
+ }
+
+ /**
+ * Sets a new profileResponse
+ *
+ * @param \net\authorize\api\contract\v1\CreateProfileResponseType $profileResponse
+ * @return self
+ */
+ public function setProfileResponse(\net\authorize\api\contract\v1\CreateProfileResponseType $profileResponse)
+ {
+ $this->profileResponse = $profileResponse;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreditCardMaskedType
+ *
+ * \r
+ * XSD Type: creditCardMaskedType
+ */
+class CreditCardMaskedType
+{
+
+ /**
+ * @property string $cardNumber
+ */
+ private $cardNumber = null;
+
+ /**
+ * @property string $expirationDate
+ */
+ private $expirationDate = null;
+
+ /**
+ * @property string $cardType
+ */
+ private $cardType = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CardArtType $cardArt
+ */
+ private $cardArt = null;
+
+ /**
+ * @property string $issuerNumber
+ */
+ private $issuerNumber = null;
+
+ /**
+ * Gets as cardNumber
+ *
+ * @return string
+ */
+ public function getCardNumber()
+ {
+ return $this->cardNumber;
+ }
+
+ /**
+ * Sets a new cardNumber
+ *
+ * @param string $cardNumber
+ * @return self
+ */
+ public function setCardNumber($cardNumber)
+ {
+ $this->cardNumber = $cardNumber;\r
+ return $this;
+ }
+
+ /**
+ * Gets as expirationDate
+ *
+ * @return string
+ */
+ public function getExpirationDate()
+ {
+ return $this->expirationDate;
+ }
+
+ /**
+ * Sets a new expirationDate
+ *
+ * @param string $expirationDate
+ * @return self
+ */
+ public function setExpirationDate($expirationDate)
+ {
+ $this->expirationDate = $expirationDate;\r
+ return $this;
+ }
+
+ /**
+ * Gets as cardType
+ *
+ * @return string
+ */
+ public function getCardType()
+ {
+ return $this->cardType;
+ }
+
+ /**
+ * Sets a new cardType
+ *
+ * @param string $cardType
+ * @return self
+ */
+ public function setCardType($cardType)
+ {
+ $this->cardType = $cardType;\r
+ return $this;
+ }
+
+ /**
+ * Gets as cardArt
+ *
+ * @return \net\authorize\api\contract\v1\CardArtType
+ */
+ public function getCardArt()
+ {
+ return $this->cardArt;
+ }
+
+ /**
+ * Sets a new cardArt
+ *
+ * @param \net\authorize\api\contract\v1\CardArtType $cardArt
+ * @return self
+ */
+ public function setCardArt(\net\authorize\api\contract\v1\CardArtType $cardArt)
+ {
+ $this->cardArt = $cardArt;\r
+ return $this;
+ }
+
+ /**
+ * Gets as issuerNumber
+ *
+ * @return string
+ */
+ public function getIssuerNumber()
+ {
+ return $this->issuerNumber;
+ }
+
+ /**
+ * Sets a new issuerNumber
+ *
+ * @param string $issuerNumber
+ * @return self
+ */
+ public function setIssuerNumber($issuerNumber)
+ {
+ $this->issuerNumber = $issuerNumber;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreditCardSimpleType
+ *
+ *
+ * XSD Type: creditCardSimpleType
+ */
+class CreditCardSimpleType
+{
+
+ /**
+ * @property string $cardNumber
+ */
+ private $cardNumber = null;
+
+ /**
+ * @property string $expirationDate
+ */
+ private $expirationDate = null;
+
+ /**
+ * Gets as cardNumber
+ *
+ * @return string
+ */
+ public function getCardNumber()
+ {
+ return $this->cardNumber;
+ }
+
+ /**
+ * Sets a new cardNumber
+ *
+ * @param string $cardNumber
+ * @return self
+ */
+ public function setCardNumber($cardNumber)
+ {
+ $this->cardNumber = $cardNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as expirationDate
+ *
+ * @return string
+ */
+ public function getExpirationDate()
+ {
+ return $this->expirationDate;
+ }
+
+ /**
+ * Sets a new expirationDate
+ *
+ * @param string $expirationDate
+ * @return self
+ */
+ public function setExpirationDate($expirationDate)
+ {
+ $this->expirationDate = $expirationDate;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreditCardTrackType
+ *
+ *
+ * XSD Type: creditCardTrackType
+ */
+class CreditCardTrackType
+{
+
+ /**
+ * @property string $track1
+ */
+ private $track1 = null;
+
+ /**
+ * @property string $track2
+ */
+ private $track2 = null;
+
+ /**
+ * Gets as track1
+ *
+ * @return string
+ */
+ public function getTrack1()
+ {
+ return $this->track1;
+ }
+
+ /**
+ * Sets a new track1
+ *
+ * @param string $track1
+ * @return self
+ */
+ public function setTrack1($track1)
+ {
+ $this->track1 = $track1;
+ return $this;
+ }
+
+ /**
+ * Gets as track2
+ *
+ * @return string
+ */
+ public function getTrack2()
+ {
+ return $this->track2;
+ }
+
+ /**
+ * Sets a new track2
+ *
+ * @param string $track2
+ * @return self
+ */
+ public function setTrack2($track2)
+ {
+ $this->track2 = $track2;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CreditCardType
+ *
+ *
+ * XSD Type: creditCardType
+ */
+class CreditCardType extends CreditCardSimpleType
+{
+
+ /**
+ * @property string $cardCode
+ */
+ private $cardCode = null;
+
+ /**
+ * @property boolean $isPaymentToken
+ */
+ private $isPaymentToken = null;
+
+ /**
+ * @property string $cryptogram
+ */
+ private $cryptogram = null;
+
+ /**
+ * Gets as cardCode
+ *
+ * @return string
+ */
+ public function getCardCode()
+ {
+ return $this->cardCode;
+ }
+
+ /**
+ * Sets a new cardCode
+ *
+ * @param string $cardCode
+ * @return self
+ */
+ public function setCardCode($cardCode)
+ {
+ $this->cardCode = $cardCode;
+ return $this;
+ }
+
+ /**
+ * Gets as isPaymentToken
+ *
+ * @return boolean
+ */
+ public function getIsPaymentToken()
+ {
+ return $this->isPaymentToken;
+ }
+
+ /**
+ * Sets a new isPaymentToken
+ *
+ * @param boolean $isPaymentToken
+ * @return self
+ */
+ public function setIsPaymentToken($isPaymentToken)
+ {
+ $this->isPaymentToken = $isPaymentToken;
+ return $this;
+ }
+
+ /**
+ * Gets as cryptogram
+ *
+ * @return string
+ */
+ public function getCryptogram()
+ {
+ return $this->cryptogram;
+ }
+
+ /**
+ * Sets a new cryptogram
+ *
+ * @param string $cryptogram
+ * @return self
+ */
+ public function setCryptogram($cryptogram)
+ {
+ $this->cryptogram = $cryptogram;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerAddressExType
+ *
+ *
+ * XSD Type: customerAddressExType
+ */
+class CustomerAddressExType extends CustomerAddressType
+{
+
+ /**
+ * @property string $customerAddressId
+ */
+ private $customerAddressId = null;
+
+ /**
+ * Gets as customerAddressId
+ *
+ * @return string
+ */
+ public function getCustomerAddressId()
+ {
+ return $this->customerAddressId;
+ }
+
+ /**
+ * Sets a new customerAddressId
+ *
+ * @param string $customerAddressId
+ * @return self
+ */
+ public function setCustomerAddressId($customerAddressId)
+ {
+ $this->customerAddressId = $customerAddressId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerAddressType
+ *
+ *
+ * XSD Type: customerAddressType
+ */
+class CustomerAddressType extends NameAndAddressType
+{
+
+ /**
+ * @property string $phoneNumber
+ */
+ private $phoneNumber = null;
+
+ /**
+ * @property string $faxNumber
+ */
+ private $faxNumber = null;
+
+ /**
+ * @property string $email
+ */
+ private $email = null;
+
+ /**
+ * Gets as phoneNumber
+ *
+ * @return string
+ */
+ public function getPhoneNumber()
+ {
+ return $this->phoneNumber;
+ }
+
+ /**
+ * Sets a new phoneNumber
+ *
+ * @param string $phoneNumber
+ * @return self
+ */
+ public function setPhoneNumber($phoneNumber)
+ {
+ $this->phoneNumber = $phoneNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as faxNumber
+ *
+ * @return string
+ */
+ public function getFaxNumber()
+ {
+ return $this->faxNumber;
+ }
+
+ /**
+ * Sets a new faxNumber
+ *
+ * @param string $faxNumber
+ * @return self
+ */
+ public function setFaxNumber($faxNumber)
+ {
+ $this->faxNumber = $faxNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as email
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Sets a new email
+ *
+ * @param string $email
+ * @return self
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerDataType
+ *
+ *
+ * XSD Type: customerDataType
+ */
+class CustomerDataType
+{
+
+ /**
+ * @property string $type
+ */
+ private $type = null;
+
+ /**
+ * @property string $id
+ */
+ private $id = null;
+
+ /**
+ * @property string $email
+ */
+ private $email = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\DriversLicenseType $driversLicense
+ */
+ private $driversLicense = null;
+
+ /**
+ * @property string $taxId
+ */
+ private $taxId = null;
+
+ /**
+ * Gets as type
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Sets a new type
+ *
+ * @param string $type
+ * @return self
+ */
+ public function setType($type)
+ {
+ $this->type = $type;
+ return $this;
+ }
+
+ /**
+ * Gets as id
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets a new id
+ *
+ * @param string $id
+ * @return self
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * Gets as email
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Sets a new email
+ *
+ * @param string $email
+ * @return self
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+ return $this;
+ }
+
+ /**
+ * Gets as driversLicense
+ *
+ * @return \net\authorize\api\contract\v1\DriversLicenseType
+ */
+ public function getDriversLicense()
+ {
+ return $this->driversLicense;
+ }
+
+ /**
+ * Sets a new driversLicense
+ *
+ * @param \net\authorize\api\contract\v1\DriversLicenseType $driversLicense
+ * @return self
+ */
+ public function setDriversLicense(\net\authorize\api\contract\v1\DriversLicenseType $driversLicense)
+ {
+ $this->driversLicense = $driversLicense;
+ return $this;
+ }
+
+ /**
+ * Gets as taxId
+ *
+ * @return string
+ */
+ public function getTaxId()
+ {
+ return $this->taxId;
+ }
+
+ /**
+ * Sets a new taxId
+ *
+ * @param string $taxId
+ * @return self
+ */
+ public function setTaxId($taxId)
+ {
+ $this->taxId = $taxId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerPaymentProfileBaseType
+ *
+ *
+ * XSD Type: customerPaymentProfileBaseType
+ */
+class CustomerPaymentProfileBaseType
+{
+
+ /**
+ * @property string $customerType
+ */
+ private $customerType = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressType $billTo
+ */
+ private $billTo = null;
+
+ /**
+ * Gets as customerType
+ *
+ * @return string
+ */
+ public function getCustomerType()
+ {
+ return $this->customerType;
+ }
+
+ /**
+ * Sets a new customerType
+ *
+ * @param string $customerType
+ * @return self
+ */
+ public function setCustomerType($customerType)
+ {
+ $this->customerType = $customerType;
+ return $this;
+ }
+
+ /**
+ * Gets as billTo
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressType
+ */
+ public function getBillTo()
+ {
+ return $this->billTo;
+ }
+
+ /**
+ * Sets a new billTo
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressType $billTo
+ * @return self
+ */
+ public function setBillTo(\net\authorize\api\contract\v1\CustomerAddressType $billTo)
+ {
+ $this->billTo = $billTo;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerPaymentProfileExType
+ *
+ *
+ * XSD Type: customerPaymentProfileExType
+ */
+class CustomerPaymentProfileExType extends CustomerPaymentProfileType
+{
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerPaymentProfileListItemType
+ *
+ *
+ * XSD Type: customerPaymentProfileListItemType
+ */
+class CustomerPaymentProfileListItemType
+{
+
+ /**
+ * @property boolean $defaultPaymentProfile
+ */
+ private $defaultPaymentProfile = null;
+
+ /**
+ * @property integer $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property integer $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressType $billTo
+ */
+ private $billTo = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentMaskedType $payment
+ */
+ private $payment = null;
+
+ /**
+ * Gets as defaultPaymentProfile
+ *
+ * @return boolean
+ */
+ public function getDefaultPaymentProfile()
+ {
+ return $this->defaultPaymentProfile;
+ }
+
+ /**
+ * Sets a new defaultPaymentProfile
+ *
+ * @param boolean $defaultPaymentProfile
+ * @return self
+ */
+ public function setDefaultPaymentProfile($defaultPaymentProfile)
+ {
+ $this->defaultPaymentProfile = $defaultPaymentProfile;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return integer
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param integer $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return integer
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param integer $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as billTo
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressType
+ */
+ public function getBillTo()
+ {
+ return $this->billTo;
+ }
+
+ /**
+ * Sets a new billTo
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressType $billTo
+ * @return self
+ */
+ public function setBillTo(\net\authorize\api\contract\v1\CustomerAddressType $billTo)
+ {
+ $this->billTo = $billTo;
+ return $this;
+ }
+
+ /**
+ * Gets as payment
+ *
+ * @return \net\authorize\api\contract\v1\PaymentMaskedType
+ */
+ public function getPayment()
+ {
+ return $this->payment;
+ }
+
+ /**
+ * Sets a new payment
+ *
+ * @param \net\authorize\api\contract\v1\PaymentMaskedType $payment
+ * @return self
+ */
+ public function setPayment(\net\authorize\api\contract\v1\PaymentMaskedType $payment)
+ {
+ $this->payment = $payment;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerPaymentProfileMaskedType
+ *
+ *
+ * XSD Type: customerPaymentProfileMaskedType
+ */
+class CustomerPaymentProfileMaskedType extends CustomerPaymentProfileBaseType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property boolean $defaultPaymentProfile
+ */
+ private $defaultPaymentProfile = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentMaskedType $payment
+ */
+ private $payment = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\DriversLicenseMaskedType
+ * $driversLicense
+ */
+ private $driversLicense = null;
+
+ /**
+ * @property string $taxId
+ */
+ private $taxId = null;
+
+ /**
+ * @property string[] $subscriptionIds
+ */
+ private $subscriptionIds = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as defaultPaymentProfile
+ *
+ * @return boolean
+ */
+ public function getDefaultPaymentProfile()
+ {
+ return $this->defaultPaymentProfile;
+ }
+
+ /**
+ * Sets a new defaultPaymentProfile
+ *
+ * @param boolean $defaultPaymentProfile
+ * @return self
+ */
+ public function setDefaultPaymentProfile($defaultPaymentProfile)
+ {
+ $this->defaultPaymentProfile = $defaultPaymentProfile;
+ return $this;
+ }
+
+ /**
+ * Gets as payment
+ *
+ * @return \net\authorize\api\contract\v1\PaymentMaskedType
+ */
+ public function getPayment()
+ {
+ return $this->payment;
+ }
+
+ /**
+ * Sets a new payment
+ *
+ * @param \net\authorize\api\contract\v1\PaymentMaskedType $payment
+ * @return self
+ */
+ public function setPayment(\net\authorize\api\contract\v1\PaymentMaskedType $payment)
+ {
+ $this->payment = $payment;
+ return $this;
+ }
+
+ /**
+ * Gets as driversLicense
+ *
+ * @return \net\authorize\api\contract\v1\DriversLicenseMaskedType
+ */
+ public function getDriversLicense()
+ {
+ return $this->driversLicense;
+ }
+
+ /**
+ * Sets a new driversLicense
+ *
+ * @param \net\authorize\api\contract\v1\DriversLicenseMaskedType $driversLicense
+ * @return self
+ */
+ public function setDriversLicense(\net\authorize\api\contract\v1\DriversLicenseMaskedType $driversLicense)
+ {
+ $this->driversLicense = $driversLicense;
+ return $this;
+ }
+
+ /**
+ * Gets as taxId
+ *
+ * @return string
+ */
+ public function getTaxId()
+ {
+ return $this->taxId;
+ }
+
+ /**
+ * Sets a new taxId
+ *
+ * @param string $taxId
+ * @return self
+ */
+ public function setTaxId($taxId)
+ {
+ $this->taxId = $taxId;
+ return $this;
+ }
+
+ /**
+ * Adds as subscriptionId
+ *
+ * @return self
+ * @param string $subscriptionId
+ */
+ public function addToSubscriptionIds($subscriptionId)
+ {
+ $this->subscriptionIds[] = $subscriptionId;
+ return $this;
+ }
+
+ /**
+ * isset subscriptionIds
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetSubscriptionIds($index)
+ {
+ return isset($this->subscriptionIds[$index]);
+ }
+
+ /**
+ * unset subscriptionIds
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetSubscriptionIds($index)
+ {
+ unset($this->subscriptionIds[$index]);
+ }
+
+ /**
+ * Gets as subscriptionIds
+ *
+ * @return string[]
+ */
+ public function getSubscriptionIds()
+ {
+ return $this->subscriptionIds;
+ }
+
+ /**
+ * Sets a new subscriptionIds
+ *
+ * @param string $subscriptionIds
+ * @return self
+ */
+ public function setSubscriptionIds(array $subscriptionIds)
+ {
+ $this->subscriptionIds = $subscriptionIds;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerPaymentProfileSortingType
+ *
+ *
+ * XSD Type: CustomerPaymentProfileSorting
+ */
+class CustomerPaymentProfileSortingType
+{
+
+ /**
+ * @property string $orderBy
+ */
+ private $orderBy = null;
+
+ /**
+ * @property boolean $orderDescending
+ */
+ private $orderDescending = null;
+
+ /**
+ * Gets as orderBy
+ *
+ * @return string
+ */
+ public function getOrderBy()
+ {
+ return $this->orderBy;
+ }
+
+ /**
+ * Sets a new orderBy
+ *
+ * @param string $orderBy
+ * @return self
+ */
+ public function setOrderBy($orderBy)
+ {
+ $this->orderBy = $orderBy;
+ return $this;
+ }
+
+ /**
+ * Gets as orderDescending
+ *
+ * @return boolean
+ */
+ public function getOrderDescending()
+ {
+ return $this->orderDescending;
+ }
+
+ /**
+ * Sets a new orderDescending
+ *
+ * @param boolean $orderDescending
+ * @return self
+ */
+ public function setOrderDescending($orderDescending)
+ {
+ $this->orderDescending = $orderDescending;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerPaymentProfileType
+ *
+ *
+ * XSD Type: customerPaymentProfileType
+ */
+class CustomerPaymentProfileType extends CustomerPaymentProfileBaseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentType $payment
+ */
+ private $payment = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\DriversLicenseType $driversLicense
+ */
+ private $driversLicense = null;
+
+ /**
+ * @property string $taxId
+ */
+ private $taxId = null;
+
+ /**
+ * @property boolean $defaultPaymentProfile
+ */
+ private $defaultPaymentProfile = null;
+
+ /**
+ * Gets as payment
+ *
+ * @return \net\authorize\api\contract\v1\PaymentType
+ */
+ public function getPayment()
+ {
+ return $this->payment;
+ }
+
+ /**
+ * Sets a new payment
+ *
+ * @param \net\authorize\api\contract\v1\PaymentType $payment
+ * @return self
+ */
+ public function setPayment(\net\authorize\api\contract\v1\PaymentType $payment)
+ {
+ $this->payment = $payment;
+ return $this;
+ }
+
+ /**
+ * Gets as driversLicense
+ *
+ * @return \net\authorize\api\contract\v1\DriversLicenseType
+ */
+ public function getDriversLicense()
+ {
+ return $this->driversLicense;
+ }
+
+ /**
+ * Sets a new driversLicense
+ *
+ * @param \net\authorize\api\contract\v1\DriversLicenseType $driversLicense
+ * @return self
+ */
+ public function setDriversLicense(\net\authorize\api\contract\v1\DriversLicenseType $driversLicense)
+ {
+ $this->driversLicense = $driversLicense;
+ return $this;
+ }
+
+ /**
+ * Gets as taxId
+ *
+ * @return string
+ */
+ public function getTaxId()
+ {
+ return $this->taxId;
+ }
+
+ /**
+ * Sets a new taxId
+ *
+ * @param string $taxId
+ * @return self
+ */
+ public function setTaxId($taxId)
+ {
+ $this->taxId = $taxId;
+ return $this;
+ }
+
+ /**
+ * Gets as defaultPaymentProfile
+ *
+ * @return boolean
+ */
+ public function getDefaultPaymentProfile()
+ {
+ return $this->defaultPaymentProfile;
+ }
+
+ /**
+ * Sets a new defaultPaymentProfile
+ *
+ * @param boolean $defaultPaymentProfile
+ * @return self
+ */
+ public function setDefaultPaymentProfile($defaultPaymentProfile)
+ {
+ $this->defaultPaymentProfile = $defaultPaymentProfile;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerProfileBaseType
+ *
+ *
+ * XSD Type: customerProfileBaseType
+ */
+class CustomerProfileBaseType
+{
+
+ /**
+ * @property string $merchantCustomerId
+ */
+ private $merchantCustomerId = null;
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * @property string $email
+ */
+ private $email = null;
+
+ /**
+ * Gets as merchantCustomerId
+ *
+ * @return string
+ */
+ public function getMerchantCustomerId()
+ {
+ return $this->merchantCustomerId;
+ }
+
+ /**
+ * Sets a new merchantCustomerId
+ *
+ * @param string $merchantCustomerId
+ * @return self
+ */
+ public function setMerchantCustomerId($merchantCustomerId)
+ {
+ $this->merchantCustomerId = $merchantCustomerId;
+ return $this;
+ }
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+ /**
+ * Gets as email
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Sets a new email
+ *
+ * @param string $email
+ * @return self
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerProfileExType
+ *
+ *
+ * XSD Type: customerProfileExType
+ */
+class CustomerProfileExType extends CustomerProfileBaseType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerProfileIdType
+ *
+ *
+ * XSD Type: customerProfileIdType
+ */
+class CustomerProfileIdType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property string $customerAddressId
+ */
+ private $customerAddressId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerAddressId
+ *
+ * @return string
+ */
+ public function getCustomerAddressId()
+ {
+ return $this->customerAddressId;
+ }
+
+ /**
+ * Sets a new customerAddressId
+ *
+ * @param string $customerAddressId
+ * @return self
+ */
+ public function setCustomerAddressId($customerAddressId)
+ {
+ $this->customerAddressId = $customerAddressId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerProfileMaskedType
+ *
+ *
+ * XSD Type: customerProfileMaskedType
+ */
+class CustomerProfileMaskedType extends CustomerProfileExType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType[]
+ * $paymentProfiles
+ */
+ private $paymentProfiles = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressExType[] $shipToList
+ */
+ private $shipToList = null;
+
+ /**
+ * Adds as paymentProfiles
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType
+ * $paymentProfiles
+ */
+ public function addToPaymentProfiles(\net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType $paymentProfiles)
+ {
+ $this->paymentProfiles[] = $paymentProfiles;
+ return $this;
+ }
+
+ /**
+ * isset paymentProfiles
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetPaymentProfiles($index)
+ {
+ return isset($this->paymentProfiles[$index]);
+ }
+
+ /**
+ * unset paymentProfiles
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetPaymentProfiles($index)
+ {
+ unset($this->paymentProfiles[$index]);
+ }
+
+ /**
+ * Gets as paymentProfiles
+ *
+ * @return \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType[]
+ */
+ public function getPaymentProfiles()
+ {
+ return $this->paymentProfiles;
+ }
+
+ /**
+ * Sets a new paymentProfiles
+ *
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType[]
+ * $paymentProfiles
+ * @return self
+ */
+ public function setPaymentProfiles(array $paymentProfiles)
+ {
+ $this->paymentProfiles = $paymentProfiles;
+ return $this;
+ }
+
+ /**
+ * Adds as shipToList
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\CustomerAddressExType $shipToList
+ */
+ public function addToShipToList(\net\authorize\api\contract\v1\CustomerAddressExType $shipToList)
+ {
+ $this->shipToList[] = $shipToList;
+ return $this;
+ }
+
+ /**
+ * isset shipToList
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetShipToList($index)
+ {
+ return isset($this->shipToList[$index]);
+ }
+
+ /**
+ * unset shipToList
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetShipToList($index)
+ {
+ unset($this->shipToList[$index]);
+ }
+
+ /**
+ * Gets as shipToList
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressExType[]
+ */
+ public function getShipToList()
+ {
+ return $this->shipToList;
+ }
+
+ /**
+ * Sets a new shipToList
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressExType[] $shipToList
+ * @return self
+ */
+ public function setShipToList(array $shipToList)
+ {
+ $this->shipToList = $shipToList;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerProfilePaymentType
+ *
+ *
+ * XSD Type: customerProfilePaymentType
+ */
+class CustomerProfilePaymentType
+{
+
+ /**
+ * @property boolean $createProfile
+ */
+ private $createProfile = null;
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentProfileType $paymentProfile
+ */
+ private $paymentProfile = null;
+
+ /**
+ * @property string $shippingProfileId
+ */
+ private $shippingProfileId = null;
+
+ /**
+ * Gets as createProfile
+ *
+ * @return boolean
+ */
+ public function getCreateProfile()
+ {
+ return $this->createProfile;
+ }
+
+ /**
+ * Sets a new createProfile
+ *
+ * @param boolean $createProfile
+ * @return self
+ */
+ public function setCreateProfile($createProfile)
+ {
+ $this->createProfile = $createProfile;
+ return $this;
+ }
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as paymentProfile
+ *
+ * @return \net\authorize\api\contract\v1\PaymentProfileType
+ */
+ public function getPaymentProfile()
+ {
+ return $this->paymentProfile;
+ }
+
+ /**
+ * Sets a new paymentProfile
+ *
+ * @param \net\authorize\api\contract\v1\PaymentProfileType $paymentProfile
+ * @return self
+ */
+ public function setPaymentProfile(\net\authorize\api\contract\v1\PaymentProfileType $paymentProfile)
+ {
+ $this->paymentProfile = $paymentProfile;
+ return $this;
+ }
+
+ /**
+ * Gets as shippingProfileId
+ *
+ * @return string
+ */
+ public function getShippingProfileId()
+ {
+ return $this->shippingProfileId;
+ }
+
+ /**
+ * Sets a new shippingProfileId
+ *
+ * @param string $shippingProfileId
+ * @return self
+ */
+ public function setShippingProfileId($shippingProfileId)
+ {
+ $this->shippingProfileId = $shippingProfileId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerProfileSummaryType
+ *
+ *
+ * XSD Type: customerProfileSummaryType
+ */
+class CustomerProfileSummaryType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * @property string $merchantCustomerId
+ */
+ private $merchantCustomerId = null;
+
+ /**
+ * @property string $email
+ */
+ private $email = null;
+
+ /**
+ * @property \DateTime $createdDate
+ */
+ private $createdDate = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+ /**
+ * Gets as merchantCustomerId
+ *
+ * @return string
+ */
+ public function getMerchantCustomerId()
+ {
+ return $this->merchantCustomerId;
+ }
+
+ /**
+ * Sets a new merchantCustomerId
+ *
+ * @param string $merchantCustomerId
+ * @return self
+ */
+ public function setMerchantCustomerId($merchantCustomerId)
+ {
+ $this->merchantCustomerId = $merchantCustomerId;
+ return $this;
+ }
+
+ /**
+ * Gets as email
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Sets a new email
+ *
+ * @param string $email
+ * @return self
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+ return $this;
+ }
+
+ /**
+ * Gets as createdDate
+ *
+ * @return \DateTime
+ */
+ public function getCreatedDate()
+ {
+ return $this->createdDate;
+ }
+
+ /**
+ * Sets a new createdDate
+ *
+ * @param \DateTime $createdDate
+ * @return self
+ */
+ public function setCreatedDate(\DateTime $createdDate)
+ {
+ $this->createdDate = $createdDate;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerProfileType
+ *
+ *
+ * XSD Type: customerProfileType
+ */
+class CustomerProfileType extends CustomerProfileBaseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerPaymentProfileType[]
+ * $paymentProfiles
+ */
+ private $paymentProfiles = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressType[] $shipToList
+ */
+ private $shipToList = null;
+
+ /**
+ * Adds as paymentProfiles
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileType
+ * $paymentProfiles
+ */
+ public function addToPaymentProfiles(\net\authorize\api\contract\v1\CustomerPaymentProfileType $paymentProfiles)
+ {
+ $this->paymentProfiles[] = $paymentProfiles;
+ return $this;
+ }
+
+ /**
+ * isset paymentProfiles
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetPaymentProfiles($index)
+ {
+ return isset($this->paymentProfiles[$index]);
+ }
+
+ /**
+ * unset paymentProfiles
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetPaymentProfiles($index)
+ {
+ unset($this->paymentProfiles[$index]);
+ }
+
+ /**
+ * Gets as paymentProfiles
+ *
+ * @return \net\authorize\api\contract\v1\CustomerPaymentProfileType[]
+ */
+ public function getPaymentProfiles()
+ {
+ return $this->paymentProfiles;
+ }
+
+ /**
+ * Sets a new paymentProfiles
+ *
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileType[]
+ * $paymentProfiles
+ * @return self
+ */
+ public function setPaymentProfiles(array $paymentProfiles)
+ {
+ $this->paymentProfiles = $paymentProfiles;
+ return $this;
+ }
+
+ /**
+ * Adds as shipToList
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\CustomerAddressType $shipToList
+ */
+ public function addToShipToList(\net\authorize\api\contract\v1\CustomerAddressType $shipToList)
+ {
+ $this->shipToList[] = $shipToList;
+ return $this;
+ }
+
+ /**
+ * isset shipToList
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetShipToList($index)
+ {
+ return isset($this->shipToList[$index]);
+ }
+
+ /**
+ * unset shipToList
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetShipToList($index)
+ {
+ unset($this->shipToList[$index]);
+ }
+
+ /**
+ * Gets as shipToList
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressType[]
+ */
+ public function getShipToList()
+ {
+ return $this->shipToList;
+ }
+
+ /**
+ * Sets a new shipToList
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressType[] $shipToList
+ * @return self
+ */
+ public function setShipToList(array $shipToList)
+ {
+ $this->shipToList = $shipToList;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing CustomerType
+ *
+ *
+ * XSD Type: customerType
+ */
+class CustomerType
+{
+
+ /**
+ * @property string $type
+ */
+ private $type = null;
+
+ /**
+ * @property string $id
+ */
+ private $id = null;
+
+ /**
+ * @property string $email
+ */
+ private $email = null;
+
+ /**
+ * @property string $phoneNumber
+ */
+ private $phoneNumber = null;
+
+ /**
+ * @property string $faxNumber
+ */
+ private $faxNumber = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\DriversLicenseType $driversLicense
+ */
+ private $driversLicense = null;
+
+ /**
+ * @property string $taxId
+ */
+ private $taxId = null;
+
+ /**
+ * Gets as type
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Sets a new type
+ *
+ * @param string $type
+ * @return self
+ */
+ public function setType($type)
+ {
+ $this->type = $type;
+ return $this;
+ }
+
+ /**
+ * Gets as id
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets a new id
+ *
+ * @param string $id
+ * @return self
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * Gets as email
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Sets a new email
+ *
+ * @param string $email
+ * @return self
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;
+ return $this;
+ }
+
+ /**
+ * Gets as phoneNumber
+ *
+ * @return string
+ */
+ public function getPhoneNumber()
+ {
+ return $this->phoneNumber;
+ }
+
+ /**
+ * Sets a new phoneNumber
+ *
+ * @param string $phoneNumber
+ * @return self
+ */
+ public function setPhoneNumber($phoneNumber)
+ {
+ $this->phoneNumber = $phoneNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as faxNumber
+ *
+ * @return string
+ */
+ public function getFaxNumber()
+ {
+ return $this->faxNumber;
+ }
+
+ /**
+ * Sets a new faxNumber
+ *
+ * @param string $faxNumber
+ * @return self
+ */
+ public function setFaxNumber($faxNumber)
+ {
+ $this->faxNumber = $faxNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as driversLicense
+ *
+ * @return \net\authorize\api\contract\v1\DriversLicenseType
+ */
+ public function getDriversLicense()
+ {
+ return $this->driversLicense;
+ }
+
+ /**
+ * Sets a new driversLicense
+ *
+ * @param \net\authorize\api\contract\v1\DriversLicenseType $driversLicense
+ * @return self
+ */
+ public function setDriversLicense(\net\authorize\api\contract\v1\DriversLicenseType $driversLicense)
+ {
+ $this->driversLicense = $driversLicense;
+ return $this;
+ }
+
+ /**
+ * Gets as taxId
+ *
+ * @return string
+ */
+ public function getTaxId()
+ {
+ return $this->taxId;
+ }
+
+ /**
+ * Sets a new taxId
+ *
+ * @param string $taxId
+ * @return self
+ */
+ public function setTaxId($taxId)
+ {
+ $this->taxId = $taxId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DecryptPaymentDataRequest
+ */
+class DecryptPaymentDataRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\OpaqueDataType $opaqueData
+ */
+ private $opaqueData = null;
+
+ /**
+ * @property string $callId
+ */
+ private $callId = null;
+
+ /**
+ * Gets as opaqueData
+ *
+ * @return \net\authorize\api\contract\v1\OpaqueDataType
+ */
+ public function getOpaqueData()
+ {
+ return $this->opaqueData;
+ }
+
+ /**
+ * Sets a new opaqueData
+ *
+ * @param \net\authorize\api\contract\v1\OpaqueDataType $opaqueData
+ * @return self
+ */
+ public function setOpaqueData(\net\authorize\api\contract\v1\OpaqueDataType $opaqueData)
+ {
+ $this->opaqueData = $opaqueData;
+ return $this;
+ }
+
+ /**
+ * Gets as callId
+ *
+ * @return string
+ */
+ public function getCallId()
+ {
+ return $this->callId;
+ }
+
+ /**
+ * Sets a new callId
+ *
+ * @param string $callId
+ * @return self
+ */
+ public function setCallId($callId)
+ {
+ $this->callId = $callId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DecryptPaymentDataResponse
+ */
+class DecryptPaymentDataResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressType $shippingInfo
+ */
+ private $shippingInfo = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressType $billingInfo
+ */
+ private $billingInfo = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CreditCardMaskedType $cardInfo
+ */
+ private $cardInfo = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentDetailsType $paymentDetails
+ */
+ private $paymentDetails = null;
+
+ /**
+ * Gets as shippingInfo
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressType
+ */
+ public function getShippingInfo()
+ {
+ return $this->shippingInfo;
+ }
+
+ /**
+ * Sets a new shippingInfo
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressType $shippingInfo
+ * @return self
+ */
+ public function setShippingInfo(\net\authorize\api\contract\v1\CustomerAddressType $shippingInfo)
+ {
+ $this->shippingInfo = $shippingInfo;
+ return $this;
+ }
+
+ /**
+ * Gets as billingInfo
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressType
+ */
+ public function getBillingInfo()
+ {
+ return $this->billingInfo;
+ }
+
+ /**
+ * Sets a new billingInfo
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressType $billingInfo
+ * @return self
+ */
+ public function setBillingInfo(\net\authorize\api\contract\v1\CustomerAddressType $billingInfo)
+ {
+ $this->billingInfo = $billingInfo;
+ return $this;
+ }
+
+ /**
+ * Gets as cardInfo
+ *
+ * @return \net\authorize\api\contract\v1\CreditCardMaskedType
+ */
+ public function getCardInfo()
+ {
+ return $this->cardInfo;
+ }
+
+ /**
+ * Sets a new cardInfo
+ *
+ * @param \net\authorize\api\contract\v1\CreditCardMaskedType $cardInfo
+ * @return self
+ */
+ public function setCardInfo(\net\authorize\api\contract\v1\CreditCardMaskedType $cardInfo)
+ {
+ $this->cardInfo = $cardInfo;
+ return $this;
+ }
+
+ /**
+ * Gets as paymentDetails
+ *
+ * @return \net\authorize\api\contract\v1\PaymentDetailsType
+ */
+ public function getPaymentDetails()
+ {
+ return $this->paymentDetails;
+ }
+
+ /**
+ * Sets a new paymentDetails
+ *
+ * @param \net\authorize\api\contract\v1\PaymentDetailsType $paymentDetails
+ * @return self
+ */
+ public function setPaymentDetails(\net\authorize\api\contract\v1\PaymentDetailsType $paymentDetails)
+ {
+ $this->paymentDetails = $paymentDetails;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DeleteCustomerPaymentProfileRequest
+ */
+class DeleteCustomerPaymentProfileRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DeleteCustomerPaymentProfileResponse
+ */
+class DeleteCustomerPaymentProfileResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DeleteCustomerProfileRequest
+ */
+class DeleteCustomerProfileRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DeleteCustomerProfileResponse
+ */
+class DeleteCustomerProfileResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DeleteCustomerShippingAddressRequest
+ */
+class DeleteCustomerShippingAddressRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerAddressId
+ */
+ private $customerAddressId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerAddressId
+ *
+ * @return string
+ */
+ public function getCustomerAddressId()
+ {
+ return $this->customerAddressId;
+ }
+
+ /**
+ * Sets a new customerAddressId
+ *
+ * @param string $customerAddressId
+ * @return self
+ */
+ public function setCustomerAddressId($customerAddressId)
+ {
+ $this->customerAddressId = $customerAddressId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DeleteCustomerShippingAddressResponse
+ */
+class DeleteCustomerShippingAddressResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DriversLicenseMaskedType
+ *
+ *
+ * XSD Type: driversLicenseMaskedType
+ */
+class DriversLicenseMaskedType
+{
+
+ /**
+ * @property string $number
+ */
+ private $number = null;
+
+ /**
+ * @property string $state
+ */
+ private $state = null;
+
+ /**
+ * @property string $dateOfBirth
+ */
+ private $dateOfBirth = null;
+
+ /**
+ * Gets as number
+ *
+ * @return string
+ */
+ public function getNumber()
+ {
+ return $this->number;
+ }
+
+ /**
+ * Sets a new number
+ *
+ * @param string $number
+ * @return self
+ */
+ public function setNumber($number)
+ {
+ $this->number = $number;
+ return $this;
+ }
+
+ /**
+ * Gets as state
+ *
+ * @return string
+ */
+ public function getState()
+ {
+ return $this->state;
+ }
+
+ /**
+ * Sets a new state
+ *
+ * @param string $state
+ * @return self
+ */
+ public function setState($state)
+ {
+ $this->state = $state;
+ return $this;
+ }
+
+ /**
+ * Gets as dateOfBirth
+ *
+ * @return string
+ */
+ public function getDateOfBirth()
+ {
+ return $this->dateOfBirth;
+ }
+
+ /**
+ * Sets a new dateOfBirth
+ *
+ * @param string $dateOfBirth
+ * @return self
+ */
+ public function setDateOfBirth($dateOfBirth)
+ {
+ $this->dateOfBirth = $dateOfBirth;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing DriversLicenseType
+ *
+ *
+ * XSD Type: driversLicenseType
+ */
+class DriversLicenseType
+{
+
+ /**
+ * @property string $number
+ */
+ private $number = null;
+
+ /**
+ * @property string $state
+ */
+ private $state = null;
+
+ /**
+ * @property string $dateOfBirth
+ */
+ private $dateOfBirth = null;
+
+ /**
+ * Gets as number
+ *
+ * @return string
+ */
+ public function getNumber()
+ {
+ return $this->number;
+ }
+
+ /**
+ * Sets a new number
+ *
+ * @param string $number
+ * @return self
+ */
+ public function setNumber($number)
+ {
+ $this->number = $number;
+ return $this;
+ }
+
+ /**
+ * Gets as state
+ *
+ * @return string
+ */
+ public function getState()
+ {
+ return $this->state;
+ }
+
+ /**
+ * Sets a new state
+ *
+ * @param string $state
+ * @return self
+ */
+ public function setState($state)
+ {
+ $this->state = $state;
+ return $this;
+ }
+
+ /**
+ * Gets as dateOfBirth
+ *
+ * @return string
+ */
+ public function getDateOfBirth()
+ {
+ return $this->dateOfBirth;
+ }
+
+ /**
+ * Sets a new dateOfBirth
+ *
+ * @param string $dateOfBirth
+ * @return self
+ */
+ public function setDateOfBirth($dateOfBirth)
+ {
+ $this->dateOfBirth = $dateOfBirth;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing EmailSettingsType
+ *
+ * Allowed values for settingName are: headerEmailReceipt and footerEmailReceipt
+ * XSD Type: emailSettingsType
+ */
+class EmailSettingsType extends ArrayOfSettingType
+{
+
+ /**
+ * @property integer $version
+ */
+ private $version = null;
+
+ /**
+ * Gets as version
+ *
+ * @return integer
+ */
+ public function getVersion()
+ {
+ return $this->version;
+ }
+
+ /**
+ * Sets a new version
+ *
+ * @param integer $version
+ * @return self
+ */
+ public function setVersion($version)
+ {
+ $this->version = $version;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing EmvTagType
+ *
+ *
+ * XSD Type: emvTag
+ */
+class EmvTagType
+{
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property string $value
+ */
+ private $value = null;
+
+ /**
+ * @property string $formatted
+ */
+ private $formatted = null;
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Gets as value
+ *
+ * @return string
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Sets a new value
+ *
+ * @param string $value
+ * @return self
+ */
+ public function setValue($value)
+ {
+ $this->value = $value;
+ return $this;
+ }
+
+ /**
+ * Gets as formatted
+ *
+ * @return string
+ */
+ public function getFormatted()
+ {
+ return $this->formatted;
+ }
+
+ /**
+ * Sets a new formatted
+ *
+ * @param string $formatted
+ * @return self
+ */
+ public function setFormatted($formatted)
+ {
+ $this->formatted = $formatted;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing EncryptedTrackDataType
+ *
+ *
+ * XSD Type: encryptedTrackDataType
+ */
+class EncryptedTrackDataType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\KeyBlockType $formOfPayment
+ */
+ private $formOfPayment = null;
+
+ /**
+ * Gets as formOfPayment
+ *
+ * @return \net\authorize\api\contract\v1\KeyBlockType
+ */
+ public function getFormOfPayment()
+ {
+ return $this->formOfPayment;
+ }
+
+ /**
+ * Sets a new formOfPayment
+ *
+ * @param \net\authorize\api\contract\v1\KeyBlockType $formOfPayment
+ * @return self
+ */
+ public function setFormOfPayment(\net\authorize\api\contract\v1\KeyBlockType $formOfPayment)
+ {
+ $this->formOfPayment = $formOfPayment;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing EnumCollection
+ */
+class EnumCollection
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileSummaryType
+ * $customerProfileSummaryType
+ */
+ private $customerProfileSummaryType = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentSimpleType $paymentSimpleType
+ */
+ private $paymentSimpleType = null;
+
+ /**
+ * @property string $accountTypeEnum
+ */
+ private $accountTypeEnum = null;
+
+ /**
+ * @property string $cardTypeEnum
+ */
+ private $cardTypeEnum = null;
+
+ /**
+ * @property string $fDSFilterActionEnum
+ */
+ private $fDSFilterActionEnum = null;
+
+ /**
+ * @property string $permissionsEnum
+ */
+ private $permissionsEnum = null;
+
+ /**
+ * @property string $settingNameEnum
+ */
+ private $settingNameEnum = null;
+
+ /**
+ * @property string $settlementStateEnum
+ */
+ private $settlementStateEnum = null;
+
+ /**
+ * @property string $transactionStatusEnum
+ */
+ private $transactionStatusEnum = null;
+
+ /**
+ * @property string $transactionTypeEnum
+ */
+ private $transactionTypeEnum = null;
+
+ /**
+ * Gets as customerProfileSummaryType
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileSummaryType
+ */
+ public function getCustomerProfileSummaryType()
+ {
+ return $this->customerProfileSummaryType;
+ }
+
+ /**
+ * Sets a new customerProfileSummaryType
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileSummaryType
+ * $customerProfileSummaryType
+ * @return self
+ */
+ public function setCustomerProfileSummaryType(\net\authorize\api\contract\v1\CustomerProfileSummaryType $customerProfileSummaryType)
+ {
+ $this->customerProfileSummaryType = $customerProfileSummaryType;
+ return $this;
+ }
+
+ /**
+ * Gets as paymentSimpleType
+ *
+ * @return \net\authorize\api\contract\v1\PaymentSimpleType
+ */
+ public function getPaymentSimpleType()
+ {
+ return $this->paymentSimpleType;
+ }
+
+ /**
+ * Sets a new paymentSimpleType
+ *
+ * @param \net\authorize\api\contract\v1\PaymentSimpleType $paymentSimpleType
+ * @return self
+ */
+ public function setPaymentSimpleType(\net\authorize\api\contract\v1\PaymentSimpleType $paymentSimpleType)
+ {
+ $this->paymentSimpleType = $paymentSimpleType;
+ return $this;
+ }
+
+ /**
+ * Gets as accountTypeEnum
+ *
+ * @return string
+ */
+ public function getAccountTypeEnum()
+ {
+ return $this->accountTypeEnum;
+ }
+
+ /**
+ * Sets a new accountTypeEnum
+ *
+ * @param string $accountTypeEnum
+ * @return self
+ */
+ public function setAccountTypeEnum($accountTypeEnum)
+ {
+ $this->accountTypeEnum = $accountTypeEnum;
+ return $this;
+ }
+
+ /**
+ * Gets as cardTypeEnum
+ *
+ * @return string
+ */
+ public function getCardTypeEnum()
+ {
+ return $this->cardTypeEnum;
+ }
+
+ /**
+ * Sets a new cardTypeEnum
+ *
+ * @param string $cardTypeEnum
+ * @return self
+ */
+ public function setCardTypeEnum($cardTypeEnum)
+ {
+ $this->cardTypeEnum = $cardTypeEnum;
+ return $this;
+ }
+
+ /**
+ * Gets as fDSFilterActionEnum
+ *
+ * @return string
+ */
+ public function getFDSFilterActionEnum()
+ {
+ return $this->fDSFilterActionEnum;
+ }
+
+ /**
+ * Sets a new fDSFilterActionEnum
+ *
+ * @param string $fDSFilterActionEnum
+ * @return self
+ */
+ public function setFDSFilterActionEnum($fDSFilterActionEnum)
+ {
+ $this->fDSFilterActionEnum = $fDSFilterActionEnum;
+ return $this;
+ }
+
+ /**
+ * Gets as permissionsEnum
+ *
+ * @return string
+ */
+ public function getPermissionsEnum()
+ {
+ return $this->permissionsEnum;
+ }
+
+ /**
+ * Sets a new permissionsEnum
+ *
+ * @param string $permissionsEnum
+ * @return self
+ */
+ public function setPermissionsEnum($permissionsEnum)
+ {
+ $this->permissionsEnum = $permissionsEnum;
+ return $this;
+ }
+
+ /**
+ * Gets as settingNameEnum
+ *
+ * @return string
+ */
+ public function getSettingNameEnum()
+ {
+ return $this->settingNameEnum;
+ }
+
+ /**
+ * Sets a new settingNameEnum
+ *
+ * @param string $settingNameEnum
+ * @return self
+ */
+ public function setSettingNameEnum($settingNameEnum)
+ {
+ $this->settingNameEnum = $settingNameEnum;
+ return $this;
+ }
+
+ /**
+ * Gets as settlementStateEnum
+ *
+ * @return string
+ */
+ public function getSettlementStateEnum()
+ {
+ return $this->settlementStateEnum;
+ }
+
+ /**
+ * Sets a new settlementStateEnum
+ *
+ * @param string $settlementStateEnum
+ * @return self
+ */
+ public function setSettlementStateEnum($settlementStateEnum)
+ {
+ $this->settlementStateEnum = $settlementStateEnum;
+ return $this;
+ }
+
+ /**
+ * Gets as transactionStatusEnum
+ *
+ * @return string
+ */
+ public function getTransactionStatusEnum()
+ {
+ return $this->transactionStatusEnum;
+ }
+
+ /**
+ * Sets a new transactionStatusEnum
+ *
+ * @param string $transactionStatusEnum
+ * @return self
+ */
+ public function setTransactionStatusEnum($transactionStatusEnum)
+ {
+ $this->transactionStatusEnum = $transactionStatusEnum;
+ return $this;
+ }
+
+ /**
+ * Gets as transactionTypeEnum
+ *
+ * @return string
+ */
+ public function getTransactionTypeEnum()
+ {
+ return $this->transactionTypeEnum;
+ }
+
+ /**
+ * Sets a new transactionTypeEnum
+ *
+ * @param string $transactionTypeEnum
+ * @return self
+ */
+ public function setTransactionTypeEnum($transactionTypeEnum)
+ {
+ $this->transactionTypeEnum = $transactionTypeEnum;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ErrorResponse
+ */
+class ErrorResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ExtendedAmountType
+ *
+ *
+ * XSD Type: extendedAmountType
+ */
+class ExtendedAmountType
+{
+
+ /**
+ * @property float $amount
+ */
+ private $amount = null;
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * Gets as amount
+ *
+ * @return float
+ */
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ /**
+ * Sets a new amount
+ *
+ * @param float $amount
+ * @return self
+ */
+ public function setAmount($amount)
+ {
+ $this->amount = $amount;
+ return $this;
+ }
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing FDSFilterType
+ *
+ *
+ * XSD Type: FDSFilterType
+ */
+class FDSFilterType
+{
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property string $action
+ */
+ private $action = null;
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Gets as action
+ *
+ * @return string
+ */
+ public function getAction()
+ {
+ return $this->action;
+ }
+
+ /**
+ * Sets a new action
+ *
+ * @param string $action
+ * @return self
+ */
+ public function setAction($action)
+ {
+ $this->action = $action;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing FingerPrintType
+ *
+ *
+ * XSD Type: fingerPrintType
+ */
+class FingerPrintType
+{
+
+ /**
+ * @property string $hashValue
+ */
+ private $hashValue = null;
+
+ /**
+ * @property string $sequence
+ */
+ private $sequence = null;
+
+ /**
+ * @property string $timestamp
+ */
+ private $timestamp = null;
+
+ /**
+ * @property string $currencyCode
+ */
+ private $currencyCode = null;
+
+ /**
+ * @property string $amount
+ */
+ private $amount = null;
+
+ /**
+ * Gets as hashValue
+ *
+ * @return string
+ */
+ public function getHashValue()
+ {
+ return $this->hashValue;
+ }
+
+ /**
+ * Sets a new hashValue
+ *
+ * @param string $hashValue
+ * @return self
+ */
+ public function setHashValue($hashValue)
+ {
+ $this->hashValue = $hashValue;
+ return $this;
+ }
+
+ /**
+ * Gets as sequence
+ *
+ * @return string
+ */
+ public function getSequence()
+ {
+ return $this->sequence;
+ }
+
+ /**
+ * Sets a new sequence
+ *
+ * @param string $sequence
+ * @return self
+ */
+ public function setSequence($sequence)
+ {
+ $this->sequence = $sequence;
+ return $this;
+ }
+
+ /**
+ * Gets as timestamp
+ *
+ * @return string
+ */
+ public function getTimestamp()
+ {
+ return $this->timestamp;
+ }
+
+ /**
+ * Sets a new timestamp
+ *
+ * @param string $timestamp
+ * @return self
+ */
+ public function setTimestamp($timestamp)
+ {
+ $this->timestamp = $timestamp;
+ return $this;
+ }
+
+ /**
+ * Gets as currencyCode
+ *
+ * @return string
+ */
+ public function getCurrencyCode()
+ {
+ return $this->currencyCode;
+ }
+
+ /**
+ * Sets a new currencyCode
+ *
+ * @param string $currencyCode
+ * @return self
+ */
+ public function setCurrencyCode($currencyCode)
+ {
+ $this->currencyCode = $currencyCode;
+ return $this;
+ }
+
+ /**
+ * Gets as amount
+ *
+ * @return string
+ */
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ /**
+ * Sets a new amount
+ *
+ * @param string $amount
+ * @return self
+ */
+ public function setAmount($amount)
+ {
+ $this->amount = $amount;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing FraudInformationType
+ *
+ *
+ * XSD Type: fraudInformationType
+ */
+class FraudInformationType
+{
+
+ /**
+ * @property string[] $fraudFilterList
+ */
+ private $fraudFilterList = null;
+
+ /**
+ * @property string $fraudAction
+ */
+ private $fraudAction = null;
+
+ /**
+ * Adds as fraudFilter
+ *
+ * @return self
+ * @param string $fraudFilter
+ */
+ public function addToFraudFilterList($fraudFilter)
+ {
+ $this->fraudFilterList[] = $fraudFilter;
+ return $this;
+ }
+
+ /**
+ * isset fraudFilterList
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetFraudFilterList($index)
+ {
+ return isset($this->fraudFilterList[$index]);
+ }
+
+ /**
+ * unset fraudFilterList
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetFraudFilterList($index)
+ {
+ unset($this->fraudFilterList[$index]);
+ }
+
+ /**
+ * Gets as fraudFilterList
+ *
+ * @return string[]
+ */
+ public function getFraudFilterList()
+ {
+ return $this->fraudFilterList;
+ }
+
+ /**
+ * Sets a new fraudFilterList
+ *
+ * @param string[] $fraudFilterList
+ * @return self
+ */
+ public function setFraudFilterList(array $fraudFilterList)
+ {
+ $this->fraudFilterList = $fraudFilterList;
+ return $this;
+ }
+
+ /**
+ * Gets as fraudAction
+ *
+ * @return string
+ */
+ public function getFraudAction()
+ {
+ return $this->fraudAction;
+ }
+
+ /**
+ * Sets a new fraudAction
+ *
+ * @param string $fraudAction
+ * @return self
+ */
+ public function setFraudAction($fraudAction)
+ {
+ $this->fraudAction = $fraudAction;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetAUJobDetailsRequest
+ */
+class GetAUJobDetailsRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $month
+ */
+ private $month = null;
+
+ /**
+ * @property string $modifiedTypeFilter
+ */
+ private $modifiedTypeFilter = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PagingType $paging
+ */
+ private $paging = null;
+
+ /**
+ * Gets as month
+ *
+ * @return string
+ */
+ public function getMonth()
+ {
+ return $this->month;
+ }
+
+ /**
+ * Sets a new month
+ *
+ * @param string $month
+ * @return self
+ */
+ public function setMonth($month)
+ {
+ $this->month = $month;
+ return $this;
+ }
+
+ /**
+ * Gets as modifiedTypeFilter
+ *
+ * @return string
+ */
+ public function getModifiedTypeFilter()
+ {
+ return $this->modifiedTypeFilter;
+ }
+
+ /**
+ * Sets a new modifiedTypeFilter
+ *
+ * @param string $modifiedTypeFilter
+ * @return self
+ */
+ public function setModifiedTypeFilter($modifiedTypeFilter)
+ {
+ $this->modifiedTypeFilter = $modifiedTypeFilter;
+ return $this;
+ }
+
+ /**
+ * Gets as paging
+ *
+ * @return \net\authorize\api\contract\v1\PagingType
+ */
+ public function getPaging()
+ {
+ return $this->paging;
+ }
+
+ /**
+ * Sets a new paging
+ *
+ * @param \net\authorize\api\contract\v1\PagingType $paging
+ * @return self
+ */
+ public function setPaging(\net\authorize\api\contract\v1\PagingType $paging)
+ {
+ $this->paging = $paging;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetAUJobDetailsResponse
+ */
+class GetAUJobDetailsResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property integer $totalNumInResultSet
+ */
+ private $totalNumInResultSet = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ListOfAUDetailsType $auDetails
+ */
+ private $auDetails = null;
+
+ /**
+ * Gets as totalNumInResultSet
+ *
+ * @return integer
+ */
+ public function getTotalNumInResultSet()
+ {
+ return $this->totalNumInResultSet;
+ }
+
+ /**
+ * Sets a new totalNumInResultSet
+ *
+ * @param integer $totalNumInResultSet
+ * @return self
+ */
+ public function setTotalNumInResultSet($totalNumInResultSet)
+ {
+ $this->totalNumInResultSet = $totalNumInResultSet;
+ return $this;
+ }
+
+ /**
+ * Gets as auDetails
+ *
+ * @return \net\authorize\api\contract\v1\ListOfAUDetailsType
+ */
+ public function getAuDetails()
+ {
+ return $this->auDetails;
+ }
+
+ /**
+ * Sets a new auDetails
+ *
+ * @param \net\authorize\api\contract\v1\ListOfAUDetailsType $auDetails
+ * @return self
+ */
+ public function setAuDetails(\net\authorize\api\contract\v1\ListOfAUDetailsType $auDetails)
+ {
+ $this->auDetails = $auDetails;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetAUJobSummaryRequest
+ */
+class GetAUJobSummaryRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $month
+ */
+ private $month = null;
+
+ /**
+ * Gets as month
+ *
+ * @return string
+ */
+ public function getMonth()
+ {
+ return $this->month;
+ }
+
+ /**
+ * Sets a new month
+ *
+ * @param string $month
+ * @return self
+ */
+ public function setMonth($month)
+ {
+ $this->month = $month;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetAUJobSummaryResponse
+ */
+class GetAUJobSummaryResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\AuResponseType[] $auSummary
+ */
+ private $auSummary = null;
+
+ /**
+ * Adds as auResponse
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\AuResponseType $auResponse
+ */
+ public function addToAuSummary(\net\authorize\api\contract\v1\AuResponseType $auResponse)
+ {
+ $this->auSummary[] = $auResponse;
+ return $this;
+ }
+
+ /**
+ * isset auSummary
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetAuSummary($index)
+ {
+ return isset($this->auSummary[$index]);
+ }
+
+ /**
+ * unset auSummary
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetAuSummary($index)
+ {
+ unset($this->auSummary[$index]);
+ }
+
+ /**
+ * Gets as auSummary
+ *
+ * @return \net\authorize\api\contract\v1\AuResponseType[]
+ */
+ public function getAuSummary()
+ {
+ return $this->auSummary;
+ }
+
+ /**
+ * Sets a new auSummary
+ *
+ * @param \net\authorize\api\contract\v1\AuResponseType[] $auSummary
+ * @return self
+ */
+ public function setAuSummary(array $auSummary)
+ {
+ $this->auSummary = $auSummary;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetBatchStatisticsRequest
+ */
+class GetBatchStatisticsRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $batchId
+ */
+ private $batchId = null;
+
+ /**
+ * Gets as batchId
+ *
+ * @return string
+ */
+ public function getBatchId()
+ {
+ return $this->batchId;
+ }
+
+ /**
+ * Sets a new batchId
+ *
+ * @param string $batchId
+ * @return self
+ */
+ public function setBatchId($batchId)
+ {
+ $this->batchId = $batchId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetBatchStatisticsResponse
+ */
+class GetBatchStatisticsResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\BatchDetailsType $batch
+ */
+ private $batch = null;
+
+ /**
+ * Gets as batch
+ *
+ * @return \net\authorize\api\contract\v1\BatchDetailsType
+ */
+ public function getBatch()
+ {
+ return $this->batch;
+ }
+
+ /**
+ * Sets a new batch
+ *
+ * @param \net\authorize\api\contract\v1\BatchDetailsType $batch
+ * @return self
+ */
+ public function setBatch(\net\authorize\api\contract\v1\BatchDetailsType $batch)
+ {
+ $this->batch = $batch;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerPaymentProfileListRequest
+ */
+class GetCustomerPaymentProfileListRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $searchType
+ */
+ private $searchType = null;
+
+ /**
+ * @property string $month
+ */
+ private $month = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerPaymentProfileSortingType
+ * $sorting
+ */
+ private $sorting = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PagingType $paging
+ */
+ private $paging = null;
+
+ /**
+ * Gets as searchType
+ *
+ * @return string
+ */
+ public function getSearchType()
+ {
+ return $this->searchType;
+ }
+
+ /**
+ * Sets a new searchType
+ *
+ * @param string $searchType
+ * @return self
+ */
+ public function setSearchType($searchType)
+ {
+ $this->searchType = $searchType;
+ return $this;
+ }
+
+ /**
+ * Gets as month
+ *
+ * @return string
+ */
+ public function getMonth()
+ {
+ return $this->month;
+ }
+
+ /**
+ * Sets a new month
+ *
+ * @param string $month
+ * @return self
+ */
+ public function setMonth($month)
+ {
+ $this->month = $month;
+ return $this;
+ }
+
+ /**
+ * Gets as sorting
+ *
+ * @return \net\authorize\api\contract\v1\CustomerPaymentProfileSortingType
+ */
+ public function getSorting()
+ {
+ return $this->sorting;
+ }
+
+ /**
+ * Sets a new sorting
+ *
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileSortingType $sorting
+ * @return self
+ */
+ public function setSorting(\net\authorize\api\contract\v1\CustomerPaymentProfileSortingType $sorting)
+ {
+ $this->sorting = $sorting;
+ return $this;
+ }
+
+ /**
+ * Gets as paging
+ *
+ * @return \net\authorize\api\contract\v1\PagingType
+ */
+ public function getPaging()
+ {
+ return $this->paging;
+ }
+
+ /**
+ * Sets a new paging
+ *
+ * @param \net\authorize\api\contract\v1\PagingType $paging
+ * @return self
+ */
+ public function setPaging(\net\authorize\api\contract\v1\PagingType $paging)
+ {
+ $this->paging = $paging;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerPaymentProfileListResponse
+ */
+class GetCustomerPaymentProfileListResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property integer $totalNumInResultSet
+ */
+ private $totalNumInResultSet = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerPaymentProfileListItemType[]
+ * $paymentProfiles
+ */
+ private $paymentProfiles = null;
+
+ /**
+ * Gets as totalNumInResultSet
+ *
+ * @return integer
+ */
+ public function getTotalNumInResultSet()
+ {
+ return $this->totalNumInResultSet;
+ }
+
+ /**
+ * Sets a new totalNumInResultSet
+ *
+ * @param integer $totalNumInResultSet
+ * @return self
+ */
+ public function setTotalNumInResultSet($totalNumInResultSet)
+ {
+ $this->totalNumInResultSet = $totalNumInResultSet;
+ return $this;
+ }
+
+ /**
+ * Adds as paymentProfile
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileListItemType
+ * $paymentProfile
+ */
+ public function addToPaymentProfiles(\net\authorize\api\contract\v1\CustomerPaymentProfileListItemType $paymentProfile)
+ {
+ $this->paymentProfiles[] = $paymentProfile;
+ return $this;
+ }
+
+ /**
+ * isset paymentProfiles
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetPaymentProfiles($index)
+ {
+ return isset($this->paymentProfiles[$index]);
+ }
+
+ /**
+ * unset paymentProfiles
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetPaymentProfiles($index)
+ {
+ unset($this->paymentProfiles[$index]);
+ }
+
+ /**
+ * Gets as paymentProfiles
+ *
+ * @return \net\authorize\api\contract\v1\CustomerPaymentProfileListItemType[]
+ */
+ public function getPaymentProfiles()
+ {
+ return $this->paymentProfiles;
+ }
+
+ /**
+ * Sets a new paymentProfiles
+ *
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileListItemType[]
+ * $paymentProfiles
+ * @return self
+ */
+ public function setPaymentProfiles(array $paymentProfiles)
+ {
+ $this->paymentProfiles = $paymentProfiles;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerPaymentProfileRequest
+ */
+class GetCustomerPaymentProfileRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property boolean $unmaskExpirationDate
+ */
+ private $unmaskExpirationDate = null;
+
+ /**
+ * @property boolean $includeIssuerInfo
+ */
+ private $includeIssuerInfo = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as unmaskExpirationDate
+ *
+ * @return boolean
+ */
+ public function getUnmaskExpirationDate()
+ {
+ return $this->unmaskExpirationDate;
+ }
+
+ /**
+ * Sets a new unmaskExpirationDate
+ *
+ * @param boolean $unmaskExpirationDate
+ * @return self
+ */
+ public function setUnmaskExpirationDate($unmaskExpirationDate)
+ {
+ $this->unmaskExpirationDate = $unmaskExpirationDate;\r
+ return $this;
+ }
+
+ /**
+ * Gets as includeIssuerInfo
+ *
+ * @return boolean
+ */
+ public function getIncludeIssuerInfo()
+ {
+ return $this->includeIssuerInfo;
+ }
+
+ /**
+ * Sets a new includeIssuerInfo
+ *
+ * @param boolean $includeIssuerInfo
+ * @return self
+ */
+ public function setIncludeIssuerInfo($includeIssuerInfo)
+ {
+ $this->includeIssuerInfo = $includeIssuerInfo;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerPaymentProfileResponse
+ */
+class GetCustomerPaymentProfileResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType
+ * $paymentProfile
+ */
+ private $paymentProfile = null;
+
+ /**
+ * Gets as paymentProfile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType
+ */
+ public function getPaymentProfile()
+ {
+ return $this->paymentProfile;
+ }
+
+ /**
+ * Sets a new paymentProfile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType
+ * $paymentProfile
+ * @return self
+ */
+ public function setPaymentProfile(\net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType $paymentProfile)
+ {
+ $this->paymentProfile = $paymentProfile;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerProfileIdsRequest
+ */
+class GetCustomerProfileIdsRequest extends ANetApiRequestType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerProfileIdsResponse
+ */
+class GetCustomerProfileIdsResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string[] $ids
+ */
+ private $ids = null;
+
+ /**
+ * Adds as numericString
+ *
+ * @return self
+ * @param string $numericString
+ */
+ public function addToIds($numericString)
+ {
+ $this->ids[] = $numericString;
+ return $this;
+ }
+
+ /**
+ * isset ids
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetIds($index)
+ {
+ return isset($this->ids[$index]);
+ }
+
+ /**
+ * unset ids
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetIds($index)
+ {
+ unset($this->ids[$index]);
+ }
+
+ /**
+ * Gets as ids
+ *
+ * @return string[]
+ */
+ public function getIds()
+ {
+ return $this->ids;
+ }
+
+ /**
+ * Sets a new ids
+ *
+ * @param string $ids
+ * @return self
+ */
+ public function setIds(array $ids)
+ {
+ $this->ids = $ids;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerProfileRequest
+ */
+class GetCustomerProfileRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $merchantCustomerId
+ */
+ private $merchantCustomerId = null;
+
+ /**
+ * @property string $email
+ */
+ private $email = null;
+
+ /**
+ * @property boolean $unmaskExpirationDate
+ */
+ private $unmaskExpirationDate = null;
+
+ /**
+ * @property boolean $includeIssuerInfo
+ */
+ private $includeIssuerInfo = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as merchantCustomerId
+ *
+ * @return string
+ */
+ public function getMerchantCustomerId()
+ {
+ return $this->merchantCustomerId;
+ }
+
+ /**
+ * Sets a new merchantCustomerId
+ *
+ * @param string $merchantCustomerId
+ * @return self
+ */
+ public function setMerchantCustomerId($merchantCustomerId)
+ {
+ $this->merchantCustomerId = $merchantCustomerId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as email
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Sets a new email
+ *
+ * @param string $email
+ * @return self
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;\r
+ return $this;
+ }
+
+ /**
+ * Gets as unmaskExpirationDate
+ *
+ * @return boolean
+ */
+ public function getUnmaskExpirationDate()
+ {
+ return $this->unmaskExpirationDate;
+ }
+
+ /**
+ * Sets a new unmaskExpirationDate
+ *
+ * @param boolean $unmaskExpirationDate
+ * @return self
+ */
+ public function setUnmaskExpirationDate($unmaskExpirationDate)
+ {
+ $this->unmaskExpirationDate = $unmaskExpirationDate;\r
+ return $this;
+ }
+
+ /**
+ * Gets as includeIssuerInfo
+ *
+ * @return boolean
+ */
+ public function getIncludeIssuerInfo()
+ {
+ return $this->includeIssuerInfo;
+ }
+
+ /**
+ * Sets a new includeIssuerInfo
+ *
+ * @param boolean $includeIssuerInfo
+ * @return self
+ */
+ public function setIncludeIssuerInfo($includeIssuerInfo)
+ {
+ $this->includeIssuerInfo = $includeIssuerInfo;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerProfileResponse
+ */
+class GetCustomerProfileResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileMaskedType $profile
+ */
+ private $profile = null;
+
+ /**
+ * @property string[] $subscriptionIds
+ */
+ private $subscriptionIds = null;
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileMaskedType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileMaskedType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfileMaskedType $profile)
+ {
+ $this->profile = $profile;
+ return $this;
+ }
+
+ /**
+ * Adds as subscriptionId
+ *
+ * @return self
+ * @param string $subscriptionId
+ */
+ public function addToSubscriptionIds($subscriptionId)
+ {
+ $this->subscriptionIds[] = $subscriptionId;
+ return $this;
+ }
+
+ /**
+ * isset subscriptionIds
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetSubscriptionIds($index)
+ {
+ return isset($this->subscriptionIds[$index]);
+ }
+
+ /**
+ * unset subscriptionIds
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetSubscriptionIds($index)
+ {
+ unset($this->subscriptionIds[$index]);
+ }
+
+ /**
+ * Gets as subscriptionIds
+ *
+ * @return string[]
+ */
+ public function getSubscriptionIds()
+ {
+ return $this->subscriptionIds;
+ }
+
+ /**
+ * Sets a new subscriptionIds
+ *
+ * @param string $subscriptionIds
+ * @return self
+ */
+ public function setSubscriptionIds(array $subscriptionIds)
+ {
+ $this->subscriptionIds = $subscriptionIds;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerShippingAddressRequest
+ */
+class GetCustomerShippingAddressRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerAddressId
+ */
+ private $customerAddressId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerAddressId
+ *
+ * @return string
+ */
+ public function getCustomerAddressId()
+ {
+ return $this->customerAddressId;
+ }
+
+ /**
+ * Sets a new customerAddressId
+ *
+ * @param string $customerAddressId
+ * @return self
+ */
+ public function setCustomerAddressId($customerAddressId)
+ {
+ $this->customerAddressId = $customerAddressId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetCustomerShippingAddressResponse
+ */
+class GetCustomerShippingAddressResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property boolean $defaultShippingAddress
+ */
+ private $defaultShippingAddress = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressExType $address
+ */
+ private $address = null;
+
+ /**
+ * @property string[] $subscriptionIds
+ */
+ private $subscriptionIds = null;
+
+ /**
+ * Gets as defaultShippingAddress
+ *
+ * @return boolean
+ */
+ public function getDefaultShippingAddress()
+ {
+ return $this->defaultShippingAddress;
+ }
+
+ /**
+ * Sets a new defaultShippingAddress
+ *
+ * @param boolean $defaultShippingAddress
+ * @return self
+ */
+ public function setDefaultShippingAddress($defaultShippingAddress)
+ {
+ $this->defaultShippingAddress = $defaultShippingAddress;
+ return $this;
+ }
+
+ /**
+ * Gets as address
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressExType
+ */
+ public function getAddress()
+ {
+ return $this->address;
+ }
+
+ /**
+ * Sets a new address
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressExType $address
+ * @return self
+ */
+ public function setAddress(\net\authorize\api\contract\v1\CustomerAddressExType $address)
+ {
+ $this->address = $address;
+ return $this;
+ }
+
+ /**
+ * Adds as subscriptionId
+ *
+ * @return self
+ * @param string $subscriptionId
+ */
+ public function addToSubscriptionIds($subscriptionId)
+ {
+ $this->subscriptionIds[] = $subscriptionId;
+ return $this;
+ }
+
+ /**
+ * isset subscriptionIds
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetSubscriptionIds($index)
+ {
+ return isset($this->subscriptionIds[$index]);
+ }
+
+ /**
+ * unset subscriptionIds
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetSubscriptionIds($index)
+ {
+ unset($this->subscriptionIds[$index]);
+ }
+
+ /**
+ * Gets as subscriptionIds
+ *
+ * @return string[]
+ */
+ public function getSubscriptionIds()
+ {
+ return $this->subscriptionIds;
+ }
+
+ /**
+ * Sets a new subscriptionIds
+ *
+ * @param string $subscriptionIds
+ * @return self
+ */
+ public function setSubscriptionIds(array $subscriptionIds)
+ {
+ $this->subscriptionIds = $subscriptionIds;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetHostedPaymentPageRequest
+ */
+class GetHostedPaymentPageRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionRequestType
+ * $transactionRequest
+ */
+ private $transactionRequest = null;
+
+ /**
+ * Allowed values for settingName are: hostedPaymentIFrameCommunicatorUrl,
+ * hostedPaymentButtonOptions, hostedPaymentReturnOptions,
+ * hostedPaymentOrderOptions, hostedPaymentPaymentOptions,
+ * hostedPaymentBillingAddressOptions, hostedPaymentShippingAddressOptions,
+ * hostedPaymentSecurityOptions, hostedPaymentCustomerOptions,
+ * hostedPaymentStyleOptions
+ *
+ * @property \net\authorize\api\contract\v1\SettingType[] $hostedPaymentSettings
+ */
+ private $hostedPaymentSettings = null;
+
+ /**
+ * Gets as transactionRequest
+ *
+ * @return \net\authorize\api\contract\v1\TransactionRequestType
+ */
+ public function getTransactionRequest()
+ {
+ return $this->transactionRequest;
+ }
+
+ /**
+ * Sets a new transactionRequest
+ *
+ * @param \net\authorize\api\contract\v1\TransactionRequestType $transactionRequest
+ * @return self
+ */
+ public function setTransactionRequest(\net\authorize\api\contract\v1\TransactionRequestType $transactionRequest)
+ {
+ $this->transactionRequest = $transactionRequest;
+ return $this;
+ }
+
+ /**
+ * Adds as setting
+ *
+ * Allowed values for settingName are: hostedPaymentIFrameCommunicatorUrl,
+ * hostedPaymentButtonOptions, hostedPaymentReturnOptions,
+ * hostedPaymentOrderOptions, hostedPaymentPaymentOptions,
+ * hostedPaymentBillingAddressOptions, hostedPaymentShippingAddressOptions,
+ * hostedPaymentSecurityOptions, hostedPaymentCustomerOptions,
+ * hostedPaymentStyleOptions
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\SettingType $setting
+ */
+ public function addToHostedPaymentSettings(\net\authorize\api\contract\v1\SettingType $setting)
+ {
+ $this->hostedPaymentSettings[] = $setting;
+ return $this;
+ }
+
+ /**
+ * isset hostedPaymentSettings
+ *
+ * Allowed values for settingName are: hostedPaymentIFrameCommunicatorUrl,
+ * hostedPaymentButtonOptions, hostedPaymentReturnOptions,
+ * hostedPaymentOrderOptions, hostedPaymentPaymentOptions,
+ * hostedPaymentBillingAddressOptions, hostedPaymentShippingAddressOptions,
+ * hostedPaymentSecurityOptions, hostedPaymentCustomerOptions,
+ * hostedPaymentStyleOptions
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetHostedPaymentSettings($index)
+ {
+ return isset($this->hostedPaymentSettings[$index]);
+ }
+
+ /**
+ * unset hostedPaymentSettings
+ *
+ * Allowed values for settingName are: hostedPaymentIFrameCommunicatorUrl,
+ * hostedPaymentButtonOptions, hostedPaymentReturnOptions,
+ * hostedPaymentOrderOptions, hostedPaymentPaymentOptions,
+ * hostedPaymentBillingAddressOptions, hostedPaymentShippingAddressOptions,
+ * hostedPaymentSecurityOptions, hostedPaymentCustomerOptions,
+ * hostedPaymentStyleOptions
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetHostedPaymentSettings($index)
+ {
+ unset($this->hostedPaymentSettings[$index]);
+ }
+
+ /**
+ * Gets as hostedPaymentSettings
+ *
+ * Allowed values for settingName are: hostedPaymentIFrameCommunicatorUrl,
+ * hostedPaymentButtonOptions, hostedPaymentReturnOptions,
+ * hostedPaymentOrderOptions, hostedPaymentPaymentOptions,
+ * hostedPaymentBillingAddressOptions, hostedPaymentShippingAddressOptions,
+ * hostedPaymentSecurityOptions, hostedPaymentCustomerOptions,
+ * hostedPaymentStyleOptions
+ *
+ * @return \net\authorize\api\contract\v1\SettingType[]
+ */
+ public function getHostedPaymentSettings()
+ {
+ return $this->hostedPaymentSettings;
+ }
+
+ /**
+ * Sets a new hostedPaymentSettings
+ *
+ * Allowed values for settingName are: hostedPaymentIFrameCommunicatorUrl,
+ * hostedPaymentButtonOptions, hostedPaymentReturnOptions,
+ * hostedPaymentOrderOptions, hostedPaymentPaymentOptions,
+ * hostedPaymentBillingAddressOptions, hostedPaymentShippingAddressOptions,
+ * hostedPaymentSecurityOptions, hostedPaymentCustomerOptions,
+ * hostedPaymentStyleOptions
+ *
+ * @param \net\authorize\api\contract\v1\SettingType[] $hostedPaymentSettings
+ * @return self
+ */
+ public function setHostedPaymentSettings(array $hostedPaymentSettings)
+ {
+ $this->hostedPaymentSettings = $hostedPaymentSettings;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetHostedPaymentPageResponse
+ */
+class GetHostedPaymentPageResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string $token
+ */
+ private $token = null;
+
+ /**
+ * Gets as token
+ *
+ * @return string
+ */
+ public function getToken()
+ {
+ return $this->token;
+ }
+
+ /**
+ * Sets a new token
+ *
+ * @param string $token
+ * @return self
+ */
+ public function setToken($token)
+ {
+ $this->token = $token;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetHostedProfilePageRequest
+ */
+class GetHostedProfilePageRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * Allowed values for settingName are: hostedProfileReturnUrl,
+ * hostedProfileReturnUrlText, hostedProfilePageBorderVisible,
+ * hostedProfileIFrameCommunicatorUrl, hostedProfileHeadingBgColor,
+ * hostedProfileBillingAddressRequired, hostedProfileCardCodeRequired,
+ * hostedProfileBillingAddressOptions, hostedProfileManageOptions.
+ *
+ * @property \net\authorize\api\contract\v1\SettingType[] $hostedProfileSettings
+ */
+ private $hostedProfileSettings = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Adds as setting
+ *
+ * Allowed values for settingName are: hostedProfileReturnUrl,
+ * hostedProfileReturnUrlText, hostedProfilePageBorderVisible,
+ * hostedProfileIFrameCommunicatorUrl, hostedProfileHeadingBgColor,
+ * hostedProfileBillingAddressRequired, hostedProfileCardCodeRequired,
+ * hostedProfileBillingAddressOptions, hostedProfileManageOptions.
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\SettingType $setting
+ */
+ public function addToHostedProfileSettings(\net\authorize\api\contract\v1\SettingType $setting)
+ {
+ $this->hostedProfileSettings[] = $setting;
+ return $this;
+ }
+
+ /**
+ * isset hostedProfileSettings
+ *
+ * Allowed values for settingName are: hostedProfileReturnUrl,
+ * hostedProfileReturnUrlText, hostedProfilePageBorderVisible,
+ * hostedProfileIFrameCommunicatorUrl, hostedProfileHeadingBgColor,
+ * hostedProfileBillingAddressRequired, hostedProfileCardCodeRequired,
+ * hostedProfileBillingAddressOptions, hostedProfileManageOptions.
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetHostedProfileSettings($index)
+ {
+ return isset($this->hostedProfileSettings[$index]);
+ }
+
+ /**
+ * unset hostedProfileSettings
+ *
+ * Allowed values for settingName are: hostedProfileReturnUrl,
+ * hostedProfileReturnUrlText, hostedProfilePageBorderVisible,
+ * hostedProfileIFrameCommunicatorUrl, hostedProfileHeadingBgColor,
+ * hostedProfileBillingAddressRequired, hostedProfileCardCodeRequired,
+ * hostedProfileBillingAddressOptions, hostedProfileManageOptions.
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetHostedProfileSettings($index)
+ {
+ unset($this->hostedProfileSettings[$index]);
+ }
+
+ /**
+ * Gets as hostedProfileSettings
+ *
+ * Allowed values for settingName are: hostedProfileReturnUrl,
+ * hostedProfileReturnUrlText, hostedProfilePageBorderVisible,
+ * hostedProfileIFrameCommunicatorUrl, hostedProfileHeadingBgColor,
+ * hostedProfileBillingAddressRequired, hostedProfileCardCodeRequired,
+ * hostedProfileBillingAddressOptions, hostedProfileManageOptions.
+ *
+ * @return \net\authorize\api\contract\v1\SettingType[]
+ */
+ public function getHostedProfileSettings()
+ {
+ return $this->hostedProfileSettings;
+ }
+
+ /**
+ * Sets a new hostedProfileSettings
+ *
+ * Allowed values for settingName are: hostedProfileReturnUrl,
+ * hostedProfileReturnUrlText, hostedProfilePageBorderVisible,
+ * hostedProfileIFrameCommunicatorUrl, hostedProfileHeadingBgColor,
+ * hostedProfileBillingAddressRequired, hostedProfileCardCodeRequired,
+ * hostedProfileBillingAddressOptions, hostedProfileManageOptions.
+ *
+ * @param \net\authorize\api\contract\v1\SettingType[] $hostedProfileSettings
+ * @return self
+ */
+ public function setHostedProfileSettings(array $hostedProfileSettings)
+ {
+ $this->hostedProfileSettings = $hostedProfileSettings;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetHostedProfilePageResponse
+ */
+class GetHostedProfilePageResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string $token
+ */
+ private $token = null;
+
+ /**
+ * Gets as token
+ *
+ * @return string
+ */
+ public function getToken()
+ {
+ return $this->token;
+ }
+
+ /**
+ * Sets a new token
+ *
+ * @param string $token
+ * @return self
+ */
+ public function setToken($token)
+ {
+ $this->token = $token;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetMerchantDetailsRequest
+ */
+class GetMerchantDetailsRequest extends ANetApiRequestType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetMerchantDetailsResponse
+ */
+class GetMerchantDetailsResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property boolean $isTestMode
+ */
+ private $isTestMode = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ProcessorType[] $processors
+ */
+ private $processors = null;
+
+ /**
+ * @property string $merchantName
+ */
+ private $merchantName = null;
+
+ /**
+ * @property string $gatewayId
+ */
+ private $gatewayId = null;
+
+ /**
+ * @property string[] $marketTypes
+ */
+ private $marketTypes = null;
+
+ /**
+ * @property string[] $productCodes
+ */
+ private $productCodes = null;
+
+ /**
+ * @property string[] $paymentMethods
+ */
+ private $paymentMethods = null;
+
+ /**
+ * @property string[] $currencies
+ */
+ private $currencies = null;
+
+ /**
+ * @property string $publicClientKey
+ */
+ private $publicClientKey = null;
+
+ /**
+ * Gets as isTestMode
+ *
+ * @return boolean
+ */
+ public function getIsTestMode()
+ {
+ return $this->isTestMode;
+ }
+
+ /**
+ * Sets a new isTestMode
+ *
+ * @param boolean $isTestMode
+ * @return self
+ */
+ public function setIsTestMode($isTestMode)
+ {
+ $this->isTestMode = $isTestMode;\r
+ return $this;
+ }
+
+ /**
+ * Adds as processor
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\ProcessorType $processor
+ */
+ public function addToProcessors(\net\authorize\api\contract\v1\ProcessorType $processor)
+ {
+ $this->processors[] = $processor;\r
+ return $this;
+ }
+
+ /**
+ * isset processors
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetProcessors($index)
+ {
+ return isset($this->processors[$index]);
+ }
+
+ /**
+ * unset processors
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetProcessors($index)
+ {
+ unset($this->processors[$index]);
+ }
+
+ /**
+ * Gets as processors
+ *
+ * @return \net\authorize\api\contract\v1\ProcessorType[]
+ */
+ public function getProcessors()
+ {
+ return $this->processors;
+ }
+
+ /**
+ * Sets a new processors
+ *
+ * @param \net\authorize\api\contract\v1\ProcessorType[] $processors
+ * @return self
+ */
+ public function setProcessors(array $processors)
+ {
+ $this->processors = $processors;\r
+ return $this;
+ }
+
+ /**
+ * Gets as merchantName
+ *
+ * @return string
+ */
+ public function getMerchantName()
+ {
+ return $this->merchantName;
+ }
+
+ /**
+ * Sets a new merchantName
+ *
+ * @param string $merchantName
+ * @return self
+ */
+ public function setMerchantName($merchantName)
+ {
+ $this->merchantName = $merchantName;\r
+ return $this;
+ }
+
+ /**
+ * Gets as gatewayId
+ *
+ * @return string
+ */
+ public function getGatewayId()
+ {
+ return $this->gatewayId;
+ }
+
+ /**
+ * Sets a new gatewayId
+ *
+ * @param string $gatewayId
+ * @return self
+ */
+ public function setGatewayId($gatewayId)
+ {
+ $this->gatewayId = $gatewayId;\r
+ return $this;
+ }
+
+ /**
+ * Adds as marketType
+ *
+ * @return self
+ * @param string $marketType
+ */
+ public function addToMarketTypes($marketType)
+ {
+ $this->marketTypes[] = $marketType;\r
+ return $this;
+ }
+
+ /**
+ * isset marketTypes
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetMarketTypes($index)
+ {
+ return isset($this->marketTypes[$index]);
+ }
+
+ /**
+ * unset marketTypes
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetMarketTypes($index)
+ {
+ unset($this->marketTypes[$index]);
+ }
+
+ /**
+ * Gets as marketTypes
+ *
+ * @return string[]
+ */
+ public function getMarketTypes()
+ {
+ return $this->marketTypes;
+ }
+
+ /**
+ * Sets a new marketTypes
+ *
+ * @param string $marketTypes
+ * @return self
+ */
+ public function setMarketTypes(array $marketTypes)
+ {
+ $this->marketTypes = $marketTypes;\r
+ return $this;
+ }
+
+ /**
+ * Adds as productCode
+ *
+ * @return self
+ * @param string $productCode
+ */
+ public function addToProductCodes($productCode)
+ {
+ $this->productCodes[] = $productCode;\r
+ return $this;
+ }
+
+ /**
+ * isset productCodes
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetProductCodes($index)
+ {
+ return isset($this->productCodes[$index]);
+ }
+
+ /**
+ * unset productCodes
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetProductCodes($index)
+ {
+ unset($this->productCodes[$index]);
+ }
+
+ /**
+ * Gets as productCodes
+ *
+ * @return string[]
+ */
+ public function getProductCodes()
+ {
+ return $this->productCodes;
+ }
+
+ /**
+ * Sets a new productCodes
+ *
+ * @param string $productCodes
+ * @return self
+ */
+ public function setProductCodes(array $productCodes)
+ {
+ $this->productCodes = $productCodes;\r
+ return $this;
+ }
+
+ /**
+ * Adds as paymentMethod
+ *
+ * @return self
+ * @param string $paymentMethod
+ */
+ public function addToPaymentMethods($paymentMethod)
+ {
+ $this->paymentMethods[] = $paymentMethod;\r
+ return $this;
+ }
+
+ /**
+ * isset paymentMethods
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetPaymentMethods($index)
+ {
+ return isset($this->paymentMethods[$index]);
+ }
+
+ /**
+ * unset paymentMethods
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetPaymentMethods($index)
+ {
+ unset($this->paymentMethods[$index]);
+ }
+
+ /**
+ * Gets as paymentMethods
+ *
+ * @return string[]
+ */
+ public function getPaymentMethods()
+ {
+ return $this->paymentMethods;
+ }
+
+ /**
+ * Sets a new paymentMethods
+ *
+ * @param string $paymentMethods
+ * @return self
+ */
+ public function setPaymentMethods(array $paymentMethods)
+ {
+ $this->paymentMethods = $paymentMethods;\r
+ return $this;
+ }
+
+ /**
+ * Adds as currency
+ *
+ * @return self
+ * @param string $currency
+ */
+ public function addToCurrencies($currency)
+ {
+ $this->currencies[] = $currency;\r
+ return $this;
+ }
+
+ /**
+ * isset currencies
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetCurrencies($index)
+ {
+ return isset($this->currencies[$index]);
+ }
+
+ /**
+ * unset currencies
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetCurrencies($index)
+ {
+ unset($this->currencies[$index]);
+ }
+
+ /**
+ * Gets as currencies
+ *
+ * @return string[]
+ */
+ public function getCurrencies()
+ {
+ return $this->currencies;
+ }
+
+ /**
+ * Sets a new currencies
+ *
+ * @param string $currencies
+ * @return self
+ */
+ public function setCurrencies(array $currencies)
+ {
+ $this->currencies = $currencies;\r
+ return $this;
+ }
+
+ /**
+ * Gets as publicClientKey
+ *
+ * @return string
+ */
+ public function getPublicClientKey()
+ {
+ return $this->publicClientKey;
+ }
+
+ /**
+ * Sets a new publicClientKey
+ *
+ * @param string $publicClientKey
+ * @return self
+ */
+ public function setPublicClientKey($publicClientKey)
+ {
+ $this->publicClientKey = $publicClientKey;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetSettledBatchListRequest
+ */
+class GetSettledBatchListRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property boolean $includeStatistics
+ */
+ private $includeStatistics = null;
+
+ /**
+ * @property \DateTime $firstSettlementDate
+ */
+ private $firstSettlementDate = null;
+
+ /**
+ * @property \DateTime $lastSettlementDate
+ */
+ private $lastSettlementDate = null;
+
+ /**
+ * Gets as includeStatistics
+ *
+ * @return boolean
+ */
+ public function getIncludeStatistics()
+ {
+ return $this->includeStatistics;
+ }
+
+ /**
+ * Sets a new includeStatistics
+ *
+ * @param boolean $includeStatistics
+ * @return self
+ */
+ public function setIncludeStatistics($includeStatistics)
+ {
+ $this->includeStatistics = $includeStatistics;
+ return $this;
+ }
+
+ /**
+ * Gets as firstSettlementDate
+ *
+ * @return \DateTime
+ */
+ public function getFirstSettlementDate()
+ {
+ return $this->firstSettlementDate;
+ }
+
+ /**
+ * Sets a new firstSettlementDate
+ *
+ * @param \DateTime $firstSettlementDate
+ * @return self
+ */
+ public function setFirstSettlementDate(\DateTime $firstSettlementDate)
+ {
+ $this->firstSettlementDate = $firstSettlementDate;
+ return $this;
+ }
+
+ /**
+ * Gets as lastSettlementDate
+ *
+ * @return \DateTime
+ */
+ public function getLastSettlementDate()
+ {
+ return $this->lastSettlementDate;
+ }
+
+ /**
+ * Sets a new lastSettlementDate
+ *
+ * @param \DateTime $lastSettlementDate
+ * @return self
+ */
+ public function setLastSettlementDate(\DateTime $lastSettlementDate)
+ {
+ $this->lastSettlementDate = $lastSettlementDate;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetSettledBatchListResponse
+ */
+class GetSettledBatchListResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\BatchDetailsType[] $batchList
+ */
+ private $batchList = null;
+
+ /**
+ * Adds as batch
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\BatchDetailsType $batch
+ */
+ public function addToBatchList(\net\authorize\api\contract\v1\BatchDetailsType $batch)
+ {
+ $this->batchList[] = $batch;
+ return $this;
+ }
+
+ /**
+ * isset batchList
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetBatchList($index)
+ {
+ return isset($this->batchList[$index]);
+ }
+
+ /**
+ * unset batchList
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetBatchList($index)
+ {
+ unset($this->batchList[$index]);
+ }
+
+ /**
+ * Gets as batchList
+ *
+ * @return \net\authorize\api\contract\v1\BatchDetailsType[]
+ */
+ public function getBatchList()
+ {
+ return $this->batchList;
+ }
+
+ /**
+ * Sets a new batchList
+ *
+ * @param \net\authorize\api\contract\v1\BatchDetailsType[] $batchList
+ * @return self
+ */
+ public function setBatchList(array $batchList)
+ {
+ $this->batchList = $batchList;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetTransactionDetailsRequest
+ */
+class GetTransactionDetailsRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetTransactionDetailsResponse
+ */
+class GetTransactionDetailsResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionDetailsType $transaction
+ */
+ private $transaction = null;
+
+ /**
+ * @property string $clientId
+ */
+ private $clientId = null;
+
+ /**
+ * @property string $transrefId
+ */
+ private $transrefId = null;
+
+ /**
+ * Gets as transaction
+ *
+ * @return \net\authorize\api\contract\v1\TransactionDetailsType
+ */
+ public function getTransaction()
+ {
+ return $this->transaction;
+ }
+
+ /**
+ * Sets a new transaction
+ *
+ * @param \net\authorize\api\contract\v1\TransactionDetailsType $transaction
+ * @return self
+ */
+ public function setTransaction(\net\authorize\api\contract\v1\TransactionDetailsType $transaction)
+ {
+ $this->transaction = $transaction;
+ return $this;
+ }
+
+ /**
+ * Gets as clientId
+ *
+ * @return string
+ */
+ public function getClientId()
+ {
+ return $this->clientId;
+ }
+
+ /**
+ * Sets a new clientId
+ *
+ * @param string $clientId
+ * @return self
+ */
+ public function setClientId($clientId)
+ {
+ $this->clientId = $clientId;
+ return $this;
+ }
+
+ /**
+ * Gets as transrefId
+ *
+ * @return string
+ */
+ public function getTransrefId()
+ {
+ return $this->transrefId;
+ }
+
+ /**
+ * Sets a new transrefId
+ *
+ * @param string $transrefId
+ * @return self
+ */
+ public function setTransrefId($transrefId)
+ {
+ $this->transrefId = $transrefId;
+ return $this;
+ }
+
+
+}
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetTransactionListForCustomerRequest
+ */
+class GetTransactionListForCustomerRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionListSortingType $sorting
+ */
+ private $sorting = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PagingType $paging
+ */
+ private $paging = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as sorting
+ *
+ * @return \net\authorize\api\contract\v1\TransactionListSortingType
+ */
+ public function getSorting()
+ {
+ return $this->sorting;
+ }
+
+ /**
+ * Sets a new sorting
+ *
+ * @param \net\authorize\api\contract\v1\TransactionListSortingType $sorting
+ * @return self
+ */
+ public function setSorting(\net\authorize\api\contract\v1\TransactionListSortingType $sorting)
+ {
+ $this->sorting = $sorting;\r
+ return $this;
+ }
+
+ /**
+ * Gets as paging
+ *
+ * @return \net\authorize\api\contract\v1\PagingType
+ */
+ public function getPaging()
+ {
+ return $this->paging;
+ }
+
+ /**
+ * Sets a new paging
+ *
+ * @param \net\authorize\api\contract\v1\PagingType $paging
+ * @return self
+ */
+ public function setPaging(\net\authorize\api\contract\v1\PagingType $paging)
+ {
+ $this->paging = $paging;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetTransactionListRequest
+ */
+class GetTransactionListRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $batchId
+ */
+ private $batchId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionListSortingType $sorting
+ */
+ private $sorting = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PagingType $paging
+ */
+ private $paging = null;
+
+ /**
+ * Gets as batchId
+ *
+ * @return string
+ */
+ public function getBatchId()
+ {
+ return $this->batchId;
+ }
+
+ /**
+ * Sets a new batchId
+ *
+ * @param string $batchId
+ * @return self
+ */
+ public function setBatchId($batchId)
+ {
+ $this->batchId = $batchId;
+ return $this;
+ }
+
+ /**
+ * Gets as sorting
+ *
+ * @return \net\authorize\api\contract\v1\TransactionListSortingType
+ */
+ public function getSorting()
+ {
+ return $this->sorting;
+ }
+
+ /**
+ * Sets a new sorting
+ *
+ * @param \net\authorize\api\contract\v1\TransactionListSortingType $sorting
+ * @return self
+ */
+ public function setSorting(\net\authorize\api\contract\v1\TransactionListSortingType $sorting)
+ {
+ $this->sorting = $sorting;
+ return $this;
+ }
+
+ /**
+ * Gets as paging
+ *
+ * @return \net\authorize\api\contract\v1\PagingType
+ */
+ public function getPaging()
+ {
+ return $this->paging;
+ }
+
+ /**
+ * Sets a new paging
+ *
+ * @param \net\authorize\api\contract\v1\PagingType $paging
+ * @return self
+ */
+ public function setPaging(\net\authorize\api\contract\v1\PagingType $paging)
+ {
+ $this->paging = $paging;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetTransactionListResponse
+ */
+class GetTransactionListResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionSummaryType[] $transactions
+ */
+ private $transactions = null;
+
+ /**
+ * @property integer $totalNumInResultSet
+ */
+ private $totalNumInResultSet = null;
+
+ /**
+ * Adds as transaction
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\TransactionSummaryType $transaction
+ */
+ public function addToTransactions(\net\authorize\api\contract\v1\TransactionSummaryType $transaction)
+ {
+ $this->transactions[] = $transaction;
+ return $this;
+ }
+
+ /**
+ * isset transactions
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetTransactions($index)
+ {
+ return isset($this->transactions[$index]);
+ }
+
+ /**
+ * unset transactions
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetTransactions($index)
+ {
+ unset($this->transactions[$index]);
+ }
+
+ /**
+ * Gets as transactions
+ *
+ * @return \net\authorize\api\contract\v1\TransactionSummaryType[]
+ */
+ public function getTransactions()
+ {
+ return $this->transactions;
+ }
+
+ /**
+ * Sets a new transactions
+ *
+ * @param \net\authorize\api\contract\v1\TransactionSummaryType[] $transactions
+ * @return self
+ */
+ public function setTransactions(array $transactions)
+ {
+ $this->transactions = $transactions;
+ return $this;
+ }
+
+ /**
+ * Gets as totalNumInResultSet
+ *
+ * @return integer
+ */
+ public function getTotalNumInResultSet()
+ {
+ return $this->totalNumInResultSet;
+ }
+
+ /**
+ * Sets a new totalNumInResultSet
+ *
+ * @param integer $totalNumInResultSet
+ * @return self
+ */
+ public function setTotalNumInResultSet($totalNumInResultSet)
+ {
+ $this->totalNumInResultSet = $totalNumInResultSet;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetUnsettledTransactionListRequest
+ */
+class GetUnsettledTransactionListRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $status
+ */
+ private $status = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionListSortingType $sorting
+ */
+ private $sorting = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PagingType $paging
+ */
+ private $paging = null;
+
+ /**
+ * Gets as status
+ *
+ * @return string
+ */
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ /**
+ * Sets a new status
+ *
+ * @param string $status
+ * @return self
+ */
+ public function setStatus($status)
+ {
+ $this->status = $status;
+ return $this;
+ }
+
+ /**
+ * Gets as sorting
+ *
+ * @return \net\authorize\api\contract\v1\TransactionListSortingType
+ */
+ public function getSorting()
+ {
+ return $this->sorting;
+ }
+
+ /**
+ * Sets a new sorting
+ *
+ * @param \net\authorize\api\contract\v1\TransactionListSortingType $sorting
+ * @return self
+ */
+ public function setSorting(\net\authorize\api\contract\v1\TransactionListSortingType $sorting)
+ {
+ $this->sorting = $sorting;
+ return $this;
+ }
+
+ /**
+ * Gets as paging
+ *
+ * @return \net\authorize\api\contract\v1\PagingType
+ */
+ public function getPaging()
+ {
+ return $this->paging;
+ }
+
+ /**
+ * Sets a new paging
+ *
+ * @param \net\authorize\api\contract\v1\PagingType $paging
+ * @return self
+ */
+ public function setPaging(\net\authorize\api\contract\v1\PagingType $paging)
+ {
+ $this->paging = $paging;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing GetUnsettledTransactionListResponse
+ */
+class GetUnsettledTransactionListResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionSummaryType[] $transactions
+ */
+ private $transactions = null;
+
+ /**
+ * @property integer $totalNumInResultSet
+ */
+ private $totalNumInResultSet = null;
+
+ /**
+ * Adds as transaction
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\TransactionSummaryType $transaction
+ */
+ public function addToTransactions(\net\authorize\api\contract\v1\TransactionSummaryType $transaction)
+ {
+ $this->transactions[] = $transaction;
+ return $this;
+ }
+
+ /**
+ * isset transactions
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetTransactions($index)
+ {
+ return isset($this->transactions[$index]);
+ }
+
+ /**
+ * unset transactions
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetTransactions($index)
+ {
+ unset($this->transactions[$index]);
+ }
+
+ /**
+ * Gets as transactions
+ *
+ * @return \net\authorize\api\contract\v1\TransactionSummaryType[]
+ */
+ public function getTransactions()
+ {
+ return $this->transactions;
+ }
+
+ /**
+ * Sets a new transactions
+ *
+ * @param \net\authorize\api\contract\v1\TransactionSummaryType[] $transactions
+ * @return self
+ */
+ public function setTransactions(array $transactions)
+ {
+ $this->transactions = $transactions;
+ return $this;
+ }
+
+ /**
+ * Gets as totalNumInResultSet
+ *
+ * @return integer
+ */
+ public function getTotalNumInResultSet()
+ {
+ return $this->totalNumInResultSet;
+ }
+
+ /**
+ * Sets a new totalNumInResultSet
+ *
+ * @param integer $totalNumInResultSet
+ * @return self
+ */
+ public function setTotalNumInResultSet($totalNumInResultSet)
+ {
+ $this->totalNumInResultSet = $totalNumInResultSet;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing HeldTransactionRequestType
+ *
+ *
+ * XSD Type: heldTransactionRequestType
+ */
+class HeldTransactionRequestType
+{
+
+ /**
+ * @property string $action
+ */
+ private $action = null;
+
+ /**
+ * @property string $refTransId
+ */
+ private $refTransId = null;
+
+ /**
+ * Gets as action
+ *
+ * @return string
+ */
+ public function getAction()
+ {
+ return $this->action;
+ }
+
+ /**
+ * Sets a new action
+ *
+ * @param string $action
+ * @return self
+ */
+ public function setAction($action)
+ {
+ $this->action = $action;
+ return $this;
+ }
+
+ /**
+ * Gets as refTransId
+ *
+ * @return string
+ */
+ public function getRefTransId()
+ {
+ return $this->refTransId;
+ }
+
+ /**
+ * Sets a new refTransId
+ *
+ * @param string $refTransId
+ * @return self
+ */
+ public function setRefTransId($refTransId)
+ {
+ $this->refTransId = $refTransId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ImpersonationAuthenticationType
+ *
+ *
+ * XSD Type: impersonationAuthenticationType
+ */
+class ImpersonationAuthenticationType
+{
+
+ /**
+ * @property string $partnerLoginId
+ */
+ private $partnerLoginId = null;
+
+ /**
+ * @property string $partnerTransactionKey
+ */
+ private $partnerTransactionKey = null;
+
+ /**
+ * Gets as partnerLoginId
+ *
+ * @return string
+ */
+ public function getPartnerLoginId()
+ {
+ return $this->partnerLoginId;
+ }
+
+ /**
+ * Sets a new partnerLoginId
+ *
+ * @param string $partnerLoginId
+ * @return self
+ */
+ public function setPartnerLoginId($partnerLoginId)
+ {
+ $this->partnerLoginId = $partnerLoginId;
+ return $this;
+ }
+
+ /**
+ * Gets as partnerTransactionKey
+ *
+ * @return string
+ */
+ public function getPartnerTransactionKey()
+ {
+ return $this->partnerTransactionKey;
+ }
+
+ /**
+ * Sets a new partnerTransactionKey
+ *
+ * @param string $partnerTransactionKey
+ * @return self
+ */
+ public function setPartnerTransactionKey($partnerTransactionKey)
+ {
+ $this->partnerTransactionKey = $partnerTransactionKey;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing IsAliveRequest
+ */
+class IsAliveRequest
+{
+
+ /**
+ * @property string $refId
+ */
+ private $refId = null;
+
+ /**
+ * Gets as refId
+ *
+ * @return string
+ */
+ public function getRefId()
+ {
+ return $this->refId;
+ }
+
+ /**
+ * Sets a new refId
+ *
+ * @param string $refId
+ * @return self
+ */
+ public function setRefId($refId)
+ {
+ $this->refId = $refId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing IsAliveResponse
+ */
+class IsAliveResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing KeyBlockType
+ *
+ *
+ * XSD Type: KeyBlock
+ */
+class KeyBlockType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\KeyValueType $value
+ */
+ private $value = null;
+
+ /**
+ * Gets as value
+ *
+ * @return \net\authorize\api\contract\v1\KeyValueType
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Sets a new value
+ *
+ * @param \net\authorize\api\contract\v1\KeyValueType $value
+ * @return self
+ */
+ public function setValue(\net\authorize\api\contract\v1\KeyValueType $value)
+ {
+ $this->value = $value;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing KeyManagementSchemeType
+ *
+ *
+ * XSD Type: KeyManagementScheme
+ */
+class KeyManagementSchemeType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType
+ * $dUKPT
+ */
+ private $dUKPT = null;
+
+ /**
+ * Gets as dUKPT
+ *
+ * @return \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType
+ */
+ public function getDUKPT()
+ {
+ return $this->dUKPT;
+ }
+
+ /**
+ * Sets a new dUKPT
+ *
+ * @param \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType $dUKPT
+ * @return self
+ */
+ public function setDUKPT(\net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType $dUKPT)
+ {
+ $this->dUKPT = $dUKPT;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\KeyManagementSchemeType;
+
+/**
+ * Class representing DUKPTAType
+ */
+class DUKPTAType
+{
+
+ /**
+ * @property string $operation
+ */
+ private $operation = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\ModeAType
+ * $mode
+ */
+ private $mode = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\DeviceInfoAType
+ * $deviceInfo
+ */
+ private $deviceInfo = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\EncryptedDataAType
+ * $encryptedData
+ */
+ private $encryptedData = null;
+
+ /**
+ * Gets as operation
+ *
+ * @return string
+ */
+ public function getOperation()
+ {
+ return $this->operation;
+ }
+
+ /**
+ * Sets a new operation
+ *
+ * @param string $operation
+ * @return self
+ */
+ public function setOperation($operation)
+ {
+ $this->operation = $operation;
+ return $this;
+ }
+
+ /**
+ * Gets as mode
+ *
+ * @return
+ * \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\ModeAType
+ */
+ public function getMode()
+ {
+ return $this->mode;
+ }
+
+ /**
+ * Sets a new mode
+ *
+ * @param
+ * \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\ModeAType
+ * $mode
+ * @return self
+ */
+ public function setMode(\net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\ModeAType $mode)
+ {
+ $this->mode = $mode;
+ return $this;
+ }
+
+ /**
+ * Gets as deviceInfo
+ *
+ * @return
+ * \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\DeviceInfoAType
+ */
+ public function getDeviceInfo()
+ {
+ return $this->deviceInfo;
+ }
+
+ /**
+ * Sets a new deviceInfo
+ *
+ * @param
+ * \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\DeviceInfoAType
+ * $deviceInfo
+ * @return self
+ */
+ public function setDeviceInfo(\net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\DeviceInfoAType $deviceInfo)
+ {
+ $this->deviceInfo = $deviceInfo;
+ return $this;
+ }
+
+ /**
+ * Gets as encryptedData
+ *
+ * @return
+ * \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\EncryptedDataAType
+ */
+ public function getEncryptedData()
+ {
+ return $this->encryptedData;
+ }
+
+ /**
+ * Sets a new encryptedData
+ *
+ * @param
+ * \net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\EncryptedDataAType
+ * $encryptedData
+ * @return self
+ */
+ public function setEncryptedData(\net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\EncryptedDataAType $encryptedData)
+ {
+ $this->encryptedData = $encryptedData;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType;
+
+/**
+ * Class representing DeviceInfoAType
+ */
+class DeviceInfoAType
+{
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType;
+
+/**
+ * Class representing EncryptedDataAType
+ */
+class EncryptedDataAType
+{
+
+ /**
+ * @property string $value
+ */
+ private $value = null;
+
+ /**
+ * Gets as value
+ *
+ * @return string
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Sets a new value
+ *
+ * @param string $value
+ * @return self
+ */
+ public function setValue($value)
+ {
+ $this->value = $value;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType;
+
+/**
+ * Class representing ModeAType
+ */
+class ModeAType
+{
+
+ /**
+ * @property string $pIN
+ */
+ private $pIN = null;
+
+ /**
+ * @property string $data
+ */
+ private $data = null;
+
+ /**
+ * Gets as pIN
+ *
+ * @return string
+ */
+ public function getPIN()
+ {
+ return $this->pIN;
+ }
+
+ /**
+ * Sets a new pIN
+ *
+ * @param string $pIN
+ * @return self
+ */
+ public function setPIN($pIN)
+ {
+ $this->pIN = $pIN;
+ return $this;
+ }
+
+ /**
+ * Gets as data
+ *
+ * @return string
+ */
+ public function getData()
+ {
+ return $this->data;
+ }
+
+ /**
+ * Sets a new data
+ *
+ * @param string $data
+ * @return self
+ */
+ public function setData($data)
+ {
+ $this->data = $data;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing KeyValueType
+ *
+ *
+ * XSD Type: KeyValue
+ */
+class KeyValueType
+{
+
+ /**
+ * @property string $encoding
+ */
+ private $encoding = null;
+
+ /**
+ * @property string $encryptionAlgorithm
+ */
+ private $encryptionAlgorithm = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\KeyManagementSchemeType $scheme
+ */
+ private $scheme = null;
+
+ /**
+ * Gets as encoding
+ *
+ * @return string
+ */
+ public function getEncoding()
+ {
+ return $this->encoding;
+ }
+
+ /**
+ * Sets a new encoding
+ *
+ * @param string $encoding
+ * @return self
+ */
+ public function setEncoding($encoding)
+ {
+ $this->encoding = $encoding;
+ return $this;
+ }
+
+ /**
+ * Gets as encryptionAlgorithm
+ *
+ * @return string
+ */
+ public function getEncryptionAlgorithm()
+ {
+ return $this->encryptionAlgorithm;
+ }
+
+ /**
+ * Sets a new encryptionAlgorithm
+ *
+ * @param string $encryptionAlgorithm
+ * @return self
+ */
+ public function setEncryptionAlgorithm($encryptionAlgorithm)
+ {
+ $this->encryptionAlgorithm = $encryptionAlgorithm;
+ return $this;
+ }
+
+ /**
+ * Gets as scheme
+ *
+ * @return \net\authorize\api\contract\v1\KeyManagementSchemeType
+ */
+ public function getScheme()
+ {
+ return $this->scheme;
+ }
+
+ /**
+ * Sets a new scheme
+ *
+ * @param \net\authorize\api\contract\v1\KeyManagementSchemeType $scheme
+ * @return self
+ */
+ public function setScheme(\net\authorize\api\contract\v1\KeyManagementSchemeType $scheme)
+ {
+ $this->scheme = $scheme;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing LineItemType
+ *
+ *
+ * XSD Type: lineItemType
+ */
+class LineItemType
+{
+
+ /**
+ * @property string $itemId
+ */
+ private $itemId = null;
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * @property float $quantity
+ */
+ private $quantity = null;
+
+ /**
+ * @property float $unitPrice
+ */
+ private $unitPrice = null;
+
+ /**
+ * @property boolean $taxable
+ */
+ private $taxable = null;
+
+ /**
+ * Gets as itemId
+ *
+ * @return string
+ */
+ public function getItemId()
+ {
+ return $this->itemId;
+ }
+
+ /**
+ * Sets a new itemId
+ *
+ * @param string $itemId
+ * @return self
+ */
+ public function setItemId($itemId)
+ {
+ $this->itemId = $itemId;
+ return $this;
+ }
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+ /**
+ * Gets as quantity
+ *
+ * @return float
+ */
+ public function getQuantity()
+ {
+ return $this->quantity;
+ }
+
+ /**
+ * Sets a new quantity
+ *
+ * @param float $quantity
+ * @return self
+ */
+ public function setQuantity($quantity)
+ {
+ $this->quantity = $quantity;
+ return $this;
+ }
+
+ /**
+ * Gets as unitPrice
+ *
+ * @return float
+ */
+ public function getUnitPrice()
+ {
+ return $this->unitPrice;
+ }
+
+ /**
+ * Sets a new unitPrice
+ *
+ * @param float $unitPrice
+ * @return self
+ */
+ public function setUnitPrice($unitPrice)
+ {
+ $this->unitPrice = $unitPrice;
+ return $this;
+ }
+
+ /**
+ * Gets as taxable
+ *
+ * @return boolean
+ */
+ public function getTaxable()
+ {
+ return $this->taxable;
+ }
+
+ /**
+ * Sets a new taxable
+ *
+ * @param boolean $taxable
+ * @return self
+ */
+ public function setTaxable($taxable)
+ {
+ $this->taxable = $taxable;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ListOfAUDetailsType
+ *
+ *
+ * XSD Type: ListOfAUDetailsType
+ */
+class ListOfAUDetailsType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\AuUpdateType[] $auUpdate
+ */
+ private $auUpdate = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\AuDeleteType[] $auDelete
+ */
+ private $auDelete = null;
+
+ /**
+ * Adds as auUpdate
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\AuUpdateType $auUpdate
+ */
+ public function addToAuUpdate(\net\authorize\api\contract\v1\AuUpdateType $auUpdate)
+ {
+ $this->auUpdate[] = $auUpdate;
+ return $this;
+ }
+
+ /**
+ * isset auUpdate
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetAuUpdate($index)
+ {
+ return isset($this->auUpdate[$index]);
+ }
+
+ /**
+ * unset auUpdate
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetAuUpdate($index)
+ {
+ unset($this->auUpdate[$index]);
+ }
+
+ /**
+ * Gets as auUpdate
+ *
+ * @return \net\authorize\api\contract\v1\AuUpdateType[]
+ */
+ public function getAuUpdate()
+ {
+ return $this->auUpdate;
+ }
+
+ /**
+ * Sets a new auUpdate
+ *
+ * @param \net\authorize\api\contract\v1\AuUpdateType[] $auUpdate
+ * @return self
+ */
+ public function setAuUpdate(array $auUpdate)
+ {
+ $this->auUpdate = $auUpdate;
+ return $this;
+ }
+
+ /**
+ * Adds as auDelete
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\AuDeleteType $auDelete
+ */
+ public function addToAuDelete(\net\authorize\api\contract\v1\AuDeleteType $auDelete)
+ {
+ $this->auDelete[] = $auDelete;
+ return $this;
+ }
+
+ /**
+ * isset auDelete
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetAuDelete($index)
+ {
+ return isset($this->auDelete[$index]);
+ }
+
+ /**
+ * unset auDelete
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetAuDelete($index)
+ {
+ unset($this->auDelete[$index]);
+ }
+
+ /**
+ * Gets as auDelete
+ *
+ * @return \net\authorize\api\contract\v1\AuDeleteType[]
+ */
+ public function getAuDelete()
+ {
+ return $this->auDelete;
+ }
+
+ /**
+ * Sets a new auDelete
+ *
+ * @param \net\authorize\api\contract\v1\AuDeleteType[] $auDelete
+ * @return self
+ */
+ public function setAuDelete(array $auDelete)
+ {
+ $this->auDelete = $auDelete;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing LogoutRequest
+ */
+class LogoutRequest extends ANetApiRequestType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing LogoutResponse
+ */
+class LogoutResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing MerchantAuthenticationType
+ *
+ * \r
+ * XSD Type: merchantAuthenticationType
+ */
+class MerchantAuthenticationType
+{
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property string $transactionKey
+ */
+ private $transactionKey = null;
+
+ /**
+ * @property string $sessionToken
+ */
+ private $sessionToken = null;
+
+ /**
+ * @property string $password
+ */
+ private $password = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ImpersonationAuthenticationType
+ * $impersonationAuthentication
+ */
+ private $impersonationAuthentication = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\FingerPrintType $fingerPrint
+ */
+ private $fingerPrint = null;
+
+ /**
+ * @property string $clientKey
+ */
+ private $clientKey = null;
+
+ /**
+ * @property string $accessToken
+ */
+ private $accessToken = null;
+
+ /**
+ * @property string $mobileDeviceId
+ */
+ private $mobileDeviceId = null;
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;\r
+ return $this;
+ }
+
+ /**
+ * Gets as transactionKey
+ *
+ * @return string
+ */
+ public function getTransactionKey()
+ {
+ return $this->transactionKey;
+ }
+
+ /**
+ * Sets a new transactionKey
+ *
+ * @param string $transactionKey
+ * @return self
+ */
+ public function setTransactionKey($transactionKey)
+ {
+ $this->transactionKey = $transactionKey;\r
+ return $this;
+ }
+
+ /**
+ * Gets as sessionToken
+ *
+ * @return string
+ */
+ public function getSessionToken()
+ {
+ return $this->sessionToken;
+ }
+
+ /**
+ * Sets a new sessionToken
+ *
+ * @param string $sessionToken
+ * @return self
+ */
+ public function setSessionToken($sessionToken)
+ {
+ $this->sessionToken = $sessionToken;\r
+ return $this;
+ }
+
+ /**
+ * Gets as password
+ *
+ * @return string
+ */
+ public function getPassword()
+ {
+ return $this->password;
+ }
+
+ /**
+ * Sets a new password
+ *
+ * @param string $password
+ * @return self
+ */
+ public function setPassword($password)
+ {
+ $this->password = $password;\r
+ return $this;
+ }
+
+ /**
+ * Gets as impersonationAuthentication
+ *
+ * @return \net\authorize\api\contract\v1\ImpersonationAuthenticationType
+ */
+ public function getImpersonationAuthentication()
+ {
+ return $this->impersonationAuthentication;
+ }
+
+ /**
+ * Sets a new impersonationAuthentication
+ *
+ * @param \net\authorize\api\contract\v1\ImpersonationAuthenticationType
+ * $impersonationAuthentication
+ * @return self
+ */
+ public function setImpersonationAuthentication(\net\authorize\api\contract\v1\ImpersonationAuthenticationType $impersonationAuthentication)
+ {
+ $this->impersonationAuthentication = $impersonationAuthentication;\r
+ return $this;
+ }
+
+ /**
+ * Gets as fingerPrint
+ *
+ * @return \net\authorize\api\contract\v1\FingerPrintType
+ */
+ public function getFingerPrint()
+ {
+ return $this->fingerPrint;
+ }
+
+ /**
+ * Sets a new fingerPrint
+ *
+ * @param \net\authorize\api\contract\v1\FingerPrintType $fingerPrint
+ * @return self
+ */
+ public function setFingerPrint(\net\authorize\api\contract\v1\FingerPrintType $fingerPrint)
+ {
+ $this->fingerPrint = $fingerPrint;\r
+ return $this;
+ }
+
+ /**
+ * Gets as clientKey
+ *
+ * @return string
+ */
+ public function getClientKey()
+ {
+ return $this->clientKey;
+ }
+
+ /**
+ * Sets a new clientKey
+ *
+ * @param string $clientKey
+ * @return self
+ */
+ public function setClientKey($clientKey)
+ {
+ $this->clientKey = $clientKey;\r
+ return $this;
+ }
+
+ /**
+ * Gets as accessToken
+ *
+ * @return string
+ */
+ public function getAccessToken()
+ {
+ return $this->accessToken;
+ }
+
+ /**
+ * Sets a new accessToken
+ *
+ * @param string $accessToken
+ * @return self
+ */
+ public function setAccessToken($accessToken)
+ {
+ $this->accessToken = $accessToken;\r
+ return $this;
+ }
+
+ /**
+ * Gets as mobileDeviceId
+ *
+ * @return string
+ */
+ public function getMobileDeviceId()
+ {
+ return $this->mobileDeviceId;
+ }
+
+ /**
+ * Sets a new mobileDeviceId
+ *
+ * @param string $mobileDeviceId
+ * @return self
+ */
+ public function setMobileDeviceId($mobileDeviceId)
+ {
+ $this->mobileDeviceId = $mobileDeviceId;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing MerchantContactType
+ *
+ *
+ * XSD Type: merchantContactType
+ */
+class MerchantContactType
+{
+
+ /**
+ * @property string $merchantName
+ */
+ private $merchantName = null;
+
+ /**
+ * @property string $merchantAddress
+ */
+ private $merchantAddress = null;
+
+ /**
+ * @property string $merchantCity
+ */
+ private $merchantCity = null;
+
+ /**
+ * @property string $merchantState
+ */
+ private $merchantState = null;
+
+ /**
+ * @property string $merchantZip
+ */
+ private $merchantZip = null;
+
+ /**
+ * @property string $merchantPhone
+ */
+ private $merchantPhone = null;
+
+ /**
+ * Gets as merchantName
+ *
+ * @return string
+ */
+ public function getMerchantName()
+ {
+ return $this->merchantName;
+ }
+
+ /**
+ * Sets a new merchantName
+ *
+ * @param string $merchantName
+ * @return self
+ */
+ public function setMerchantName($merchantName)
+ {
+ $this->merchantName = $merchantName;
+ return $this;
+ }
+
+ /**
+ * Gets as merchantAddress
+ *
+ * @return string
+ */
+ public function getMerchantAddress()
+ {
+ return $this->merchantAddress;
+ }
+
+ /**
+ * Sets a new merchantAddress
+ *
+ * @param string $merchantAddress
+ * @return self
+ */
+ public function setMerchantAddress($merchantAddress)
+ {
+ $this->merchantAddress = $merchantAddress;
+ return $this;
+ }
+
+ /**
+ * Gets as merchantCity
+ *
+ * @return string
+ */
+ public function getMerchantCity()
+ {
+ return $this->merchantCity;
+ }
+
+ /**
+ * Sets a new merchantCity
+ *
+ * @param string $merchantCity
+ * @return self
+ */
+ public function setMerchantCity($merchantCity)
+ {
+ $this->merchantCity = $merchantCity;
+ return $this;
+ }
+
+ /**
+ * Gets as merchantState
+ *
+ * @return string
+ */
+ public function getMerchantState()
+ {
+ return $this->merchantState;
+ }
+
+ /**
+ * Sets a new merchantState
+ *
+ * @param string $merchantState
+ * @return self
+ */
+ public function setMerchantState($merchantState)
+ {
+ $this->merchantState = $merchantState;
+ return $this;
+ }
+
+ /**
+ * Gets as merchantZip
+ *
+ * @return string
+ */
+ public function getMerchantZip()
+ {
+ return $this->merchantZip;
+ }
+
+ /**
+ * Sets a new merchantZip
+ *
+ * @param string $merchantZip
+ * @return self
+ */
+ public function setMerchantZip($merchantZip)
+ {
+ $this->merchantZip = $merchantZip;
+ return $this;
+ }
+
+ /**
+ * Gets as merchantPhone
+ *
+ * @return string
+ */
+ public function getMerchantPhone()
+ {
+ return $this->merchantPhone;
+ }
+
+ /**
+ * Sets a new merchantPhone
+ *
+ * @param string $merchantPhone
+ * @return self
+ */
+ public function setMerchantPhone($merchantPhone)
+ {
+ $this->merchantPhone = $merchantPhone;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing MessagesType
+ *
+ *
+ * XSD Type: messagesType
+ */
+class MessagesType
+{
+
+ /**
+ * @property string $resultCode
+ */
+ private $resultCode = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\MessagesType\MessageAType[] $message
+ */
+ private $message = null;
+
+ /**
+ * Gets as resultCode
+ *
+ * @return string
+ */
+ public function getResultCode()
+ {
+ return $this->resultCode;
+ }
+
+ /**
+ * Sets a new resultCode
+ *
+ * @param string $resultCode
+ * @return self
+ */
+ public function setResultCode($resultCode)
+ {
+ $this->resultCode = $resultCode;
+ return $this;
+ }
+
+ /**
+ * Adds as message
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\MessagesType\MessageAType $message
+ */
+ public function addToMessage(\net\authorize\api\contract\v1\MessagesType\MessageAType $message)
+ {
+ $this->message[] = $message;
+ return $this;
+ }
+
+ /**
+ * isset message
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetMessage($index)
+ {
+ return isset($this->message[$index]);
+ }
+
+ /**
+ * unset message
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetMessage($index)
+ {
+ unset($this->message[$index]);
+ }
+
+ /**
+ * Gets as message
+ *
+ * @return \net\authorize\api\contract\v1\MessagesType\MessageAType[]
+ */
+ public function getMessage()
+ {
+ return $this->message;
+ }
+
+ /**
+ * Sets a new message
+ *
+ * @param \net\authorize\api\contract\v1\MessagesType\MessageAType[] $message
+ * @return self
+ */
+ public function setMessage(array $message)
+ {
+ $this->message = $message;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\MessagesType;
+
+/**
+ * Class representing MessageAType
+ */
+class MessageAType
+{
+
+ /**
+ * @property string $code
+ */
+ private $code = null;
+
+ /**
+ * @property string $text
+ */
+ private $text = null;
+
+ /**
+ * Gets as code
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Sets a new code
+ *
+ * @param string $code
+ * @return self
+ */
+ public function setCode($code)
+ {
+ $this->code = $code;
+ return $this;
+ }
+
+ /**
+ * Gets as text
+ *
+ * @return string
+ */
+ public function getText()
+ {
+ return $this->text;
+ }
+
+ /**
+ * Sets a new text
+ *
+ * @param string $text
+ * @return self
+ */
+ public function setText($text)
+ {
+ $this->text = $text;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing MobileDeviceLoginRequest
+ */
+class MobileDeviceLoginRequest extends ANetApiRequestType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing MobileDeviceLoginResponse
+ */
+class MobileDeviceLoginResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\MerchantContactType $merchantContact
+ */
+ private $merchantContact = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PermissionType[] $userPermissions
+ */
+ private $userPermissions = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransRetailInfoType $merchantAccount
+ */
+ private $merchantAccount = null;
+
+ /**
+ * Gets as merchantContact
+ *
+ * @return \net\authorize\api\contract\v1\MerchantContactType
+ */
+ public function getMerchantContact()
+ {
+ return $this->merchantContact;
+ }
+
+ /**
+ * Sets a new merchantContact
+ *
+ * @param \net\authorize\api\contract\v1\MerchantContactType $merchantContact
+ * @return self
+ */
+ public function setMerchantContact(\net\authorize\api\contract\v1\MerchantContactType $merchantContact)
+ {
+ $this->merchantContact = $merchantContact;
+ return $this;
+ }
+
+ /**
+ * Adds as permission
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\PermissionType $permission
+ */
+ public function addToUserPermissions(\net\authorize\api\contract\v1\PermissionType $permission)
+ {
+ $this->userPermissions[] = $permission;
+ return $this;
+ }
+
+ /**
+ * isset userPermissions
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetUserPermissions($index)
+ {
+ return isset($this->userPermissions[$index]);
+ }
+
+ /**
+ * unset userPermissions
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetUserPermissions($index)
+ {
+ unset($this->userPermissions[$index]);
+ }
+
+ /**
+ * Gets as userPermissions
+ *
+ * @return \net\authorize\api\contract\v1\PermissionType[]
+ */
+ public function getUserPermissions()
+ {
+ return $this->userPermissions;
+ }
+
+ /**
+ * Sets a new userPermissions
+ *
+ * @param \net\authorize\api\contract\v1\PermissionType[] $userPermissions
+ * @return self
+ */
+ public function setUserPermissions(array $userPermissions)
+ {
+ $this->userPermissions = $userPermissions;
+ return $this;
+ }
+
+ /**
+ * Gets as merchantAccount
+ *
+ * @return \net\authorize\api\contract\v1\TransRetailInfoType
+ */
+ public function getMerchantAccount()
+ {
+ return $this->merchantAccount;
+ }
+
+ /**
+ * Sets a new merchantAccount
+ *
+ * @param \net\authorize\api\contract\v1\TransRetailInfoType $merchantAccount
+ * @return self
+ */
+ public function setMerchantAccount(\net\authorize\api\contract\v1\TransRetailInfoType $merchantAccount)
+ {
+ $this->merchantAccount = $merchantAccount;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing MobileDeviceRegistrationRequest
+ */
+class MobileDeviceRegistrationRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\MobileDeviceType $mobileDevice
+ */
+ private $mobileDevice = null;
+
+ /**
+ * Gets as mobileDevice
+ *
+ * @return \net\authorize\api\contract\v1\MobileDeviceType
+ */
+ public function getMobileDevice()
+ {
+ return $this->mobileDevice;
+ }
+
+ /**
+ * Sets a new mobileDevice
+ *
+ * @param \net\authorize\api\contract\v1\MobileDeviceType $mobileDevice
+ * @return self
+ */
+ public function setMobileDevice(\net\authorize\api\contract\v1\MobileDeviceType $mobileDevice)
+ {
+ $this->mobileDevice = $mobileDevice;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing MobileDeviceRegistrationResponse
+ */
+class MobileDeviceRegistrationResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing MobileDeviceType
+ *
+ *
+ * XSD Type: mobileDeviceType
+ */
+class MobileDeviceType
+{
+
+ /**
+ * @property string $mobileDeviceId
+ */
+ private $mobileDeviceId = null;
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * @property string $phoneNumber
+ */
+ private $phoneNumber = null;
+
+ /**
+ * @property string $devicePlatform
+ */
+ private $devicePlatform = null;
+
+ /**
+ * @property string $deviceActivation
+ */
+ private $deviceActivation = null;
+
+ /**
+ * Gets as mobileDeviceId
+ *
+ * @return string
+ */
+ public function getMobileDeviceId()
+ {
+ return $this->mobileDeviceId;
+ }
+
+ /**
+ * Sets a new mobileDeviceId
+ *
+ * @param string $mobileDeviceId
+ * @return self
+ */
+ public function setMobileDeviceId($mobileDeviceId)
+ {
+ $this->mobileDeviceId = $mobileDeviceId;
+ return $this;
+ }
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+ /**
+ * Gets as phoneNumber
+ *
+ * @return string
+ */
+ public function getPhoneNumber()
+ {
+ return $this->phoneNumber;
+ }
+
+ /**
+ * Sets a new phoneNumber
+ *
+ * @param string $phoneNumber
+ * @return self
+ */
+ public function setPhoneNumber($phoneNumber)
+ {
+ $this->phoneNumber = $phoneNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as devicePlatform
+ *
+ * @return string
+ */
+ public function getDevicePlatform()
+ {
+ return $this->devicePlatform;
+ }
+
+ /**
+ * Sets a new devicePlatform
+ *
+ * @param string $devicePlatform
+ * @return self
+ */
+ public function setDevicePlatform($devicePlatform)
+ {
+ $this->devicePlatform = $devicePlatform;
+ return $this;
+ }
+
+ /**
+ * Gets as deviceActivation
+ *
+ * @return string
+ */
+ public function getDeviceActivation()
+ {
+ return $this->deviceActivation;
+ }
+
+ /**
+ * Sets a new deviceActivation
+ *
+ * @param string $deviceActivation
+ * @return self
+ */
+ public function setDeviceActivation($deviceActivation)
+ {
+ $this->deviceActivation = $deviceActivation;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing NameAndAddressType
+ *
+ *
+ * XSD Type: nameAndAddressType
+ */
+class NameAndAddressType
+{
+
+ /**
+ * @property string $firstName
+ */
+ private $firstName = null;
+
+ /**
+ * @property string $lastName
+ */
+ private $lastName = null;
+
+ /**
+ * @property string $company
+ */
+ private $company = null;
+
+ /**
+ * @property string $address
+ */
+ private $address = null;
+
+ /**
+ * @property string $city
+ */
+ private $city = null;
+
+ /**
+ * @property string $state
+ */
+ private $state = null;
+
+ /**
+ * @property string $zip
+ */
+ private $zip = null;
+
+ /**
+ * @property string $country
+ */
+ private $country = null;
+
+ /**
+ * Gets as firstName
+ *
+ * @return string
+ */
+ public function getFirstName()
+ {
+ return $this->firstName;
+ }
+
+ /**
+ * Sets a new firstName
+ *
+ * @param string $firstName
+ * @return self
+ */
+ public function setFirstName($firstName)
+ {
+ $this->firstName = $firstName;
+ return $this;
+ }
+
+ /**
+ * Gets as lastName
+ *
+ * @return string
+ */
+ public function getLastName()
+ {
+ return $this->lastName;
+ }
+
+ /**
+ * Sets a new lastName
+ *
+ * @param string $lastName
+ * @return self
+ */
+ public function setLastName($lastName)
+ {
+ $this->lastName = $lastName;
+ return $this;
+ }
+
+ /**
+ * Gets as company
+ *
+ * @return string
+ */
+ public function getCompany()
+ {
+ return $this->company;
+ }
+
+ /**
+ * Sets a new company
+ *
+ * @param string $company
+ * @return self
+ */
+ public function setCompany($company)
+ {
+ $this->company = $company;
+ return $this;
+ }
+
+ /**
+ * Gets as address
+ *
+ * @return string
+ */
+ public function getAddress()
+ {
+ return $this->address;
+ }
+
+ /**
+ * Sets a new address
+ *
+ * @param string $address
+ * @return self
+ */
+ public function setAddress($address)
+ {
+ $this->address = $address;
+ return $this;
+ }
+
+ /**
+ * Gets as city
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+ return $this->city;
+ }
+
+ /**
+ * Sets a new city
+ *
+ * @param string $city
+ * @return self
+ */
+ public function setCity($city)
+ {
+ $this->city = $city;
+ return $this;
+ }
+
+ /**
+ * Gets as state
+ *
+ * @return string
+ */
+ public function getState()
+ {
+ return $this->state;
+ }
+
+ /**
+ * Sets a new state
+ *
+ * @param string $state
+ * @return self
+ */
+ public function setState($state)
+ {
+ $this->state = $state;
+ return $this;
+ }
+
+ /**
+ * Gets as zip
+ *
+ * @return string
+ */
+ public function getZip()
+ {
+ return $this->zip;
+ }
+
+ /**
+ * Sets a new zip
+ *
+ * @param string $zip
+ * @return self
+ */
+ public function setZip($zip)
+ {
+ $this->zip = $zip;
+ return $this;
+ }
+
+ /**
+ * Gets as country
+ *
+ * @return string
+ */
+ public function getCountry()
+ {
+ return $this->country;
+ }
+
+ /**
+ * Sets a new country
+ *
+ * @param string $country
+ * @return self
+ */
+ public function setCountry($country)
+ {
+ $this->country = $country;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing OpaqueDataType
+ *
+ *
+ * XSD Type: opaqueDataType
+ */
+class OpaqueDataType
+{
+
+ /**
+ * @property string $dataDescriptor
+ */
+ private $dataDescriptor = null;
+
+ /**
+ * @property string $dataValue
+ */
+ private $dataValue = null;
+
+ /**
+ * @property string $dataKey
+ */
+ private $dataKey = null;
+
+ /**
+ * Gets as dataDescriptor
+ *
+ * @return string
+ */
+ public function getDataDescriptor()
+ {
+ return $this->dataDescriptor;
+ }
+
+ /**
+ * Sets a new dataDescriptor
+ *
+ * @param string $dataDescriptor
+ * @return self
+ */
+ public function setDataDescriptor($dataDescriptor)
+ {
+ $this->dataDescriptor = $dataDescriptor;
+ return $this;
+ }
+
+ /**
+ * Gets as dataValue
+ *
+ * @return string
+ */
+ public function getDataValue()
+ {
+ return $this->dataValue;
+ }
+
+ /**
+ * Sets a new dataValue
+ *
+ * @param string $dataValue
+ * @return self
+ */
+ public function setDataValue($dataValue)
+ {
+ $this->dataValue = $dataValue;
+ return $this;
+ }
+
+ /**
+ * Gets as dataKey
+ *
+ * @return string
+ */
+ public function getDataKey()
+ {
+ return $this->dataKey;
+ }
+
+ /**
+ * Sets a new dataKey
+ *
+ * @param string $dataKey
+ * @return self
+ */
+ public function setDataKey($dataKey)
+ {
+ $this->dataKey = $dataKey;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing OrderExType
+ *
+ *
+ * XSD Type: orderExType
+ */
+class OrderExType extends OrderType
+{
+
+ /**
+ * @property string $purchaseOrderNumber
+ */
+ private $purchaseOrderNumber = null;
+
+ /**
+ * Gets as purchaseOrderNumber
+ *
+ * @return string
+ */
+ public function getPurchaseOrderNumber()
+ {
+ return $this->purchaseOrderNumber;
+ }
+
+ /**
+ * Sets a new purchaseOrderNumber
+ *
+ * @param string $purchaseOrderNumber
+ * @return self
+ */
+ public function setPurchaseOrderNumber($purchaseOrderNumber)
+ {
+ $this->purchaseOrderNumber = $purchaseOrderNumber;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing OrderType
+ *
+ *
+ * XSD Type: orderType
+ */
+class OrderType
+{
+
+ /**
+ * @property string $invoiceNumber
+ */
+ private $invoiceNumber = null;
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * Gets as invoiceNumber
+ *
+ * @return string
+ */
+ public function getInvoiceNumber()
+ {
+ return $this->invoiceNumber;
+ }
+
+ /**
+ * Sets a new invoiceNumber
+ *
+ * @param string $invoiceNumber
+ * @return self
+ */
+ public function setInvoiceNumber($invoiceNumber)
+ {
+ $this->invoiceNumber = $invoiceNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PagingType
+ *
+ *
+ * XSD Type: Paging
+ */
+class PagingType
+{
+
+ /**
+ * @property integer $limit
+ */
+ private $limit = null;
+
+ /**
+ * @property integer $offset
+ */
+ private $offset = null;
+
+ /**
+ * Gets as limit
+ *
+ * @return integer
+ */
+ public function getLimit()
+ {
+ return $this->limit;
+ }
+
+ /**
+ * Sets a new limit
+ *
+ * @param integer $limit
+ * @return self
+ */
+ public function setLimit($limit)
+ {
+ $this->limit = $limit;
+ return $this;
+ }
+
+ /**
+ * Gets as offset
+ *
+ * @return integer
+ */
+ public function getOffset()
+ {
+ return $this->offset;
+ }
+
+ /**
+ * Sets a new offset
+ *
+ * @param integer $offset
+ * @return self
+ */
+ public function setOffset($offset)
+ {
+ $this->offset = $offset;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PayPalType
+ *
+ *
+ * XSD Type: payPalType
+ */
+class PayPalType
+{
+
+ /**
+ * @property string $successUrl
+ */
+ private $successUrl = null;
+
+ /**
+ * @property string $cancelUrl
+ */
+ private $cancelUrl = null;
+
+ /**
+ * @property string $paypalLc
+ */
+ private $paypalLc = null;
+
+ /**
+ * @property string $paypalHdrImg
+ */
+ private $paypalHdrImg = null;
+
+ /**
+ * @property string $paypalPayflowcolor
+ */
+ private $paypalPayflowcolor = null;
+
+ /**
+ * @property string $payerID
+ */
+ private $payerID = null;
+
+ /**
+ * Gets as successUrl
+ *
+ * @return string
+ */
+ public function getSuccessUrl()
+ {
+ return $this->successUrl;
+ }
+
+ /**
+ * Sets a new successUrl
+ *
+ * @param string $successUrl
+ * @return self
+ */
+ public function setSuccessUrl($successUrl)
+ {
+ $this->successUrl = $successUrl;
+ return $this;
+ }
+
+ /**
+ * Gets as cancelUrl
+ *
+ * @return string
+ */
+ public function getCancelUrl()
+ {
+ return $this->cancelUrl;
+ }
+
+ /**
+ * Sets a new cancelUrl
+ *
+ * @param string $cancelUrl
+ * @return self
+ */
+ public function setCancelUrl($cancelUrl)
+ {
+ $this->cancelUrl = $cancelUrl;
+ return $this;
+ }
+
+ /**
+ * Gets as paypalLc
+ *
+ * @return string
+ */
+ public function getPaypalLc()
+ {
+ return $this->paypalLc;
+ }
+
+ /**
+ * Sets a new paypalLc
+ *
+ * @param string $paypalLc
+ * @return self
+ */
+ public function setPaypalLc($paypalLc)
+ {
+ $this->paypalLc = $paypalLc;
+ return $this;
+ }
+
+ /**
+ * Gets as paypalHdrImg
+ *
+ * @return string
+ */
+ public function getPaypalHdrImg()
+ {
+ return $this->paypalHdrImg;
+ }
+
+ /**
+ * Sets a new paypalHdrImg
+ *
+ * @param string $paypalHdrImg
+ * @return self
+ */
+ public function setPaypalHdrImg($paypalHdrImg)
+ {
+ $this->paypalHdrImg = $paypalHdrImg;
+ return $this;
+ }
+
+ /**
+ * Gets as paypalPayflowcolor
+ *
+ * @return string
+ */
+ public function getPaypalPayflowcolor()
+ {
+ return $this->paypalPayflowcolor;
+ }
+
+ /**
+ * Sets a new paypalPayflowcolor
+ *
+ * @param string $paypalPayflowcolor
+ * @return self
+ */
+ public function setPaypalPayflowcolor($paypalPayflowcolor)
+ {
+ $this->paypalPayflowcolor = $paypalPayflowcolor;
+ return $this;
+ }
+
+ /**
+ * Gets as payerID
+ *
+ * @return string
+ */
+ public function getPayerID()
+ {
+ return $this->payerID;
+ }
+
+ /**
+ * Sets a new payerID
+ *
+ * @param string $payerID
+ * @return self
+ */
+ public function setPayerID($payerID)
+ {
+ $this->payerID = $payerID;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PaymentDetailsType
+ *
+ *
+ * XSD Type: paymentDetails
+ */
+class PaymentDetailsType
+{
+
+ /**
+ * @property string $currency
+ */
+ private $currency = null;
+
+ /**
+ * @property string $promoCode
+ */
+ private $promoCode = null;
+
+ /**
+ * @property string $misc
+ */
+ private $misc = null;
+
+ /**
+ * @property string $giftWrap
+ */
+ private $giftWrap = null;
+
+ /**
+ * @property string $discount
+ */
+ private $discount = null;
+
+ /**
+ * @property string $tax
+ */
+ private $tax = null;
+
+ /**
+ * @property string $shippingHandling
+ */
+ private $shippingHandling = null;
+
+ /**
+ * @property string $subTotal
+ */
+ private $subTotal = null;
+
+ /**
+ * @property string $orderID
+ */
+ private $orderID = null;
+
+ /**
+ * @property string $amount
+ */
+ private $amount = null;
+
+ /**
+ * Gets as currency
+ *
+ * @return string
+ */
+ public function getCurrency()
+ {
+ return $this->currency;
+ }
+
+ /**
+ * Sets a new currency
+ *
+ * @param string $currency
+ * @return self
+ */
+ public function setCurrency($currency)
+ {
+ $this->currency = $currency;
+ return $this;
+ }
+
+ /**
+ * Gets as promoCode
+ *
+ * @return string
+ */
+ public function getPromoCode()
+ {
+ return $this->promoCode;
+ }
+
+ /**
+ * Sets a new promoCode
+ *
+ * @param string $promoCode
+ * @return self
+ */
+ public function setPromoCode($promoCode)
+ {
+ $this->promoCode = $promoCode;
+ return $this;
+ }
+
+ /**
+ * Gets as misc
+ *
+ * @return string
+ */
+ public function getMisc()
+ {
+ return $this->misc;
+ }
+
+ /**
+ * Sets a new misc
+ *
+ * @param string $misc
+ * @return self
+ */
+ public function setMisc($misc)
+ {
+ $this->misc = $misc;
+ return $this;
+ }
+
+ /**
+ * Gets as giftWrap
+ *
+ * @return string
+ */
+ public function getGiftWrap()
+ {
+ return $this->giftWrap;
+ }
+
+ /**
+ * Sets a new giftWrap
+ *
+ * @param string $giftWrap
+ * @return self
+ */
+ public function setGiftWrap($giftWrap)
+ {
+ $this->giftWrap = $giftWrap;
+ return $this;
+ }
+
+ /**
+ * Gets as discount
+ *
+ * @return string
+ */
+ public function getDiscount()
+ {
+ return $this->discount;
+ }
+
+ /**
+ * Sets a new discount
+ *
+ * @param string $discount
+ * @return self
+ */
+ public function setDiscount($discount)
+ {
+ $this->discount = $discount;
+ return $this;
+ }
+
+ /**
+ * Gets as tax
+ *
+ * @return string
+ */
+ public function getTax()
+ {
+ return $this->tax;
+ }
+
+ /**
+ * Sets a new tax
+ *
+ * @param string $tax
+ * @return self
+ */
+ public function setTax($tax)
+ {
+ $this->tax = $tax;
+ return $this;
+ }
+
+ /**
+ * Gets as shippingHandling
+ *
+ * @return string
+ */
+ public function getShippingHandling()
+ {
+ return $this->shippingHandling;
+ }
+
+ /**
+ * Sets a new shippingHandling
+ *
+ * @param string $shippingHandling
+ * @return self
+ */
+ public function setShippingHandling($shippingHandling)
+ {
+ $this->shippingHandling = $shippingHandling;
+ return $this;
+ }
+
+ /**
+ * Gets as subTotal
+ *
+ * @return string
+ */
+ public function getSubTotal()
+ {
+ return $this->subTotal;
+ }
+
+ /**
+ * Sets a new subTotal
+ *
+ * @param string $subTotal
+ * @return self
+ */
+ public function setSubTotal($subTotal)
+ {
+ $this->subTotal = $subTotal;
+ return $this;
+ }
+
+ /**
+ * Gets as orderID
+ *
+ * @return string
+ */
+ public function getOrderID()
+ {
+ return $this->orderID;
+ }
+
+ /**
+ * Sets a new orderID
+ *
+ * @param string $orderID
+ * @return self
+ */
+ public function setOrderID($orderID)
+ {
+ $this->orderID = $orderID;
+ return $this;
+ }
+
+ /**
+ * Gets as amount
+ *
+ * @return string
+ */
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ /**
+ * Sets a new amount
+ *
+ * @param string $amount
+ * @return self
+ */
+ public function setAmount($amount)
+ {
+ $this->amount = $amount;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PaymentEmvType
+ *
+ *
+ * XSD Type: paymentEmvType
+ */
+class PaymentEmvType
+{
+
+ /**
+ * @property mixed $emvData
+ */
+ private $emvData = null;
+
+ /**
+ * @property mixed $emvDescriptor
+ */
+ private $emvDescriptor = null;
+
+ /**
+ * @property mixed $emvVersion
+ */
+ private $emvVersion = null;
+
+ /**
+ * Gets as emvData
+ *
+ * @return mixed
+ */
+ public function getEmvData()
+ {
+ return $this->emvData;
+ }
+
+ /**
+ * Sets a new emvData
+ *
+ * @param mixed $emvData
+ * @return self
+ */
+ public function setEmvData($emvData)
+ {
+ $this->emvData = $emvData;
+ return $this;
+ }
+
+ /**
+ * Gets as emvDescriptor
+ *
+ * @return mixed
+ */
+ public function getEmvDescriptor()
+ {
+ return $this->emvDescriptor;
+ }
+
+ /**
+ * Sets a new emvDescriptor
+ *
+ * @param mixed $emvDescriptor
+ * @return self
+ */
+ public function setEmvDescriptor($emvDescriptor)
+ {
+ $this->emvDescriptor = $emvDescriptor;
+ return $this;
+ }
+
+ /**
+ * Gets as emvVersion
+ *
+ * @return mixed
+ */
+ public function getEmvVersion()
+ {
+ return $this->emvVersion;
+ }
+
+ /**
+ * Sets a new emvVersion
+ *
+ * @param mixed $emvVersion
+ * @return self
+ */
+ public function setEmvVersion($emvVersion)
+ {
+ $this->emvVersion = $emvVersion;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PaymentMaskedType
+ *
+ *
+ * XSD Type: paymentMaskedType
+ */
+class PaymentMaskedType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CreditCardMaskedType $creditCard
+ */
+ private $creditCard = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\BankAccountMaskedType $bankAccount
+ */
+ private $bankAccount = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\TokenMaskedType $tokenInformation
+ */
+ private $tokenInformation = null;
+
+ /**
+ * Gets as creditCard
+ *
+ * @return \net\authorize\api\contract\v1\CreditCardMaskedType
+ */
+ public function getCreditCard()
+ {
+ return $this->creditCard;
+ }
+
+ /**
+ * Sets a new creditCard
+ *
+ * @param \net\authorize\api\contract\v1\CreditCardMaskedType $creditCard
+ * @return self
+ */
+ public function setCreditCard(\net\authorize\api\contract\v1\CreditCardMaskedType $creditCard)
+ {
+ $this->creditCard = $creditCard;
+ return $this;
+ }
+
+ /**
+ * Gets as bankAccount
+ *
+ * @return \net\authorize\api\contract\v1\BankAccountMaskedType
+ */
+ public function getBankAccount()
+ {
+ return $this->bankAccount;
+ }
+
+ /**
+ * Sets a new bankAccount
+ *
+ * @param \net\authorize\api\contract\v1\BankAccountMaskedType $bankAccount
+ * @return self
+ */
+ public function setBankAccount(\net\authorize\api\contract\v1\BankAccountMaskedType $bankAccount)
+ {
+ $this->bankAccount = $bankAccount;
+ return $this;
+ }
+
+ /**
+ * Gets as tokenInformation
+ *
+ * @return \net\authorize\api\contract\v1\TokenMaskedType
+ */
+ public function getTokenInformation()
+ {
+ return $this->tokenInformation;
+ }
+
+ /**
+ * Sets a new tokenInformation
+ *
+ * @param \net\authorize\api\contract\v1\TokenMaskedType $tokenInformation
+ * @return self
+ */
+ public function setTokenInformation(\net\authorize\api\contract\v1\TokenMaskedType $tokenInformation)
+ {
+ $this->tokenInformation = $tokenInformation;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PaymentProfileType
+ *
+ *
+ * XSD Type: paymentProfile
+ */
+class PaymentProfileType
+{
+
+ /**
+ * @property string $paymentProfileId
+ */
+ private $paymentProfileId = null;
+
+ /**
+ * @property string $cardCode
+ */
+ private $cardCode = null;
+
+ /**
+ * Gets as paymentProfileId
+ *
+ * @return string
+ */
+ public function getPaymentProfileId()
+ {
+ return $this->paymentProfileId;
+ }
+
+ /**
+ * Sets a new paymentProfileId
+ *
+ * @param string $paymentProfileId
+ * @return self
+ */
+ public function setPaymentProfileId($paymentProfileId)
+ {
+ $this->paymentProfileId = $paymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as cardCode
+ *
+ * @return string
+ */
+ public function getCardCode()
+ {
+ return $this->cardCode;
+ }
+
+ /**
+ * Sets a new cardCode
+ *
+ * @param string $cardCode
+ * @return self
+ */
+ public function setCardCode($cardCode)
+ {
+ $this->cardCode = $cardCode;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PaymentScheduleType
+ *
+ *
+ * XSD Type: paymentScheduleType
+ */
+class PaymentScheduleType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentScheduleType\IntervalAType
+ * $interval
+ */
+ private $interval = null;
+
+ /**
+ * @property \DateTime $startDate
+ */
+ private $startDate = null;
+
+ /**
+ * @property integer $totalOccurrences
+ */
+ private $totalOccurrences = null;
+
+ /**
+ * @property integer $trialOccurrences
+ */
+ private $trialOccurrences = null;
+
+ /**
+ * Gets as interval
+ *
+ * @return \net\authorize\api\contract\v1\PaymentScheduleType\IntervalAType
+ */
+ public function getInterval()
+ {
+ return $this->interval;
+ }
+
+ /**
+ * Sets a new interval
+ *
+ * @param \net\authorize\api\contract\v1\PaymentScheduleType\IntervalAType
+ * $interval
+ * @return self
+ */
+ public function setInterval(\net\authorize\api\contract\v1\PaymentScheduleType\IntervalAType $interval)
+ {
+ $this->interval = $interval;
+ return $this;
+ }
+
+ /**
+ * Gets as startDate
+ *
+ * @return \DateTime
+ */
+ public function getStartDate()
+ {
+ return $this->startDate;
+ }
+
+ /**
+ * Sets a new startDate
+ *
+ * @param \DateTime $startDate
+ * @return self
+ */
+ public function setStartDate(\DateTime $startDate)
+ {
+ $this->startDate = $startDate;
+ return $this;
+ }
+
+ /**
+ * Gets as totalOccurrences
+ *
+ * @return integer
+ */
+ public function getTotalOccurrences()
+ {
+ return $this->totalOccurrences;
+ }
+
+ /**
+ * Sets a new totalOccurrences
+ *
+ * @param integer $totalOccurrences
+ * @return self
+ */
+ public function setTotalOccurrences($totalOccurrences)
+ {
+ $this->totalOccurrences = $totalOccurrences;
+ return $this;
+ }
+
+ /**
+ * Gets as trialOccurrences
+ *
+ * @return integer
+ */
+ public function getTrialOccurrences()
+ {
+ return $this->trialOccurrences;
+ }
+
+ /**
+ * Sets a new trialOccurrences
+ *
+ * @param integer $trialOccurrences
+ * @return self
+ */
+ public function setTrialOccurrences($trialOccurrences)
+ {
+ $this->trialOccurrences = $trialOccurrences;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\PaymentScheduleType;
+
+/**
+ * Class representing IntervalAType
+ */
+class IntervalAType
+{
+
+ /**
+ * @property integer $length
+ */
+ private $length = null;
+
+ /**
+ * @property string $unit
+ */
+ private $unit = null;
+
+ /**
+ * Gets as length
+ *
+ * @return integer
+ */
+ public function getLength()
+ {
+ return $this->length;
+ }
+
+ /**
+ * Sets a new length
+ *
+ * @param integer $length
+ * @return self
+ */
+ public function setLength($length)
+ {
+ $this->length = $length;
+ return $this;
+ }
+
+ /**
+ * Gets as unit
+ *
+ * @return string
+ */
+ public function getUnit()
+ {
+ return $this->unit;
+ }
+
+ /**
+ * Sets a new unit
+ *
+ * @param string $unit
+ * @return self
+ */
+ public function setUnit($unit)
+ {
+ $this->unit = $unit;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PaymentSimpleType
+ *
+ *
+ * XSD Type: paymentSimpleType
+ */
+class PaymentSimpleType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CreditCardSimpleType $creditCard
+ */
+ private $creditCard = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\BankAccountType $bankAccount
+ */
+ private $bankAccount = null;
+
+ /**
+ * Gets as creditCard
+ *
+ * @return \net\authorize\api\contract\v1\CreditCardSimpleType
+ */
+ public function getCreditCard()
+ {
+ return $this->creditCard;
+ }
+
+ /**
+ * Sets a new creditCard
+ *
+ * @param \net\authorize\api\contract\v1\CreditCardSimpleType $creditCard
+ * @return self
+ */
+ public function setCreditCard(\net\authorize\api\contract\v1\CreditCardSimpleType $creditCard)
+ {
+ $this->creditCard = $creditCard;
+ return $this;
+ }
+
+ /**
+ * Gets as bankAccount
+ *
+ * @return \net\authorize\api\contract\v1\BankAccountType
+ */
+ public function getBankAccount()
+ {
+ return $this->bankAccount;
+ }
+
+ /**
+ * Sets a new bankAccount
+ *
+ * @param \net\authorize\api\contract\v1\BankAccountType $bankAccount
+ * @return self
+ */
+ public function setBankAccount(\net\authorize\api\contract\v1\BankAccountType $bankAccount)
+ {
+ $this->bankAccount = $bankAccount;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PaymentType
+ *
+ *
+ * XSD Type: paymentType
+ */
+class PaymentType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CreditCardType $creditCard
+ */
+ private $creditCard = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\BankAccountType $bankAccount
+ */
+ private $bankAccount = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CreditCardTrackType $trackData
+ */
+ private $trackData = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\EncryptedTrackDataType
+ * $encryptedTrackData
+ */
+ private $encryptedTrackData = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PayPalType $payPal
+ */
+ private $payPal = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\OpaqueDataType $opaqueData
+ */
+ private $opaqueData = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentEmvType $emv
+ */
+ private $emv = null;
+
+ /**
+ * Gets as creditCard
+ *
+ * @return \net\authorize\api\contract\v1\CreditCardType
+ */
+ public function getCreditCard()
+ {
+ return $this->creditCard;
+ }
+
+ /**
+ * Sets a new creditCard
+ *
+ * @param \net\authorize\api\contract\v1\CreditCardType $creditCard
+ * @return self
+ */
+ public function setCreditCard(\net\authorize\api\contract\v1\CreditCardType $creditCard)
+ {
+ $this->creditCard = $creditCard;
+ return $this;
+ }
+
+ /**
+ * Gets as bankAccount
+ *
+ * @return \net\authorize\api\contract\v1\BankAccountType
+ */
+ public function getBankAccount()
+ {
+ return $this->bankAccount;
+ }
+
+ /**
+ * Sets a new bankAccount
+ *
+ * @param \net\authorize\api\contract\v1\BankAccountType $bankAccount
+ * @return self
+ */
+ public function setBankAccount(\net\authorize\api\contract\v1\BankAccountType $bankAccount)
+ {
+ $this->bankAccount = $bankAccount;
+ return $this;
+ }
+
+ /**
+ * Gets as trackData
+ *
+ * @return \net\authorize\api\contract\v1\CreditCardTrackType
+ */
+ public function getTrackData()
+ {
+ return $this->trackData;
+ }
+
+ /**
+ * Sets a new trackData
+ *
+ * @param \net\authorize\api\contract\v1\CreditCardTrackType $trackData
+ * @return self
+ */
+ public function setTrackData(\net\authorize\api\contract\v1\CreditCardTrackType $trackData)
+ {
+ $this->trackData = $trackData;
+ return $this;
+ }
+
+ /**
+ * Gets as encryptedTrackData
+ *
+ * @return \net\authorize\api\contract\v1\EncryptedTrackDataType
+ */
+ public function getEncryptedTrackData()
+ {
+ return $this->encryptedTrackData;
+ }
+
+ /**
+ * Sets a new encryptedTrackData
+ *
+ * @param \net\authorize\api\contract\v1\EncryptedTrackDataType $encryptedTrackData
+ * @return self
+ */
+ public function setEncryptedTrackData(\net\authorize\api\contract\v1\EncryptedTrackDataType $encryptedTrackData)
+ {
+ $this->encryptedTrackData = $encryptedTrackData;
+ return $this;
+ }
+
+ /**
+ * Gets as payPal
+ *
+ * @return \net\authorize\api\contract\v1\PayPalType
+ */
+ public function getPayPal()
+ {
+ return $this->payPal;
+ }
+
+ /**
+ * Sets a new payPal
+ *
+ * @param \net\authorize\api\contract\v1\PayPalType $payPal
+ * @return self
+ */
+ public function setPayPal(\net\authorize\api\contract\v1\PayPalType $payPal)
+ {
+ $this->payPal = $payPal;
+ return $this;
+ }
+
+ /**
+ * Gets as opaqueData
+ *
+ * @return \net\authorize\api\contract\v1\OpaqueDataType
+ */
+ public function getOpaqueData()
+ {
+ return $this->opaqueData;
+ }
+
+ /**
+ * Sets a new opaqueData
+ *
+ * @param \net\authorize\api\contract\v1\OpaqueDataType $opaqueData
+ * @return self
+ */
+ public function setOpaqueData(\net\authorize\api\contract\v1\OpaqueDataType $opaqueData)
+ {
+ $this->opaqueData = $opaqueData;
+ return $this;
+ }
+
+ /**
+ * Gets as emv
+ *
+ * @return \net\authorize\api\contract\v1\PaymentEmvType
+ */
+ public function getEmv()
+ {
+ return $this->emv;
+ }
+
+ /**
+ * Sets a new emv
+ *
+ * @param \net\authorize\api\contract\v1\PaymentEmvType $emv
+ * @return self
+ */
+ public function setEmv(\net\authorize\api\contract\v1\PaymentEmvType $emv)
+ {
+ $this->emv = $emv;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing PermissionType
+ *
+ *
+ * XSD Type: permissionType
+ */
+class PermissionType
+{
+
+ /**
+ * @property string $permissionName
+ */
+ private $permissionName = null;
+
+ /**
+ * Gets as permissionName
+ *
+ * @return string
+ */
+ public function getPermissionName()
+ {
+ return $this->permissionName;
+ }
+
+ /**
+ * Sets a new permissionName
+ *
+ * @param string $permissionName
+ * @return self
+ */
+ public function setPermissionName($permissionName)
+ {
+ $this->permissionName = $permissionName;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProcessorType
+ *
+ * \r
+ * XSD Type: processorType
+ */
+class ProcessorType
+{
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property integer $id
+ */
+ private $id = null;
+
+ /**
+ * @property string[] $cardTypes
+ */
+ private $cardTypes = null;
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;\r
+ return $this;
+ }
+
+ /**
+ * Gets as id
+ *
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets a new id
+ *
+ * @param integer $id
+ * @return self
+ */
+ public function setId($id)
+ {
+ $this->id = $id;\r
+ return $this;
+ }
+
+ /**
+ * Adds as cardType
+ *
+ * @return self
+ * @param string $cardType
+ */
+ public function addToCardTypes($cardType)
+ {
+ $this->cardTypes[] = $cardType;\r
+ return $this;
+ }
+
+ /**
+ * isset cardTypes
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetCardTypes($index)
+ {
+ return isset($this->cardTypes[$index]);
+ }
+
+ /**
+ * unset cardTypes
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetCardTypes($index)
+ {
+ unset($this->cardTypes[$index]);
+ }
+
+ /**
+ * Gets as cardTypes
+ *
+ * @return string[]
+ */
+ public function getCardTypes()
+ {
+ return $this->cardTypes;
+ }
+
+ /**
+ * Sets a new cardTypes
+ *
+ * @param string[] $cardTypes
+ * @return self
+ */
+ public function setCardTypes(array $cardTypes)
+ {
+ $this->cardTypes = $cardTypes;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProfileTransAmountType
+ *
+ *
+ * XSD Type: profileTransAmountType
+ */
+class ProfileTransAmountType
+{
+
+ /**
+ * @property float $amount
+ */
+ private $amount = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $tax
+ */
+ private $tax = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $shipping
+ */
+ private $shipping = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $duty
+ */
+ private $duty = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\LineItemType[] $lineItems
+ */
+ private $lineItems = null;
+
+ /**
+ * Gets as amount
+ *
+ * @return float
+ */
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ /**
+ * Sets a new amount
+ *
+ * @param float $amount
+ * @return self
+ */
+ public function setAmount($amount)
+ {
+ $this->amount = $amount;
+ return $this;
+ }
+
+ /**
+ * Gets as tax
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getTax()
+ {
+ return $this->tax;
+ }
+
+ /**
+ * Sets a new tax
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $tax
+ * @return self
+ */
+ public function setTax(\net\authorize\api\contract\v1\ExtendedAmountType $tax)
+ {
+ $this->tax = $tax;
+ return $this;
+ }
+
+ /**
+ * Gets as shipping
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getShipping()
+ {
+ return $this->shipping;
+ }
+
+ /**
+ * Sets a new shipping
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $shipping
+ * @return self
+ */
+ public function setShipping(\net\authorize\api\contract\v1\ExtendedAmountType $shipping)
+ {
+ $this->shipping = $shipping;
+ return $this;
+ }
+
+ /**
+ * Gets as duty
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getDuty()
+ {
+ return $this->duty;
+ }
+
+ /**
+ * Sets a new duty
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $duty
+ * @return self
+ */
+ public function setDuty(\net\authorize\api\contract\v1\ExtendedAmountType $duty)
+ {
+ $this->duty = $duty;
+ return $this;
+ }
+
+ /**
+ * Adds as lineItems
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\LineItemType $lineItems
+ */
+ public function addToLineItems(\net\authorize\api\contract\v1\LineItemType $lineItems)
+ {
+ $this->lineItems[] = $lineItems;
+ return $this;
+ }
+
+ /**
+ * isset lineItems
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetLineItems($index)
+ {
+ return isset($this->lineItems[$index]);
+ }
+
+ /**
+ * unset lineItems
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetLineItems($index)
+ {
+ unset($this->lineItems[$index]);
+ }
+
+ /**
+ * Gets as lineItems
+ *
+ * @return \net\authorize\api\contract\v1\LineItemType[]
+ */
+ public function getLineItems()
+ {
+ return $this->lineItems;
+ }
+
+ /**
+ * Sets a new lineItems
+ *
+ * @param \net\authorize\api\contract\v1\LineItemType[] $lineItems
+ * @return self
+ */
+ public function setLineItems(array $lineItems)
+ {
+ $this->lineItems = $lineItems;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProfileTransAuthCaptureType
+ *
+ *
+ * XSD Type: profileTransAuthCaptureType
+ */
+class ProfileTransAuthCaptureType extends ProfileTransOrderType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProfileTransAuthOnlyType
+ *
+ *
+ * XSD Type: profileTransAuthOnlyType
+ */
+class ProfileTransAuthOnlyType extends ProfileTransOrderType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProfileTransCaptureOnlyType
+ *
+ *
+ * XSD Type: profileTransCaptureOnlyType
+ */
+class ProfileTransCaptureOnlyType extends ProfileTransOrderType
+{
+
+ /**
+ * @property string $approvalCode
+ */
+ private $approvalCode = null;
+
+ /**
+ * Gets as approvalCode
+ *
+ * @return string
+ */
+ public function getApprovalCode()
+ {
+ return $this->approvalCode;
+ }
+
+ /**
+ * Sets a new approvalCode
+ *
+ * @param string $approvalCode
+ * @return self
+ */
+ public function setApprovalCode($approvalCode)
+ {
+ $this->approvalCode = $approvalCode;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProfileTransOrderType
+ *
+ *
+ * XSD Type: profileTransOrderType
+ */
+class ProfileTransOrderType extends ProfileTransAmountType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property string $customerShippingAddressId
+ */
+ private $customerShippingAddressId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\OrderExType $order
+ */
+ private $order = null;
+
+ /**
+ * @property boolean $taxExempt
+ */
+ private $taxExempt = null;
+
+ /**
+ * @property boolean $recurringBilling
+ */
+ private $recurringBilling = null;
+
+ /**
+ * @property string $cardCode
+ */
+ private $cardCode = null;
+
+ /**
+ * @property string $splitTenderId
+ */
+ private $splitTenderId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerShippingAddressId
+ *
+ * @return string
+ */
+ public function getCustomerShippingAddressId()
+ {
+ return $this->customerShippingAddressId;
+ }
+
+ /**
+ * Sets a new customerShippingAddressId
+ *
+ * @param string $customerShippingAddressId
+ * @return self
+ */
+ public function setCustomerShippingAddressId($customerShippingAddressId)
+ {
+ $this->customerShippingAddressId = $customerShippingAddressId;
+ return $this;
+ }
+
+ /**
+ * Gets as order
+ *
+ * @return \net\authorize\api\contract\v1\OrderExType
+ */
+ public function getOrder()
+ {
+ return $this->order;
+ }
+
+ /**
+ * Sets a new order
+ *
+ * @param \net\authorize\api\contract\v1\OrderExType $order
+ * @return self
+ */
+ public function setOrder(\net\authorize\api\contract\v1\OrderExType $order)
+ {
+ $this->order = $order;
+ return $this;
+ }
+
+ /**
+ * Gets as taxExempt
+ *
+ * @return boolean
+ */
+ public function getTaxExempt()
+ {
+ return $this->taxExempt;
+ }
+
+ /**
+ * Sets a new taxExempt
+ *
+ * @param boolean $taxExempt
+ * @return self
+ */
+ public function setTaxExempt($taxExempt)
+ {
+ $this->taxExempt = $taxExempt;
+ return $this;
+ }
+
+ /**
+ * Gets as recurringBilling
+ *
+ * @return boolean
+ */
+ public function getRecurringBilling()
+ {
+ return $this->recurringBilling;
+ }
+
+ /**
+ * Sets a new recurringBilling
+ *
+ * @param boolean $recurringBilling
+ * @return self
+ */
+ public function setRecurringBilling($recurringBilling)
+ {
+ $this->recurringBilling = $recurringBilling;
+ return $this;
+ }
+
+ /**
+ * Gets as cardCode
+ *
+ * @return string
+ */
+ public function getCardCode()
+ {
+ return $this->cardCode;
+ }
+
+ /**
+ * Sets a new cardCode
+ *
+ * @param string $cardCode
+ * @return self
+ */
+ public function setCardCode($cardCode)
+ {
+ $this->cardCode = $cardCode;
+ return $this;
+ }
+
+ /**
+ * Gets as splitTenderId
+ *
+ * @return string
+ */
+ public function getSplitTenderId()
+ {
+ return $this->splitTenderId;
+ }
+
+ /**
+ * Sets a new splitTenderId
+ *
+ * @param string $splitTenderId
+ * @return self
+ */
+ public function setSplitTenderId($splitTenderId)
+ {
+ $this->splitTenderId = $splitTenderId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProfileTransPriorAuthCaptureType
+ *
+ *
+ * XSD Type: profileTransPriorAuthCaptureType
+ */
+class ProfileTransPriorAuthCaptureType extends ProfileTransAmountType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property string $customerShippingAddressId
+ */
+ private $customerShippingAddressId = null;
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerShippingAddressId
+ *
+ * @return string
+ */
+ public function getCustomerShippingAddressId()
+ {
+ return $this->customerShippingAddressId;
+ }
+
+ /**
+ * Sets a new customerShippingAddressId
+ *
+ * @param string $customerShippingAddressId
+ * @return self
+ */
+ public function setCustomerShippingAddressId($customerShippingAddressId)
+ {
+ $this->customerShippingAddressId = $customerShippingAddressId;
+ return $this;
+ }
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProfileTransRefundType
+ *
+ *
+ * XSD Type: profileTransRefundType
+ */
+class ProfileTransRefundType extends ProfileTransAmountType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property string $customerShippingAddressId
+ */
+ private $customerShippingAddressId = null;
+
+ /**
+ * @property string $creditCardNumberMasked
+ */
+ private $creditCardNumberMasked = null;
+
+ /**
+ * @property string $bankRoutingNumberMasked
+ */
+ private $bankRoutingNumberMasked = null;
+
+ /**
+ * @property string $bankAccountNumberMasked
+ */
+ private $bankAccountNumberMasked = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\OrderExType $order
+ */
+ private $order = null;
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerShippingAddressId
+ *
+ * @return string
+ */
+ public function getCustomerShippingAddressId()
+ {
+ return $this->customerShippingAddressId;
+ }
+
+ /**
+ * Sets a new customerShippingAddressId
+ *
+ * @param string $customerShippingAddressId
+ * @return self
+ */
+ public function setCustomerShippingAddressId($customerShippingAddressId)
+ {
+ $this->customerShippingAddressId = $customerShippingAddressId;
+ return $this;
+ }
+
+ /**
+ * Gets as creditCardNumberMasked
+ *
+ * @return string
+ */
+ public function getCreditCardNumberMasked()
+ {
+ return $this->creditCardNumberMasked;
+ }
+
+ /**
+ * Sets a new creditCardNumberMasked
+ *
+ * @param string $creditCardNumberMasked
+ * @return self
+ */
+ public function setCreditCardNumberMasked($creditCardNumberMasked)
+ {
+ $this->creditCardNumberMasked = $creditCardNumberMasked;
+ return $this;
+ }
+
+ /**
+ * Gets as bankRoutingNumberMasked
+ *
+ * @return string
+ */
+ public function getBankRoutingNumberMasked()
+ {
+ return $this->bankRoutingNumberMasked;
+ }
+
+ /**
+ * Sets a new bankRoutingNumberMasked
+ *
+ * @param string $bankRoutingNumberMasked
+ * @return self
+ */
+ public function setBankRoutingNumberMasked($bankRoutingNumberMasked)
+ {
+ $this->bankRoutingNumberMasked = $bankRoutingNumberMasked;
+ return $this;
+ }
+
+ /**
+ * Gets as bankAccountNumberMasked
+ *
+ * @return string
+ */
+ public function getBankAccountNumberMasked()
+ {
+ return $this->bankAccountNumberMasked;
+ }
+
+ /**
+ * Sets a new bankAccountNumberMasked
+ *
+ * @param string $bankAccountNumberMasked
+ * @return self
+ */
+ public function setBankAccountNumberMasked($bankAccountNumberMasked)
+ {
+ $this->bankAccountNumberMasked = $bankAccountNumberMasked;
+ return $this;
+ }
+
+ /**
+ * Gets as order
+ *
+ * @return \net\authorize\api\contract\v1\OrderExType
+ */
+ public function getOrder()
+ {
+ return $this->order;
+ }
+
+ /**
+ * Sets a new order
+ *
+ * @param \net\authorize\api\contract\v1\OrderExType $order
+ * @return self
+ */
+ public function setOrder(\net\authorize\api\contract\v1\OrderExType $order)
+ {
+ $this->order = $order;
+ return $this;
+ }
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProfileTransVoidType
+ *
+ *
+ * XSD Type: profileTransVoidType
+ */
+class ProfileTransVoidType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property string $customerShippingAddressId
+ */
+ private $customerShippingAddressId = null;
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerShippingAddressId
+ *
+ * @return string
+ */
+ public function getCustomerShippingAddressId()
+ {
+ return $this->customerShippingAddressId;
+ }
+
+ /**
+ * Sets a new customerShippingAddressId
+ *
+ * @param string $customerShippingAddressId
+ * @return self
+ */
+ public function setCustomerShippingAddressId($customerShippingAddressId)
+ {
+ $this->customerShippingAddressId = $customerShippingAddressId;
+ return $this;
+ }
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ProfileTransactionType
+ *
+ *
+ * XSD Type: profileTransactionType
+ */
+class ProfileTransactionType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\ProfileTransAuthCaptureType
+ * $profileTransAuthCapture
+ */
+ private $profileTransAuthCapture = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ProfileTransAuthOnlyType
+ * $profileTransAuthOnly
+ */
+ private $profileTransAuthOnly = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ProfileTransPriorAuthCaptureType
+ * $profileTransPriorAuthCapture
+ */
+ private $profileTransPriorAuthCapture = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ProfileTransCaptureOnlyType
+ * $profileTransCaptureOnly
+ */
+ private $profileTransCaptureOnly = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ProfileTransRefundType
+ * $profileTransRefund
+ */
+ private $profileTransRefund = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ProfileTransVoidType $profileTransVoid
+ */
+ private $profileTransVoid = null;
+
+ /**
+ * Gets as profileTransAuthCapture
+ *
+ * @return \net\authorize\api\contract\v1\ProfileTransAuthCaptureType
+ */
+ public function getProfileTransAuthCapture()
+ {
+ return $this->profileTransAuthCapture;
+ }
+
+ /**
+ * Sets a new profileTransAuthCapture
+ *
+ * @param \net\authorize\api\contract\v1\ProfileTransAuthCaptureType
+ * $profileTransAuthCapture
+ * @return self
+ */
+ public function setProfileTransAuthCapture(\net\authorize\api\contract\v1\ProfileTransAuthCaptureType $profileTransAuthCapture)
+ {
+ $this->profileTransAuthCapture = $profileTransAuthCapture;
+ return $this;
+ }
+
+ /**
+ * Gets as profileTransAuthOnly
+ *
+ * @return \net\authorize\api\contract\v1\ProfileTransAuthOnlyType
+ */
+ public function getProfileTransAuthOnly()
+ {
+ return $this->profileTransAuthOnly;
+ }
+
+ /**
+ * Sets a new profileTransAuthOnly
+ *
+ * @param \net\authorize\api\contract\v1\ProfileTransAuthOnlyType
+ * $profileTransAuthOnly
+ * @return self
+ */
+ public function setProfileTransAuthOnly(\net\authorize\api\contract\v1\ProfileTransAuthOnlyType $profileTransAuthOnly)
+ {
+ $this->profileTransAuthOnly = $profileTransAuthOnly;
+ return $this;
+ }
+
+ /**
+ * Gets as profileTransPriorAuthCapture
+ *
+ * @return \net\authorize\api\contract\v1\ProfileTransPriorAuthCaptureType
+ */
+ public function getProfileTransPriorAuthCapture()
+ {
+ return $this->profileTransPriorAuthCapture;
+ }
+
+ /**
+ * Sets a new profileTransPriorAuthCapture
+ *
+ * @param \net\authorize\api\contract\v1\ProfileTransPriorAuthCaptureType
+ * $profileTransPriorAuthCapture
+ * @return self
+ */
+ public function setProfileTransPriorAuthCapture(\net\authorize\api\contract\v1\ProfileTransPriorAuthCaptureType $profileTransPriorAuthCapture)
+ {
+ $this->profileTransPriorAuthCapture = $profileTransPriorAuthCapture;
+ return $this;
+ }
+
+ /**
+ * Gets as profileTransCaptureOnly
+ *
+ * @return \net\authorize\api\contract\v1\ProfileTransCaptureOnlyType
+ */
+ public function getProfileTransCaptureOnly()
+ {
+ return $this->profileTransCaptureOnly;
+ }
+
+ /**
+ * Sets a new profileTransCaptureOnly
+ *
+ * @param \net\authorize\api\contract\v1\ProfileTransCaptureOnlyType
+ * $profileTransCaptureOnly
+ * @return self
+ */
+ public function setProfileTransCaptureOnly(\net\authorize\api\contract\v1\ProfileTransCaptureOnlyType $profileTransCaptureOnly)
+ {
+ $this->profileTransCaptureOnly = $profileTransCaptureOnly;
+ return $this;
+ }
+
+ /**
+ * Gets as profileTransRefund
+ *
+ * @return \net\authorize\api\contract\v1\ProfileTransRefundType
+ */
+ public function getProfileTransRefund()
+ {
+ return $this->profileTransRefund;
+ }
+
+ /**
+ * Sets a new profileTransRefund
+ *
+ * @param \net\authorize\api\contract\v1\ProfileTransRefundType $profileTransRefund
+ * @return self
+ */
+ public function setProfileTransRefund(\net\authorize\api\contract\v1\ProfileTransRefundType $profileTransRefund)
+ {
+ $this->profileTransRefund = $profileTransRefund;
+ return $this;
+ }
+
+ /**
+ * Gets as profileTransVoid
+ *
+ * @return \net\authorize\api\contract\v1\ProfileTransVoidType
+ */
+ public function getProfileTransVoid()
+ {
+ return $this->profileTransVoid;
+ }
+
+ /**
+ * Sets a new profileTransVoid
+ *
+ * @param \net\authorize\api\contract\v1\ProfileTransVoidType $profileTransVoid
+ * @return self
+ */
+ public function setProfileTransVoid(\net\authorize\api\contract\v1\ProfileTransVoidType $profileTransVoid)
+ {
+ $this->profileTransVoid = $profileTransVoid;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ReturnedItemType
+ *
+ *
+ * XSD Type: returnedItemType
+ */
+class ReturnedItemType
+{
+
+ /**
+ * @property string $id
+ */
+ private $id = null;
+
+ /**
+ * @property \DateTime $dateUTC
+ */
+ private $dateUTC = null;
+
+ /**
+ * @property \DateTime $dateLocal
+ */
+ private $dateLocal = null;
+
+ /**
+ * @property string $code
+ */
+ private $code = null;
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * Gets as id
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets a new id
+ *
+ * @param string $id
+ * @return self
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * Gets as dateUTC
+ *
+ * @return \DateTime
+ */
+ public function getDateUTC()
+ {
+ return $this->dateUTC;
+ }
+
+ /**
+ * Sets a new dateUTC
+ *
+ * @param \DateTime $dateUTC
+ * @return self
+ */
+ public function setDateUTC(\DateTime $dateUTC)
+ {
+ $this->dateUTC = $dateUTC;
+ return $this;
+ }
+
+ /**
+ * Gets as dateLocal
+ *
+ * @return \DateTime
+ */
+ public function getDateLocal()
+ {
+ return $this->dateLocal;
+ }
+
+ /**
+ * Sets a new dateLocal
+ *
+ * @param \DateTime $dateLocal
+ * @return self
+ */
+ public function setDateLocal(\DateTime $dateLocal)
+ {
+ $this->dateLocal = $dateLocal;
+ return $this;
+ }
+
+ /**
+ * Gets as code
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Sets a new code
+ *
+ * @param string $code
+ * @return self
+ */
+ public function setCode($code)
+ {
+ $this->code = $code;
+ return $this;
+ }
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SecurePaymentContainerErrorType
+ *
+ * \r
+ * XSD Type: securePaymentContainerErrorType
+ */
+class SecurePaymentContainerErrorType
+{
+
+ /**
+ * @property string $code
+ */
+ private $code = null;
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * Gets as code
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Sets a new code
+ *
+ * @param string $code
+ * @return self
+ */
+ public function setCode($code)
+ {
+ $this->code = $code;\r
+ return $this;
+ }
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SecurePaymentContainerRequest
+ */
+class SecurePaymentContainerRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\WebCheckOutDataType $data
+ */
+ private $data = null;
+
+ /**
+ * Gets as data
+ *
+ * @return \net\authorize\api\contract\v1\WebCheckOutDataType
+ */
+ public function getData()
+ {
+ return $this->data;
+ }
+
+ /**
+ * Sets a new data
+ *
+ * @param \net\authorize\api\contract\v1\WebCheckOutDataType $data
+ * @return self
+ */
+ public function setData(\net\authorize\api\contract\v1\WebCheckOutDataType $data)
+ {
+ $this->data = $data;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SecurePaymentContainerResponse
+ */
+class SecurePaymentContainerResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\OpaqueDataType $opaqueData
+ */
+ private $opaqueData = null;
+
+ /**
+ * Gets as opaqueData
+ *
+ * @return \net\authorize\api\contract\v1\OpaqueDataType
+ */
+ public function getOpaqueData()
+ {
+ return $this->opaqueData;
+ }
+
+ /**
+ * Sets a new opaqueData
+ *
+ * @param \net\authorize\api\contract\v1\OpaqueDataType $opaqueData
+ * @return self
+ */
+ public function setOpaqueData(\net\authorize\api\contract\v1\OpaqueDataType $opaqueData)
+ {
+ $this->opaqueData = $opaqueData;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SendCustomerTransactionReceiptRequest
+ */
+class SendCustomerTransactionReceiptRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * @property string $customerEmail
+ */
+ private $customerEmail = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\EmailSettingsType $emailSettings
+ */
+ private $emailSettings = null;
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerEmail
+ *
+ * @return string
+ */
+ public function getCustomerEmail()
+ {
+ return $this->customerEmail;
+ }
+
+ /**
+ * Sets a new customerEmail
+ *
+ * @param string $customerEmail
+ * @return self
+ */
+ public function setCustomerEmail($customerEmail)
+ {
+ $this->customerEmail = $customerEmail;
+ return $this;
+ }
+
+ /**
+ * Gets as emailSettings
+ *
+ * @return \net\authorize\api\contract\v1\EmailSettingsType
+ */
+ public function getEmailSettings()
+ {
+ return $this->emailSettings;
+ }
+
+ /**
+ * Sets a new emailSettings
+ *
+ * @param \net\authorize\api\contract\v1\EmailSettingsType $emailSettings
+ * @return self
+ */
+ public function setEmailSettings(\net\authorize\api\contract\v1\EmailSettingsType $emailSettings)
+ {
+ $this->emailSettings = $emailSettings;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SendCustomerTransactionReceiptResponse
+ */
+class SendCustomerTransactionReceiptResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SettingType
+ *
+ *
+ * XSD Type: settingType
+ */
+class SettingType
+{
+
+ /**
+ * @property string $settingName
+ */
+ private $settingName = null;
+
+ /**
+ * @property string $settingValue
+ */
+ private $settingValue = null;
+
+ /**
+ * Gets as settingName
+ *
+ * @return string
+ */
+ public function getSettingName()
+ {
+ return $this->settingName;
+ }
+
+ /**
+ * Sets a new settingName
+ *
+ * @param string $settingName
+ * @return self
+ */
+ public function setSettingName($settingName)
+ {
+ $this->settingName = $settingName;
+ return $this;
+ }
+
+ /**
+ * Gets as settingValue
+ *
+ * @return string
+ */
+ public function getSettingValue()
+ {
+ return $this->settingValue;
+ }
+
+ /**
+ * Sets a new settingValue
+ *
+ * @param string $settingValue
+ * @return self
+ */
+ public function setSettingValue($settingValue)
+ {
+ $this->settingValue = $settingValue;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SolutionType
+ *
+ *
+ * XSD Type: solutionType
+ */
+class SolutionType
+{
+
+ /**
+ * @property string $id
+ */
+ private $id = null;
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property string $vendorName
+ */
+ private $vendorName = null;
+
+ /**
+ * Gets as id
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets a new id
+ *
+ * @param string $id
+ * @return self
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Gets as vendorName
+ *
+ * @return string
+ */
+ public function getVendorName()
+ {
+ return $this->vendorName;
+ }
+
+ /**
+ * Sets a new vendorName
+ *
+ * @param string $vendorName
+ * @return self
+ */
+ public function setVendorName($vendorName)
+ {
+ $this->vendorName = $vendorName;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SubMerchantType
+ *
+ * \r
+ * XSD Type: subMerchantType
+ */
+class SubMerchantType
+{
+
+ /**
+ * @property string $identifier
+ */
+ private $identifier = null;
+
+ /**
+ * @property string $doingBusinessAs
+ */
+ private $doingBusinessAs = null;
+
+ /**
+ * @property string $paymentServiceProviderName
+ */
+ private $paymentServiceProviderName = null;
+
+ /**
+ * @property string $paymentServiceFacilitator
+ */
+ private $paymentServiceFacilitator = null;
+
+ /**
+ * @property string $streetAddress
+ */
+ private $streetAddress = null;
+
+ /**
+ * @property string $phone
+ */
+ private $phone = null;
+
+ /**
+ * @property string $email
+ */
+ private $email = null;
+
+ /**
+ * @property string $postalCode
+ */
+ private $postalCode = null;
+
+ /**
+ * @property string $city
+ */
+ private $city = null;
+
+ /**
+ * @property string $regionCode
+ */
+ private $regionCode = null;
+
+ /**
+ * @property string $countryCode
+ */
+ private $countryCode = null;
+
+ /**
+ * Gets as identifier
+ *
+ * @return string
+ */
+ public function getIdentifier()
+ {
+ return $this->identifier;
+ }
+
+ /**
+ * Sets a new identifier
+ *
+ * @param string $identifier
+ * @return self
+ */
+ public function setIdentifier($identifier)
+ {
+ $this->identifier = $identifier;\r
+ return $this;
+ }
+
+ /**
+ * Gets as doingBusinessAs
+ *
+ * @return string
+ */
+ public function getDoingBusinessAs()
+ {
+ return $this->doingBusinessAs;
+ }
+
+ /**
+ * Sets a new doingBusinessAs
+ *
+ * @param string $doingBusinessAs
+ * @return self
+ */
+ public function setDoingBusinessAs($doingBusinessAs)
+ {
+ $this->doingBusinessAs = $doingBusinessAs;\r
+ return $this;
+ }
+
+ /**
+ * Gets as paymentServiceProviderName
+ *
+ * @return string
+ */
+ public function getPaymentServiceProviderName()
+ {
+ return $this->paymentServiceProviderName;
+ }
+
+ /**
+ * Sets a new paymentServiceProviderName
+ *
+ * @param string $paymentServiceProviderName
+ * @return self
+ */
+ public function setPaymentServiceProviderName($paymentServiceProviderName)
+ {
+ $this->paymentServiceProviderName = $paymentServiceProviderName;\r
+ return $this;
+ }
+
+ /**
+ * Gets as paymentServiceFacilitator
+ *
+ * @return string
+ */
+ public function getPaymentServiceFacilitator()
+ {
+ return $this->paymentServiceFacilitator;
+ }
+
+ /**
+ * Sets a new paymentServiceFacilitator
+ *
+ * @param string $paymentServiceFacilitator
+ * @return self
+ */
+ public function setPaymentServiceFacilitator($paymentServiceFacilitator)
+ {
+ $this->paymentServiceFacilitator = $paymentServiceFacilitator;\r
+ return $this;
+ }
+
+ /**
+ * Gets as streetAddress
+ *
+ * @return string
+ */
+ public function getStreetAddress()
+ {
+ return $this->streetAddress;
+ }
+
+ /**
+ * Sets a new streetAddress
+ *
+ * @param string $streetAddress
+ * @return self
+ */
+ public function setStreetAddress($streetAddress)
+ {
+ $this->streetAddress = $streetAddress;\r
+ return $this;
+ }
+
+ /**
+ * Gets as phone
+ *
+ * @return string
+ */
+ public function getPhone()
+ {
+ return $this->phone;
+ }
+
+ /**
+ * Sets a new phone
+ *
+ * @param string $phone
+ * @return self
+ */
+ public function setPhone($phone)
+ {
+ $this->phone = $phone;\r
+ return $this;
+ }
+
+ /**
+ * Gets as email
+ *
+ * @return string
+ */
+ public function getEmail()
+ {
+ return $this->email;
+ }
+
+ /**
+ * Sets a new email
+ *
+ * @param string $email
+ * @return self
+ */
+ public function setEmail($email)
+ {
+ $this->email = $email;\r
+ return $this;
+ }
+
+ /**
+ * Gets as postalCode
+ *
+ * @return string
+ */
+ public function getPostalCode()
+ {
+ return $this->postalCode;
+ }
+
+ /**
+ * Sets a new postalCode
+ *
+ * @param string $postalCode
+ * @return self
+ */
+ public function setPostalCode($postalCode)
+ {
+ $this->postalCode = $postalCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as city
+ *
+ * @return string
+ */
+ public function getCity()
+ {
+ return $this->city;
+ }
+
+ /**
+ * Sets a new city
+ *
+ * @param string $city
+ * @return self
+ */
+ public function setCity($city)
+ {
+ $this->city = $city;\r
+ return $this;
+ }
+
+ /**
+ * Gets as regionCode
+ *
+ * @return string
+ */
+ public function getRegionCode()
+ {
+ return $this->regionCode;
+ }
+
+ /**
+ * Sets a new regionCode
+ *
+ * @param string $regionCode
+ * @return self
+ */
+ public function setRegionCode($regionCode)
+ {
+ $this->regionCode = $regionCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as countryCode
+ *
+ * @return string
+ */
+ public function getCountryCode()
+ {
+ return $this->countryCode;
+ }
+
+ /**
+ * Sets a new countryCode
+ *
+ * @param string $countryCode
+ * @return self
+ */
+ public function setCountryCode($countryCode)
+ {
+ $this->countryCode = $countryCode;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SubscriptionCustomerProfileType
+ *
+ *
+ * XSD Type: subscriptionCustomerProfileType
+ */
+class SubscriptionCustomerProfileType extends CustomerProfileExType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType
+ * $paymentProfile
+ */
+ private $paymentProfile = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressExType $shippingProfile
+ */
+ private $shippingProfile = null;
+
+ /**
+ * Gets as paymentProfile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType
+ */
+ public function getPaymentProfile()
+ {
+ return $this->paymentProfile;
+ }
+
+ /**
+ * Sets a new paymentProfile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType
+ * $paymentProfile
+ * @return self
+ */
+ public function setPaymentProfile(\net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType $paymentProfile)
+ {
+ $this->paymentProfile = $paymentProfile;
+ return $this;
+ }
+
+ /**
+ * Gets as shippingProfile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressExType
+ */
+ public function getShippingProfile()
+ {
+ return $this->shippingProfile;
+ }
+
+ /**
+ * Sets a new shippingProfile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressExType $shippingProfile
+ * @return self
+ */
+ public function setShippingProfile(\net\authorize\api\contract\v1\CustomerAddressExType $shippingProfile)
+ {
+ $this->shippingProfile = $shippingProfile;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SubscriptionDetailType
+ *
+ *
+ * XSD Type: SubscriptionDetail
+ */
+class SubscriptionDetailType
+{
+
+ /**
+ * @property integer $id
+ */
+ private $id = null;
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property string $status
+ */
+ private $status = null;
+
+ /**
+ * @property \DateTime $createTimeStampUTC
+ */
+ private $createTimeStampUTC = null;
+
+ /**
+ * @property string $firstName
+ */
+ private $firstName = null;
+
+ /**
+ * @property string $lastName
+ */
+ private $lastName = null;
+
+ /**
+ * @property integer $totalOccurrences
+ */
+ private $totalOccurrences = null;
+
+ /**
+ * @property integer $pastOccurrences
+ */
+ private $pastOccurrences = null;
+
+ /**
+ * @property string $paymentMethod
+ */
+ private $paymentMethod = null;
+
+ /**
+ * @property string $accountNumber
+ */
+ private $accountNumber = null;
+
+ /**
+ * @property string $invoice
+ */
+ private $invoice = null;
+
+ /**
+ * @property float $amount
+ */
+ private $amount = null;
+
+ /**
+ * @property string $currencyCode
+ */
+ private $currencyCode = null;
+
+ /**
+ * @property integer $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property integer $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property integer $customerShippingProfileId
+ */
+ private $customerShippingProfileId = null;
+
+ /**
+ * Gets as id
+ *
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets a new id
+ *
+ * @param integer $id
+ * @return self
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Gets as status
+ *
+ * @return string
+ */
+ public function getStatus()
+ {
+ return $this->status;
+ }
+
+ /**
+ * Sets a new status
+ *
+ * @param string $status
+ * @return self
+ */
+ public function setStatus($status)
+ {
+ $this->status = $status;
+ return $this;
+ }
+
+ /**
+ * Gets as createTimeStampUTC
+ *
+ * @return \DateTime
+ */
+ public function getCreateTimeStampUTC()
+ {
+ return $this->createTimeStampUTC;
+ }
+
+ /**
+ * Sets a new createTimeStampUTC
+ *
+ * @param \DateTime $createTimeStampUTC
+ * @return self
+ */
+ public function setCreateTimeStampUTC(\DateTime $createTimeStampUTC)
+ {
+ $this->createTimeStampUTC = $createTimeStampUTC;
+ return $this;
+ }
+
+ /**
+ * Gets as firstName
+ *
+ * @return string
+ */
+ public function getFirstName()
+ {
+ return $this->firstName;
+ }
+
+ /**
+ * Sets a new firstName
+ *
+ * @param string $firstName
+ * @return self
+ */
+ public function setFirstName($firstName)
+ {
+ $this->firstName = $firstName;
+ return $this;
+ }
+
+ /**
+ * Gets as lastName
+ *
+ * @return string
+ */
+ public function getLastName()
+ {
+ return $this->lastName;
+ }
+
+ /**
+ * Sets a new lastName
+ *
+ * @param string $lastName
+ * @return self
+ */
+ public function setLastName($lastName)
+ {
+ $this->lastName = $lastName;
+ return $this;
+ }
+
+ /**
+ * Gets as totalOccurrences
+ *
+ * @return integer
+ */
+ public function getTotalOccurrences()
+ {
+ return $this->totalOccurrences;
+ }
+
+ /**
+ * Sets a new totalOccurrences
+ *
+ * @param integer $totalOccurrences
+ * @return self
+ */
+ public function setTotalOccurrences($totalOccurrences)
+ {
+ $this->totalOccurrences = $totalOccurrences;
+ return $this;
+ }
+
+ /**
+ * Gets as pastOccurrences
+ *
+ * @return integer
+ */
+ public function getPastOccurrences()
+ {
+ return $this->pastOccurrences;
+ }
+
+ /**
+ * Sets a new pastOccurrences
+ *
+ * @param integer $pastOccurrences
+ * @return self
+ */
+ public function setPastOccurrences($pastOccurrences)
+ {
+ $this->pastOccurrences = $pastOccurrences;
+ return $this;
+ }
+
+ /**
+ * Gets as paymentMethod
+ *
+ * @return string
+ */
+ public function getPaymentMethod()
+ {
+ return $this->paymentMethod;
+ }
+
+ /**
+ * Sets a new paymentMethod
+ *
+ * @param string $paymentMethod
+ * @return self
+ */
+ public function setPaymentMethod($paymentMethod)
+ {
+ $this->paymentMethod = $paymentMethod;
+ return $this;
+ }
+
+ /**
+ * Gets as accountNumber
+ *
+ * @return string
+ */
+ public function getAccountNumber()
+ {
+ return $this->accountNumber;
+ }
+
+ /**
+ * Sets a new accountNumber
+ *
+ * @param string $accountNumber
+ * @return self
+ */
+ public function setAccountNumber($accountNumber)
+ {
+ $this->accountNumber = $accountNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as invoice
+ *
+ * @return string
+ */
+ public function getInvoice()
+ {
+ return $this->invoice;
+ }
+
+ /**
+ * Sets a new invoice
+ *
+ * @param string $invoice
+ * @return self
+ */
+ public function setInvoice($invoice)
+ {
+ $this->invoice = $invoice;
+ return $this;
+ }
+
+ /**
+ * Gets as amount
+ *
+ * @return float
+ */
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ /**
+ * Sets a new amount
+ *
+ * @param float $amount
+ * @return self
+ */
+ public function setAmount($amount)
+ {
+ $this->amount = $amount;
+ return $this;
+ }
+
+ /**
+ * Gets as currencyCode
+ *
+ * @return string
+ */
+ public function getCurrencyCode()
+ {
+ return $this->currencyCode;
+ }
+
+ /**
+ * Sets a new currencyCode
+ *
+ * @param string $currencyCode
+ * @return self
+ */
+ public function setCurrencyCode($currencyCode)
+ {
+ $this->currencyCode = $currencyCode;
+ return $this;
+ }
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return integer
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param integer $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return integer
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param integer $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerShippingProfileId
+ *
+ * @return integer
+ */
+ public function getCustomerShippingProfileId()
+ {
+ return $this->customerShippingProfileId;
+ }
+
+ /**
+ * Sets a new customerShippingProfileId
+ *
+ * @param integer $customerShippingProfileId
+ * @return self
+ */
+ public function setCustomerShippingProfileId($customerShippingProfileId)
+ {
+ $this->customerShippingProfileId = $customerShippingProfileId;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing SubscriptionPaymentType
+ *
+ *
+ * XSD Type: subscriptionPaymentType
+ */
+class SubscriptionPaymentType
+{
+
+ /**
+ * @property integer $id
+ */
+ private $id = null;
+
+ /**
+ * @property integer $payNum
+ */
+ private $payNum = null;
+
+ /**
+ * Gets as id
+ *
+ * @return integer
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets a new id
+ *
+ * @param integer $id
+ * @return self
+ */
+ public function setId($id)
+ {
+ $this->id = $id;
+ return $this;
+ }
+
+ /**
+ * Gets as payNum
+ *
+ * @return integer
+ */
+ public function getPayNum()
+ {
+ return $this->payNum;
+ }
+
+ /**
+ * Sets a new payNum
+ *
+ * @param integer $payNum
+ * @return self
+ */
+ public function setPayNum($payNum)
+ {
+ $this->payNum = $payNum;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing TokenMaskedType
+ *
+ *
+ * XSD Type: tokenMaskedType
+ */
+class TokenMaskedType
+{
+
+ /**
+ * @property string $tokenSource
+ */
+ private $tokenSource = null;
+
+ /**
+ * @property string $tokenNumber
+ */
+ private $tokenNumber = null;
+
+ /**
+ * @property string $expirationDate
+ */
+ private $expirationDate = null;
+
+ /**
+ * Gets as tokenSource
+ *
+ * @return string
+ */
+ public function getTokenSource()
+ {
+ return $this->tokenSource;
+ }
+
+ /**
+ * Sets a new tokenSource
+ *
+ * @param string $tokenSource
+ * @return self
+ */
+ public function setTokenSource($tokenSource)
+ {
+ $this->tokenSource = $tokenSource;
+ return $this;
+ }
+
+ /**
+ * Gets as tokenNumber
+ *
+ * @return string
+ */
+ public function getTokenNumber()
+ {
+ return $this->tokenNumber;
+ }
+
+ /**
+ * Sets a new tokenNumber
+ *
+ * @param string $tokenNumber
+ * @return self
+ */
+ public function setTokenNumber($tokenNumber)
+ {
+ $this->tokenNumber = $tokenNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as expirationDate
+ *
+ * @return string
+ */
+ public function getExpirationDate()
+ {
+ return $this->expirationDate;
+ }
+
+ /**
+ * Sets a new expirationDate
+ *
+ * @param string $expirationDate
+ * @return self
+ */
+ public function setExpirationDate($expirationDate)
+ {
+ $this->expirationDate = $expirationDate;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing TransRetailInfoType
+ *
+ * \r
+ * XSD Type: transRetailInfoType
+ */
+class TransRetailInfoType
+{
+
+ /**
+ * @property string $marketType
+ */
+ private $marketType = null;
+
+ /**
+ * @property string $deviceType
+ */
+ private $deviceType = null;
+
+ /**
+ * @property string $customerSignature
+ */
+ private $customerSignature = null;
+
+ /**
+ * @property string $terminalNumber
+ */
+ private $terminalNumber = null;
+
+ /**
+ * Gets as marketType
+ *
+ * @return string
+ */
+ public function getMarketType()
+ {
+ return $this->marketType;
+ }
+
+ /**
+ * Sets a new marketType
+ *
+ * @param string $marketType
+ * @return self
+ */
+ public function setMarketType($marketType)
+ {
+ $this->marketType = $marketType;\r
+ return $this;
+ }
+
+ /**
+ * Gets as deviceType
+ *
+ * @return string
+ */
+ public function getDeviceType()
+ {
+ return $this->deviceType;
+ }
+
+ /**
+ * Sets a new deviceType
+ *
+ * @param string $deviceType
+ * @return self
+ */
+ public function setDeviceType($deviceType)
+ {
+ $this->deviceType = $deviceType;\r
+ return $this;
+ }
+
+ /**
+ * Gets as customerSignature
+ *
+ * @return string
+ */
+ public function getCustomerSignature()
+ {
+ return $this->customerSignature;
+ }
+
+ /**
+ * Sets a new customerSignature
+ *
+ * @param string $customerSignature
+ * @return self
+ */
+ public function setCustomerSignature($customerSignature)
+ {
+ $this->customerSignature = $customerSignature;\r
+ return $this;
+ }
+
+ /**
+ * Gets as terminalNumber
+ *
+ * @return string
+ */
+ public function getTerminalNumber()
+ {
+ return $this->terminalNumber;
+ }
+
+ /**
+ * Sets a new terminalNumber
+ *
+ * @param string $terminalNumber
+ * @return self
+ */
+ public function setTerminalNumber($terminalNumber)
+ {
+ $this->terminalNumber = $terminalNumber;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing TransactionDetailsType
+ *
+ * \r
+ * XSD Type: transactionDetailsType
+ */
+class TransactionDetailsType
+{
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * @property string $refTransId
+ */
+ private $refTransId = null;
+
+ /**
+ * @property string $splitTenderId
+ */
+ private $splitTenderId = null;
+
+ /**
+ * @property \DateTime $submitTimeUTC
+ */
+ private $submitTimeUTC = null;
+
+ /**
+ * @property \DateTime $submitTimeLocal
+ */
+ private $submitTimeLocal = null;
+
+ /**
+ * @property string $transactionType
+ */
+ private $transactionType = null;
+
+ /**
+ * @property string $transactionStatus
+ */
+ private $transactionStatus = null;
+
+ /**
+ * @property integer $responseCode
+ */
+ private $responseCode = null;
+
+ /**
+ * @property integer $responseReasonCode
+ */
+ private $responseReasonCode = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\SubscriptionPaymentType $subscription
+ */
+ private $subscription = null;
+
+ /**
+ * @property string $responseReasonDescription
+ */
+ private $responseReasonDescription = null;
+
+ /**
+ * @property string $authCode
+ */
+ private $authCode = null;
+
+ /**
+ * @property string $aVSResponse
+ */
+ private $aVSResponse = null;
+
+ /**
+ * @property string $cardCodeResponse
+ */
+ private $cardCodeResponse = null;
+
+ /**
+ * @property string $cAVVResponse
+ */
+ private $cAVVResponse = null;
+
+ /**
+ * @property string $fDSFilterAction
+ */
+ private $fDSFilterAction = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\FDSFilterType[] $fDSFilters
+ */
+ private $fDSFilters = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\BatchDetailsType $batch
+ */
+ private $batch = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\OrderExType $order
+ */
+ private $order = null;
+
+ /**
+ * @property float $requestedAmount
+ */
+ private $requestedAmount = null;
+
+ /**
+ * @property float $authAmount
+ */
+ private $authAmount = null;
+
+ /**
+ * @property float $settleAmount
+ */
+ private $settleAmount = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $tax
+ */
+ private $tax = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $shipping
+ */
+ private $shipping = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $duty
+ */
+ private $duty = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\LineItemType[] $lineItems
+ */
+ private $lineItems = null;
+
+ /**
+ * @property float $prepaidBalanceRemaining
+ */
+ private $prepaidBalanceRemaining = null;
+
+ /**
+ * @property boolean $taxExempt
+ */
+ private $taxExempt = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentMaskedType $payment
+ */
+ private $payment = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerDataType $customer
+ */
+ private $customer = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressType $billTo
+ */
+ private $billTo = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\NameAndAddressType $shipTo
+ */
+ private $shipTo = null;
+
+ /**
+ * @property boolean $recurringBilling
+ */
+ private $recurringBilling = null;
+
+ /**
+ * @property string $customerIP
+ */
+ private $customerIP = null;
+
+ /**
+ * @property string $product
+ */
+ private $product = null;
+
+ /**
+ * @property string $entryMode
+ */
+ private $entryMode = null;
+
+ /**
+ * @property string $marketType
+ */
+ private $marketType = null;
+
+ /**
+ * @property string $mobileDeviceId
+ */
+ private $mobileDeviceId = null;
+
+ /**
+ * @property string $customerSignature
+ */
+ private $customerSignature = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ReturnedItemType[] $returnedItems
+ */
+ private $returnedItems = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\SolutionType $solution
+ */
+ private $solution = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType[]
+ * $emvDetails
+ */
+ private $emvDetails = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ */
+ private $profile = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $surcharge
+ */
+ private $surcharge = null;
+
+ /**
+ * @property string $employeeId
+ */
+ private $employeeId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $tip
+ */
+ private $tip = null;
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as refTransId
+ *
+ * @return string
+ */
+ public function getRefTransId()
+ {
+ return $this->refTransId;
+ }
+
+ /**
+ * Sets a new refTransId
+ *
+ * @param string $refTransId
+ * @return self
+ */
+ public function setRefTransId($refTransId)
+ {
+ $this->refTransId = $refTransId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as splitTenderId
+ *
+ * @return string
+ */
+ public function getSplitTenderId()
+ {
+ return $this->splitTenderId;
+ }
+
+ /**
+ * Sets a new splitTenderId
+ *
+ * @param string $splitTenderId
+ * @return self
+ */
+ public function setSplitTenderId($splitTenderId)
+ {
+ $this->splitTenderId = $splitTenderId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as submitTimeUTC
+ *
+ * @return \DateTime
+ */
+ public function getSubmitTimeUTC()
+ {
+ return $this->submitTimeUTC;
+ }
+
+ /**
+ * Sets a new submitTimeUTC
+ *
+ * @param \DateTime $submitTimeUTC
+ * @return self
+ */
+ public function setSubmitTimeUTC(\DateTime $submitTimeUTC)
+ {
+ $this->submitTimeUTC = $submitTimeUTC;\r
+ return $this;
+ }
+
+ /**
+ * Gets as submitTimeLocal
+ *
+ * @return \DateTime
+ */
+ public function getSubmitTimeLocal()
+ {
+ return $this->submitTimeLocal;
+ }
+
+ /**
+ * Sets a new submitTimeLocal
+ *
+ * @param \DateTime $submitTimeLocal
+ * @return self
+ */
+ public function setSubmitTimeLocal(\DateTime $submitTimeLocal)
+ {
+ $this->submitTimeLocal = $submitTimeLocal;\r
+ return $this;
+ }
+
+ /**
+ * Gets as transactionType
+ *
+ * @return string
+ */
+ public function getTransactionType()
+ {
+ return $this->transactionType;
+ }
+
+ /**
+ * Sets a new transactionType
+ *
+ * @param string $transactionType
+ * @return self
+ */
+ public function setTransactionType($transactionType)
+ {
+ $this->transactionType = $transactionType;\r
+ return $this;
+ }
+
+ /**
+ * Gets as transactionStatus
+ *
+ * @return string
+ */
+ public function getTransactionStatus()
+ {
+ return $this->transactionStatus;
+ }
+
+ /**
+ * Sets a new transactionStatus
+ *
+ * @param string $transactionStatus
+ * @return self
+ */
+ public function setTransactionStatus($transactionStatus)
+ {
+ $this->transactionStatus = $transactionStatus;\r
+ return $this;
+ }
+
+ /**
+ * Gets as responseCode
+ *
+ * @return integer
+ */
+ public function getResponseCode()
+ {
+ return $this->responseCode;
+ }
+
+ /**
+ * Sets a new responseCode
+ *
+ * @param integer $responseCode
+ * @return self
+ */
+ public function setResponseCode($responseCode)
+ {
+ $this->responseCode = $responseCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as responseReasonCode
+ *
+ * @return integer
+ */
+ public function getResponseReasonCode()
+ {
+ return $this->responseReasonCode;
+ }
+
+ /**
+ * Sets a new responseReasonCode
+ *
+ * @param integer $responseReasonCode
+ * @return self
+ */
+ public function setResponseReasonCode($responseReasonCode)
+ {
+ $this->responseReasonCode = $responseReasonCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as subscription
+ *
+ * @return \net\authorize\api\contract\v1\SubscriptionPaymentType
+ */
+ public function getSubscription()
+ {
+ return $this->subscription;
+ }
+
+ /**
+ * Sets a new subscription
+ *
+ * @param \net\authorize\api\contract\v1\SubscriptionPaymentType $subscription
+ * @return self
+ */
+ public function setSubscription(\net\authorize\api\contract\v1\SubscriptionPaymentType $subscription)
+ {
+ $this->subscription = $subscription;\r
+ return $this;
+ }
+
+ /**
+ * Gets as responseReasonDescription
+ *
+ * @return string
+ */
+ public function getResponseReasonDescription()
+ {
+ return $this->responseReasonDescription;
+ }
+
+ /**
+ * Sets a new responseReasonDescription
+ *
+ * @param string $responseReasonDescription
+ * @return self
+ */
+ public function setResponseReasonDescription($responseReasonDescription)
+ {
+ $this->responseReasonDescription = $responseReasonDescription;\r
+ return $this;
+ }
+
+ /**
+ * Gets as authCode
+ *
+ * @return string
+ */
+ public function getAuthCode()
+ {
+ return $this->authCode;
+ }
+
+ /**
+ * Sets a new authCode
+ *
+ * @param string $authCode
+ * @return self
+ */
+ public function setAuthCode($authCode)
+ {
+ $this->authCode = $authCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as aVSResponse
+ *
+ * @return string
+ */
+ public function getAVSResponse()
+ {
+ return $this->aVSResponse;
+ }
+
+ /**
+ * Sets a new aVSResponse
+ *
+ * @param string $aVSResponse
+ * @return self
+ */
+ public function setAVSResponse($aVSResponse)
+ {
+ $this->aVSResponse = $aVSResponse;\r
+ return $this;
+ }
+
+ /**
+ * Gets as cardCodeResponse
+ *
+ * @return string
+ */
+ public function getCardCodeResponse()
+ {
+ return $this->cardCodeResponse;
+ }
+
+ /**
+ * Sets a new cardCodeResponse
+ *
+ * @param string $cardCodeResponse
+ * @return self
+ */
+ public function setCardCodeResponse($cardCodeResponse)
+ {
+ $this->cardCodeResponse = $cardCodeResponse;\r
+ return $this;
+ }
+
+ /**
+ * Gets as cAVVResponse
+ *
+ * @return string
+ */
+ public function getCAVVResponse()
+ {
+ return $this->cAVVResponse;
+ }
+
+ /**
+ * Sets a new cAVVResponse
+ *
+ * @param string $cAVVResponse
+ * @return self
+ */
+ public function setCAVVResponse($cAVVResponse)
+ {
+ $this->cAVVResponse = $cAVVResponse;\r
+ return $this;
+ }
+
+ /**
+ * Gets as fDSFilterAction
+ *
+ * @return string
+ */
+ public function getFDSFilterAction()
+ {
+ return $this->fDSFilterAction;
+ }
+
+ /**
+ * Sets a new fDSFilterAction
+ *
+ * @param string $fDSFilterAction
+ * @return self
+ */
+ public function setFDSFilterAction($fDSFilterAction)
+ {
+ $this->fDSFilterAction = $fDSFilterAction;\r
+ return $this;
+ }
+
+ /**
+ * Adds as fDSFilter
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\FDSFilterType $fDSFilter
+ */
+ public function addToFDSFilters(\net\authorize\api\contract\v1\FDSFilterType $fDSFilter)
+ {
+ $this->fDSFilters[] = $fDSFilter;\r
+ return $this;
+ }
+
+ /**
+ * isset fDSFilters
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetFDSFilters($index)
+ {
+ return isset($this->fDSFilters[$index]);
+ }
+
+ /**
+ * unset fDSFilters
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetFDSFilters($index)
+ {
+ unset($this->fDSFilters[$index]);
+ }
+
+ /**
+ * Gets as fDSFilters
+ *
+ * @return \net\authorize\api\contract\v1\FDSFilterType[]
+ */
+ public function getFDSFilters()
+ {
+ return $this->fDSFilters;
+ }
+
+ /**
+ * Sets a new fDSFilters
+ *
+ * @param \net\authorize\api\contract\v1\FDSFilterType[] $fDSFilters
+ * @return self
+ */
+ public function setFDSFilters(array $fDSFilters)
+ {
+ $this->fDSFilters = $fDSFilters;\r
+ return $this;
+ }
+
+ /**
+ * Gets as batch
+ *
+ * @return \net\authorize\api\contract\v1\BatchDetailsType
+ */
+ public function getBatch()
+ {
+ return $this->batch;
+ }
+
+ /**
+ * Sets a new batch
+ *
+ * @param \net\authorize\api\contract\v1\BatchDetailsType $batch
+ * @return self
+ */
+ public function setBatch(\net\authorize\api\contract\v1\BatchDetailsType $batch)
+ {
+ $this->batch = $batch;\r
+ return $this;
+ }
+
+ /**
+ * Gets as order
+ *
+ * @return \net\authorize\api\contract\v1\OrderExType
+ */
+ public function getOrder()
+ {
+ return $this->order;
+ }
+
+ /**
+ * Sets a new order
+ *
+ * @param \net\authorize\api\contract\v1\OrderExType $order
+ * @return self
+ */
+ public function setOrder(\net\authorize\api\contract\v1\OrderExType $order)
+ {
+ $this->order = $order;\r
+ return $this;
+ }
+
+ /**
+ * Gets as requestedAmount
+ *
+ * @return float
+ */
+ public function getRequestedAmount()
+ {
+ return $this->requestedAmount;
+ }
+
+ /**
+ * Sets a new requestedAmount
+ *
+ * @param float $requestedAmount
+ * @return self
+ */
+ public function setRequestedAmount($requestedAmount)
+ {
+ $this->requestedAmount = $requestedAmount;\r
+ return $this;
+ }
+
+ /**
+ * Gets as authAmount
+ *
+ * @return float
+ */
+ public function getAuthAmount()
+ {
+ return $this->authAmount;
+ }
+
+ /**
+ * Sets a new authAmount
+ *
+ * @param float $authAmount
+ * @return self
+ */
+ public function setAuthAmount($authAmount)
+ {
+ $this->authAmount = $authAmount;\r
+ return $this;
+ }
+
+ /**
+ * Gets as settleAmount
+ *
+ * @return float
+ */
+ public function getSettleAmount()
+ {
+ return $this->settleAmount;
+ }
+
+ /**
+ * Sets a new settleAmount
+ *
+ * @param float $settleAmount
+ * @return self
+ */
+ public function setSettleAmount($settleAmount)
+ {
+ $this->settleAmount = $settleAmount;\r
+ return $this;
+ }
+
+ /**
+ * Gets as tax
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getTax()
+ {
+ return $this->tax;
+ }
+
+ /**
+ * Sets a new tax
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $tax
+ * @return self
+ */
+ public function setTax(\net\authorize\api\contract\v1\ExtendedAmountType $tax)
+ {
+ $this->tax = $tax;\r
+ return $this;
+ }
+
+ /**
+ * Gets as shipping
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getShipping()
+ {
+ return $this->shipping;
+ }
+
+ /**
+ * Sets a new shipping
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $shipping
+ * @return self
+ */
+ public function setShipping(\net\authorize\api\contract\v1\ExtendedAmountType $shipping)
+ {
+ $this->shipping = $shipping;\r
+ return $this;
+ }
+
+ /**
+ * Gets as duty
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getDuty()
+ {
+ return $this->duty;
+ }
+
+ /**
+ * Sets a new duty
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $duty
+ * @return self
+ */
+ public function setDuty(\net\authorize\api\contract\v1\ExtendedAmountType $duty)
+ {
+ $this->duty = $duty;\r
+ return $this;
+ }
+
+ /**
+ * Adds as lineItem
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\LineItemType $lineItem
+ */
+ public function addToLineItems(\net\authorize\api\contract\v1\LineItemType $lineItem)
+ {
+ $this->lineItems[] = $lineItem;\r
+ return $this;
+ }
+
+ /**
+ * isset lineItems
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetLineItems($index)
+ {
+ return isset($this->lineItems[$index]);
+ }
+
+ /**
+ * unset lineItems
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetLineItems($index)
+ {
+ unset($this->lineItems[$index]);
+ }
+
+ /**
+ * Gets as lineItems
+ *
+ * @return \net\authorize\api\contract\v1\LineItemType[]
+ */
+ public function getLineItems()
+ {
+ return $this->lineItems;
+ }
+
+ /**
+ * Sets a new lineItems
+ *
+ * @param \net\authorize\api\contract\v1\LineItemType[] $lineItems
+ * @return self
+ */
+ public function setLineItems(array $lineItems)
+ {
+ $this->lineItems = $lineItems;\r
+ return $this;
+ }
+
+ /**
+ * Gets as prepaidBalanceRemaining
+ *
+ * @return float
+ */
+ public function getPrepaidBalanceRemaining()
+ {
+ return $this->prepaidBalanceRemaining;
+ }
+
+ /**
+ * Sets a new prepaidBalanceRemaining
+ *
+ * @param float $prepaidBalanceRemaining
+ * @return self
+ */
+ public function setPrepaidBalanceRemaining($prepaidBalanceRemaining)
+ {
+ $this->prepaidBalanceRemaining = $prepaidBalanceRemaining;\r
+ return $this;
+ }
+
+ /**
+ * Gets as taxExempt
+ *
+ * @return boolean
+ */
+ public function getTaxExempt()
+ {
+ return $this->taxExempt;
+ }
+
+ /**
+ * Sets a new taxExempt
+ *
+ * @param boolean $taxExempt
+ * @return self
+ */
+ public function setTaxExempt($taxExempt)
+ {
+ $this->taxExempt = $taxExempt;\r
+ return $this;
+ }
+
+ /**
+ * Gets as payment
+ *
+ * @return \net\authorize\api\contract\v1\PaymentMaskedType
+ */
+ public function getPayment()
+ {
+ return $this->payment;
+ }
+
+ /**
+ * Sets a new payment
+ *
+ * @param \net\authorize\api\contract\v1\PaymentMaskedType $payment
+ * @return self
+ */
+ public function setPayment(\net\authorize\api\contract\v1\PaymentMaskedType $payment)
+ {
+ $this->payment = $payment;\r
+ return $this;
+ }
+
+ /**
+ * Gets as customer
+ *
+ * @return \net\authorize\api\contract\v1\CustomerDataType
+ */
+ public function getCustomer()
+ {
+ return $this->customer;
+ }
+
+ /**
+ * Sets a new customer
+ *
+ * @param \net\authorize\api\contract\v1\CustomerDataType $customer
+ * @return self
+ */
+ public function setCustomer(\net\authorize\api\contract\v1\CustomerDataType $customer)
+ {
+ $this->customer = $customer;\r
+ return $this;
+ }
+
+ /**
+ * Gets as billTo
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressType
+ */
+ public function getBillTo()
+ {
+ return $this->billTo;
+ }
+
+ /**
+ * Sets a new billTo
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressType $billTo
+ * @return self
+ */
+ public function setBillTo(\net\authorize\api\contract\v1\CustomerAddressType $billTo)
+ {
+ $this->billTo = $billTo;\r
+ return $this;
+ }
+
+ /**
+ * Gets as shipTo
+ *
+ * @return \net\authorize\api\contract\v1\NameAndAddressType
+ */
+ public function getShipTo()
+ {
+ return $this->shipTo;
+ }
+
+ /**
+ * Sets a new shipTo
+ *
+ * @param \net\authorize\api\contract\v1\NameAndAddressType $shipTo
+ * @return self
+ */
+ public function setShipTo(\net\authorize\api\contract\v1\NameAndAddressType $shipTo)
+ {
+ $this->shipTo = $shipTo;\r
+ return $this;
+ }
+
+ /**
+ * Gets as recurringBilling
+ *
+ * @return boolean
+ */
+ public function getRecurringBilling()
+ {
+ return $this->recurringBilling;
+ }
+
+ /**
+ * Sets a new recurringBilling
+ *
+ * @param boolean $recurringBilling
+ * @return self
+ */
+ public function setRecurringBilling($recurringBilling)
+ {
+ $this->recurringBilling = $recurringBilling;\r
+ return $this;
+ }
+
+ /**
+ * Gets as customerIP
+ *
+ * @return string
+ */
+ public function getCustomerIP()
+ {
+ return $this->customerIP;
+ }
+
+ /**
+ * Sets a new customerIP
+ *
+ * @param string $customerIP
+ * @return self
+ */
+ public function setCustomerIP($customerIP)
+ {
+ $this->customerIP = $customerIP;\r
+ return $this;
+ }
+
+ /**
+ * Gets as product
+ *
+ * @return string
+ */
+ public function getProduct()
+ {
+ return $this->product;
+ }
+
+ /**
+ * Sets a new product
+ *
+ * @param string $product
+ * @return self
+ */
+ public function setProduct($product)
+ {
+ $this->product = $product;\r
+ return $this;
+ }
+
+ /**
+ * Gets as entryMode
+ *
+ * @return string
+ */
+ public function getEntryMode()
+ {
+ return $this->entryMode;
+ }
+
+ /**
+ * Sets a new entryMode
+ *
+ * @param string $entryMode
+ * @return self
+ */
+ public function setEntryMode($entryMode)
+ {
+ $this->entryMode = $entryMode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as marketType
+ *
+ * @return string
+ */
+ public function getMarketType()
+ {
+ return $this->marketType;
+ }
+
+ /**
+ * Sets a new marketType
+ *
+ * @param string $marketType
+ * @return self
+ */
+ public function setMarketType($marketType)
+ {
+ $this->marketType = $marketType;\r
+ return $this;
+ }
+
+ /**
+ * Gets as mobileDeviceId
+ *
+ * @return string
+ */
+ public function getMobileDeviceId()
+ {
+ return $this->mobileDeviceId;
+ }
+
+ /**
+ * Sets a new mobileDeviceId
+ *
+ * @param string $mobileDeviceId
+ * @return self
+ */
+ public function setMobileDeviceId($mobileDeviceId)
+ {
+ $this->mobileDeviceId = $mobileDeviceId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as customerSignature
+ *
+ * @return string
+ */
+ public function getCustomerSignature()
+ {
+ return $this->customerSignature;
+ }
+
+ /**
+ * Sets a new customerSignature
+ *
+ * @param string $customerSignature
+ * @return self
+ */
+ public function setCustomerSignature($customerSignature)
+ {
+ $this->customerSignature = $customerSignature;\r
+ return $this;
+ }
+
+ /**
+ * Adds as returnedItem
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\ReturnedItemType $returnedItem
+ */
+ public function addToReturnedItems(\net\authorize\api\contract\v1\ReturnedItemType $returnedItem)
+ {
+ $this->returnedItems[] = $returnedItem;\r
+ return $this;
+ }
+
+ /**
+ * isset returnedItems
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetReturnedItems($index)
+ {
+ return isset($this->returnedItems[$index]);
+ }
+
+ /**
+ * unset returnedItems
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetReturnedItems($index)
+ {
+ unset($this->returnedItems[$index]);
+ }
+
+ /**
+ * Gets as returnedItems
+ *
+ * @return \net\authorize\api\contract\v1\ReturnedItemType[]
+ */
+ public function getReturnedItems()
+ {
+ return $this->returnedItems;
+ }
+
+ /**
+ * Sets a new returnedItems
+ *
+ * @param \net\authorize\api\contract\v1\ReturnedItemType[] $returnedItems
+ * @return self
+ */
+ public function setReturnedItems(array $returnedItems)
+ {
+ $this->returnedItems = $returnedItems;\r
+ return $this;
+ }
+
+ /**
+ * Gets as solution
+ *
+ * @return \net\authorize\api\contract\v1\SolutionType
+ */
+ public function getSolution()
+ {
+ return $this->solution;
+ }
+
+ /**
+ * Sets a new solution
+ *
+ * @param \net\authorize\api\contract\v1\SolutionType $solution
+ * @return self
+ */
+ public function setSolution(\net\authorize\api\contract\v1\SolutionType $solution)
+ {
+ $this->solution = $solution;\r
+ return $this;
+ }
+
+ /**
+ * Adds as tag
+ *
+ * @return self
+ * @param
+ * \net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType
+ * $tag
+ */
+ public function addToEmvDetails(\net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType $tag)
+ {
+ $this->emvDetails[] = $tag;\r
+ return $this;
+ }
+
+ /**
+ * isset emvDetails
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetEmvDetails($index)
+ {
+ return isset($this->emvDetails[$index]);
+ }
+
+ /**
+ * unset emvDetails
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetEmvDetails($index)
+ {
+ unset($this->emvDetails[$index]);
+ }
+
+ /**
+ * Gets as emvDetails
+ *
+ * @return
+ * \net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType[]
+ */
+ public function getEmvDetails()
+ {
+ return $this->emvDetails;
+ }
+
+ /**
+ * Sets a new emvDetails
+ *
+ * @param
+ * \net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType[]
+ * $emvDetails
+ * @return self
+ */
+ public function setEmvDetails(array $emvDetails)
+ {
+ $this->emvDetails = $emvDetails;\r
+ return $this;
+ }
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileIdType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfileIdType $profile)
+ {
+ $this->profile = $profile;\r
+ return $this;
+ }
+
+ /**
+ * Gets as surcharge
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getSurcharge()
+ {
+ return $this->surcharge;
+ }
+
+ /**
+ * Sets a new surcharge
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $surcharge
+ * @return self
+ */
+ public function setSurcharge(\net\authorize\api\contract\v1\ExtendedAmountType $surcharge)
+ {
+ $this->surcharge = $surcharge;\r
+ return $this;
+ }
+
+ /**
+ * Gets as employeeId
+ *
+ * @return string
+ */
+ public function getEmployeeId()
+ {
+ return $this->employeeId;
+ }
+
+ /**
+ * Sets a new employeeId
+ *
+ * @param string $employeeId
+ * @return self
+ */
+ public function setEmployeeId($employeeId)
+ {
+ $this->employeeId = $employeeId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as tip
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getTip()
+ {
+ return $this->tip;
+ }
+
+ /**
+ * Sets a new tip
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $tip
+ * @return self
+ */
+ public function setTip(\net\authorize\api\contract\v1\ExtendedAmountType $tip)
+ {
+ $this->tip = $tip;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionDetailsType;
+
+/**
+ * Class representing EmvDetailsAType
+ */
+class EmvDetailsAType
+{
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType[]
+ * $tag
+ */
+ private $tag = null;
+
+ /**
+ * Adds as tag
+ *
+ * @return self
+ * @param
+ * \net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType
+ * $tag
+ */
+ public function addToTag(\net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType $tag)
+ {
+ $this->tag[] = $tag;
+ return $this;
+ }
+
+ /**
+ * isset tag
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetTag($index)
+ {
+ return isset($this->tag[$index]);
+ }
+
+ /**
+ * unset tag
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetTag($index)
+ {
+ unset($this->tag[$index]);
+ }
+
+ /**
+ * Gets as tag
+ *
+ * @return
+ * \net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType[]
+ */
+ public function getTag()
+ {
+ return $this->tag;
+ }
+
+ /**
+ * Sets a new tag
+ *
+ * @param
+ * \net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType[]
+ * $tag
+ * @return self
+ */
+ public function setTag(array $tag)
+ {
+ $this->tag = $tag;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType;
+
+/**
+ * Class representing TagAType
+ */
+class TagAType
+{
+
+ /**
+ * @property string $tagId
+ */
+ private $tagId = null;
+
+ /**
+ * @property string $data
+ */
+ private $data = null;
+
+ /**
+ * Gets as tagId
+ *
+ * @return string
+ */
+ public function getTagId()
+ {
+ return $this->tagId;
+ }
+
+ /**
+ * Sets a new tagId
+ *
+ * @param string $tagId
+ * @return self
+ */
+ public function setTagId($tagId)
+ {
+ $this->tagId = $tagId;
+ return $this;
+ }
+
+ /**
+ * Gets as data
+ *
+ * @return string
+ */
+ public function getData()
+ {
+ return $this->data;
+ }
+
+ /**
+ * Sets a new data
+ *
+ * @param string $data
+ * @return self
+ */
+ public function setData($data)
+ {
+ $this->data = $data;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing TransactionListSortingType
+ *
+ *
+ * XSD Type: TransactionListSorting
+ */
+class TransactionListSortingType
+{
+
+ /**
+ * @property string $orderBy
+ */
+ private $orderBy = null;
+
+ /**
+ * @property boolean $orderDescending
+ */
+ private $orderDescending = null;
+
+ /**
+ * Gets as orderBy
+ *
+ * @return string
+ */
+ public function getOrderBy()
+ {
+ return $this->orderBy;
+ }
+
+ /**
+ * Sets a new orderBy
+ *
+ * @param string $orderBy
+ * @return self
+ */
+ public function setOrderBy($orderBy)
+ {
+ $this->orderBy = $orderBy;
+ return $this;
+ }
+
+ /**
+ * Gets as orderDescending
+ *
+ * @return boolean
+ */
+ public function getOrderDescending()
+ {
+ return $this->orderDescending;
+ }
+
+ /**
+ * Sets a new orderDescending
+ *
+ * @param boolean $orderDescending
+ * @return self
+ */
+ public function setOrderDescending($orderDescending)
+ {
+ $this->orderDescending = $orderDescending;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing TransactionRequestType
+ *
+ * \r
+ * XSD Type: transactionRequestType
+ */
+class TransactionRequestType
+{
+
+ /**
+ * @property string $transactionType
+ */
+ private $transactionType = null;
+
+ /**
+ * @property float $amount
+ */
+ private $amount = null;
+
+ /**
+ * @property string $currencyCode
+ */
+ private $currencyCode = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\PaymentType $payment
+ */
+ private $payment = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfilePaymentType $profile
+ */
+ private $profile = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\SolutionType $solution
+ */
+ private $solution = null;
+
+ /**
+ * @property string $callId
+ */
+ private $callId = null;
+
+ /**
+ * @property string $terminalNumber
+ */
+ private $terminalNumber = null;
+
+ /**
+ * @property string $authCode
+ */
+ private $authCode = null;
+
+ /**
+ * @property string $refTransId
+ */
+ private $refTransId = null;
+
+ /**
+ * @property string $splitTenderId
+ */
+ private $splitTenderId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\OrderType $order
+ */
+ private $order = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\LineItemType[] $lineItems
+ */
+ private $lineItems = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $tax
+ */
+ private $tax = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $duty
+ */
+ private $duty = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $shipping
+ */
+ private $shipping = null;
+
+ /**
+ * @property boolean $taxExempt
+ */
+ private $taxExempt = null;
+
+ /**
+ * @property string $poNumber
+ */
+ private $poNumber = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerDataType $customer
+ */
+ private $customer = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressType $billTo
+ */
+ private $billTo = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\NameAndAddressType $shipTo
+ */
+ private $shipTo = null;
+
+ /**
+ * @property string $customerIP
+ */
+ private $customerIP = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CcAuthenticationType
+ * $cardholderAuthentication
+ */
+ private $cardholderAuthentication = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransRetailInfoType $retail
+ */
+ private $retail = null;
+
+ /**
+ * @property string $employeeId
+ */
+ private $employeeId = null;
+
+ /**
+ * Allowed values for settingName are: emailCustomer, merchantEmail,
+ * allowPartialAuth, headerEmailReceipt, footerEmailReceipt, recurringBilling,
+ * duplicateWindow, testRequest.
+ *
+ * @property \net\authorize\api\contract\v1\SettingType[] $transactionSettings
+ */
+ private $transactionSettings = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\UserFieldType[] $userFields
+ */
+ private $userFields = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $surcharge
+ */
+ private $surcharge = null;
+
+ /**
+ * @property string $merchantDescriptor
+ */
+ private $merchantDescriptor = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\SubMerchantType $subMerchant
+ */
+ private $subMerchant = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\ExtendedAmountType $tip
+ */
+ private $tip = null;
+
+ /**
+ * Gets as transactionType
+ *
+ * @return string
+ */
+ public function getTransactionType()
+ {
+ return $this->transactionType;
+ }
+
+ /**
+ * Sets a new transactionType
+ *
+ * @param string $transactionType
+ * @return self
+ */
+ public function setTransactionType($transactionType)
+ {
+ $this->transactionType = $transactionType;\r
+ return $this;
+ }
+
+ /**
+ * Gets as amount
+ *
+ * @return float
+ */
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ /**
+ * Sets a new amount
+ *
+ * @param float $amount
+ * @return self
+ */
+ public function setAmount($amount)
+ {
+ $this->amount = $amount;\r
+ return $this;
+ }
+
+ /**
+ * Gets as currencyCode
+ *
+ * @return string
+ */
+ public function getCurrencyCode()
+ {
+ return $this->currencyCode;
+ }
+
+ /**
+ * Sets a new currencyCode
+ *
+ * @param string $currencyCode
+ * @return self
+ */
+ public function setCurrencyCode($currencyCode)
+ {
+ $this->currencyCode = $currencyCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as payment
+ *
+ * @return \net\authorize\api\contract\v1\PaymentType
+ */
+ public function getPayment()
+ {
+ return $this->payment;
+ }
+
+ /**
+ * Sets a new payment
+ *
+ * @param \net\authorize\api\contract\v1\PaymentType $payment
+ * @return self
+ */
+ public function setPayment(\net\authorize\api\contract\v1\PaymentType $payment)
+ {
+ $this->payment = $payment;\r
+ return $this;
+ }
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfilePaymentType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfilePaymentType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfilePaymentType $profile)
+ {
+ $this->profile = $profile;\r
+ return $this;
+ }
+
+ /**
+ * Gets as solution
+ *
+ * @return \net\authorize\api\contract\v1\SolutionType
+ */
+ public function getSolution()
+ {
+ return $this->solution;
+ }
+
+ /**
+ * Sets a new solution
+ *
+ * @param \net\authorize\api\contract\v1\SolutionType $solution
+ * @return self
+ */
+ public function setSolution(\net\authorize\api\contract\v1\SolutionType $solution)
+ {
+ $this->solution = $solution;\r
+ return $this;
+ }
+
+ /**
+ * Gets as callId
+ *
+ * @return string
+ */
+ public function getCallId()
+ {
+ return $this->callId;
+ }
+
+ /**
+ * Sets a new callId
+ *
+ * @param string $callId
+ * @return self
+ */
+ public function setCallId($callId)
+ {
+ $this->callId = $callId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as terminalNumber
+ *
+ * @return string
+ */
+ public function getTerminalNumber()
+ {
+ return $this->terminalNumber;
+ }
+
+ /**
+ * Sets a new terminalNumber
+ *
+ * @param string $terminalNumber
+ * @return self
+ */
+ public function setTerminalNumber($terminalNumber)
+ {
+ $this->terminalNumber = $terminalNumber;\r
+ return $this;
+ }
+
+ /**
+ * Gets as authCode
+ *
+ * @return string
+ */
+ public function getAuthCode()
+ {
+ return $this->authCode;
+ }
+
+ /**
+ * Sets a new authCode
+ *
+ * @param string $authCode
+ * @return self
+ */
+ public function setAuthCode($authCode)
+ {
+ $this->authCode = $authCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as refTransId
+ *
+ * @return string
+ */
+ public function getRefTransId()
+ {
+ return $this->refTransId;
+ }
+
+ /**
+ * Sets a new refTransId
+ *
+ * @param string $refTransId
+ * @return self
+ */
+ public function setRefTransId($refTransId)
+ {
+ $this->refTransId = $refTransId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as splitTenderId
+ *
+ * @return string
+ */
+ public function getSplitTenderId()
+ {
+ return $this->splitTenderId;
+ }
+
+ /**
+ * Sets a new splitTenderId
+ *
+ * @param string $splitTenderId
+ * @return self
+ */
+ public function setSplitTenderId($splitTenderId)
+ {
+ $this->splitTenderId = $splitTenderId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as order
+ *
+ * @return \net\authorize\api\contract\v1\OrderType
+ */
+ public function getOrder()
+ {
+ return $this->order;
+ }
+
+ /**
+ * Sets a new order
+ *
+ * @param \net\authorize\api\contract\v1\OrderType $order
+ * @return self
+ */
+ public function setOrder(\net\authorize\api\contract\v1\OrderType $order)
+ {
+ $this->order = $order;\r
+ return $this;
+ }
+
+ /**
+ * Adds as lineItem
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\LineItemType $lineItem
+ */
+ public function addToLineItems(\net\authorize\api\contract\v1\LineItemType $lineItem)
+ {
+ $this->lineItems[] = $lineItem;\r
+ return $this;
+ }
+
+ /**
+ * isset lineItems
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetLineItems($index)
+ {
+ return isset($this->lineItems[$index]);
+ }
+
+ /**
+ * unset lineItems
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetLineItems($index)
+ {
+ unset($this->lineItems[$index]);
+ }
+
+ /**
+ * Gets as lineItems
+ *
+ * @return \net\authorize\api\contract\v1\LineItemType[]
+ */
+ public function getLineItems()
+ {
+ return $this->lineItems;
+ }
+
+ /**
+ * Sets a new lineItems
+ *
+ * @param \net\authorize\api\contract\v1\LineItemType[] $lineItems
+ * @return self
+ */
+ public function setLineItems(array $lineItems)
+ {
+ $this->lineItems = $lineItems;\r
+ return $this;
+ }
+
+ /**
+ * Gets as tax
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getTax()
+ {
+ return $this->tax;
+ }
+
+ /**
+ * Sets a new tax
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $tax
+ * @return self
+ */
+ public function setTax(\net\authorize\api\contract\v1\ExtendedAmountType $tax)
+ {
+ $this->tax = $tax;\r
+ return $this;
+ }
+
+ /**
+ * Gets as duty
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getDuty()
+ {
+ return $this->duty;
+ }
+
+ /**
+ * Sets a new duty
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $duty
+ * @return self
+ */
+ public function setDuty(\net\authorize\api\contract\v1\ExtendedAmountType $duty)
+ {
+ $this->duty = $duty;\r
+ return $this;
+ }
+
+ /**
+ * Gets as shipping
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getShipping()
+ {
+ return $this->shipping;
+ }
+
+ /**
+ * Sets a new shipping
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $shipping
+ * @return self
+ */
+ public function setShipping(\net\authorize\api\contract\v1\ExtendedAmountType $shipping)
+ {
+ $this->shipping = $shipping;\r
+ return $this;
+ }
+
+ /**
+ * Gets as taxExempt
+ *
+ * @return boolean
+ */
+ public function getTaxExempt()
+ {
+ return $this->taxExempt;
+ }
+
+ /**
+ * Sets a new taxExempt
+ *
+ * @param boolean $taxExempt
+ * @return self
+ */
+ public function setTaxExempt($taxExempt)
+ {
+ $this->taxExempt = $taxExempt;\r
+ return $this;
+ }
+
+ /**
+ * Gets as poNumber
+ *
+ * @return string
+ */
+ public function getPoNumber()
+ {
+ return $this->poNumber;
+ }
+
+ /**
+ * Sets a new poNumber
+ *
+ * @param string $poNumber
+ * @return self
+ */
+ public function setPoNumber($poNumber)
+ {
+ $this->poNumber = $poNumber;\r
+ return $this;
+ }
+
+ /**
+ * Gets as customer
+ *
+ * @return \net\authorize\api\contract\v1\CustomerDataType
+ */
+ public function getCustomer()
+ {
+ return $this->customer;
+ }
+
+ /**
+ * Sets a new customer
+ *
+ * @param \net\authorize\api\contract\v1\CustomerDataType $customer
+ * @return self
+ */
+ public function setCustomer(\net\authorize\api\contract\v1\CustomerDataType $customer)
+ {
+ $this->customer = $customer;\r
+ return $this;
+ }
+
+ /**
+ * Gets as billTo
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressType
+ */
+ public function getBillTo()
+ {
+ return $this->billTo;
+ }
+
+ /**
+ * Sets a new billTo
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressType $billTo
+ * @return self
+ */
+ public function setBillTo(\net\authorize\api\contract\v1\CustomerAddressType $billTo)
+ {
+ $this->billTo = $billTo;\r
+ return $this;
+ }
+
+ /**
+ * Gets as shipTo
+ *
+ * @return \net\authorize\api\contract\v1\NameAndAddressType
+ */
+ public function getShipTo()
+ {
+ return $this->shipTo;
+ }
+
+ /**
+ * Sets a new shipTo
+ *
+ * @param \net\authorize\api\contract\v1\NameAndAddressType $shipTo
+ * @return self
+ */
+ public function setShipTo(\net\authorize\api\contract\v1\NameAndAddressType $shipTo)
+ {
+ $this->shipTo = $shipTo;\r
+ return $this;
+ }
+
+ /**
+ * Gets as customerIP
+ *
+ * @return string
+ */
+ public function getCustomerIP()
+ {
+ return $this->customerIP;
+ }
+
+ /**
+ * Sets a new customerIP
+ *
+ * @param string $customerIP
+ * @return self
+ */
+ public function setCustomerIP($customerIP)
+ {
+ $this->customerIP = $customerIP;\r
+ return $this;
+ }
+
+ /**
+ * Gets as cardholderAuthentication
+ *
+ * @return \net\authorize\api\contract\v1\CcAuthenticationType
+ */
+ public function getCardholderAuthentication()
+ {
+ return $this->cardholderAuthentication;
+ }
+
+ /**
+ * Sets a new cardholderAuthentication
+ *
+ * @param \net\authorize\api\contract\v1\CcAuthenticationType
+ * $cardholderAuthentication
+ * @return self
+ */
+ public function setCardholderAuthentication(\net\authorize\api\contract\v1\CcAuthenticationType $cardholderAuthentication)
+ {
+ $this->cardholderAuthentication = $cardholderAuthentication;\r
+ return $this;
+ }
+
+ /**
+ * Gets as retail
+ *
+ * @return \net\authorize\api\contract\v1\TransRetailInfoType
+ */
+ public function getRetail()
+ {
+ return $this->retail;
+ }
+
+ /**
+ * Sets a new retail
+ *
+ * @param \net\authorize\api\contract\v1\TransRetailInfoType $retail
+ * @return self
+ */
+ public function setRetail(\net\authorize\api\contract\v1\TransRetailInfoType $retail)
+ {
+ $this->retail = $retail;\r
+ return $this;
+ }
+
+ /**
+ * Gets as employeeId
+ *
+ * @return string
+ */
+ public function getEmployeeId()
+ {
+ return $this->employeeId;
+ }
+
+ /**
+ * Sets a new employeeId
+ *
+ * @param string $employeeId
+ * @return self
+ */
+ public function setEmployeeId($employeeId)
+ {
+ $this->employeeId = $employeeId;\r
+ return $this;
+ }
+
+ /**
+ * Adds as setting
+ *
+ * Allowed values for settingName are: emailCustomer, merchantEmail,
+ * allowPartialAuth, headerEmailReceipt, footerEmailReceipt, recurringBilling,
+ * duplicateWindow, testRequest.
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\SettingType $setting
+ */
+ public function addToTransactionSettings(\net\authorize\api\contract\v1\SettingType $setting)
+ {
+ $this->transactionSettings[] = $setting;\r
+ return $this;
+ }
+
+ /**
+ * isset transactionSettings
+ *
+ * Allowed values for settingName are: emailCustomer, merchantEmail,
+ * allowPartialAuth, headerEmailReceipt, footerEmailReceipt, recurringBilling,
+ * duplicateWindow, testRequest.
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetTransactionSettings($index)
+ {
+ return isset($this->transactionSettings[$index]);
+ }
+
+ /**
+ * unset transactionSettings
+ *
+ * Allowed values for settingName are: emailCustomer, merchantEmail,
+ * allowPartialAuth, headerEmailReceipt, footerEmailReceipt, recurringBilling,
+ * duplicateWindow, testRequest.
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetTransactionSettings($index)
+ {
+ unset($this->transactionSettings[$index]);
+ }
+
+ /**
+ * Gets as transactionSettings
+ *
+ * Allowed values for settingName are: emailCustomer, merchantEmail,
+ * allowPartialAuth, headerEmailReceipt, footerEmailReceipt, recurringBilling,
+ * duplicateWindow, testRequest.
+ *
+ * @return \net\authorize\api\contract\v1\SettingType[]
+ */
+ public function getTransactionSettings()
+ {
+ return $this->transactionSettings;
+ }
+
+ /**
+ * Sets a new transactionSettings
+ *
+ * Allowed values for settingName are: emailCustomer, merchantEmail,
+ * allowPartialAuth, headerEmailReceipt, footerEmailReceipt, recurringBilling,
+ * duplicateWindow, testRequest.
+ *
+ * @param \net\authorize\api\contract\v1\SettingType[] $transactionSettings
+ * @return self
+ */
+ public function setTransactionSettings(array $transactionSettings)
+ {
+ $this->transactionSettings = $transactionSettings;\r
+ return $this;
+ }
+
+ /**
+ * Adds as userField
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\UserFieldType $userField
+ */
+ public function addToUserFields(\net\authorize\api\contract\v1\UserFieldType $userField)
+ {
+ $this->userFields[] = $userField;\r
+ return $this;
+ }
+
+ /**
+ * isset userFields
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetUserFields($index)
+ {
+ return isset($this->userFields[$index]);
+ }
+
+ /**
+ * unset userFields
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetUserFields($index)
+ {
+ unset($this->userFields[$index]);
+ }
+
+ /**
+ * Gets as userFields
+ *
+ * @return \net\authorize\api\contract\v1\UserFieldType[]
+ */
+ public function getUserFields()
+ {
+ return $this->userFields;
+ }
+
+ /**
+ * Sets a new userFields
+ *
+ * @param \net\authorize\api\contract\v1\UserFieldType[] $userFields
+ * @return self
+ */
+ public function setUserFields(array $userFields)
+ {
+ $this->userFields = $userFields;\r
+ return $this;
+ }
+
+ /**
+ * Gets as surcharge
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getSurcharge()
+ {
+ return $this->surcharge;
+ }
+
+ /**
+ * Sets a new surcharge
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $surcharge
+ * @return self
+ */
+ public function setSurcharge(\net\authorize\api\contract\v1\ExtendedAmountType $surcharge)
+ {
+ $this->surcharge = $surcharge;\r
+ return $this;
+ }
+
+ /**
+ * Gets as merchantDescriptor
+ *
+ * @return string
+ */
+ public function getMerchantDescriptor()
+ {
+ return $this->merchantDescriptor;
+ }
+
+ /**
+ * Sets a new merchantDescriptor
+ *
+ * @param string $merchantDescriptor
+ * @return self
+ */
+ public function setMerchantDescriptor($merchantDescriptor)
+ {
+ $this->merchantDescriptor = $merchantDescriptor;\r
+ return $this;
+ }
+
+ /**
+ * Gets as subMerchant
+ *
+ * @return \net\authorize\api\contract\v1\SubMerchantType
+ */
+ public function getSubMerchant()
+ {
+ return $this->subMerchant;
+ }
+
+ /**
+ * Sets a new subMerchant
+ *
+ * @param \net\authorize\api\contract\v1\SubMerchantType $subMerchant
+ * @return self
+ */
+ public function setSubMerchant(\net\authorize\api\contract\v1\SubMerchantType $subMerchant)
+ {
+ $this->subMerchant = $subMerchant;\r
+ return $this;
+ }
+
+ /**
+ * Gets as tip
+ *
+ * @return \net\authorize\api\contract\v1\ExtendedAmountType
+ */
+ public function getTip()
+ {
+ return $this->tip;
+ }
+
+ /**
+ * Sets a new tip
+ *
+ * @param \net\authorize\api\contract\v1\ExtendedAmountType $tip
+ * @return self
+ */
+ public function setTip(\net\authorize\api\contract\v1\ExtendedAmountType $tip)
+ {
+ $this->tip = $tip;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionRequestType;
+
+/**
+ * Class representing UserFieldsAType
+ */
+class UserFieldsAType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\UserFieldType[] $userField
+ */
+ private $userField = null;
+
+ /**
+ * Adds as userField
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\UserFieldType $userField
+ */
+ public function addToUserField(\net\authorize\api\contract\v1\UserFieldType $userField)
+ {
+ $this->userField[] = $userField;
+ return $this;
+ }
+
+ /**
+ * isset userField
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetUserField($index)
+ {
+ return isset($this->userField[$index]);
+ }
+
+ /**
+ * unset userField
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetUserField($index)
+ {
+ unset($this->userField[$index]);
+ }
+
+ /**
+ * Gets as userField
+ *
+ * @return \net\authorize\api\contract\v1\UserFieldType[]
+ */
+ public function getUserField()
+ {
+ return $this->userField;
+ }
+
+ /**
+ * Sets a new userField
+ *
+ * @param \net\authorize\api\contract\v1\UserFieldType[] $userField
+ * @return self
+ */
+ public function setUserField(array $userField)
+ {
+ $this->userField = $userField;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing TransactionResponseType
+ *
+ * \r
+ * XSD Type: transactionResponse
+ */
+class TransactionResponseType
+{
+
+ /**
+ * @property string $responseCode
+ */
+ private $responseCode = null;
+
+ /**
+ * @property string $rawResponseCode
+ */
+ private $rawResponseCode = null;
+
+ /**
+ * @property string $authCode
+ */
+ private $authCode = null;
+
+ /**
+ * @property string $avsResultCode
+ */
+ private $avsResultCode = null;
+
+ /**
+ * @property string $cvvResultCode
+ */
+ private $cvvResultCode = null;
+
+ /**
+ * @property string $cavvResultCode
+ */
+ private $cavvResultCode = null;
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * @property string $refTransID
+ */
+ private $refTransID = null;
+
+ /**
+ * @property string $transHash
+ */
+ private $transHash = null;
+
+ /**
+ * @property string $testRequest
+ */
+ private $testRequest = null;
+
+ /**
+ * @property string $accountNumber
+ */
+ private $accountNumber = null;
+
+ /**
+ * @property string $entryMode
+ */
+ private $entryMode = null;
+
+ /**
+ * @property string $accountType
+ */
+ private $accountType = null;
+
+ /**
+ * @property string $splitTenderId
+ */
+ private $splitTenderId = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionResponseType\PrePaidCardAType
+ * $prePaidCard
+ */
+ private $prePaidCard = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType[]
+ * $messages
+ */
+ private $messages = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType[]
+ * $errors
+ */
+ private $errors = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType[]
+ * $splitTenderPayments
+ */
+ private $splitTenderPayments = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\UserFieldType[] $userFields
+ */
+ private $userFields = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\NameAndAddressType $shipTo
+ */
+ private $shipTo = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionResponseType\SecureAcceptanceAType
+ * $secureAcceptance
+ */
+ private $secureAcceptance = null;
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionResponseType\EmvResponseAType
+ * $emvResponse
+ */
+ private $emvResponse = null;
+
+ /**
+ * @property string $transHashSha2
+ */
+ private $transHashSha2 = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ */
+ private $profile = null;
+
+ /**
+ * Gets as responseCode
+ *
+ * @return string
+ */
+ public function getResponseCode()
+ {
+ return $this->responseCode;
+ }
+
+ /**
+ * Sets a new responseCode
+ *
+ * @param string $responseCode
+ * @return self
+ */
+ public function setResponseCode($responseCode)
+ {
+ $this->responseCode = $responseCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as rawResponseCode
+ *
+ * @return string
+ */
+ public function getRawResponseCode()
+ {
+ return $this->rawResponseCode;
+ }
+
+ /**
+ * Sets a new rawResponseCode
+ *
+ * @param string $rawResponseCode
+ * @return self
+ */
+ public function setRawResponseCode($rawResponseCode)
+ {
+ $this->rawResponseCode = $rawResponseCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as authCode
+ *
+ * @return string
+ */
+ public function getAuthCode()
+ {
+ return $this->authCode;
+ }
+
+ /**
+ * Sets a new authCode
+ *
+ * @param string $authCode
+ * @return self
+ */
+ public function setAuthCode($authCode)
+ {
+ $this->authCode = $authCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as avsResultCode
+ *
+ * @return string
+ */
+ public function getAvsResultCode()
+ {
+ return $this->avsResultCode;
+ }
+
+ /**
+ * Sets a new avsResultCode
+ *
+ * @param string $avsResultCode
+ * @return self
+ */
+ public function setAvsResultCode($avsResultCode)
+ {
+ $this->avsResultCode = $avsResultCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as cvvResultCode
+ *
+ * @return string
+ */
+ public function getCvvResultCode()
+ {
+ return $this->cvvResultCode;
+ }
+
+ /**
+ * Sets a new cvvResultCode
+ *
+ * @param string $cvvResultCode
+ * @return self
+ */
+ public function setCvvResultCode($cvvResultCode)
+ {
+ $this->cvvResultCode = $cvvResultCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as cavvResultCode
+ *
+ * @return string
+ */
+ public function getCavvResultCode()
+ {
+ return $this->cavvResultCode;
+ }
+
+ /**
+ * Sets a new cavvResultCode
+ *
+ * @param string $cavvResultCode
+ * @return self
+ */
+ public function setCavvResultCode($cavvResultCode)
+ {
+ $this->cavvResultCode = $cavvResultCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as refTransID
+ *
+ * @return string
+ */
+ public function getRefTransID()
+ {
+ return $this->refTransID;
+ }
+
+ /**
+ * Sets a new refTransID
+ *
+ * @param string $refTransID
+ * @return self
+ */
+ public function setRefTransID($refTransID)
+ {
+ $this->refTransID = $refTransID;\r
+ return $this;
+ }
+
+ /**
+ * Gets as transHash
+ *
+ * @return string
+ */
+ public function getTransHash()
+ {
+ return $this->transHash;
+ }
+
+ /**
+ * Sets a new transHash
+ *
+ * @param string $transHash
+ * @return self
+ */
+ public function setTransHash($transHash)
+ {
+ $this->transHash = $transHash;\r
+ return $this;
+ }
+
+ /**
+ * Gets as testRequest
+ *
+ * @return string
+ */
+ public function getTestRequest()
+ {
+ return $this->testRequest;
+ }
+
+ /**
+ * Sets a new testRequest
+ *
+ * @param string $testRequest
+ * @return self
+ */
+ public function setTestRequest($testRequest)
+ {
+ $this->testRequest = $testRequest;\r
+ return $this;
+ }
+
+ /**
+ * Gets as accountNumber
+ *
+ * @return string
+ */
+ public function getAccountNumber()
+ {
+ return $this->accountNumber;
+ }
+
+ /**
+ * Sets a new accountNumber
+ *
+ * @param string $accountNumber
+ * @return self
+ */
+ public function setAccountNumber($accountNumber)
+ {
+ $this->accountNumber = $accountNumber;\r
+ return $this;
+ }
+
+ /**
+ * Gets as entryMode
+ *
+ * @return string
+ */
+ public function getEntryMode()
+ {
+ return $this->entryMode;
+ }
+
+ /**
+ * Sets a new entryMode
+ *
+ * @param string $entryMode
+ * @return self
+ */
+ public function setEntryMode($entryMode)
+ {
+ $this->entryMode = $entryMode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as accountType
+ *
+ * @return string
+ */
+ public function getAccountType()
+ {
+ return $this->accountType;
+ }
+
+ /**
+ * Sets a new accountType
+ *
+ * @param string $accountType
+ * @return self
+ */
+ public function setAccountType($accountType)
+ {
+ $this->accountType = $accountType;\r
+ return $this;
+ }
+
+ /**
+ * Gets as splitTenderId
+ *
+ * @return string
+ */
+ public function getSplitTenderId()
+ {
+ return $this->splitTenderId;
+ }
+
+ /**
+ * Sets a new splitTenderId
+ *
+ * @param string $splitTenderId
+ * @return self
+ */
+ public function setSplitTenderId($splitTenderId)
+ {
+ $this->splitTenderId = $splitTenderId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as prePaidCard
+ *
+ * @return \net\authorize\api\contract\v1\TransactionResponseType\PrePaidCardAType
+ */
+ public function getPrePaidCard()
+ {
+ return $this->prePaidCard;
+ }
+
+ /**
+ * Sets a new prePaidCard
+ *
+ * @param \net\authorize\api\contract\v1\TransactionResponseType\PrePaidCardAType
+ * $prePaidCard
+ * @return self
+ */
+ public function setPrePaidCard(\net\authorize\api\contract\v1\TransactionResponseType\PrePaidCardAType $prePaidCard)
+ {
+ $this->prePaidCard = $prePaidCard;\r
+ return $this;
+ }
+
+ /**
+ * Adds as message
+ *
+ * @return self
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType
+ * $message
+ */
+ public function addToMessages(\net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType $message)
+ {
+ $this->messages[] = $message;\r
+ return $this;
+ }
+
+ /**
+ * isset messages
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetMessages($index)
+ {
+ return isset($this->messages[$index]);
+ }
+
+ /**
+ * unset messages
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetMessages($index)
+ {
+ unset($this->messages[$index]);
+ }
+
+ /**
+ * Gets as messages
+ *
+ * @return
+ * \net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType[]
+ */
+ public function getMessages()
+ {
+ return $this->messages;
+ }
+
+ /**
+ * Sets a new messages
+ *
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType[]
+ * $messages
+ * @return self
+ */
+ public function setMessages(array $messages)
+ {
+ $this->messages = $messages;\r
+ return $this;
+ }
+
+ /**
+ * Adds as error
+ *
+ * @return self
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType
+ * $error
+ */
+ public function addToErrors(\net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType $error)
+ {
+ $this->errors[] = $error;\r
+ return $this;
+ }
+
+ /**
+ * isset errors
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetErrors($index)
+ {
+ return isset($this->errors[$index]);
+ }
+
+ /**
+ * unset errors
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetErrors($index)
+ {
+ unset($this->errors[$index]);
+ }
+
+ /**
+ * Gets as errors
+ *
+ * @return
+ * \net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType[]
+ */
+ public function getErrors()
+ {
+ return $this->errors;
+ }
+
+ /**
+ * Sets a new errors
+ *
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType[]
+ * $errors
+ * @return self
+ */
+ public function setErrors(array $errors)
+ {
+ $this->errors = $errors;\r
+ return $this;
+ }
+
+ /**
+ * Adds as splitTenderPayment
+ *
+ * @return self
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType
+ * $splitTenderPayment
+ */
+ public function addToSplitTenderPayments(\net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType $splitTenderPayment)
+ {
+ $this->splitTenderPayments[] = $splitTenderPayment;\r
+ return $this;
+ }
+
+ /**
+ * isset splitTenderPayments
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetSplitTenderPayments($index)
+ {
+ return isset($this->splitTenderPayments[$index]);
+ }
+
+ /**
+ * unset splitTenderPayments
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetSplitTenderPayments($index)
+ {
+ unset($this->splitTenderPayments[$index]);
+ }
+
+ /**
+ * Gets as splitTenderPayments
+ *
+ * @return
+ * \net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType[]
+ */
+ public function getSplitTenderPayments()
+ {
+ return $this->splitTenderPayments;
+ }
+
+ /**
+ * Sets a new splitTenderPayments
+ *
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType[]
+ * $splitTenderPayments
+ * @return self
+ */
+ public function setSplitTenderPayments(array $splitTenderPayments)
+ {
+ $this->splitTenderPayments = $splitTenderPayments;\r
+ return $this;
+ }
+
+ /**
+ * Adds as userField
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\UserFieldType $userField
+ */
+ public function addToUserFields(\net\authorize\api\contract\v1\UserFieldType $userField)
+ {
+ $this->userFields[] = $userField;\r
+ return $this;
+ }
+
+ /**
+ * isset userFields
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetUserFields($index)
+ {
+ return isset($this->userFields[$index]);
+ }
+
+ /**
+ * unset userFields
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetUserFields($index)
+ {
+ unset($this->userFields[$index]);
+ }
+
+ /**
+ * Gets as userFields
+ *
+ * @return \net\authorize\api\contract\v1\UserFieldType[]
+ */
+ public function getUserFields()
+ {
+ return $this->userFields;
+ }
+
+ /**
+ * Sets a new userFields
+ *
+ * @param \net\authorize\api\contract\v1\UserFieldType[] $userFields
+ * @return self
+ */
+ public function setUserFields(array $userFields)
+ {
+ $this->userFields = $userFields;\r
+ return $this;
+ }
+
+ /**
+ * Gets as shipTo
+ *
+ * @return \net\authorize\api\contract\v1\NameAndAddressType
+ */
+ public function getShipTo()
+ {
+ return $this->shipTo;
+ }
+
+ /**
+ * Sets a new shipTo
+ *
+ * @param \net\authorize\api\contract\v1\NameAndAddressType $shipTo
+ * @return self
+ */
+ public function setShipTo(\net\authorize\api\contract\v1\NameAndAddressType $shipTo)
+ {
+ $this->shipTo = $shipTo;\r
+ return $this;
+ }
+
+ /**
+ * Gets as secureAcceptance
+ *
+ * @return
+ * \net\authorize\api\contract\v1\TransactionResponseType\SecureAcceptanceAType
+ */
+ public function getSecureAcceptance()
+ {
+ return $this->secureAcceptance;
+ }
+
+ /**
+ * Sets a new secureAcceptance
+ *
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\SecureAcceptanceAType
+ * $secureAcceptance
+ * @return self
+ */
+ public function setSecureAcceptance(\net\authorize\api\contract\v1\TransactionResponseType\SecureAcceptanceAType $secureAcceptance)
+ {
+ $this->secureAcceptance = $secureAcceptance;\r
+ return $this;
+ }
+
+ /**
+ * Gets as emvResponse
+ *
+ * @return \net\authorize\api\contract\v1\TransactionResponseType\EmvResponseAType
+ */
+ public function getEmvResponse()
+ {
+ return $this->emvResponse;
+ }
+
+ /**
+ * Sets a new emvResponse
+ *
+ * @param \net\authorize\api\contract\v1\TransactionResponseType\EmvResponseAType
+ * $emvResponse
+ * @return self
+ */
+ public function setEmvResponse(\net\authorize\api\contract\v1\TransactionResponseType\EmvResponseAType $emvResponse)
+ {
+ $this->emvResponse = $emvResponse;\r
+ return $this;
+ }
+
+ /**
+ * Gets as transHashSha2
+ *
+ * @return string
+ */
+ public function getTransHashSha2()
+ {
+ return $this->transHashSha2;
+ }
+
+ /**
+ * Sets a new transHashSha2
+ *
+ * @param string $transHashSha2
+ * @return self
+ */
+ public function setTransHashSha2($transHashSha2)
+ {
+ $this->transHashSha2 = $transHashSha2;\r
+ return $this;
+ }
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileIdType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfileIdType $profile)
+ {
+ $this->profile = $profile;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType;
+
+/**
+ * Class representing EmvResponseAType
+ */
+class EmvResponseAType
+{
+
+ /**
+ * @property string $tlvData
+ */
+ private $tlvData = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\EmvTagType[] $tags
+ */
+ private $tags = null;
+
+ /**
+ * Gets as tlvData
+ *
+ * @return string
+ */
+ public function getTlvData()
+ {
+ return $this->tlvData;
+ }
+
+ /**
+ * Sets a new tlvData
+ *
+ * @param string $tlvData
+ * @return self
+ */
+ public function setTlvData($tlvData)
+ {
+ $this->tlvData = $tlvData;
+ return $this;
+ }
+
+ /**
+ * Adds as tag
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\EmvTagType $tag
+ */
+ public function addToTags(\net\authorize\api\contract\v1\EmvTagType $tag)
+ {
+ $this->tags[] = $tag;
+ return $this;
+ }
+
+ /**
+ * isset tags
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetTags($index)
+ {
+ return isset($this->tags[$index]);
+ }
+
+ /**
+ * unset tags
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetTags($index)
+ {
+ unset($this->tags[$index]);
+ }
+
+ /**
+ * Gets as tags
+ *
+ * @return \net\authorize\api\contract\v1\EmvTagType[]
+ */
+ public function getTags()
+ {
+ return $this->tags;
+ }
+
+ /**
+ * Sets a new tags
+ *
+ * @param \net\authorize\api\contract\v1\EmvTagType[] $tags
+ * @return self
+ */
+ public function setTags(array $tags)
+ {
+ $this->tags = $tags;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType\EmvResponseAType;
+
+/**
+ * Class representing TagsAType
+ */
+class TagsAType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\EmvTagType[] $tag
+ */
+ private $tag = null;
+
+ /**
+ * Adds as tag
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\EmvTagType $tag
+ */
+ public function addToTag(\net\authorize\api\contract\v1\EmvTagType $tag)
+ {
+ $this->tag[] = $tag;
+ return $this;
+ }
+
+ /**
+ * isset tag
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetTag($index)
+ {
+ return isset($this->tag[$index]);
+ }
+
+ /**
+ * unset tag
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetTag($index)
+ {
+ unset($this->tag[$index]);
+ }
+
+ /**
+ * Gets as tag
+ *
+ * @return \net\authorize\api\contract\v1\EmvTagType[]
+ */
+ public function getTag()
+ {
+ return $this->tag;
+ }
+
+ /**
+ * Sets a new tag
+ *
+ * @param \net\authorize\api\contract\v1\EmvTagType[] $tag
+ * @return self
+ */
+ public function setTag(array $tag)
+ {
+ $this->tag = $tag;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType;
+
+/**
+ * Class representing ErrorsAType
+ */
+class ErrorsAType
+{
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType[]
+ * $error
+ */
+ private $error = null;
+
+ /**
+ * Adds as error
+ *
+ * @return self
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType
+ * $error
+ */
+ public function addToError(\net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType $error)
+ {
+ $this->error[] = $error;
+ return $this;
+ }
+
+ /**
+ * isset error
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetError($index)
+ {
+ return isset($this->error[$index]);
+ }
+
+ /**
+ * unset error
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetError($index)
+ {
+ unset($this->error[$index]);
+ }
+
+ /**
+ * Gets as error
+ *
+ * @return
+ * \net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType[]
+ */
+ public function getError()
+ {
+ return $this->error;
+ }
+
+ /**
+ * Sets a new error
+ *
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType[]
+ * $error
+ * @return self
+ */
+ public function setError(array $error)
+ {
+ $this->error = $error;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType;
+
+/**
+ * Class representing ErrorAType
+ */
+class ErrorAType
+{
+
+ /**
+ * @property string $errorCode
+ */
+ private $errorCode = null;
+
+ /**
+ * @property string $errorText
+ */
+ private $errorText = null;
+
+ /**
+ * Gets as errorCode
+ *
+ * @return string
+ */
+ public function getErrorCode()
+ {
+ return $this->errorCode;
+ }
+
+ /**
+ * Sets a new errorCode
+ *
+ * @param string $errorCode
+ * @return self
+ */
+ public function setErrorCode($errorCode)
+ {
+ $this->errorCode = $errorCode;
+ return $this;
+ }
+
+ /**
+ * Gets as errorText
+ *
+ * @return string
+ */
+ public function getErrorText()
+ {
+ return $this->errorText;
+ }
+
+ /**
+ * Sets a new errorText
+ *
+ * @param string $errorText
+ * @return self
+ */
+ public function setErrorText($errorText)
+ {
+ $this->errorText = $errorText;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType;
+
+/**
+ * Class representing MessagesAType
+ */
+class MessagesAType
+{
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType[]
+ * $message
+ */
+ private $message = null;
+
+ /**
+ * Adds as message
+ *
+ * @return self
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType
+ * $message
+ */
+ public function addToMessage(\net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType $message)
+ {
+ $this->message[] = $message;
+ return $this;
+ }
+
+ /**
+ * isset message
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetMessage($index)
+ {
+ return isset($this->message[$index]);
+ }
+
+ /**
+ * unset message
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetMessage($index)
+ {
+ unset($this->message[$index]);
+ }
+
+ /**
+ * Gets as message
+ *
+ * @return
+ * \net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType[]
+ */
+ public function getMessage()
+ {
+ return $this->message;
+ }
+
+ /**
+ * Sets a new message
+ *
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType[]
+ * $message
+ * @return self
+ */
+ public function setMessage(array $message)
+ {
+ $this->message = $message;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType\MessagesAType;
+
+/**
+ * Class representing MessageAType
+ */
+class MessageAType
+{
+
+ /**
+ * @property string $code
+ */
+ private $code = null;
+
+ /**
+ * @property string $description
+ */
+ private $description = null;
+
+ /**
+ * Gets as code
+ *
+ * @return string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * Sets a new code
+ *
+ * @param string $code
+ * @return self
+ */
+ public function setCode($code)
+ {
+ $this->code = $code;
+ return $this;
+ }
+
+ /**
+ * Gets as description
+ *
+ * @return string
+ */
+ public function getDescription()
+ {
+ return $this->description;
+ }
+
+ /**
+ * Sets a new description
+ *
+ * @param string $description
+ * @return self
+ */
+ public function setDescription($description)
+ {
+ $this->description = $description;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType;
+
+/**
+ * Class representing PrePaidCardAType
+ */
+class PrePaidCardAType
+{
+
+ /**
+ * @property string $requestedAmount
+ */
+ private $requestedAmount = null;
+
+ /**
+ * @property string $approvedAmount
+ */
+ private $approvedAmount = null;
+
+ /**
+ * @property string $balanceOnCard
+ */
+ private $balanceOnCard = null;
+
+ /**
+ * Gets as requestedAmount
+ *
+ * @return string
+ */
+ public function getRequestedAmount()
+ {
+ return $this->requestedAmount;
+ }
+
+ /**
+ * Sets a new requestedAmount
+ *
+ * @param string $requestedAmount
+ * @return self
+ */
+ public function setRequestedAmount($requestedAmount)
+ {
+ $this->requestedAmount = $requestedAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as approvedAmount
+ *
+ * @return string
+ */
+ public function getApprovedAmount()
+ {
+ return $this->approvedAmount;
+ }
+
+ /**
+ * Sets a new approvedAmount
+ *
+ * @param string $approvedAmount
+ * @return self
+ */
+ public function setApprovedAmount($approvedAmount)
+ {
+ $this->approvedAmount = $approvedAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as balanceOnCard
+ *
+ * @return string
+ */
+ public function getBalanceOnCard()
+ {
+ return $this->balanceOnCard;
+ }
+
+ /**
+ * Sets a new balanceOnCard
+ *
+ * @param string $balanceOnCard
+ * @return self
+ */
+ public function setBalanceOnCard($balanceOnCard)
+ {
+ $this->balanceOnCard = $balanceOnCard;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType;
+
+/**
+ * Class representing SecureAcceptanceAType
+ */
+class SecureAcceptanceAType
+{
+
+ /**
+ * @property string $secureAcceptanceUrl
+ */
+ private $secureAcceptanceUrl = null;
+
+ /**
+ * @property string $payerID
+ */
+ private $payerID = null;
+
+ /**
+ * @property string $payerEmail
+ */
+ private $payerEmail = null;
+
+ /**
+ * Gets as secureAcceptanceUrl
+ *
+ * @return string
+ */
+ public function getSecureAcceptanceUrl()
+ {
+ return $this->secureAcceptanceUrl;
+ }
+
+ /**
+ * Sets a new secureAcceptanceUrl
+ *
+ * @param string $secureAcceptanceUrl
+ * @return self
+ */
+ public function setSecureAcceptanceUrl($secureAcceptanceUrl)
+ {
+ $this->secureAcceptanceUrl = $secureAcceptanceUrl;
+ return $this;
+ }
+
+ /**
+ * Gets as payerID
+ *
+ * @return string
+ */
+ public function getPayerID()
+ {
+ return $this->payerID;
+ }
+
+ /**
+ * Sets a new payerID
+ *
+ * @param string $payerID
+ * @return self
+ */
+ public function setPayerID($payerID)
+ {
+ $this->payerID = $payerID;
+ return $this;
+ }
+
+ /**
+ * Gets as payerEmail
+ *
+ * @return string
+ */
+ public function getPayerEmail()
+ {
+ return $this->payerEmail;
+ }
+
+ /**
+ * Sets a new payerEmail
+ *
+ * @param string $payerEmail
+ * @return self
+ */
+ public function setPayerEmail($payerEmail)
+ {
+ $this->payerEmail = $payerEmail;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType;
+
+/**
+ * Class representing SplitTenderPaymentsAType
+ */
+class SplitTenderPaymentsAType
+{
+
+ /**
+ * @property
+ * \net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType[]
+ * $splitTenderPayment
+ */
+ private $splitTenderPayment = null;
+
+ /**
+ * Adds as splitTenderPayment
+ *
+ * @return self
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType
+ * $splitTenderPayment
+ */
+ public function addToSplitTenderPayment(\net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType $splitTenderPayment)
+ {
+ $this->splitTenderPayment[] = $splitTenderPayment;
+ return $this;
+ }
+
+ /**
+ * isset splitTenderPayment
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetSplitTenderPayment($index)
+ {
+ return isset($this->splitTenderPayment[$index]);
+ }
+
+ /**
+ * unset splitTenderPayment
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetSplitTenderPayment($index)
+ {
+ unset($this->splitTenderPayment[$index]);
+ }
+
+ /**
+ * Gets as splitTenderPayment
+ *
+ * @return
+ * \net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType[]
+ */
+ public function getSplitTenderPayment()
+ {
+ return $this->splitTenderPayment;
+ }
+
+ /**
+ * Sets a new splitTenderPayment
+ *
+ * @param
+ * \net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType[]
+ * $splitTenderPayment
+ * @return self
+ */
+ public function setSplitTenderPayment(array $splitTenderPayment)
+ {
+ $this->splitTenderPayment = $splitTenderPayment;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType;
+
+/**
+ * Class representing SplitTenderPaymentAType
+ */
+class SplitTenderPaymentAType
+{
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * @property string $responseCode
+ */
+ private $responseCode = null;
+
+ /**
+ * @property string $responseToCustomer
+ */
+ private $responseToCustomer = null;
+
+ /**
+ * @property string $authCode
+ */
+ private $authCode = null;
+
+ /**
+ * @property string $accountNumber
+ */
+ private $accountNumber = null;
+
+ /**
+ * @property string $accountType
+ */
+ private $accountType = null;
+
+ /**
+ * @property string $requestedAmount
+ */
+ private $requestedAmount = null;
+
+ /**
+ * @property string $approvedAmount
+ */
+ private $approvedAmount = null;
+
+ /**
+ * @property string $balanceOnCard
+ */
+ private $balanceOnCard = null;
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;
+ return $this;
+ }
+
+ /**
+ * Gets as responseCode
+ *
+ * @return string
+ */
+ public function getResponseCode()
+ {
+ return $this->responseCode;
+ }
+
+ /**
+ * Sets a new responseCode
+ *
+ * @param string $responseCode
+ * @return self
+ */
+ public function setResponseCode($responseCode)
+ {
+ $this->responseCode = $responseCode;
+ return $this;
+ }
+
+ /**
+ * Gets as responseToCustomer
+ *
+ * @return string
+ */
+ public function getResponseToCustomer()
+ {
+ return $this->responseToCustomer;
+ }
+
+ /**
+ * Sets a new responseToCustomer
+ *
+ * @param string $responseToCustomer
+ * @return self
+ */
+ public function setResponseToCustomer($responseToCustomer)
+ {
+ $this->responseToCustomer = $responseToCustomer;
+ return $this;
+ }
+
+ /**
+ * Gets as authCode
+ *
+ * @return string
+ */
+ public function getAuthCode()
+ {
+ return $this->authCode;
+ }
+
+ /**
+ * Sets a new authCode
+ *
+ * @param string $authCode
+ * @return self
+ */
+ public function setAuthCode($authCode)
+ {
+ $this->authCode = $authCode;
+ return $this;
+ }
+
+ /**
+ * Gets as accountNumber
+ *
+ * @return string
+ */
+ public function getAccountNumber()
+ {
+ return $this->accountNumber;
+ }
+
+ /**
+ * Sets a new accountNumber
+ *
+ * @param string $accountNumber
+ * @return self
+ */
+ public function setAccountNumber($accountNumber)
+ {
+ $this->accountNumber = $accountNumber;
+ return $this;
+ }
+
+ /**
+ * Gets as accountType
+ *
+ * @return string
+ */
+ public function getAccountType()
+ {
+ return $this->accountType;
+ }
+
+ /**
+ * Sets a new accountType
+ *
+ * @param string $accountType
+ * @return self
+ */
+ public function setAccountType($accountType)
+ {
+ $this->accountType = $accountType;
+ return $this;
+ }
+
+ /**
+ * Gets as requestedAmount
+ *
+ * @return string
+ */
+ public function getRequestedAmount()
+ {
+ return $this->requestedAmount;
+ }
+
+ /**
+ * Sets a new requestedAmount
+ *
+ * @param string $requestedAmount
+ * @return self
+ */
+ public function setRequestedAmount($requestedAmount)
+ {
+ $this->requestedAmount = $requestedAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as approvedAmount
+ *
+ * @return string
+ */
+ public function getApprovedAmount()
+ {
+ return $this->approvedAmount;
+ }
+
+ /**
+ * Sets a new approvedAmount
+ *
+ * @param string $approvedAmount
+ * @return self
+ */
+ public function setApprovedAmount($approvedAmount)
+ {
+ $this->approvedAmount = $approvedAmount;
+ return $this;
+ }
+
+ /**
+ * Gets as balanceOnCard
+ *
+ * @return string
+ */
+ public function getBalanceOnCard()
+ {
+ return $this->balanceOnCard;
+ }
+
+ /**
+ * Sets a new balanceOnCard
+ *
+ * @param string $balanceOnCard
+ * @return self
+ */
+ public function setBalanceOnCard($balanceOnCard)
+ {
+ $this->balanceOnCard = $balanceOnCard;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\TransactionResponseType;
+
+/**
+ * Class representing UserFieldsAType
+ */
+class UserFieldsAType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\UserFieldType[] $userField
+ */
+ private $userField = null;
+
+ /**
+ * Adds as userField
+ *
+ * @return self
+ * @param \net\authorize\api\contract\v1\UserFieldType $userField
+ */
+ public function addToUserField(\net\authorize\api\contract\v1\UserFieldType $userField)
+ {
+ $this->userField[] = $userField;
+ return $this;
+ }
+
+ /**
+ * isset userField
+ *
+ * @param scalar $index
+ * @return boolean
+ */
+ public function issetUserField($index)
+ {
+ return isset($this->userField[$index]);
+ }
+
+ /**
+ * unset userField
+ *
+ * @param scalar $index
+ * @return void
+ */
+ public function unsetUserField($index)
+ {
+ unset($this->userField[$index]);
+ }
+
+ /**
+ * Gets as userField
+ *
+ * @return \net\authorize\api\contract\v1\UserFieldType[]
+ */
+ public function getUserField()
+ {
+ return $this->userField;
+ }
+
+ /**
+ * Sets a new userField
+ *
+ * @param \net\authorize\api\contract\v1\UserFieldType[] $userField
+ * @return self
+ */
+ public function setUserField(array $userField)
+ {
+ $this->userField = $userField;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing TransactionSummaryType
+ *
+ * \r
+ * XSD Type: transactionSummaryType
+ */
+class TransactionSummaryType
+{
+
+ /**
+ * @property string $transId
+ */
+ private $transId = null;
+
+ /**
+ * @property \DateTime $submitTimeUTC
+ */
+ private $submitTimeUTC = null;
+
+ /**
+ * @property \DateTime $submitTimeLocal
+ */
+ private $submitTimeLocal = null;
+
+ /**
+ * @property string $transactionStatus
+ */
+ private $transactionStatus = null;
+
+ /**
+ * @property string $invoiceNumber
+ */
+ private $invoiceNumber = null;
+
+ /**
+ * @property string $firstName
+ */
+ private $firstName = null;
+
+ /**
+ * @property string $lastName
+ */
+ private $lastName = null;
+
+ /**
+ * @property string $accountType
+ */
+ private $accountType = null;
+
+ /**
+ * @property string $accountNumber
+ */
+ private $accountNumber = null;
+
+ /**
+ * @property float $settleAmount
+ */
+ private $settleAmount = null;
+
+ /**
+ * @property string $marketType
+ */
+ private $marketType = null;
+
+ /**
+ * @property string $product
+ */
+ private $product = null;
+
+ /**
+ * @property string $mobileDeviceId
+ */
+ private $mobileDeviceId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\SubscriptionPaymentType $subscription
+ */
+ private $subscription = null;
+
+ /**
+ * @property boolean $hasReturnedItems
+ */
+ private $hasReturnedItems = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\FraudInformationType $fraudInformation
+ */
+ private $fraudInformation = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ */
+ private $profile = null;
+
+ /**
+ * Gets as transId
+ *
+ * @return string
+ */
+ public function getTransId()
+ {
+ return $this->transId;
+ }
+
+ /**
+ * Sets a new transId
+ *
+ * @param string $transId
+ * @return self
+ */
+ public function setTransId($transId)
+ {
+ $this->transId = $transId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as submitTimeUTC
+ *
+ * @return \DateTime
+ */
+ public function getSubmitTimeUTC()
+ {
+ return $this->submitTimeUTC;
+ }
+
+ /**
+ * Sets a new submitTimeUTC
+ *
+ * @param \DateTime $submitTimeUTC
+ * @return self
+ */
+ public function setSubmitTimeUTC(\DateTime $submitTimeUTC)
+ {
+ $this->submitTimeUTC = $submitTimeUTC;\r
+ return $this;
+ }
+
+ /**
+ * Gets as submitTimeLocal
+ *
+ * @return \DateTime
+ */
+ public function getSubmitTimeLocal()
+ {
+ return $this->submitTimeLocal;
+ }
+
+ /**
+ * Sets a new submitTimeLocal
+ *
+ * @param \DateTime $submitTimeLocal
+ * @return self
+ */
+ public function setSubmitTimeLocal(\DateTime $submitTimeLocal)
+ {
+ $this->submitTimeLocal = $submitTimeLocal;\r
+ return $this;
+ }
+
+ /**
+ * Gets as transactionStatus
+ *
+ * @return string
+ */
+ public function getTransactionStatus()
+ {
+ return $this->transactionStatus;
+ }
+
+ /**
+ * Sets a new transactionStatus
+ *
+ * @param string $transactionStatus
+ * @return self
+ */
+ public function setTransactionStatus($transactionStatus)
+ {
+ $this->transactionStatus = $transactionStatus;\r
+ return $this;
+ }
+
+ /**
+ * Gets as invoiceNumber
+ *
+ * @return string
+ */
+ public function getInvoiceNumber()
+ {
+ return $this->invoiceNumber;
+ }
+
+ /**
+ * Sets a new invoiceNumber
+ *
+ * @param string $invoiceNumber
+ * @return self
+ */
+ public function setInvoiceNumber($invoiceNumber)
+ {
+ $this->invoiceNumber = $invoiceNumber;\r
+ return $this;
+ }
+
+ /**
+ * Gets as firstName
+ *
+ * @return string
+ */
+ public function getFirstName()
+ {
+ return $this->firstName;
+ }
+
+ /**
+ * Sets a new firstName
+ *
+ * @param string $firstName
+ * @return self
+ */
+ public function setFirstName($firstName)
+ {
+ $this->firstName = $firstName;\r
+ return $this;
+ }
+
+ /**
+ * Gets as lastName
+ *
+ * @return string
+ */
+ public function getLastName()
+ {
+ return $this->lastName;
+ }
+
+ /**
+ * Sets a new lastName
+ *
+ * @param string $lastName
+ * @return self
+ */
+ public function setLastName($lastName)
+ {
+ $this->lastName = $lastName;\r
+ return $this;
+ }
+
+ /**
+ * Gets as accountType
+ *
+ * @return string
+ */
+ public function getAccountType()
+ {
+ return $this->accountType;
+ }
+
+ /**
+ * Sets a new accountType
+ *
+ * @param string $accountType
+ * @return self
+ */
+ public function setAccountType($accountType)
+ {
+ $this->accountType = $accountType;\r
+ return $this;
+ }
+
+ /**
+ * Gets as accountNumber
+ *
+ * @return string
+ */
+ public function getAccountNumber()
+ {
+ return $this->accountNumber;
+ }
+
+ /**
+ * Sets a new accountNumber
+ *
+ * @param string $accountNumber
+ * @return self
+ */
+ public function setAccountNumber($accountNumber)
+ {
+ $this->accountNumber = $accountNumber;\r
+ return $this;
+ }
+
+ /**
+ * Gets as settleAmount
+ *
+ * @return float
+ */
+ public function getSettleAmount()
+ {
+ return $this->settleAmount;
+ }
+
+ /**
+ * Sets a new settleAmount
+ *
+ * @param float $settleAmount
+ * @return self
+ */
+ public function setSettleAmount($settleAmount)
+ {
+ $this->settleAmount = $settleAmount;\r
+ return $this;
+ }
+
+ /**
+ * Gets as marketType
+ *
+ * @return string
+ */
+ public function getMarketType()
+ {
+ return $this->marketType;
+ }
+
+ /**
+ * Sets a new marketType
+ *
+ * @param string $marketType
+ * @return self
+ */
+ public function setMarketType($marketType)
+ {
+ $this->marketType = $marketType;\r
+ return $this;
+ }
+
+ /**
+ * Gets as product
+ *
+ * @return string
+ */
+ public function getProduct()
+ {
+ return $this->product;
+ }
+
+ /**
+ * Sets a new product
+ *
+ * @param string $product
+ * @return self
+ */
+ public function setProduct($product)
+ {
+ $this->product = $product;\r
+ return $this;
+ }
+
+ /**
+ * Gets as mobileDeviceId
+ *
+ * @return string
+ */
+ public function getMobileDeviceId()
+ {
+ return $this->mobileDeviceId;
+ }
+
+ /**
+ * Sets a new mobileDeviceId
+ *
+ * @param string $mobileDeviceId
+ * @return self
+ */
+ public function setMobileDeviceId($mobileDeviceId)
+ {
+ $this->mobileDeviceId = $mobileDeviceId;\r
+ return $this;
+ }
+
+ /**
+ * Gets as subscription
+ *
+ * @return \net\authorize\api\contract\v1\SubscriptionPaymentType
+ */
+ public function getSubscription()
+ {
+ return $this->subscription;
+ }
+
+ /**
+ * Sets a new subscription
+ *
+ * @param \net\authorize\api\contract\v1\SubscriptionPaymentType $subscription
+ * @return self
+ */
+ public function setSubscription(\net\authorize\api\contract\v1\SubscriptionPaymentType $subscription)
+ {
+ $this->subscription = $subscription;\r
+ return $this;
+ }
+
+ /**
+ * Gets as hasReturnedItems
+ *
+ * @return boolean
+ */
+ public function getHasReturnedItems()
+ {
+ return $this->hasReturnedItems;
+ }
+
+ /**
+ * Sets a new hasReturnedItems
+ *
+ * @param boolean $hasReturnedItems
+ * @return self
+ */
+ public function setHasReturnedItems($hasReturnedItems)
+ {
+ $this->hasReturnedItems = $hasReturnedItems;\r
+ return $this;
+ }
+
+ /**
+ * Gets as fraudInformation
+ *
+ * @return \net\authorize\api\contract\v1\FraudInformationType
+ */
+ public function getFraudInformation()
+ {
+ return $this->fraudInformation;
+ }
+
+ /**
+ * Sets a new fraudInformation
+ *
+ * @param \net\authorize\api\contract\v1\FraudInformationType $fraudInformation
+ * @return self
+ */
+ public function setFraudInformation(\net\authorize\api\contract\v1\FraudInformationType $fraudInformation)
+ {
+ $this->fraudInformation = $fraudInformation;\r
+ return $this;
+ }
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileIdType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileIdType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfileIdType $profile)
+ {
+ $this->profile = $profile;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateCustomerPaymentProfileRequest
+ */
+class UpdateCustomerPaymentProfileRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerPaymentProfileExType
+ * $paymentProfile
+ */
+ private $paymentProfile = null;
+
+ /**
+ * @property string $validationMode
+ */
+ private $validationMode = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as paymentProfile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerPaymentProfileExType
+ */
+ public function getPaymentProfile()
+ {
+ return $this->paymentProfile;
+ }
+
+ /**
+ * Sets a new paymentProfile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerPaymentProfileExType
+ * $paymentProfile
+ * @return self
+ */
+ public function setPaymentProfile(\net\authorize\api\contract\v1\CustomerPaymentProfileExType $paymentProfile)
+ {
+ $this->paymentProfile = $paymentProfile;
+ return $this;
+ }
+
+ /**
+ * Gets as validationMode
+ *
+ * @return string
+ */
+ public function getValidationMode()
+ {
+ return $this->validationMode;
+ }
+
+ /**
+ * Sets a new validationMode
+ *
+ * @param string $validationMode
+ * @return self
+ */
+ public function setValidationMode($validationMode)
+ {
+ $this->validationMode = $validationMode;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateCustomerPaymentProfileResponse
+ */
+class UpdateCustomerPaymentProfileResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string $validationDirectResponse
+ */
+ private $validationDirectResponse = null;
+
+ /**
+ * Gets as validationDirectResponse
+ *
+ * @return string
+ */
+ public function getValidationDirectResponse()
+ {
+ return $this->validationDirectResponse;
+ }
+
+ /**
+ * Sets a new validationDirectResponse
+ *
+ * @param string $validationDirectResponse
+ * @return self
+ */
+ public function setValidationDirectResponse($validationDirectResponse)
+ {
+ $this->validationDirectResponse = $validationDirectResponse;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateCustomerProfileRequest
+ */
+class UpdateCustomerProfileRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerProfileExType $profile
+ */
+ private $profile = null;
+
+ /**
+ * Gets as profile
+ *
+ * @return \net\authorize\api\contract\v1\CustomerProfileExType
+ */
+ public function getProfile()
+ {
+ return $this->profile;
+ }
+
+ /**
+ * Sets a new profile
+ *
+ * @param \net\authorize\api\contract\v1\CustomerProfileExType $profile
+ * @return self
+ */
+ public function setProfile(\net\authorize\api\contract\v1\CustomerProfileExType $profile)
+ {
+ $this->profile = $profile;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateCustomerProfileResponse
+ */
+class UpdateCustomerProfileResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateCustomerShippingAddressRequest
+ */
+class UpdateCustomerShippingAddressRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\CustomerAddressExType $address
+ */
+ private $address = null;
+
+ /**
+ * @property boolean $defaultShippingAddress
+ */
+ private $defaultShippingAddress = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as address
+ *
+ * @return \net\authorize\api\contract\v1\CustomerAddressExType
+ */
+ public function getAddress()
+ {
+ return $this->address;
+ }
+
+ /**
+ * Sets a new address
+ *
+ * @param \net\authorize\api\contract\v1\CustomerAddressExType $address
+ * @return self
+ */
+ public function setAddress(\net\authorize\api\contract\v1\CustomerAddressExType $address)
+ {
+ $this->address = $address;
+ return $this;
+ }
+
+ /**
+ * Gets as defaultShippingAddress
+ *
+ * @return boolean
+ */
+ public function getDefaultShippingAddress()
+ {
+ return $this->defaultShippingAddress;
+ }
+
+ /**
+ * Sets a new defaultShippingAddress
+ *
+ * @param boolean $defaultShippingAddress
+ * @return self
+ */
+ public function setDefaultShippingAddress($defaultShippingAddress)
+ {
+ $this->defaultShippingAddress = $defaultShippingAddress;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateCustomerShippingAddressResponse
+ */
+class UpdateCustomerShippingAddressResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateHeldTransactionRequest
+ */
+class UpdateHeldTransactionRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\HeldTransactionRequestType
+ * $heldTransactionRequest
+ */
+ private $heldTransactionRequest = null;
+
+ /**
+ * Gets as heldTransactionRequest
+ *
+ * @return \net\authorize\api\contract\v1\HeldTransactionRequestType
+ */
+ public function getHeldTransactionRequest()
+ {
+ return $this->heldTransactionRequest;
+ }
+
+ /**
+ * Sets a new heldTransactionRequest
+ *
+ * @param \net\authorize\api\contract\v1\HeldTransactionRequestType
+ * $heldTransactionRequest
+ * @return self
+ */
+ public function setHeldTransactionRequest(\net\authorize\api\contract\v1\HeldTransactionRequestType $heldTransactionRequest)
+ {
+ $this->heldTransactionRequest = $heldTransactionRequest;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateHeldTransactionResponse
+ */
+class UpdateHeldTransactionResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property \net\authorize\api\contract\v1\TransactionResponseType
+ * $transactionResponse
+ */
+ private $transactionResponse = null;
+
+ /**
+ * Gets as transactionResponse
+ *
+ * @return \net\authorize\api\contract\v1\TransactionResponseType
+ */
+ public function getTransactionResponse()
+ {
+ return $this->transactionResponse;
+ }
+
+ /**
+ * Sets a new transactionResponse
+ *
+ * @param \net\authorize\api\contract\v1\TransactionResponseType
+ * $transactionResponse
+ * @return self
+ */
+ public function setTransactionResponse(\net\authorize\api\contract\v1\TransactionResponseType $transactionResponse)
+ {
+ $this->transactionResponse = $transactionResponse;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateSplitTenderGroupRequest
+ */
+class UpdateSplitTenderGroupRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $splitTenderId
+ */
+ private $splitTenderId = null;
+
+ /**
+ * @property string $splitTenderStatus
+ */
+ private $splitTenderStatus = null;
+
+ /**
+ * Gets as splitTenderId
+ *
+ * @return string
+ */
+ public function getSplitTenderId()
+ {
+ return $this->splitTenderId;
+ }
+
+ /**
+ * Sets a new splitTenderId
+ *
+ * @param string $splitTenderId
+ * @return self
+ */
+ public function setSplitTenderId($splitTenderId)
+ {
+ $this->splitTenderId = $splitTenderId;
+ return $this;
+ }
+
+ /**
+ * Gets as splitTenderStatus
+ *
+ * @return string
+ */
+ public function getSplitTenderStatus()
+ {
+ return $this->splitTenderStatus;
+ }
+
+ /**
+ * Sets a new splitTenderStatus
+ *
+ * @param string $splitTenderStatus
+ * @return self
+ */
+ public function setSplitTenderStatus($splitTenderStatus)
+ {
+ $this->splitTenderStatus = $splitTenderStatus;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UpdateSplitTenderGroupResponse
+ */
+class UpdateSplitTenderGroupResponse extends ANetApiResponseType
+{
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing UserFieldType
+ *
+ *
+ * XSD Type: userField
+ */
+class UserFieldType
+{
+
+ /**
+ * @property string $name
+ */
+ private $name = null;
+
+ /**
+ * @property string $value
+ */
+ private $value = null;
+
+ /**
+ * Gets as name
+ *
+ * @return string
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets a new name
+ *
+ * @param string $name
+ * @return self
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ * Gets as value
+ *
+ * @return string
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+
+ /**
+ * Sets a new value
+ *
+ * @param string $value
+ * @return self
+ */
+ public function setValue($value)
+ {
+ $this->value = $value;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ValidateCustomerPaymentProfileRequest
+ */
+class ValidateCustomerPaymentProfileRequest extends ANetApiRequestType
+{
+
+ /**
+ * @property string $customerProfileId
+ */
+ private $customerProfileId = null;
+
+ /**
+ * @property string $customerPaymentProfileId
+ */
+ private $customerPaymentProfileId = null;
+
+ /**
+ * @property string $customerShippingAddressId
+ */
+ private $customerShippingAddressId = null;
+
+ /**
+ * @property string $cardCode
+ */
+ private $cardCode = null;
+
+ /**
+ * @property string $validationMode
+ */
+ private $validationMode = null;
+
+ /**
+ * Gets as customerProfileId
+ *
+ * @return string
+ */
+ public function getCustomerProfileId()
+ {
+ return $this->customerProfileId;
+ }
+
+ /**
+ * Sets a new customerProfileId
+ *
+ * @param string $customerProfileId
+ * @return self
+ */
+ public function setCustomerProfileId($customerProfileId)
+ {
+ $this->customerProfileId = $customerProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerPaymentProfileId
+ *
+ * @return string
+ */
+ public function getCustomerPaymentProfileId()
+ {
+ return $this->customerPaymentProfileId;
+ }
+
+ /**
+ * Sets a new customerPaymentProfileId
+ *
+ * @param string $customerPaymentProfileId
+ * @return self
+ */
+ public function setCustomerPaymentProfileId($customerPaymentProfileId)
+ {
+ $this->customerPaymentProfileId = $customerPaymentProfileId;
+ return $this;
+ }
+
+ /**
+ * Gets as customerShippingAddressId
+ *
+ * @return string
+ */
+ public function getCustomerShippingAddressId()
+ {
+ return $this->customerShippingAddressId;
+ }
+
+ /**
+ * Sets a new customerShippingAddressId
+ *
+ * @param string $customerShippingAddressId
+ * @return self
+ */
+ public function setCustomerShippingAddressId($customerShippingAddressId)
+ {
+ $this->customerShippingAddressId = $customerShippingAddressId;
+ return $this;
+ }
+
+ /**
+ * Gets as cardCode
+ *
+ * @return string
+ */
+ public function getCardCode()
+ {
+ return $this->cardCode;
+ }
+
+ /**
+ * Sets a new cardCode
+ *
+ * @param string $cardCode
+ * @return self
+ */
+ public function setCardCode($cardCode)
+ {
+ $this->cardCode = $cardCode;
+ return $this;
+ }
+
+ /**
+ * Gets as validationMode
+ *
+ * @return string
+ */
+ public function getValidationMode()
+ {
+ return $this->validationMode;
+ }
+
+ /**
+ * Sets a new validationMode
+ *
+ * @param string $validationMode
+ * @return self
+ */
+ public function setValidationMode($validationMode)
+ {
+ $this->validationMode = $validationMode;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing ValidateCustomerPaymentProfileResponse
+ */
+class ValidateCustomerPaymentProfileResponse extends ANetApiResponseType
+{
+
+ /**
+ * @property string $directResponse
+ */
+ private $directResponse = null;
+
+ /**
+ * Gets as directResponse
+ *
+ * @return string
+ */
+ public function getDirectResponse()
+ {
+ return $this->directResponse;
+ }
+
+ /**
+ * Sets a new directResponse
+ *
+ * @param string $directResponse
+ * @return self
+ */
+ public function setDirectResponse($directResponse)
+ {
+ $this->directResponse = $directResponse;
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1;
+
+/**
+ * Class representing WebCheckOutDataType
+ *
+ * \r
+ * XSD Type: webCheckOutDataType
+ */
+class WebCheckOutDataType
+{
+
+ /**
+ * @property string $type
+ */
+ private $type = null;
+
+ /**
+ * @property string $id
+ */
+ private $id = null;
+
+ /**
+ * @property \net\authorize\api\contract\v1\WebCheckOutDataType\TokenAType $token
+ */
+ private $token = null;
+
+ /**
+ * Gets as type
+ *
+ * @return string
+ */
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Sets a new type
+ *
+ * @param string $type
+ * @return self
+ */
+ public function setType($type)
+ {
+ $this->type = $type;\r
+ return $this;
+ }
+
+ /**
+ * Gets as id
+ *
+ * @return string
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ * Sets a new id
+ *
+ * @param string $id
+ * @return self
+ */
+ public function setId($id)
+ {
+ $this->id = $id;\r
+ return $this;
+ }
+
+ /**
+ * Gets as token
+ *
+ * @return \net\authorize\api\contract\v1\WebCheckOutDataType\TokenAType
+ */
+ public function getToken()
+ {
+ return $this->token;
+ }
+
+ /**
+ * Sets a new token
+ *
+ * @param \net\authorize\api\contract\v1\WebCheckOutDataType\TokenAType $token
+ * @return self
+ */
+ public function setToken(\net\authorize\api\contract\v1\WebCheckOutDataType\TokenAType $token)
+ {
+ $this->token = $token;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+
+namespace net\authorize\api\contract\v1\WebCheckOutDataType;
+
+/**
+ * Class representing TokenAType
+ */
+class TokenAType
+{
+
+ /**
+ * @property string $cardNumber
+ */
+ private $cardNumber = null;
+
+ /**
+ * @property string $expirationDate
+ */
+ private $expirationDate = null;
+
+ /**
+ * @property string $cardCode
+ */
+ private $cardCode = null;
+
+ /**
+ * @property string $zip
+ */
+ private $zip = null;
+
+ /**
+ * @property string $fullName
+ */
+ private $fullName = null;
+
+ /**
+ * Gets as cardNumber
+ *
+ * @return string
+ */
+ public function getCardNumber()
+ {
+ return $this->cardNumber;
+ }
+
+ /**
+ * Sets a new cardNumber
+ *
+ * @param string $cardNumber
+ * @return self
+ */
+ public function setCardNumber($cardNumber)
+ {
+ $this->cardNumber = $cardNumber;\r
+ return $this;
+ }
+
+ /**
+ * Gets as expirationDate
+ *
+ * @return string
+ */
+ public function getExpirationDate()
+ {
+ return $this->expirationDate;
+ }
+
+ /**
+ * Sets a new expirationDate
+ *
+ * @param string $expirationDate
+ * @return self
+ */
+ public function setExpirationDate($expirationDate)
+ {
+ $this->expirationDate = $expirationDate;\r
+ return $this;
+ }
+
+ /**
+ * Gets as cardCode
+ *
+ * @return string
+ */
+ public function getCardCode()
+ {
+ return $this->cardCode;
+ }
+
+ /**
+ * Sets a new cardCode
+ *
+ * @param string $cardCode
+ * @return self
+ */
+ public function setCardCode($cardCode)
+ {
+ $this->cardCode = $cardCode;\r
+ return $this;
+ }
+
+ /**
+ * Gets as zip
+ *
+ * @return string
+ */
+ public function getZip()
+ {
+ return $this->zip;
+ }
+
+ /**
+ * Sets a new zip
+ *
+ * @param string $zip
+ * @return self
+ */
+ public function setZip($zip)
+ {
+ $this->zip = $zip;\r
+ return $this;
+ }
+
+ /**
+ * Gets as fullName
+ *
+ * @return string
+ */
+ public function getFullName()
+ {
+ return $this->fullName;
+ }
+
+ /**
+ * Sets a new fullName
+ *
+ * @param string $fullName
+ * @return self
+ */
+ public function setFullName($fullName)
+ {
+ $this->fullName = $fullName;\r
+ return $this;
+ }
+
+
+}
+
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class ARBCancelSubscriptionController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\ARBCancelSubscriptionResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class ARBCreateSubscriptionController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\ARBCreateSubscriptionResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class ARBGetSubscriptionController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\ARBGetSubscriptionResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class ARBGetSubscriptionListController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\ARBGetSubscriptionListResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class ARBGetSubscriptionStatusController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\ARBGetSubscriptionStatusResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class ARBUpdateSubscriptionController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\ARBUpdateSubscriptionResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class AuthenticateTestController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\AuthenticateTestResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class CreateCustomerPaymentProfileController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\CreateCustomerPaymentProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class CreateCustomerProfileController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\CreateCustomerProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class CreateCustomerProfileFromTransactionController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\CreateCustomerProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class CreateCustomerProfileTransactionController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\CreateCustomerProfileTransactionResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class CreateCustomerShippingAddressController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\CreateCustomerShippingAddressResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class CreateTransactionController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\CreateTransactionResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class DecryptPaymentDataController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\DecryptPaymentDataResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class DeleteCustomerPaymentProfileController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\DeleteCustomerPaymentProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class DeleteCustomerProfileController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\DeleteCustomerProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class DeleteCustomerShippingAddressController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\DeleteCustomerShippingAddressResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetAUJobDetailsController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetAUJobDetailsResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetAUJobSummaryController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetAUJobSummaryResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetBatchStatisticsController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetBatchStatisticsResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetCustomerPaymentProfileController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetCustomerPaymentProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetCustomerPaymentProfileListController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetCustomerPaymentProfileListResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetCustomerProfileController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetCustomerProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetCustomerProfileIdsController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetCustomerProfileIdsResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetCustomerShippingAddressController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetCustomerShippingAddressResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetHostedPaymentPageController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetHostedPaymentPageResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetHostedProfilePageController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetHostedProfilePageResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetMerchantDetailsController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetMerchantDetailsResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetSettledBatchListController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetSettledBatchListResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetTransactionDetailsController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetTransactionDetailsResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetTransactionListController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetTransactionListResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetTransactionListForCustomerController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetTransactionListResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class GetUnsettledTransactionListController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\GetUnsettledTransactionListResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class IsAliveController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\IsAliveResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class LogoutController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\LogoutResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class MobileDeviceLoginController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\MobileDeviceLoginResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class MobileDeviceRegistrationController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\MobileDeviceRegistrationResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class SecurePaymentContainerController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\SecurePaymentContainerResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class SendCustomerTransactionReceiptController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\SendCustomerTransactionReceiptResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class UpdateCustomerPaymentProfileController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\UpdateCustomerPaymentProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class UpdateCustomerProfileController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\UpdateCustomerProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class UpdateCustomerShippingAddressController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\UpdateCustomerShippingAddressResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class UpdateHeldTransactionController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\UpdateHeldTransactionResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class UpdateSplitTenderGroupController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\UpdateSplitTenderGroupResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class ValidateCustomerPaymentProfileController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\ValidateCustomerPaymentProfileResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\api\controller\base;
+
+use InvalidArgumentException;
+use JMS\Serializer\SerializerBuilder;
+use JMS\Serializer\handler\HandlerRegistryInterface;
+use GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler\BaseTypesHandler;
+use GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler\XmlSchemaDateHandler;
+
+use \net\authorize\util\HttpClient;
+use \net\authorize\util\Helpers;
+use \net\authorize\util\LogFactory as LogFactory;
+
+
+abstract class ApiOperationBase implements IApiOperation
+{
+ /**
+ * @var \net\authorize\api\contract\v1\AnetApiRequestType
+ */
+ private $apiRequest = null;
+
+ /**
+ * @var \net\authorize\api\contract\v1\AnetApiResponseType
+ */
+ private $apiResponse = null;
+
+ /**
+ * @var String
+ */
+ private $apiResponseType = '';
+
+ /**
+ * @var \JMS\Serializer\Serializer;
+ */
+ public $serializer = null;
+
+ /**
+ * @var \net\authorize\util\HttpClient;
+ */
+ public $httpClient = null;
+ private $logger = null;
+ /**
+ * Constructor.
+ *
+ * @param \net\authorize\api\contract\v1\AnetApiRequestType $request ApiRequest to send
+ * @param string $responseType response type expected
+ * @throws InvalidArgumentException if invalid request
+ */
+ public function __construct(\net\authorize\api\contract\v1\AnetApiRequestType $request, $responseType)
+ {
+ $this->logger = LogFactory::getLog(get_class($this));
+
+ if ( null == $request)
+ {
+ throw new InvalidArgumentException( "request cannot be null");
+ }
+
+ if ( null == $responseType || '' == $responseType)
+ {
+ throw new InvalidArgumentException( "responseType cannot be null or empty");
+ }
+
+ if ( null != $this->apiResponse)
+ {
+ throw new InvalidArgumentException( "response has to be null");
+ }
+
+ $this->apiRequest = $request;
+ $this->validate();
+
+ $this->apiResponseType = $responseType;
+ $this->httpClient = new HttpClient;
+
+ $serializerBuilder = SerializerBuilder::create();
+ $serializerBuilder->addMetadataDir( __DIR__ . '/../../yml/v1', 'net\authorize\api\contract\v1');//..\..\yml\v1\ //'/../lib/net/authorize/api/yml/v1'
+ $serializerBuilder->configureHandlers(
+ function (HandlerRegistryInterface $h)
+
+ use($serializerBuilder)
+ {
+ $serializerBuilder->addDefaultHandlers();
+ $h->registerSubscribingHandler(new BaseTypesHandler()); // XMLSchema List handling
+ $h->registerSubscribingHandler(new XmlSchemaDateHandler()); // XMLSchema date handling
+ }
+ );
+ $this->serializer = $serializerBuilder->build();
+ }
+
+ /**
+ * Retrieves response
+ * @return \net\authorize\api\contract\v1\AnetApiResponseType
+ */
+ public function getApiResponse()
+ {
+ return $this->apiResponse;
+ }
+
+ /**
+ * Sends request and retrieves response
+ * @return \net\authorize\api\contract\v1\AnetApiResponseType
+ */
+ public function executeWithApiResponse($endPoint = \net\authorize\api\constants\ANetEnvironment::CUSTOM)
+ {
+ $this->execute($endPoint);
+ return $this->apiResponse;
+ }
+
+ public function execute($endPoint = \net\authorize\api\constants\ANetEnvironment::CUSTOM)
+ {
+ $this->beforeExecute();
+
+ $this->apiRequest->setClientId("sdk-php-" . \net\authorize\api\constants\ANetEnvironment::VERSION);
+
+ $this->logger->info("Request Serialization Begin");
+ $this->logger->debug($this->apiRequest);
+ $xmlRequest = $this->serializer->serialize($this->apiRequest, 'xml');
+
+ $this->logger->info("Request Serialization End");
+ /*
+ //$xmlRequest = '<?xml version="1.0" encoding="UTF-8"?> <ARBGetSubscriptionListRequest xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"> <merchantAuthentication> <name>4YJmeW7V77us</name> <transactionKey>4qHK9u63F753be4Z</transactionKey> </merchantAuthentication> <refId><![CDATA[ref1416999093]]></refId> <searchType><![CDATA[subscriptionActive]]></searchType> <sorting> <orderBy><![CDATA[firstName]]></orderBy> <orderDescending>false</orderDescending> </sorting> <paging> <limit>10</limit> <offset>1</offset> </paging> </ARBGetSubscriptionListRequest> ';
+ */
+ $this->httpClient->setPostUrl( $endPoint);
+ $xmlResponse = $this->httpClient->_sendRequest($xmlRequest);
+ if ( null == $xmlResponse)
+ {
+ throw new \Exception( "Error getting valid response from api. Check log file for error details");
+ }
+ $this->logger->info("Response De-Serialization Begin");
+ $this->apiResponse = $this->serializer->deserialize( $xmlResponse, $this->apiResponseType , 'xml');
+ $this->logger->info("Response De-Serialization End");
+
+ $this->afterExecute();
+ }
+
+ private function validate()
+ {
+ $merchantAuthentication = $this->apiRequest->getMerchantAuthentication();
+ if ( null == $merchantAuthentication)
+ {
+ throw new \InvalidArgumentException( "MerchantAuthentication cannot be null");
+ }
+
+ $this->validateRequest();
+ }
+
+ protected function beforeExecute() {}
+ protected function afterExecute() {}
+ protected function validateRequest() {} //need to make this abstract
+
+ protected function now()
+ {
+ return date( DATE_RFC2822);
+ }
+}
--- /dev/null
+<?php
+namespace net\authorize\api\controller\base;
+
+interface IApiOperation
+{
+ /**
+ * @return \net\authorize\api\contract\v1\ANetApiResponseType
+ */
+ public function getApiResponse();
+ /**
+ * @return \net\authorize\api\contract\v1\ANetApiResponseType
+ */
+public function executeWithApiResponse( $endPoint = null);
+ /**
+ * @return void
+ */
+public function execute( $endPoint = null);
+ /*
+ //TS GetApiResponse();
+ AuthorizeNet.Api.Contracts.V1.ANetApiResponse GetErrorResponse();
+ //TS ExecuteWithApiResponse(AuthorizeNet.Environment environment = null);
+ //void Execute(AuthorizeNet.Environment environment = null);
+ AuthorizeNet.Api.Contracts.V1.messageTypeEnum GetResultCode();
+ List<string> GetResults();
+ */
+}
\ No newline at end of file
--- /dev/null
+net\authorize\api\contract\v1\ANetApiRequestType:
+ properties:
+ merchantAuthentication:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantAuthentication
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantAuthentication
+ setter: setMerchantAuthentication
+ type: net\authorize\api\contract\v1\MerchantAuthenticationType
+ clientId:
+ expose: true
+ access_type: public_method
+ serialized_name: clientId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getClientId
+ setter: setClientId
+ type: string
+ refId:
+ expose: true
+ access_type: public_method
+ serialized_name: refId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefId
+ setter: setRefId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ANetApiResponseType:
+ properties:
+ refId:
+ expose: true
+ access_type: public_method
+ serialized_name: refId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefId
+ setter: setRefId
+ type: string
+ messages:
+ expose: true
+ access_type: public_method
+ serialized_name: messages
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMessages
+ setter: setMessages
+ type: net\authorize\api\contract\v1\MessagesType
+ sessionToken:
+ expose: true
+ access_type: public_method
+ serialized_name: sessionToken
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSessionToken
+ setter: setSessionToken
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ARBCancelSubscriptionRequest:
+ xml_root_name: ARBCancelSubscriptionRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ subscriptionId:
+ expose: true
+ access_type: public_method
+ serialized_name: subscriptionId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscriptionId
+ setter: setSubscriptionId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ARBCancelSubscriptionResponse:
+ xml_root_name: ARBCancelSubscriptionResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\ARBCreateSubscriptionRequest:
+ xml_root_name: ARBCreateSubscriptionRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ subscription:
+ expose: true
+ access_type: public_method
+ serialized_name: subscription
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscription
+ setter: setSubscription
+ type: net\authorize\api\contract\v1\ARBSubscriptionType
--- /dev/null
+net\authorize\api\contract\v1\ARBCreateSubscriptionResponse:
+ xml_root_name: ARBCreateSubscriptionResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ subscriptionId:
+ expose: true
+ access_type: public_method
+ serialized_name: subscriptionId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscriptionId
+ setter: setSubscriptionId
+ type: string
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfileIdType
--- /dev/null
+net\authorize\api\contract\v1\ARBGetSubscriptionListRequest:
+ xml_root_name: ARBGetSubscriptionListRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ searchType:
+ expose: true
+ access_type: public_method
+ serialized_name: searchType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSearchType
+ setter: setSearchType
+ type: string
+ sorting:
+ expose: true
+ access_type: public_method
+ serialized_name: sorting
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSorting
+ setter: setSorting
+ type: net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType
+ paging:
+ expose: true
+ access_type: public_method
+ serialized_name: paging
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaging
+ setter: setPaging
+ type: net\authorize\api\contract\v1\PagingType
--- /dev/null
+net\authorize\api\contract\v1\ARBGetSubscriptionListResponse:
+ xml_root_name: ARBGetSubscriptionListResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ totalNumInResultSet:
+ expose: true
+ access_type: public_method
+ serialized_name: totalNumInResultSet
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTotalNumInResultSet
+ setter: setTotalNumInResultSet
+ type: integer
+ subscriptionDetails:
+ expose: true
+ access_type: public_method
+ serialized_name: subscriptionDetails
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscriptionDetails
+ setter: setSubscriptionDetails
+ type: array<net\authorize\api\contract\v1\SubscriptionDetailType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: subscriptionDetail
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType:
+ properties:
+ orderBy:
+ expose: true
+ access_type: public_method
+ serialized_name: orderBy
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrderBy
+ setter: setOrderBy
+ type: string
+ orderDescending:
+ expose: true
+ access_type: public_method
+ serialized_name: orderDescending
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrderDescending
+ setter: setOrderDescending
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\ARBGetSubscriptionRequest:
+ xml_root_name: ARBGetSubscriptionRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ subscriptionId:
+ expose: true
+ access_type: public_method
+ serialized_name: subscriptionId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscriptionId
+ setter: setSubscriptionId
+ type: string
+ includeTransactions:
+ expose: true
+ access_type: public_method
+ serialized_name: includeTransactions
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getIncludeTransactions
+ setter: setIncludeTransactions
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\ARBGetSubscriptionResponse:
+ xml_root_name: ARBGetSubscriptionResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ subscription:
+ expose: true
+ access_type: public_method
+ serialized_name: subscription
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscription
+ setter: setSubscription
+ type: net\authorize\api\contract\v1\ARBSubscriptionMaskedType
--- /dev/null
+net\authorize\api\contract\v1\ARBGetSubscriptionStatusRequest:
+ xml_root_name: ARBGetSubscriptionStatusRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ subscriptionId:
+ expose: true
+ access_type: public_method
+ serialized_name: subscriptionId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscriptionId
+ setter: setSubscriptionId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ARBGetSubscriptionStatusResponse:
+ xml_root_name: ARBGetSubscriptionStatusResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ status:
+ expose: true
+ access_type: public_method
+ serialized_name: status
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getStatus
+ setter: setStatus
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ARBSubscriptionMaskedType:
+ properties:
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ paymentSchedule:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentSchedule
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentSchedule
+ setter: setPaymentSchedule
+ type: net\authorize\api\contract\v1\PaymentScheduleType
+ amount:
+ expose: true
+ access_type: public_method
+ serialized_name: amount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAmount
+ setter: setAmount
+ type: float
+ trialAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: trialAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTrialAmount
+ setter: setTrialAmount
+ type: float
+ status:
+ expose: true
+ access_type: public_method
+ serialized_name: status
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getStatus
+ setter: setStatus
+ type: string
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\SubscriptionCustomerProfileType
+ order:
+ expose: true
+ access_type: public_method
+ serialized_name: order
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrder
+ setter: setOrder
+ type: net\authorize\api\contract\v1\OrderType
+ arbTransactions:
+ expose: true
+ access_type: public_method
+ serialized_name: arbTransactions
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getArbTransactions
+ setter: setArbTransactions
+ type: array<net\authorize\api\contract\v1\ArbTransactionType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: arbTransaction
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\ARBSubscriptionType:
+ properties:
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ paymentSchedule:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentSchedule
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentSchedule
+ setter: setPaymentSchedule
+ type: net\authorize\api\contract\v1\PaymentScheduleType
+ amount:
+ expose: true
+ access_type: public_method
+ serialized_name: amount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAmount
+ setter: setAmount
+ type: float
+ trialAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: trialAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTrialAmount
+ setter: setTrialAmount
+ type: float
+ payment:
+ expose: true
+ access_type: public_method
+ serialized_name: payment
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayment
+ setter: setPayment
+ type: net\authorize\api\contract\v1\PaymentType
+ order:
+ expose: true
+ access_type: public_method
+ serialized_name: order
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrder
+ setter: setOrder
+ type: net\authorize\api\contract\v1\OrderType
+ customer:
+ expose: true
+ access_type: public_method
+ serialized_name: customer
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomer
+ setter: setCustomer
+ type: net\authorize\api\contract\v1\CustomerType
+ billTo:
+ expose: true
+ access_type: public_method
+ serialized_name: billTo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBillTo
+ setter: setBillTo
+ type: net\authorize\api\contract\v1\NameAndAddressType
+ shipTo:
+ expose: true
+ access_type: public_method
+ serialized_name: shipTo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShipTo
+ setter: setShipTo
+ type: net\authorize\api\contract\v1\NameAndAddressType
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfileIdType
--- /dev/null
+net\authorize\api\contract\v1\ARBUpdateSubscriptionRequest:
+ xml_root_name: ARBUpdateSubscriptionRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ subscriptionId:
+ expose: true
+ access_type: public_method
+ serialized_name: subscriptionId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscriptionId
+ setter: setSubscriptionId
+ type: string
+ subscription:
+ expose: true
+ access_type: public_method
+ serialized_name: subscription
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscription
+ setter: setSubscription
+ type: net\authorize\api\contract\v1\ARBSubscriptionType
--- /dev/null
+net\authorize\api\contract\v1\ARBUpdateSubscriptionResponse:
+ xml_root_name: ARBUpdateSubscriptionResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfileIdType
--- /dev/null
+net\authorize\api\contract\v1\ArbTransactionType:
+ properties:
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
+ response:
+ expose: true
+ access_type: public_method
+ serialized_name: response
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getResponse
+ setter: setResponse
+ type: string
+ submitTimeUTC:
+ expose: true
+ access_type: public_method
+ serialized_name: submitTimeUTC
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubmitTimeUTC
+ setter: setSubmitTimeUTC
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ payNum:
+ expose: true
+ access_type: public_method
+ serialized_name: payNum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayNum
+ setter: setPayNum
+ type: integer
+ attemptNum:
+ expose: true
+ access_type: public_method
+ serialized_name: attemptNum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAttemptNum
+ setter: setAttemptNum
+ type: integer
--- /dev/null
+net\authorize\api\contract\v1\ArrayOfSettingType:
+ properties:
+ setting:
+ expose: true
+ access_type: public_method
+ serialized_name: setting
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSetting
+ setter: setSetting
+ xml_list:
+ inline: true
+ entry_name: setting
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\SettingType>
--- /dev/null
+net\authorize\api\contract\v1\AuDeleteType:
+ properties:
+ creditCard:
+ expose: true
+ access_type: public_method
+ serialized_name: creditCard
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCreditCard
+ setter: setCreditCard
+ type: net\authorize\api\contract\v1\CreditCardMaskedType
--- /dev/null
+net\authorize\api\contract\v1\AuDetailsType:
+ properties:
+ customerProfileID:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileID
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileID
+ setter: setCustomerProfileID
+ type: integer
+ customerPaymentProfileID:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileID
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileID
+ setter: setCustomerPaymentProfileID
+ type: integer
+ firstName:
+ expose: true
+ access_type: public_method
+ serialized_name: firstName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFirstName
+ setter: setFirstName
+ type: string
+ lastName:
+ expose: true
+ access_type: public_method
+ serialized_name: lastName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLastName
+ setter: setLastName
+ type: string
+ updateTimeUTC:
+ expose: true
+ access_type: public_method
+ serialized_name: updateTimeUTC
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUpdateTimeUTC
+ setter: setUpdateTimeUTC
+ type: string
+ auReasonCode:
+ expose: true
+ access_type: public_method
+ serialized_name: auReasonCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuReasonCode
+ setter: setAuReasonCode
+ type: string
+ reasonDescription:
+ expose: true
+ access_type: public_method
+ serialized_name: reasonDescription
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getReasonDescription
+ setter: setReasonDescription
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\AuResponseType:
+ properties:
+ auReasonCode:
+ expose: true
+ access_type: public_method
+ serialized_name: auReasonCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuReasonCode
+ setter: setAuReasonCode
+ type: string
+ profileCount:
+ expose: true
+ access_type: public_method
+ serialized_name: profileCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfileCount
+ setter: setProfileCount
+ type: integer
+ reasonDescription:
+ expose: true
+ access_type: public_method
+ serialized_name: reasonDescription
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getReasonDescription
+ setter: setReasonDescription
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\AuUpdateType:
+ properties:
+ newCreditCard:
+ expose: true
+ access_type: public_method
+ serialized_name: newCreditCard
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getNewCreditCard
+ setter: setNewCreditCard
+ type: net\authorize\api\contract\v1\CreditCardMaskedType
+ oldCreditCard:
+ expose: true
+ access_type: public_method
+ serialized_name: oldCreditCard
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOldCreditCard
+ setter: setOldCreditCard
+ type: net\authorize\api\contract\v1\CreditCardMaskedType
--- /dev/null
+net\authorize\api\contract\v1\AuthenticateTestRequest:
+ xml_root_name: authenticateTestRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\AuthenticateTestResponse:
+ xml_root_name: authenticateTestResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\BankAccountMaskedType:
+ properties:
+ accountType:
+ expose: true
+ access_type: public_method
+ serialized_name: accountType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountType
+ setter: setAccountType
+ type: string
+ routingNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: routingNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRoutingNumber
+ setter: setRoutingNumber
+ type: string
+ accountNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: accountNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountNumber
+ setter: setAccountNumber
+ type: string
+ nameOnAccount:
+ expose: true
+ access_type: public_method
+ serialized_name: nameOnAccount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getNameOnAccount
+ setter: setNameOnAccount
+ type: string
+ echeckType:
+ expose: true
+ access_type: public_method
+ serialized_name: echeckType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEcheckType
+ setter: setEcheckType
+ type: string
+ bankName:
+ expose: true
+ access_type: public_method
+ serialized_name: bankName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBankName
+ setter: setBankName
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\BankAccountType:
+ properties:
+ accountType:
+ expose: true
+ access_type: public_method
+ serialized_name: accountType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountType
+ setter: setAccountType
+ type: string
+ routingNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: routingNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRoutingNumber
+ setter: setRoutingNumber
+ type: string
+ accountNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: accountNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountNumber
+ setter: setAccountNumber
+ type: string
+ nameOnAccount:
+ expose: true
+ access_type: public_method
+ serialized_name: nameOnAccount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getNameOnAccount
+ setter: setNameOnAccount
+ type: string
+ echeckType:
+ expose: true
+ access_type: public_method
+ serialized_name: echeckType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEcheckType
+ setter: setEcheckType
+ type: string
+ bankName:
+ expose: true
+ access_type: public_method
+ serialized_name: bankName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBankName
+ setter: setBankName
+ type: string
+ checkNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: checkNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCheckNumber
+ setter: setCheckNumber
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\BatchDetailsType:
+ properties:
+ batchId:
+ expose: true
+ access_type: public_method
+ serialized_name: batchId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBatchId
+ setter: setBatchId
+ type: string
+ settlementTimeUTC:
+ expose: true
+ access_type: public_method
+ serialized_name: settlementTimeUTC
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSettlementTimeUTC
+ setter: setSettlementTimeUTC
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ settlementTimeLocal:
+ expose: true
+ access_type: public_method
+ serialized_name: settlementTimeLocal
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSettlementTimeLocal
+ setter: setSettlementTimeLocal
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ settlementState:
+ expose: true
+ access_type: public_method
+ serialized_name: settlementState
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSettlementState
+ setter: setSettlementState
+ type: string
+ paymentMethod:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentMethod
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentMethod
+ setter: setPaymentMethod
+ type: string
+ marketType:
+ expose: true
+ access_type: public_method
+ serialized_name: marketType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMarketType
+ setter: setMarketType
+ type: string
+ product:
+ expose: true
+ access_type: public_method
+ serialized_name: product
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProduct
+ setter: setProduct
+ type: string
+ statistics:
+ expose: true
+ access_type: public_method
+ serialized_name: statistics
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getStatistics
+ setter: setStatistics
+ type: array<net\authorize\api\contract\v1\BatchStatisticType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: statistic
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\BatchStatisticType:
+ properties:
+ accountType:
+ expose: true
+ access_type: public_method
+ serialized_name: accountType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountType
+ setter: setAccountType
+ type: string
+ chargeAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: chargeAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getChargeAmount
+ setter: setChargeAmount
+ type: float
+ chargeCount:
+ expose: true
+ access_type: public_method
+ serialized_name: chargeCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getChargeCount
+ setter: setChargeCount
+ type: integer
+ refundAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: refundAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefundAmount
+ setter: setRefundAmount
+ type: float
+ refundCount:
+ expose: true
+ access_type: public_method
+ serialized_name: refundCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefundCount
+ setter: setRefundCount
+ type: integer
+ voidCount:
+ expose: true
+ access_type: public_method
+ serialized_name: voidCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getVoidCount
+ setter: setVoidCount
+ type: integer
+ declineCount:
+ expose: true
+ access_type: public_method
+ serialized_name: declineCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDeclineCount
+ setter: setDeclineCount
+ type: integer
+ errorCount:
+ expose: true
+ access_type: public_method
+ serialized_name: errorCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getErrorCount
+ setter: setErrorCount
+ type: integer
+ returnedItemAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: returnedItemAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getReturnedItemAmount
+ setter: setReturnedItemAmount
+ type: float
+ returnedItemCount:
+ expose: true
+ access_type: public_method
+ serialized_name: returnedItemCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getReturnedItemCount
+ setter: setReturnedItemCount
+ type: integer
+ chargebackAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: chargebackAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getChargebackAmount
+ setter: setChargebackAmount
+ type: float
+ chargebackCount:
+ expose: true
+ access_type: public_method
+ serialized_name: chargebackCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getChargebackCount
+ setter: setChargebackCount
+ type: integer
+ correctionNoticeCount:
+ expose: true
+ access_type: public_method
+ serialized_name: correctionNoticeCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCorrectionNoticeCount
+ setter: setCorrectionNoticeCount
+ type: integer
+ chargeChargeBackAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: chargeChargeBackAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getChargeChargeBackAmount
+ setter: setChargeChargeBackAmount
+ type: float
+ chargeChargeBackCount:
+ expose: true
+ access_type: public_method
+ serialized_name: chargeChargeBackCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getChargeChargeBackCount
+ setter: setChargeChargeBackCount
+ type: integer
+ refundChargeBackAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: refundChargeBackAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefundChargeBackAmount
+ setter: setRefundChargeBackAmount
+ type: float
+ refundChargeBackCount:
+ expose: true
+ access_type: public_method
+ serialized_name: refundChargeBackCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefundChargeBackCount
+ setter: setRefundChargeBackCount
+ type: integer
+ chargeReturnedItemsAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: chargeReturnedItemsAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getChargeReturnedItemsAmount
+ setter: setChargeReturnedItemsAmount
+ type: float
+ chargeReturnedItemsCount:
+ expose: true
+ access_type: public_method
+ serialized_name: chargeReturnedItemsCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getChargeReturnedItemsCount
+ setter: setChargeReturnedItemsCount
+ type: integer
+ refundReturnedItemsAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: refundReturnedItemsAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefundReturnedItemsAmount
+ setter: setRefundReturnedItemsAmount
+ type: float
+ refundReturnedItemsCount:
+ expose: true
+ access_type: public_method
+ serialized_name: refundReturnedItemsCount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefundReturnedItemsCount
+ setter: setRefundReturnedItemsCount
+ type: integer
--- /dev/null
+net\authorize\api\contract\v1\CardArtType:
+ properties:
+ cardBrand:
+ expose: true
+ access_type: public_method
+ serialized_name: cardBrand
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardBrand
+ setter: setCardBrand
+ type: string
+ cardImageHeight:
+ expose: true
+ access_type: public_method
+ serialized_name: cardImageHeight
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardImageHeight
+ setter: setCardImageHeight
+ type: string
+ cardImageUrl:
+ expose: true
+ access_type: public_method
+ serialized_name: cardImageUrl
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardImageUrl
+ setter: setCardImageUrl
+ type: string
+ cardImageWidth:
+ expose: true
+ access_type: public_method
+ serialized_name: cardImageWidth
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardImageWidth
+ setter: setCardImageWidth
+ type: string
+ cardType:
+ expose: true
+ access_type: public_method
+ serialized_name: cardType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardType
+ setter: setCardType
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CcAuthenticationType:
+ properties:
+ authenticationIndicator:
+ expose: true
+ access_type: public_method
+ serialized_name: authenticationIndicator
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuthenticationIndicator
+ setter: setAuthenticationIndicator
+ type: string
+ cardholderAuthenticationValue:
+ expose: true
+ access_type: public_method
+ serialized_name: cardholderAuthenticationValue
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardholderAuthenticationValue
+ setter: setCardholderAuthenticationValue
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreateCustomerPaymentProfileRequest:
+ xml_root_name: createCustomerPaymentProfileRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ paymentProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentProfile
+ setter: setPaymentProfile
+ type: net\authorize\api\contract\v1\CustomerPaymentProfileType
+ validationMode:
+ expose: true
+ access_type: public_method
+ serialized_name: validationMode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValidationMode
+ setter: setValidationMode
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreateCustomerPaymentProfileResponse:
+ xml_root_name: createCustomerPaymentProfileResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ validationDirectResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: validationDirectResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValidationDirectResponse
+ setter: setValidationDirectResponse
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreateCustomerProfileFromTransactionRequest:
+ xml_root_name: createCustomerProfileFromTransactionRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
+ customer:
+ expose: true
+ access_type: public_method
+ serialized_name: customer
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomer
+ setter: setCustomer
+ type: net\authorize\api\contract\v1\CustomerProfileBaseType
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ defaultPaymentProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: defaultPaymentProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDefaultPaymentProfile
+ setter: setDefaultPaymentProfile
+ type: boolean
+ defaultShippingAddress:
+ expose: true
+ access_type: public_method
+ serialized_name: defaultShippingAddress
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDefaultShippingAddress
+ setter: setDefaultShippingAddress
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\CreateCustomerProfileRequest:
+ xml_root_name: createCustomerProfileRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfileType
+ validationMode:
+ expose: true
+ access_type: public_method
+ serialized_name: validationMode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValidationMode
+ setter: setValidationMode
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreateCustomerProfileResponse:
+ xml_root_name: createCustomerProfileResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileIdList:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileIdList
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileIdList
+ setter: setCustomerPaymentProfileIdList
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: numericString
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ customerShippingAddressIdList:
+ expose: true
+ access_type: public_method
+ serialized_name: customerShippingAddressIdList
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerShippingAddressIdList
+ setter: setCustomerShippingAddressIdList
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: numericString
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ validationDirectResponseList:
+ expose: true
+ access_type: public_method
+ serialized_name: validationDirectResponseList
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValidationDirectResponseList
+ setter: setValidationDirectResponseList
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: string
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\CreateCustomerProfileTransactionRequest:
+ xml_root_name: createCustomerProfileTransactionRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transaction:
+ expose: true
+ access_type: public_method
+ serialized_name: transaction
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransaction
+ setter: setTransaction
+ type: net\authorize\api\contract\v1\ProfileTransactionType
+ extraOptions:
+ expose: true
+ access_type: public_method
+ serialized_name: extraOptions
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getExtraOptions
+ setter: setExtraOptions
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreateCustomerProfileTransactionResponse:
+ xml_root_name: createCustomerProfileTransactionResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transactionResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionResponse
+ setter: setTransactionResponse
+ type: net\authorize\api\contract\v1\TransactionResponseType
+ directResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: directResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDirectResponse
+ setter: setDirectResponse
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreateCustomerShippingAddressRequest:
+ xml_root_name: createCustomerShippingAddressRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ address:
+ expose: true
+ access_type: public_method
+ serialized_name: address
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAddress
+ setter: setAddress
+ type: net\authorize\api\contract\v1\CustomerAddressType
+ defaultShippingAddress:
+ expose: true
+ access_type: public_method
+ serialized_name: defaultShippingAddress
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDefaultShippingAddress
+ setter: setDefaultShippingAddress
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\CreateCustomerShippingAddressResponse:
+ xml_root_name: createCustomerShippingAddressResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerAddressId
+ setter: setCustomerAddressId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreateProfileResponseType:
+ properties:
+ messages:
+ expose: true
+ access_type: public_method
+ serialized_name: messages
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMessages
+ setter: setMessages
+ type: net\authorize\api\contract\v1\MessagesType
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileIdList:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileIdList
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileIdList
+ setter: setCustomerPaymentProfileIdList
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: numericString
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ customerShippingAddressIdList:
+ expose: true
+ access_type: public_method
+ serialized_name: customerShippingAddressIdList
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerShippingAddressIdList
+ setter: setCustomerShippingAddressIdList
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: numericString
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\CreateTransactionRequest:
+ xml_root_name: createTransactionRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transactionRequest:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionRequest
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionRequest
+ setter: setTransactionRequest
+ type: net\authorize\api\contract\v1\TransactionRequestType
--- /dev/null
+net\authorize\api\contract\v1\CreateTransactionResponse:
+ xml_root_name: createTransactionResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transactionResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionResponse
+ setter: setTransactionResponse
+ type: net\authorize\api\contract\v1\TransactionResponseType
+ profileResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: profileResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfileResponse
+ setter: setProfileResponse
+ type: net\authorize\api\contract\v1\CreateProfileResponseType
--- /dev/null
+net\authorize\api\contract\v1\CreditCardMaskedType:
+ properties:
+ cardNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: cardNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardNumber
+ setter: setCardNumber
+ type: string
+ expirationDate:
+ expose: true
+ access_type: public_method
+ serialized_name: expirationDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getExpirationDate
+ setter: setExpirationDate
+ type: string
+ cardType:
+ expose: true
+ access_type: public_method
+ serialized_name: cardType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardType
+ setter: setCardType
+ type: string
+ cardArt:
+ expose: true
+ access_type: public_method
+ serialized_name: cardArt
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardArt
+ setter: setCardArt
+ type: net\authorize\api\contract\v1\CardArtType
+ issuerNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: issuerNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getIssuerNumber
+ setter: setIssuerNumber
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreditCardSimpleType:
+ properties:
+ cardNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: cardNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardNumber
+ setter: setCardNumber
+ type: string
+ expirationDate:
+ expose: true
+ access_type: public_method
+ serialized_name: expirationDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getExpirationDate
+ setter: setExpirationDate
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreditCardTrackType:
+ properties:
+ track1:
+ expose: true
+ access_type: public_method
+ serialized_name: track1
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTrack1
+ setter: setTrack1
+ type: string
+ track2:
+ expose: true
+ access_type: public_method
+ serialized_name: track2
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTrack2
+ setter: setTrack2
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CreditCardType:
+ properties:
+ cardCode:
+ expose: true
+ access_type: public_method
+ serialized_name: cardCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardCode
+ setter: setCardCode
+ type: string
+ isPaymentToken:
+ expose: true
+ access_type: public_method
+ serialized_name: isPaymentToken
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getIsPaymentToken
+ setter: setIsPaymentToken
+ type: boolean
+ cryptogram:
+ expose: true
+ access_type: public_method
+ serialized_name: cryptogram
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCryptogram
+ setter: setCryptogram
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CustomerAddressExType:
+ properties:
+ customerAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerAddressId
+ setter: setCustomerAddressId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CustomerAddressType:
+ properties:
+ phoneNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: phoneNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPhoneNumber
+ setter: setPhoneNumber
+ type: string
+ faxNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: faxNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFaxNumber
+ setter: setFaxNumber
+ type: string
+ email:
+ expose: true
+ access_type: public_method
+ serialized_name: email
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmail
+ setter: setEmail
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CustomerDataType:
+ properties:
+ type:
+ expose: true
+ access_type: public_method
+ serialized_name: type
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getType
+ setter: setType
+ type: string
+ id:
+ expose: true
+ access_type: public_method
+ serialized_name: id
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getId
+ setter: setId
+ type: string
+ email:
+ expose: true
+ access_type: public_method
+ serialized_name: email
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmail
+ setter: setEmail
+ type: string
+ driversLicense:
+ expose: true
+ access_type: public_method
+ serialized_name: driversLicense
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDriversLicense
+ setter: setDriversLicense
+ type: net\authorize\api\contract\v1\DriversLicenseType
+ taxId:
+ expose: true
+ access_type: public_method
+ serialized_name: taxId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTaxId
+ setter: setTaxId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CustomerPaymentProfileBaseType:
+ properties:
+ customerType:
+ expose: true
+ access_type: public_method
+ serialized_name: customerType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerType
+ setter: setCustomerType
+ type: string
+ billTo:
+ expose: true
+ access_type: public_method
+ serialized_name: billTo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBillTo
+ setter: setBillTo
+ type: net\authorize\api\contract\v1\CustomerAddressType
--- /dev/null
+net\authorize\api\contract\v1\CustomerPaymentProfileExType:
+ properties:
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CustomerPaymentProfileListItemType:
+ properties:
+ defaultPaymentProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: defaultPaymentProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDefaultPaymentProfile
+ setter: setDefaultPaymentProfile
+ type: boolean
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: integer
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: integer
+ billTo:
+ expose: true
+ access_type: public_method
+ serialized_name: billTo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBillTo
+ setter: setBillTo
+ type: net\authorize\api\contract\v1\CustomerAddressType
+ payment:
+ expose: true
+ access_type: public_method
+ serialized_name: payment
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayment
+ setter: setPayment
+ type: net\authorize\api\contract\v1\PaymentMaskedType
--- /dev/null
+net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType:
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ defaultPaymentProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: defaultPaymentProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDefaultPaymentProfile
+ setter: setDefaultPaymentProfile
+ type: boolean
+ payment:
+ expose: true
+ access_type: public_method
+ serialized_name: payment
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayment
+ setter: setPayment
+ type: net\authorize\api\contract\v1\PaymentMaskedType
+ driversLicense:
+ expose: true
+ access_type: public_method
+ serialized_name: driversLicense
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDriversLicense
+ setter: setDriversLicense
+ type: net\authorize\api\contract\v1\DriversLicenseMaskedType
+ taxId:
+ expose: true
+ access_type: public_method
+ serialized_name: taxId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTaxId
+ setter: setTaxId
+ type: string
+ subscriptionIds:
+ expose: true
+ access_type: public_method
+ serialized_name: subscriptionIds
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscriptionIds
+ setter: setSubscriptionIds
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: subscriptionId
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\CustomerPaymentProfileSortingType:
+ properties:
+ orderBy:
+ expose: true
+ access_type: public_method
+ serialized_name: orderBy
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrderBy
+ setter: setOrderBy
+ type: string
+ orderDescending:
+ expose: true
+ access_type: public_method
+ serialized_name: orderDescending
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrderDescending
+ setter: setOrderDescending
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\CustomerPaymentProfileType:
+ properties:
+ payment:
+ expose: true
+ access_type: public_method
+ serialized_name: payment
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayment
+ setter: setPayment
+ type: net\authorize\api\contract\v1\PaymentType
+ driversLicense:
+ expose: true
+ access_type: public_method
+ serialized_name: driversLicense
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDriversLicense
+ setter: setDriversLicense
+ type: net\authorize\api\contract\v1\DriversLicenseType
+ taxId:
+ expose: true
+ access_type: public_method
+ serialized_name: taxId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTaxId
+ setter: setTaxId
+ type: string
+ defaultPaymentProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: defaultPaymentProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDefaultPaymentProfile
+ setter: setDefaultPaymentProfile
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\CustomerProfileBaseType:
+ properties:
+ merchantCustomerId:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantCustomerId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantCustomerId
+ setter: setMerchantCustomerId
+ type: string
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
+ email:
+ expose: true
+ access_type: public_method
+ serialized_name: email
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmail
+ setter: setEmail
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CustomerProfileExType:
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CustomerProfileIdType:
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ customerAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerAddressId
+ setter: setCustomerAddressId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CustomerProfileMaskedType:
+ properties:
+ paymentProfiles:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentProfiles
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentProfiles
+ setter: setPaymentProfiles
+ xml_list:
+ inline: true
+ entry_name: paymentProfiles
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType>
+ shipToList:
+ expose: true
+ access_type: public_method
+ serialized_name: shipToList
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShipToList
+ setter: setShipToList
+ xml_list:
+ inline: true
+ entry_name: shipToList
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\CustomerAddressExType>
--- /dev/null
+net\authorize\api\contract\v1\CustomerProfilePaymentType:
+ properties:
+ createProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: createProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCreateProfile
+ setter: setCreateProfile
+ type: boolean
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ paymentProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentProfile
+ setter: setPaymentProfile
+ type: net\authorize\api\contract\v1\PaymentProfileType
+ shippingProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: shippingProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShippingProfileId
+ setter: setShippingProfileId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\CustomerProfileSummaryType:
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
+ merchantCustomerId:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantCustomerId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantCustomerId
+ setter: setMerchantCustomerId
+ type: string
+ email:
+ expose: true
+ access_type: public_method
+ serialized_name: email
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmail
+ setter: setEmail
+ type: string
+ createdDate:
+ expose: true
+ access_type: public_method
+ serialized_name: createdDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCreatedDate
+ setter: setCreatedDate
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
--- /dev/null
+net\authorize\api\contract\v1\CustomerProfileType:
+ properties:
+ paymentProfiles:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentProfiles
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentProfiles
+ setter: setPaymentProfiles
+ xml_list:
+ inline: true
+ entry_name: paymentProfiles
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\CustomerPaymentProfileType>
+ shipToList:
+ expose: true
+ access_type: public_method
+ serialized_name: shipToList
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShipToList
+ setter: setShipToList
+ xml_list:
+ inline: true
+ entry_name: shipToList
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\CustomerAddressType>
--- /dev/null
+net\authorize\api\contract\v1\CustomerType:
+ properties:
+ type:
+ expose: true
+ access_type: public_method
+ serialized_name: type
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getType
+ setter: setType
+ type: string
+ id:
+ expose: true
+ access_type: public_method
+ serialized_name: id
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getId
+ setter: setId
+ type: string
+ email:
+ expose: true
+ access_type: public_method
+ serialized_name: email
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmail
+ setter: setEmail
+ type: string
+ phoneNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: phoneNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPhoneNumber
+ setter: setPhoneNumber
+ type: string
+ faxNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: faxNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFaxNumber
+ setter: setFaxNumber
+ type: string
+ driversLicense:
+ expose: true
+ access_type: public_method
+ serialized_name: driversLicense
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDriversLicense
+ setter: setDriversLicense
+ type: net\authorize\api\contract\v1\DriversLicenseType
+ taxId:
+ expose: true
+ access_type: public_method
+ serialized_name: taxId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTaxId
+ setter: setTaxId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\DecryptPaymentDataRequest:
+ xml_root_name: decryptPaymentDataRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ opaqueData:
+ expose: true
+ access_type: public_method
+ serialized_name: opaqueData
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOpaqueData
+ setter: setOpaqueData
+ type: net\authorize\api\contract\v1\OpaqueDataType
+ callId:
+ expose: true
+ access_type: public_method
+ serialized_name: callId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCallId
+ setter: setCallId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\DecryptPaymentDataResponse:
+ xml_root_name: decryptPaymentDataResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ shippingInfo:
+ expose: true
+ access_type: public_method
+ serialized_name: shippingInfo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShippingInfo
+ setter: setShippingInfo
+ type: net\authorize\api\contract\v1\CustomerAddressType
+ billingInfo:
+ expose: true
+ access_type: public_method
+ serialized_name: billingInfo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBillingInfo
+ setter: setBillingInfo
+ type: net\authorize\api\contract\v1\CustomerAddressType
+ cardInfo:
+ expose: true
+ access_type: public_method
+ serialized_name: cardInfo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardInfo
+ setter: setCardInfo
+ type: net\authorize\api\contract\v1\CreditCardMaskedType
+ paymentDetails:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentDetails
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentDetails
+ setter: setPaymentDetails
+ type: net\authorize\api\contract\v1\PaymentDetailsType
--- /dev/null
+net\authorize\api\contract\v1\DeleteCustomerPaymentProfileRequest:
+ xml_root_name: deleteCustomerPaymentProfileRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\DeleteCustomerPaymentProfileResponse:
+ xml_root_name: deleteCustomerPaymentProfileResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\DeleteCustomerProfileRequest:
+ xml_root_name: deleteCustomerProfileRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\DeleteCustomerProfileResponse:
+ xml_root_name: deleteCustomerProfileResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\DeleteCustomerShippingAddressRequest:
+ xml_root_name: deleteCustomerShippingAddressRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerAddressId
+ setter: setCustomerAddressId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\DeleteCustomerShippingAddressResponse:
+ xml_root_name: deleteCustomerShippingAddressResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\DriversLicenseMaskedType:
+ properties:
+ number:
+ expose: true
+ access_type: public_method
+ serialized_name: number
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getNumber
+ setter: setNumber
+ type: string
+ state:
+ expose: true
+ access_type: public_method
+ serialized_name: state
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getState
+ setter: setState
+ type: string
+ dateOfBirth:
+ expose: true
+ access_type: public_method
+ serialized_name: dateOfBirth
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDateOfBirth
+ setter: setDateOfBirth
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\DriversLicenseType:
+ properties:
+ number:
+ expose: true
+ access_type: public_method
+ serialized_name: number
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getNumber
+ setter: setNumber
+ type: string
+ state:
+ expose: true
+ access_type: public_method
+ serialized_name: state
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getState
+ setter: setState
+ type: string
+ dateOfBirth:
+ expose: true
+ access_type: public_method
+ serialized_name: dateOfBirth
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDateOfBirth
+ setter: setDateOfBirth
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\EmailSettingsType:
+ properties:
+ version:
+ expose: true
+ access_type: public_method
+ serialized_name: version
+ accessor:
+ getter: getVersion
+ setter: setVersion
+ xml_attribute: true
+ type: integer
--- /dev/null
+net\authorize\api\contract\v1\EmvTagType:
+ properties:
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ value:
+ expose: true
+ access_type: public_method
+ serialized_name: value
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValue
+ setter: setValue
+ type: string
+ formatted:
+ expose: true
+ access_type: public_method
+ serialized_name: formatted
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFormatted
+ setter: setFormatted
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\EncryptedTrackDataType:
+ properties:
+ formOfPayment:
+ expose: true
+ access_type: public_method
+ serialized_name: FormOfPayment
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFormOfPayment
+ setter: setFormOfPayment
+ type: net\authorize\api\contract\v1\KeyBlockType
--- /dev/null
+net\authorize\api\contract\v1\EnumCollection:
+ xml_root_name: EnumCollection
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileSummaryType:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileSummaryType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileSummaryType
+ setter: setCustomerProfileSummaryType
+ type: net\authorize\api\contract\v1\CustomerProfileSummaryType
+ paymentSimpleType:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentSimpleType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentSimpleType
+ setter: setPaymentSimpleType
+ type: net\authorize\api\contract\v1\PaymentSimpleType
+ accountTypeEnum:
+ expose: true
+ access_type: public_method
+ serialized_name: accountTypeEnum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountTypeEnum
+ setter: setAccountTypeEnum
+ type: string
+ cardTypeEnum:
+ expose: true
+ access_type: public_method
+ serialized_name: cardTypeEnum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardTypeEnum
+ setter: setCardTypeEnum
+ type: string
+ fDSFilterActionEnum:
+ expose: true
+ access_type: public_method
+ serialized_name: FDSFilterActionEnum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFDSFilterActionEnum
+ setter: setFDSFilterActionEnum
+ type: string
+ permissionsEnum:
+ expose: true
+ access_type: public_method
+ serialized_name: permissionsEnum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPermissionsEnum
+ setter: setPermissionsEnum
+ type: string
+ settingNameEnum:
+ expose: true
+ access_type: public_method
+ serialized_name: settingNameEnum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSettingNameEnum
+ setter: setSettingNameEnum
+ type: string
+ settlementStateEnum:
+ expose: true
+ access_type: public_method
+ serialized_name: settlementStateEnum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSettlementStateEnum
+ setter: setSettlementStateEnum
+ type: string
+ transactionStatusEnum:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionStatusEnum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionStatusEnum
+ setter: setTransactionStatusEnum
+ type: string
+ transactionTypeEnum:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionTypeEnum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionTypeEnum
+ setter: setTransactionTypeEnum
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ErrorResponse:
+ xml_root_name: ErrorResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\ExtendedAmountType:
+ properties:
+ amount:
+ expose: true
+ access_type: public_method
+ serialized_name: amount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAmount
+ setter: setAmount
+ type: float
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\FDSFilterType:
+ properties:
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ action:
+ expose: true
+ access_type: public_method
+ serialized_name: action
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAction
+ setter: setAction
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\FingerPrintType:
+ properties:
+ hashValue:
+ expose: true
+ access_type: public_method
+ serialized_name: hashValue
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getHashValue
+ setter: setHashValue
+ type: string
+ sequence:
+ expose: true
+ access_type: public_method
+ serialized_name: sequence
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSequence
+ setter: setSequence
+ type: string
+ timestamp:
+ expose: true
+ access_type: public_method
+ serialized_name: timestamp
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTimestamp
+ setter: setTimestamp
+ type: string
+ currencyCode:
+ expose: true
+ access_type: public_method
+ serialized_name: currencyCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCurrencyCode
+ setter: setCurrencyCode
+ type: string
+ amount:
+ expose: true
+ access_type: public_method
+ serialized_name: amount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAmount
+ setter: setAmount
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\FraudInformationType:
+ properties:
+ fraudFilterList:
+ expose: true
+ access_type: public_method
+ serialized_name: fraudFilterList
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFraudFilterList
+ setter: setFraudFilterList
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: fraudFilter
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ fraudAction:
+ expose: true
+ access_type: public_method
+ serialized_name: fraudAction
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFraudAction
+ setter: setFraudAction
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\GetAUJobDetailsRequest:
+ xml_root_name: getAUJobDetailsRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ month:
+ expose: true
+ access_type: public_method
+ serialized_name: month
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMonth
+ setter: setMonth
+ type: string
+ modifiedTypeFilter:
+ expose: true
+ access_type: public_method
+ serialized_name: modifiedTypeFilter
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getModifiedTypeFilter
+ setter: setModifiedTypeFilter
+ type: string
+ paging:
+ expose: true
+ access_type: public_method
+ serialized_name: paging
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaging
+ setter: setPaging
+ type: net\authorize\api\contract\v1\PagingType
--- /dev/null
+net\authorize\api\contract\v1\GetAUJobDetailsResponse:
+ xml_root_name: getAUJobDetailsResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ totalNumInResultSet:
+ expose: true
+ access_type: public_method
+ serialized_name: totalNumInResultSet
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTotalNumInResultSet
+ setter: setTotalNumInResultSet
+ type: integer
+ auDetails:
+ expose: true
+ access_type: public_method
+ serialized_name: auDetails
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuDetails
+ setter: setAuDetails
+ type: net\authorize\api\contract\v1\ListOfAUDetailsType
--- /dev/null
+net\authorize\api\contract\v1\GetAUJobSummaryRequest:
+ xml_root_name: getAUJobSummaryRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ month:
+ expose: true
+ access_type: public_method
+ serialized_name: month
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMonth
+ setter: setMonth
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\GetAUJobSummaryResponse:
+ xml_root_name: getAUJobSummaryResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ auSummary:
+ expose: true
+ access_type: public_method
+ serialized_name: auSummary
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuSummary
+ setter: setAuSummary
+ type: array<net\authorize\api\contract\v1\AuResponseType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: auResponse
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\GetBatchStatisticsRequest:
+ xml_root_name: getBatchStatisticsRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ batchId:
+ expose: true
+ access_type: public_method
+ serialized_name: batchId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBatchId
+ setter: setBatchId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\GetBatchStatisticsResponse:
+ xml_root_name: getBatchStatisticsResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ batch:
+ expose: true
+ access_type: public_method
+ serialized_name: batch
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBatch
+ setter: setBatch
+ type: net\authorize\api\contract\v1\BatchDetailsType
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerPaymentProfileListRequest:
+ xml_root_name: getCustomerPaymentProfileListRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ searchType:
+ expose: true
+ access_type: public_method
+ serialized_name: searchType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSearchType
+ setter: setSearchType
+ type: string
+ month:
+ expose: true
+ access_type: public_method
+ serialized_name: month
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMonth
+ setter: setMonth
+ type: string
+ sorting:
+ expose: true
+ access_type: public_method
+ serialized_name: sorting
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSorting
+ setter: setSorting
+ type: net\authorize\api\contract\v1\CustomerPaymentProfileSortingType
+ paging:
+ expose: true
+ access_type: public_method
+ serialized_name: paging
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaging
+ setter: setPaging
+ type: net\authorize\api\contract\v1\PagingType
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerPaymentProfileListResponse:
+ xml_root_name: getCustomerPaymentProfileListResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ totalNumInResultSet:
+ expose: true
+ access_type: public_method
+ serialized_name: totalNumInResultSet
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTotalNumInResultSet
+ setter: setTotalNumInResultSet
+ type: integer
+ paymentProfiles:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentProfiles
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentProfiles
+ setter: setPaymentProfiles
+ type: array<net\authorize\api\contract\v1\CustomerPaymentProfileListItemType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: paymentProfile
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerPaymentProfileRequest:
+ xml_root_name: getCustomerPaymentProfileRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ unmaskExpirationDate:
+ expose: true
+ access_type: public_method
+ serialized_name: unmaskExpirationDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUnmaskExpirationDate
+ setter: setUnmaskExpirationDate
+ type: boolean
+ includeIssuerInfo:
+ expose: true
+ access_type: public_method
+ serialized_name: includeIssuerInfo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getIncludeIssuerInfo
+ setter: setIncludeIssuerInfo
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerPaymentProfileResponse:
+ xml_root_name: getCustomerPaymentProfileResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ paymentProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentProfile
+ setter: setPaymentProfile
+ type: net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerProfileIdsRequest:
+ xml_root_name: getCustomerProfileIdsRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerProfileIdsResponse:
+ xml_root_name: getCustomerProfileIdsResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ ids:
+ expose: true
+ access_type: public_method
+ serialized_name: ids
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getIds
+ setter: setIds
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: numericString
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerProfileRequest:
+ xml_root_name: getCustomerProfileRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ merchantCustomerId:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantCustomerId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantCustomerId
+ setter: setMerchantCustomerId
+ type: string
+ email:
+ expose: true
+ access_type: public_method
+ serialized_name: email
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmail
+ setter: setEmail
+ type: string
+ unmaskExpirationDate:
+ expose: true
+ access_type: public_method
+ serialized_name: unmaskExpirationDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUnmaskExpirationDate
+ setter: setUnmaskExpirationDate
+ type: boolean
+ includeIssuerInfo:
+ expose: true
+ access_type: public_method
+ serialized_name: includeIssuerInfo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getIncludeIssuerInfo
+ setter: setIncludeIssuerInfo
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerProfileResponse:
+ xml_root_name: getCustomerProfileResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfileMaskedType
+ subscriptionIds:
+ expose: true
+ access_type: public_method
+ serialized_name: subscriptionIds
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscriptionIds
+ setter: setSubscriptionIds
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: subscriptionId
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerShippingAddressRequest:
+ xml_root_name: getCustomerShippingAddressRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerAddressId
+ setter: setCustomerAddressId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\GetCustomerShippingAddressResponse:
+ xml_root_name: getCustomerShippingAddressResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ defaultShippingAddress:
+ expose: true
+ access_type: public_method
+ serialized_name: defaultShippingAddress
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDefaultShippingAddress
+ setter: setDefaultShippingAddress
+ type: boolean
+ address:
+ expose: true
+ access_type: public_method
+ serialized_name: address
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAddress
+ setter: setAddress
+ type: net\authorize\api\contract\v1\CustomerAddressExType
+ subscriptionIds:
+ expose: true
+ access_type: public_method
+ serialized_name: subscriptionIds
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscriptionIds
+ setter: setSubscriptionIds
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: subscriptionId
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\GetHostedPaymentPageRequest:
+ xml_root_name: getHostedPaymentPageRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transactionRequest:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionRequest
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionRequest
+ setter: setTransactionRequest
+ type: net\authorize\api\contract\v1\TransactionRequestType
+ hostedPaymentSettings:
+ expose: true
+ access_type: public_method
+ serialized_name: hostedPaymentSettings
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getHostedPaymentSettings
+ setter: setHostedPaymentSettings
+ type: array<net\authorize\api\contract\v1\SettingType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: setting
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\GetHostedPaymentPageResponse:
+ xml_root_name: getHostedPaymentPageResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ token:
+ expose: true
+ access_type: public_method
+ serialized_name: token
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getToken
+ setter: setToken
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\GetHostedProfilePageRequest:
+ xml_root_name: getHostedProfilePageRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ hostedProfileSettings:
+ expose: true
+ access_type: public_method
+ serialized_name: hostedProfileSettings
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getHostedProfileSettings
+ setter: setHostedProfileSettings
+ type: array<net\authorize\api\contract\v1\SettingType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: setting
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\GetHostedProfilePageResponse:
+ xml_root_name: getHostedProfilePageResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ token:
+ expose: true
+ access_type: public_method
+ serialized_name: token
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getToken
+ setter: setToken
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\GetMerchantDetailsRequest:
+ xml_root_name: getMerchantDetailsRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\GetMerchantDetailsResponse:
+ xml_root_name: getMerchantDetailsResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ isTestMode:
+ expose: true
+ access_type: public_method
+ serialized_name: isTestMode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getIsTestMode
+ setter: setIsTestMode
+ type: boolean
+ processors:
+ expose: true
+ access_type: public_method
+ serialized_name: processors
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProcessors
+ setter: setProcessors
+ type: array<net\authorize\api\contract\v1\ProcessorType>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: processor
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ merchantName:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantName
+ setter: setMerchantName
+ type: string
+ gatewayId:
+ expose: true
+ access_type: public_method
+ serialized_name: gatewayId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getGatewayId
+ setter: setGatewayId
+ type: string
+ marketTypes:
+ expose: true
+ access_type: public_method
+ serialized_name: marketTypes
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMarketTypes
+ setter: setMarketTypes
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: marketType
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ productCodes:
+ expose: true
+ access_type: public_method
+ serialized_name: productCodes
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProductCodes
+ setter: setProductCodes
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: productCode
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ paymentMethods:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentMethods
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentMethods
+ setter: setPaymentMethods
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: paymentMethod
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ currencies:
+ expose: true
+ access_type: public_method
+ serialized_name: currencies
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCurrencies
+ setter: setCurrencies
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: currency
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ publicClientKey:
+ expose: true
+ access_type: public_method
+ serialized_name: publicClientKey
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPublicClientKey
+ setter: setPublicClientKey
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\GetSettledBatchListRequest:
+ xml_root_name: getSettledBatchListRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ includeStatistics:
+ expose: true
+ access_type: public_method
+ serialized_name: includeStatistics
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getIncludeStatistics
+ setter: setIncludeStatistics
+ type: boolean
+ firstSettlementDate:
+ expose: true
+ access_type: public_method
+ serialized_name: firstSettlementDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFirstSettlementDate
+ setter: setFirstSettlementDate
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ lastSettlementDate:
+ expose: true
+ access_type: public_method
+ serialized_name: lastSettlementDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLastSettlementDate
+ setter: setLastSettlementDate
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
--- /dev/null
+net\authorize\api\contract\v1\GetSettledBatchListResponse:
+ xml_root_name: getSettledBatchListResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ batchList:
+ expose: true
+ access_type: public_method
+ serialized_name: batchList
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBatchList
+ setter: setBatchList
+ type: array<net\authorize\api\contract\v1\BatchDetailsType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: batch
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\GetTransactionDetailsRequest:
+ xml_root_name: getTransactionDetailsRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\GetTransactionDetailsResponse:
+ xml_root_name: getTransactionDetailsResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transaction:
+ expose: true
+ access_type: public_method
+ serialized_name: transaction
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransaction
+ setter: setTransaction
+ type: net\authorize\api\contract\v1\TransactionDetailsType
+ clientId:
+ expose: true
+ access_type: public_method
+ serialized_name: clientId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getClientId
+ setter: setClientId
+ type: string
+ transrefId:
+ expose: true
+ access_type: public_method
+ serialized_name: transrefId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransrefId
+ setter: setTransrefId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\GetTransactionListForCustomerRequest:
+ xml_root_name: getTransactionListForCustomerRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ sorting:
+ expose: true
+ access_type: public_method
+ serialized_name: sorting
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSorting
+ setter: setSorting
+ type: net\authorize\api\contract\v1\TransactionListSortingType
+ paging:
+ expose: true
+ access_type: public_method
+ serialized_name: paging
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaging
+ setter: setPaging
+ type: net\authorize\api\contract\v1\PagingType
--- /dev/null
+net\authorize\api\contract\v1\GetTransactionListRequest:
+ xml_root_name: getTransactionListRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ batchId:
+ expose: true
+ access_type: public_method
+ serialized_name: batchId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBatchId
+ setter: setBatchId
+ type: string
+ sorting:
+ expose: true
+ access_type: public_method
+ serialized_name: sorting
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSorting
+ setter: setSorting
+ type: net\authorize\api\contract\v1\TransactionListSortingType
+ paging:
+ expose: true
+ access_type: public_method
+ serialized_name: paging
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaging
+ setter: setPaging
+ type: net\authorize\api\contract\v1\PagingType
--- /dev/null
+net\authorize\api\contract\v1\GetTransactionListResponse:
+ xml_root_name: getTransactionListResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transactions:
+ expose: true
+ access_type: public_method
+ serialized_name: transactions
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactions
+ setter: setTransactions
+ type: array<net\authorize\api\contract\v1\TransactionSummaryType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: transaction
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ totalNumInResultSet:
+ expose: true
+ access_type: public_method
+ serialized_name: totalNumInResultSet
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTotalNumInResultSet
+ setter: setTotalNumInResultSet
+ type: integer
--- /dev/null
+net\authorize\api\contract\v1\GetUnsettledTransactionListRequest:
+ xml_root_name: getUnsettledTransactionListRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ status:
+ expose: true
+ access_type: public_method
+ serialized_name: status
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getStatus
+ setter: setStatus
+ type: string
+ sorting:
+ expose: true
+ access_type: public_method
+ serialized_name: sorting
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSorting
+ setter: setSorting
+ type: net\authorize\api\contract\v1\TransactionListSortingType
+ paging:
+ expose: true
+ access_type: public_method
+ serialized_name: paging
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaging
+ setter: setPaging
+ type: net\authorize\api\contract\v1\PagingType
--- /dev/null
+net\authorize\api\contract\v1\GetUnsettledTransactionListResponse:
+ xml_root_name: getUnsettledTransactionListResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transactions:
+ expose: true
+ access_type: public_method
+ serialized_name: transactions
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactions
+ setter: setTransactions
+ type: array<net\authorize\api\contract\v1\TransactionSummaryType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: transaction
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ totalNumInResultSet:
+ expose: true
+ access_type: public_method
+ serialized_name: totalNumInResultSet
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTotalNumInResultSet
+ setter: setTotalNumInResultSet
+ type: integer
--- /dev/null
+net\authorize\api\contract\v1\HeldTransactionRequestType:
+ properties:
+ action:
+ expose: true
+ access_type: public_method
+ serialized_name: action
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAction
+ setter: setAction
+ type: string
+ refTransId:
+ expose: true
+ access_type: public_method
+ serialized_name: refTransId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefTransId
+ setter: setRefTransId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ImpersonationAuthenticationType:
+ properties:
+ partnerLoginId:
+ expose: true
+ access_type: public_method
+ serialized_name: partnerLoginId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPartnerLoginId
+ setter: setPartnerLoginId
+ type: string
+ partnerTransactionKey:
+ expose: true
+ access_type: public_method
+ serialized_name: partnerTransactionKey
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPartnerTransactionKey
+ setter: setPartnerTransactionKey
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\IsAliveRequest:
+ xml_root_name: isAliveRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ refId:
+ expose: true
+ access_type: public_method
+ serialized_name: refId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefId
+ setter: setRefId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\IsAliveResponse:
+ xml_root_name: isAliveResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\KeyBlockType:
+ properties:
+ value:
+ expose: true
+ access_type: public_method
+ serialized_name: Value
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValue
+ setter: setValue
+ type: net\authorize\api\contract\v1\KeyValueType
--- /dev/null
+net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\DeviceInfoAType:
+ properties:
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: Description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\EncryptedDataAType:
+ properties:
+ value:
+ expose: true
+ access_type: public_method
+ serialized_name: Value
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValue
+ setter: setValue
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\ModeAType:
+ properties:
+ pIN:
+ expose: true
+ access_type: public_method
+ serialized_name: PIN
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPIN
+ setter: setPIN
+ type: string
+ data:
+ expose: true
+ access_type: public_method
+ serialized_name: Data
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getData
+ setter: setData
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType:
+ properties:
+ operation:
+ expose: true
+ access_type: public_method
+ serialized_name: Operation
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOperation
+ setter: setOperation
+ type: string
+ mode:
+ expose: true
+ access_type: public_method
+ serialized_name: Mode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMode
+ setter: setMode
+ type: net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\ModeAType
+ deviceInfo:
+ expose: true
+ access_type: public_method
+ serialized_name: DeviceInfo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDeviceInfo
+ setter: setDeviceInfo
+ type: net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\DeviceInfoAType
+ encryptedData:
+ expose: true
+ access_type: public_method
+ serialized_name: EncryptedData
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEncryptedData
+ setter: setEncryptedData
+ type: net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType\EncryptedDataAType
--- /dev/null
+net\authorize\api\contract\v1\KeyManagementSchemeType:
+ properties:
+ dUKPT:
+ expose: true
+ access_type: public_method
+ serialized_name: DUKPT
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDUKPT
+ setter: setDUKPT
+ type: net\authorize\api\contract\v1\KeyManagementSchemeType\DUKPTAType
--- /dev/null
+net\authorize\api\contract\v1\KeyValueType:
+ properties:
+ encoding:
+ expose: true
+ access_type: public_method
+ serialized_name: Encoding
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEncoding
+ setter: setEncoding
+ type: string
+ encryptionAlgorithm:
+ expose: true
+ access_type: public_method
+ serialized_name: EncryptionAlgorithm
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEncryptionAlgorithm
+ setter: setEncryptionAlgorithm
+ type: string
+ scheme:
+ expose: true
+ access_type: public_method
+ serialized_name: Scheme
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getScheme
+ setter: setScheme
+ type: net\authorize\api\contract\v1\KeyManagementSchemeType
--- /dev/null
+net\authorize\api\contract\v1\LineItemType:
+ properties:
+ itemId:
+ expose: true
+ access_type: public_method
+ serialized_name: itemId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getItemId
+ setter: setItemId
+ type: string
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
+ quantity:
+ expose: true
+ access_type: public_method
+ serialized_name: quantity
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getQuantity
+ setter: setQuantity
+ type: float
+ unitPrice:
+ expose: true
+ access_type: public_method
+ serialized_name: unitPrice
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUnitPrice
+ setter: setUnitPrice
+ type: float
+ taxable:
+ expose: true
+ access_type: public_method
+ serialized_name: taxable
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTaxable
+ setter: setTaxable
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\ListOfAUDetailsType:
+ properties:
+ auUpdate:
+ expose: true
+ access_type: public_method
+ serialized_name: auUpdate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuUpdate
+ setter: setAuUpdate
+ xml_list:
+ inline: true
+ entry_name: auUpdate
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\AuUpdateType>
+ auDelete:
+ expose: true
+ access_type: public_method
+ serialized_name: auDelete
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuDelete
+ setter: setAuDelete
+ xml_list:
+ inline: true
+ entry_name: auDelete
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\AuDeleteType>
--- /dev/null
+net\authorize\api\contract\v1\LogoutRequest:
+ xml_root_name: logoutRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\LogoutResponse:
+ xml_root_name: logoutResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\MerchantAuthenticationType:
+ properties:
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ transactionKey:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionKey
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionKey
+ setter: setTransactionKey
+ type: string
+ sessionToken:
+ expose: true
+ access_type: public_method
+ serialized_name: sessionToken
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSessionToken
+ setter: setSessionToken
+ type: string
+ password:
+ expose: true
+ access_type: public_method
+ serialized_name: password
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPassword
+ setter: setPassword
+ type: string
+ impersonationAuthentication:
+ expose: true
+ access_type: public_method
+ serialized_name: impersonationAuthentication
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getImpersonationAuthentication
+ setter: setImpersonationAuthentication
+ type: net\authorize\api\contract\v1\ImpersonationAuthenticationType
+ fingerPrint:
+ expose: true
+ access_type: public_method
+ serialized_name: fingerPrint
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFingerPrint
+ setter: setFingerPrint
+ type: net\authorize\api\contract\v1\FingerPrintType
+ clientKey:
+ expose: true
+ access_type: public_method
+ serialized_name: clientKey
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getClientKey
+ setter: setClientKey
+ type: string
+ accessToken:
+ expose: true
+ access_type: public_method
+ serialized_name: accessToken
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccessToken
+ setter: setAccessToken
+ type: string
+ mobileDeviceId:
+ expose: true
+ access_type: public_method
+ serialized_name: mobileDeviceId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMobileDeviceId
+ setter: setMobileDeviceId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\MerchantContactType:
+ properties:
+ merchantName:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantName
+ setter: setMerchantName
+ type: string
+ merchantAddress:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantAddress
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantAddress
+ setter: setMerchantAddress
+ type: string
+ merchantCity:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantCity
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantCity
+ setter: setMerchantCity
+ type: string
+ merchantState:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantState
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantState
+ setter: setMerchantState
+ type: string
+ merchantZip:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantZip
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantZip
+ setter: setMerchantZip
+ type: string
+ merchantPhone:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantPhone
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantPhone
+ setter: setMerchantPhone
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\MessagesType\MessageAType:
+ properties:
+ code:
+ expose: true
+ access_type: public_method
+ serialized_name: code
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCode
+ setter: setCode
+ type: string
+ text:
+ expose: true
+ access_type: public_method
+ serialized_name: text
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getText
+ setter: setText
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\MessagesType:
+ properties:
+ resultCode:
+ expose: true
+ access_type: public_method
+ serialized_name: resultCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getResultCode
+ setter: setResultCode
+ type: string
+ message:
+ expose: true
+ access_type: public_method
+ serialized_name: message
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMessage
+ setter: setMessage
+ xml_list:
+ inline: true
+ entry_name: message
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\MessagesType\MessageAType>
--- /dev/null
+net\authorize\api\contract\v1\MobileDeviceLoginRequest:
+ xml_root_name: mobileDeviceLoginRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\MobileDeviceLoginResponse:
+ xml_root_name: mobileDeviceLoginResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ merchantContact:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantContact
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantContact
+ setter: setMerchantContact
+ type: net\authorize\api\contract\v1\MerchantContactType
+ userPermissions:
+ expose: true
+ access_type: public_method
+ serialized_name: userPermissions
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUserPermissions
+ setter: setUserPermissions
+ type: array<net\authorize\api\contract\v1\PermissionType>
+ xml_list:
+ inline: false
+ skip_when_empty: false
+ entry_name: permission
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ merchantAccount:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantAccount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantAccount
+ setter: setMerchantAccount
+ type: net\authorize\api\contract\v1\TransRetailInfoType
--- /dev/null
+net\authorize\api\contract\v1\MobileDeviceRegistrationRequest:
+ xml_root_name: mobileDeviceRegistrationRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ mobileDevice:
+ expose: true
+ access_type: public_method
+ serialized_name: mobileDevice
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMobileDevice
+ setter: setMobileDevice
+ type: net\authorize\api\contract\v1\MobileDeviceType
--- /dev/null
+net\authorize\api\contract\v1\MobileDeviceRegistrationResponse:
+ xml_root_name: mobileDeviceRegistrationResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\MobileDeviceType:
+ properties:
+ mobileDeviceId:
+ expose: true
+ access_type: public_method
+ serialized_name: mobileDeviceId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMobileDeviceId
+ setter: setMobileDeviceId
+ type: string
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
+ phoneNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: phoneNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPhoneNumber
+ setter: setPhoneNumber
+ type: string
+ devicePlatform:
+ expose: true
+ access_type: public_method
+ serialized_name: devicePlatform
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDevicePlatform
+ setter: setDevicePlatform
+ type: string
+ deviceActivation:
+ expose: true
+ access_type: public_method
+ serialized_name: deviceActivation
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDeviceActivation
+ setter: setDeviceActivation
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\NameAndAddressType:
+ properties:
+ firstName:
+ expose: true
+ access_type: public_method
+ serialized_name: firstName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFirstName
+ setter: setFirstName
+ type: string
+ lastName:
+ expose: true
+ access_type: public_method
+ serialized_name: lastName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLastName
+ setter: setLastName
+ type: string
+ company:
+ expose: true
+ access_type: public_method
+ serialized_name: company
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCompany
+ setter: setCompany
+ type: string
+ address:
+ expose: true
+ access_type: public_method
+ serialized_name: address
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAddress
+ setter: setAddress
+ type: string
+ city:
+ expose: true
+ access_type: public_method
+ serialized_name: city
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCity
+ setter: setCity
+ type: string
+ state:
+ expose: true
+ access_type: public_method
+ serialized_name: state
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getState
+ setter: setState
+ type: string
+ zip:
+ expose: true
+ access_type: public_method
+ serialized_name: zip
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getZip
+ setter: setZip
+ type: string
+ country:
+ expose: true
+ access_type: public_method
+ serialized_name: country
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCountry
+ setter: setCountry
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\OpaqueDataType:
+ properties:
+ dataDescriptor:
+ expose: true
+ access_type: public_method
+ serialized_name: dataDescriptor
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDataDescriptor
+ setter: setDataDescriptor
+ type: string
+ dataValue:
+ expose: true
+ access_type: public_method
+ serialized_name: dataValue
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDataValue
+ setter: setDataValue
+ type: string
+ dataKey:
+ expose: true
+ access_type: public_method
+ serialized_name: dataKey
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDataKey
+ setter: setDataKey
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\OrderExType:
+ properties:
+ purchaseOrderNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: purchaseOrderNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPurchaseOrderNumber
+ setter: setPurchaseOrderNumber
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\OrderType:
+ properties:
+ invoiceNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: invoiceNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getInvoiceNumber
+ setter: setInvoiceNumber
+ type: string
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\PagingType:
+ properties:
+ limit:
+ expose: true
+ access_type: public_method
+ serialized_name: limit
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLimit
+ setter: setLimit
+ type: integer
+ offset:
+ expose: true
+ access_type: public_method
+ serialized_name: offset
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOffset
+ setter: setOffset
+ type: integer
--- /dev/null
+net\authorize\api\contract\v1\PayPalType:
+ properties:
+ successUrl:
+ expose: true
+ access_type: public_method
+ serialized_name: successUrl
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSuccessUrl
+ setter: setSuccessUrl
+ type: string
+ cancelUrl:
+ expose: true
+ access_type: public_method
+ serialized_name: cancelUrl
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCancelUrl
+ setter: setCancelUrl
+ type: string
+ paypalLc:
+ expose: true
+ access_type: public_method
+ serialized_name: paypalLc
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaypalLc
+ setter: setPaypalLc
+ type: string
+ paypalHdrImg:
+ expose: true
+ access_type: public_method
+ serialized_name: paypalHdrImg
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaypalHdrImg
+ setter: setPaypalHdrImg
+ type: string
+ paypalPayflowcolor:
+ expose: true
+ access_type: public_method
+ serialized_name: paypalPayflowcolor
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaypalPayflowcolor
+ setter: setPaypalPayflowcolor
+ type: string
+ payerID:
+ expose: true
+ access_type: public_method
+ serialized_name: payerID
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayerID
+ setter: setPayerID
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\PaymentDetailsType:
+ properties:
+ currency:
+ expose: true
+ access_type: public_method
+ serialized_name: currency
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCurrency
+ setter: setCurrency
+ type: string
+ promoCode:
+ expose: true
+ access_type: public_method
+ serialized_name: promoCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPromoCode
+ setter: setPromoCode
+ type: string
+ misc:
+ expose: true
+ access_type: public_method
+ serialized_name: misc
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMisc
+ setter: setMisc
+ type: string
+ giftWrap:
+ expose: true
+ access_type: public_method
+ serialized_name: giftWrap
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getGiftWrap
+ setter: setGiftWrap
+ type: string
+ discount:
+ expose: true
+ access_type: public_method
+ serialized_name: discount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDiscount
+ setter: setDiscount
+ type: string
+ tax:
+ expose: true
+ access_type: public_method
+ serialized_name: tax
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTax
+ setter: setTax
+ type: string
+ shippingHandling:
+ expose: true
+ access_type: public_method
+ serialized_name: shippingHandling
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShippingHandling
+ setter: setShippingHandling
+ type: string
+ subTotal:
+ expose: true
+ access_type: public_method
+ serialized_name: subTotal
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubTotal
+ setter: setSubTotal
+ type: string
+ orderID:
+ expose: true
+ access_type: public_method
+ serialized_name: orderID
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrderID
+ setter: setOrderID
+ type: string
+ amount:
+ expose: true
+ access_type: public_method
+ serialized_name: amount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAmount
+ setter: setAmount
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\PaymentEmvType:
+ properties:
+ emvData:
+ expose: true
+ access_type: public_method
+ serialized_name: emvData
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmvData
+ setter: setEmvData
+ type: W3\XMLSchema\2001\AnyType
+ emvDescriptor:
+ expose: true
+ access_type: public_method
+ serialized_name: emvDescriptor
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmvDescriptor
+ setter: setEmvDescriptor
+ type: W3\XMLSchema\2001\AnyType
+ emvVersion:
+ expose: true
+ access_type: public_method
+ serialized_name: emvVersion
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmvVersion
+ setter: setEmvVersion
+ type: W3\XMLSchema\2001\AnyType
--- /dev/null
+net\authorize\api\contract\v1\PaymentMaskedType:
+ properties:
+ creditCard:
+ expose: true
+ access_type: public_method
+ serialized_name: creditCard
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCreditCard
+ setter: setCreditCard
+ type: net\authorize\api\contract\v1\CreditCardMaskedType
+ bankAccount:
+ expose: true
+ access_type: public_method
+ serialized_name: bankAccount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBankAccount
+ setter: setBankAccount
+ type: net\authorize\api\contract\v1\BankAccountMaskedType
+ tokenInformation:
+ expose: true
+ access_type: public_method
+ serialized_name: tokenInformation
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTokenInformation
+ setter: setTokenInformation
+ type: net\authorize\api\contract\v1\TokenMaskedType
--- /dev/null
+net\authorize\api\contract\v1\PaymentProfileType:
+ properties:
+ paymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentProfileId
+ setter: setPaymentProfileId
+ type: string
+ cardCode:
+ expose: true
+ access_type: public_method
+ serialized_name: cardCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardCode
+ setter: setCardCode
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\PaymentScheduleType\IntervalAType:
+ properties:
+ length:
+ expose: true
+ access_type: public_method
+ serialized_name: length
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLength
+ setter: setLength
+ type: integer
+ unit:
+ expose: true
+ access_type: public_method
+ serialized_name: unit
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUnit
+ setter: setUnit
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\PaymentScheduleType:
+ properties:
+ interval:
+ expose: true
+ access_type: public_method
+ serialized_name: interval
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getInterval
+ setter: setInterval
+ type: net\authorize\api\contract\v1\PaymentScheduleType\IntervalAType
+ startDate:
+ expose: true
+ access_type: public_method
+ serialized_name: startDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getStartDate
+ setter: setStartDate
+ type: 'DateTime<''Y-m-d''>'
+ totalOccurrences:
+ expose: true
+ access_type: public_method
+ serialized_name: totalOccurrences
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTotalOccurrences
+ setter: setTotalOccurrences
+ type: integer
+ trialOccurrences:
+ expose: true
+ access_type: public_method
+ serialized_name: trialOccurrences
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTrialOccurrences
+ setter: setTrialOccurrences
+ type: integer
--- /dev/null
+net\authorize\api\contract\v1\PaymentSimpleType:
+ properties:
+ creditCard:
+ expose: true
+ access_type: public_method
+ serialized_name: creditCard
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCreditCard
+ setter: setCreditCard
+ type: net\authorize\api\contract\v1\CreditCardSimpleType
+ bankAccount:
+ expose: true
+ access_type: public_method
+ serialized_name: bankAccount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBankAccount
+ setter: setBankAccount
+ type: net\authorize\api\contract\v1\BankAccountType
--- /dev/null
+net\authorize\api\contract\v1\PaymentType:
+ properties:
+ creditCard:
+ expose: true
+ access_type: public_method
+ serialized_name: creditCard
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCreditCard
+ setter: setCreditCard
+ type: net\authorize\api\contract\v1\CreditCardType
+ bankAccount:
+ expose: true
+ access_type: public_method
+ serialized_name: bankAccount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBankAccount
+ setter: setBankAccount
+ type: net\authorize\api\contract\v1\BankAccountType
+ trackData:
+ expose: true
+ access_type: public_method
+ serialized_name: trackData
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTrackData
+ setter: setTrackData
+ type: net\authorize\api\contract\v1\CreditCardTrackType
+ encryptedTrackData:
+ expose: true
+ access_type: public_method
+ serialized_name: encryptedTrackData
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEncryptedTrackData
+ setter: setEncryptedTrackData
+ type: net\authorize\api\contract\v1\EncryptedTrackDataType
+ payPal:
+ expose: true
+ access_type: public_method
+ serialized_name: payPal
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayPal
+ setter: setPayPal
+ type: net\authorize\api\contract\v1\PayPalType
+ opaqueData:
+ expose: true
+ access_type: public_method
+ serialized_name: opaqueData
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOpaqueData
+ setter: setOpaqueData
+ type: net\authorize\api\contract\v1\OpaqueDataType
+ emv:
+ expose: true
+ access_type: public_method
+ serialized_name: emv
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmv
+ setter: setEmv
+ type: net\authorize\api\contract\v1\PaymentEmvType
--- /dev/null
+net\authorize\api\contract\v1\PermissionType:
+ properties:
+ permissionName:
+ expose: true
+ access_type: public_method
+ serialized_name: permissionName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPermissionName
+ setter: setPermissionName
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ProcessorType:
+ properties:
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ id:
+ expose: true
+ access_type: public_method
+ serialized_name: id
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getId
+ setter: setId
+ type: integer
+ cardTypes:
+ expose: true
+ access_type: public_method
+ serialized_name: cardTypes
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardTypes
+ setter: setCardTypes
+ type: array<string>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: cardType
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\ProfileTransAmountType:
+ properties:
+ amount:
+ expose: true
+ access_type: public_method
+ serialized_name: amount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAmount
+ setter: setAmount
+ type: float
+ tax:
+ expose: true
+ access_type: public_method
+ serialized_name: tax
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTax
+ setter: setTax
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ shipping:
+ expose: true
+ access_type: public_method
+ serialized_name: shipping
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShipping
+ setter: setShipping
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ duty:
+ expose: true
+ access_type: public_method
+ serialized_name: duty
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDuty
+ setter: setDuty
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ lineItems:
+ expose: true
+ access_type: public_method
+ serialized_name: lineItems
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLineItems
+ setter: setLineItems
+ xml_list:
+ inline: true
+ entry_name: lineItems
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\LineItemType>
--- /dev/null
+net\authorize\api\contract\v1\ProfileTransAuthCaptureType:
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\ProfileTransAuthOnlyType:
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\ProfileTransCaptureOnlyType:
+ properties:
+ approvalCode:
+ expose: true
+ access_type: public_method
+ serialized_name: approvalCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getApprovalCode
+ setter: setApprovalCode
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ProfileTransOrderType:
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ customerShippingAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerShippingAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerShippingAddressId
+ setter: setCustomerShippingAddressId
+ type: string
+ order:
+ expose: true
+ access_type: public_method
+ serialized_name: order
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrder
+ setter: setOrder
+ type: net\authorize\api\contract\v1\OrderExType
+ taxExempt:
+ expose: true
+ access_type: public_method
+ serialized_name: taxExempt
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTaxExempt
+ setter: setTaxExempt
+ type: boolean
+ recurringBilling:
+ expose: true
+ access_type: public_method
+ serialized_name: recurringBilling
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRecurringBilling
+ setter: setRecurringBilling
+ type: boolean
+ cardCode:
+ expose: true
+ access_type: public_method
+ serialized_name: cardCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardCode
+ setter: setCardCode
+ type: string
+ splitTenderId:
+ expose: true
+ access_type: public_method
+ serialized_name: splitTenderId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSplitTenderId
+ setter: setSplitTenderId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ProfileTransPriorAuthCaptureType:
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ customerShippingAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerShippingAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerShippingAddressId
+ setter: setCustomerShippingAddressId
+ type: string
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ProfileTransRefundType:
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ customerShippingAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerShippingAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerShippingAddressId
+ setter: setCustomerShippingAddressId
+ type: string
+ creditCardNumberMasked:
+ expose: true
+ access_type: public_method
+ serialized_name: creditCardNumberMasked
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCreditCardNumberMasked
+ setter: setCreditCardNumberMasked
+ type: string
+ bankRoutingNumberMasked:
+ expose: true
+ access_type: public_method
+ serialized_name: bankRoutingNumberMasked
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBankRoutingNumberMasked
+ setter: setBankRoutingNumberMasked
+ type: string
+ bankAccountNumberMasked:
+ expose: true
+ access_type: public_method
+ serialized_name: bankAccountNumberMasked
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBankAccountNumberMasked
+ setter: setBankAccountNumberMasked
+ type: string
+ order:
+ expose: true
+ access_type: public_method
+ serialized_name: order
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrder
+ setter: setOrder
+ type: net\authorize\api\contract\v1\OrderExType
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ProfileTransVoidType:
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ customerShippingAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerShippingAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerShippingAddressId
+ setter: setCustomerShippingAddressId
+ type: string
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ProfileTransactionType:
+ properties:
+ profileTransAuthCapture:
+ expose: true
+ access_type: public_method
+ serialized_name: profileTransAuthCapture
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfileTransAuthCapture
+ setter: setProfileTransAuthCapture
+ type: net\authorize\api\contract\v1\ProfileTransAuthCaptureType
+ profileTransAuthOnly:
+ expose: true
+ access_type: public_method
+ serialized_name: profileTransAuthOnly
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfileTransAuthOnly
+ setter: setProfileTransAuthOnly
+ type: net\authorize\api\contract\v1\ProfileTransAuthOnlyType
+ profileTransPriorAuthCapture:
+ expose: true
+ access_type: public_method
+ serialized_name: profileTransPriorAuthCapture
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfileTransPriorAuthCapture
+ setter: setProfileTransPriorAuthCapture
+ type: net\authorize\api\contract\v1\ProfileTransPriorAuthCaptureType
+ profileTransCaptureOnly:
+ expose: true
+ access_type: public_method
+ serialized_name: profileTransCaptureOnly
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfileTransCaptureOnly
+ setter: setProfileTransCaptureOnly
+ type: net\authorize\api\contract\v1\ProfileTransCaptureOnlyType
+ profileTransRefund:
+ expose: true
+ access_type: public_method
+ serialized_name: profileTransRefund
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfileTransRefund
+ setter: setProfileTransRefund
+ type: net\authorize\api\contract\v1\ProfileTransRefundType
+ profileTransVoid:
+ expose: true
+ access_type: public_method
+ serialized_name: profileTransVoid
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfileTransVoid
+ setter: setProfileTransVoid
+ type: net\authorize\api\contract\v1\ProfileTransVoidType
--- /dev/null
+net\authorize\api\contract\v1\ReturnedItemType:
+ properties:
+ id:
+ expose: true
+ access_type: public_method
+ serialized_name: id
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getId
+ setter: setId
+ type: string
+ dateUTC:
+ expose: true
+ access_type: public_method
+ serialized_name: dateUTC
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDateUTC
+ setter: setDateUTC
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ dateLocal:
+ expose: true
+ access_type: public_method
+ serialized_name: dateLocal
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDateLocal
+ setter: setDateLocal
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ code:
+ expose: true
+ access_type: public_method
+ serialized_name: code
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCode
+ setter: setCode
+ type: string
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\SecurePaymentContainerErrorType:
+ properties:
+ code:
+ expose: true
+ access_type: public_method
+ serialized_name: code
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCode
+ setter: setCode
+ type: string
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\SecurePaymentContainerRequest:
+ xml_root_name: securePaymentContainerRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ data:
+ expose: true
+ access_type: public_method
+ serialized_name: data
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getData
+ setter: setData
+ type: net\authorize\api\contract\v1\WebCheckOutDataType
--- /dev/null
+net\authorize\api\contract\v1\SecurePaymentContainerResponse:
+ xml_root_name: securePaymentContainerResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ opaqueData:
+ expose: true
+ access_type: public_method
+ serialized_name: opaqueData
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOpaqueData
+ setter: setOpaqueData
+ type: net\authorize\api\contract\v1\OpaqueDataType
--- /dev/null
+net\authorize\api\contract\v1\SendCustomerTransactionReceiptRequest:
+ xml_root_name: sendCustomerTransactionReceiptRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
+ customerEmail:
+ expose: true
+ access_type: public_method
+ serialized_name: customerEmail
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerEmail
+ setter: setCustomerEmail
+ type: string
+ emailSettings:
+ expose: true
+ access_type: public_method
+ serialized_name: emailSettings
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmailSettings
+ setter: setEmailSettings
+ type: net\authorize\api\contract\v1\EmailSettingsType
--- /dev/null
+net\authorize\api\contract\v1\SendCustomerTransactionReceiptResponse:
+ xml_root_name: sendCustomerTransactionReceiptResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\SettingType:
+ properties:
+ settingName:
+ expose: true
+ access_type: public_method
+ serialized_name: settingName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSettingName
+ setter: setSettingName
+ type: string
+ settingValue:
+ expose: true
+ access_type: public_method
+ serialized_name: settingValue
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSettingValue
+ setter: setSettingValue
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\SolutionType:
+ properties:
+ id:
+ expose: true
+ access_type: public_method
+ serialized_name: id
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getId
+ setter: setId
+ type: string
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ vendorName:
+ expose: true
+ access_type: public_method
+ serialized_name: vendorName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getVendorName
+ setter: setVendorName
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\SubMerchantType:
+ properties:
+ identifier:
+ expose: true
+ access_type: public_method
+ serialized_name: identifier
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getIdentifier
+ setter: setIdentifier
+ type: string
+ doingBusinessAs:
+ expose: true
+ access_type: public_method
+ serialized_name: doingBusinessAs
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDoingBusinessAs
+ setter: setDoingBusinessAs
+ type: string
+ paymentServiceProviderName:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentServiceProviderName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentServiceProviderName
+ setter: setPaymentServiceProviderName
+ type: string
+ paymentServiceFacilitator:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentServiceFacilitator
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentServiceFacilitator
+ setter: setPaymentServiceFacilitator
+ type: string
+ streetAddress:
+ expose: true
+ access_type: public_method
+ serialized_name: streetAddress
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getStreetAddress
+ setter: setStreetAddress
+ type: string
+ phone:
+ expose: true
+ access_type: public_method
+ serialized_name: phone
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPhone
+ setter: setPhone
+ type: string
+ email:
+ expose: true
+ access_type: public_method
+ serialized_name: email
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmail
+ setter: setEmail
+ type: string
+ postalCode:
+ expose: true
+ access_type: public_method
+ serialized_name: postalCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPostalCode
+ setter: setPostalCode
+ type: string
+ city:
+ expose: true
+ access_type: public_method
+ serialized_name: city
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCity
+ setter: setCity
+ type: string
+ regionCode:
+ expose: true
+ access_type: public_method
+ serialized_name: regionCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRegionCode
+ setter: setRegionCode
+ type: string
+ countryCode:
+ expose: true
+ access_type: public_method
+ serialized_name: countryCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCountryCode
+ setter: setCountryCode
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\SubscriptionCustomerProfileType:
+ properties:
+ paymentProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentProfile
+ setter: setPaymentProfile
+ type: net\authorize\api\contract\v1\CustomerPaymentProfileMaskedType
+ shippingProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: shippingProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShippingProfile
+ setter: setShippingProfile
+ type: net\authorize\api\contract\v1\CustomerAddressExType
--- /dev/null
+net\authorize\api\contract\v1\SubscriptionDetailType:
+ properties:
+ id:
+ expose: true
+ access_type: public_method
+ serialized_name: id
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getId
+ setter: setId
+ type: integer
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ status:
+ expose: true
+ access_type: public_method
+ serialized_name: status
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getStatus
+ setter: setStatus
+ type: string
+ createTimeStampUTC:
+ expose: true
+ access_type: public_method
+ serialized_name: createTimeStampUTC
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCreateTimeStampUTC
+ setter: setCreateTimeStampUTC
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ firstName:
+ expose: true
+ access_type: public_method
+ serialized_name: firstName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFirstName
+ setter: setFirstName
+ type: string
+ lastName:
+ expose: true
+ access_type: public_method
+ serialized_name: lastName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLastName
+ setter: setLastName
+ type: string
+ totalOccurrences:
+ expose: true
+ access_type: public_method
+ serialized_name: totalOccurrences
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTotalOccurrences
+ setter: setTotalOccurrences
+ type: integer
+ pastOccurrences:
+ expose: true
+ access_type: public_method
+ serialized_name: pastOccurrences
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPastOccurrences
+ setter: setPastOccurrences
+ type: integer
+ paymentMethod:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentMethod
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentMethod
+ setter: setPaymentMethod
+ type: string
+ accountNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: accountNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountNumber
+ setter: setAccountNumber
+ type: string
+ invoice:
+ expose: true
+ access_type: public_method
+ serialized_name: invoice
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getInvoice
+ setter: setInvoice
+ type: string
+ amount:
+ expose: true
+ access_type: public_method
+ serialized_name: amount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAmount
+ setter: setAmount
+ type: float
+ currencyCode:
+ expose: true
+ access_type: public_method
+ serialized_name: currencyCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCurrencyCode
+ setter: setCurrencyCode
+ type: string
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: integer
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: integer
+ customerShippingProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerShippingProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerShippingProfileId
+ setter: setCustomerShippingProfileId
+ type: integer
--- /dev/null
+net\authorize\api\contract\v1\SubscriptionPaymentType:
+ properties:
+ id:
+ expose: true
+ access_type: public_method
+ serialized_name: id
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getId
+ setter: setId
+ type: integer
+ payNum:
+ expose: true
+ access_type: public_method
+ serialized_name: payNum
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayNum
+ setter: setPayNum
+ type: integer
--- /dev/null
+net\authorize\api\contract\v1\TokenMaskedType:
+ properties:
+ tokenSource:
+ expose: true
+ access_type: public_method
+ serialized_name: tokenSource
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTokenSource
+ setter: setTokenSource
+ type: string
+ tokenNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: tokenNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTokenNumber
+ setter: setTokenNumber
+ type: string
+ expirationDate:
+ expose: true
+ access_type: public_method
+ serialized_name: expirationDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getExpirationDate
+ setter: setExpirationDate
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\TransRetailInfoType:
+ properties:
+ marketType:
+ expose: true
+ access_type: public_method
+ serialized_name: marketType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMarketType
+ setter: setMarketType
+ type: string
+ deviceType:
+ expose: true
+ access_type: public_method
+ serialized_name: deviceType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDeviceType
+ setter: setDeviceType
+ type: string
+ customerSignature:
+ expose: true
+ access_type: public_method
+ serialized_name: customerSignature
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerSignature
+ setter: setCustomerSignature
+ type: string
+ terminalNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: terminalNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTerminalNumber
+ setter: setTerminalNumber
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType:
+ properties:
+ tagId:
+ expose: true
+ access_type: public_method
+ serialized_name: tagId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTagId
+ setter: setTagId
+ type: string
+ data:
+ expose: true
+ access_type: public_method
+ serialized_name: data
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getData
+ setter: setData
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType:
+ properties:
+ tag:
+ expose: true
+ access_type: public_method
+ serialized_name: tag
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTag
+ setter: setTag
+ xml_list:
+ inline: true
+ entry_name: tag
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType>
--- /dev/null
+net\authorize\api\contract\v1\TransactionDetailsType:
+ properties:
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
+ refTransId:
+ expose: true
+ access_type: public_method
+ serialized_name: refTransId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefTransId
+ setter: setRefTransId
+ type: string
+ splitTenderId:
+ expose: true
+ access_type: public_method
+ serialized_name: splitTenderId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSplitTenderId
+ setter: setSplitTenderId
+ type: string
+ submitTimeUTC:
+ expose: true
+ access_type: public_method
+ serialized_name: submitTimeUTC
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubmitTimeUTC
+ setter: setSubmitTimeUTC
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ submitTimeLocal:
+ expose: true
+ access_type: public_method
+ serialized_name: submitTimeLocal
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubmitTimeLocal
+ setter: setSubmitTimeLocal
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ transactionType:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionType
+ setter: setTransactionType
+ type: string
+ transactionStatus:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionStatus
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionStatus
+ setter: setTransactionStatus
+ type: string
+ responseCode:
+ expose: true
+ access_type: public_method
+ serialized_name: responseCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getResponseCode
+ setter: setResponseCode
+ type: integer
+ responseReasonCode:
+ expose: true
+ access_type: public_method
+ serialized_name: responseReasonCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getResponseReasonCode
+ setter: setResponseReasonCode
+ type: integer
+ subscription:
+ expose: true
+ access_type: public_method
+ serialized_name: subscription
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscription
+ setter: setSubscription
+ type: net\authorize\api\contract\v1\SubscriptionPaymentType
+ responseReasonDescription:
+ expose: true
+ access_type: public_method
+ serialized_name: responseReasonDescription
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getResponseReasonDescription
+ setter: setResponseReasonDescription
+ type: string
+ authCode:
+ expose: true
+ access_type: public_method
+ serialized_name: authCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuthCode
+ setter: setAuthCode
+ type: string
+ aVSResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: AVSResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAVSResponse
+ setter: setAVSResponse
+ type: string
+ cardCodeResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: cardCodeResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardCodeResponse
+ setter: setCardCodeResponse
+ type: string
+ cAVVResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: CAVVResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCAVVResponse
+ setter: setCAVVResponse
+ type: string
+ fDSFilterAction:
+ expose: true
+ access_type: public_method
+ serialized_name: FDSFilterAction
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFDSFilterAction
+ setter: setFDSFilterAction
+ type: string
+ fDSFilters:
+ expose: true
+ access_type: public_method
+ serialized_name: FDSFilters
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFDSFilters
+ setter: setFDSFilters
+ type: array<net\authorize\api\contract\v1\FDSFilterType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: FDSFilter
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ batch:
+ expose: true
+ access_type: public_method
+ serialized_name: batch
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBatch
+ setter: setBatch
+ type: net\authorize\api\contract\v1\BatchDetailsType
+ order:
+ expose: true
+ access_type: public_method
+ serialized_name: order
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrder
+ setter: setOrder
+ type: net\authorize\api\contract\v1\OrderExType
+ requestedAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: requestedAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRequestedAmount
+ setter: setRequestedAmount
+ type: float
+ authAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: authAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuthAmount
+ setter: setAuthAmount
+ type: float
+ settleAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: settleAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSettleAmount
+ setter: setSettleAmount
+ type: float
+ tax:
+ expose: true
+ access_type: public_method
+ serialized_name: tax
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTax
+ setter: setTax
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ shipping:
+ expose: true
+ access_type: public_method
+ serialized_name: shipping
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShipping
+ setter: setShipping
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ duty:
+ expose: true
+ access_type: public_method
+ serialized_name: duty
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDuty
+ setter: setDuty
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ lineItems:
+ expose: true
+ access_type: public_method
+ serialized_name: lineItems
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLineItems
+ setter: setLineItems
+ type: array<net\authorize\api\contract\v1\LineItemType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: lineItem
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ prepaidBalanceRemaining:
+ expose: true
+ access_type: public_method
+ serialized_name: prepaidBalanceRemaining
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPrepaidBalanceRemaining
+ setter: setPrepaidBalanceRemaining
+ type: float
+ taxExempt:
+ expose: true
+ access_type: public_method
+ serialized_name: taxExempt
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTaxExempt
+ setter: setTaxExempt
+ type: boolean
+ payment:
+ expose: true
+ access_type: public_method
+ serialized_name: payment
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayment
+ setter: setPayment
+ type: net\authorize\api\contract\v1\PaymentMaskedType
+ customer:
+ expose: true
+ access_type: public_method
+ serialized_name: customer
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomer
+ setter: setCustomer
+ type: net\authorize\api\contract\v1\CustomerDataType
+ billTo:
+ expose: true
+ access_type: public_method
+ serialized_name: billTo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBillTo
+ setter: setBillTo
+ type: net\authorize\api\contract\v1\CustomerAddressType
+ shipTo:
+ expose: true
+ access_type: public_method
+ serialized_name: shipTo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShipTo
+ setter: setShipTo
+ type: net\authorize\api\contract\v1\NameAndAddressType
+ recurringBilling:
+ expose: true
+ access_type: public_method
+ serialized_name: recurringBilling
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRecurringBilling
+ setter: setRecurringBilling
+ type: boolean
+ customerIP:
+ expose: true
+ access_type: public_method
+ serialized_name: customerIP
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerIP
+ setter: setCustomerIP
+ type: string
+ product:
+ expose: true
+ access_type: public_method
+ serialized_name: product
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProduct
+ setter: setProduct
+ type: string
+ entryMode:
+ expose: true
+ access_type: public_method
+ serialized_name: entryMode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEntryMode
+ setter: setEntryMode
+ type: string
+ marketType:
+ expose: true
+ access_type: public_method
+ serialized_name: marketType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMarketType
+ setter: setMarketType
+ type: string
+ mobileDeviceId:
+ expose: true
+ access_type: public_method
+ serialized_name: mobileDeviceId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMobileDeviceId
+ setter: setMobileDeviceId
+ type: string
+ customerSignature:
+ expose: true
+ access_type: public_method
+ serialized_name: customerSignature
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerSignature
+ setter: setCustomerSignature
+ type: string
+ returnedItems:
+ expose: true
+ access_type: public_method
+ serialized_name: returnedItems
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getReturnedItems
+ setter: setReturnedItems
+ type: array<net\authorize\api\contract\v1\ReturnedItemType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: returnedItem
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ solution:
+ expose: true
+ access_type: public_method
+ serialized_name: solution
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSolution
+ setter: setSolution
+ type: net\authorize\api\contract\v1\SolutionType
+ emvDetails:
+ expose: true
+ access_type: public_method
+ serialized_name: emvDetails
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmvDetails
+ setter: setEmvDetails
+ type: array<net\authorize\api\contract\v1\TransactionDetailsType\EmvDetailsAType\TagAType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: tag
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfileIdType
+ surcharge:
+ expose: true
+ access_type: public_method
+ serialized_name: surcharge
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSurcharge
+ setter: setSurcharge
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ employeeId:
+ expose: true
+ access_type: public_method
+ serialized_name: employeeId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmployeeId
+ setter: setEmployeeId
+ type: string
+ tip:
+ expose: true
+ access_type: public_method
+ serialized_name: tip
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTip
+ setter: setTip
+ type: net\authorize\api\contract\v1\ExtendedAmountType
--- /dev/null
+net\authorize\api\contract\v1\TransactionListSortingType:
+ properties:
+ orderBy:
+ expose: true
+ access_type: public_method
+ serialized_name: orderBy
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrderBy
+ setter: setOrderBy
+ type: string
+ orderDescending:
+ expose: true
+ access_type: public_method
+ serialized_name: orderDescending
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrderDescending
+ setter: setOrderDescending
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\TransactionRequestType\UserFieldsAType:
+ properties:
+ userField:
+ expose: true
+ access_type: public_method
+ serialized_name: userField
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUserField
+ setter: setUserField
+ xml_list:
+ inline: true
+ entry_name: userField
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\UserFieldType>
--- /dev/null
+net\authorize\api\contract\v1\TransactionRequestType:
+ properties:
+ transactionType:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionType
+ setter: setTransactionType
+ type: string
+ amount:
+ expose: true
+ access_type: public_method
+ serialized_name: amount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAmount
+ setter: setAmount
+ type: float
+ currencyCode:
+ expose: true
+ access_type: public_method
+ serialized_name: currencyCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCurrencyCode
+ setter: setCurrencyCode
+ type: string
+ payment:
+ expose: true
+ access_type: public_method
+ serialized_name: payment
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayment
+ setter: setPayment
+ type: net\authorize\api\contract\v1\PaymentType
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfilePaymentType
+ solution:
+ expose: true
+ access_type: public_method
+ serialized_name: solution
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSolution
+ setter: setSolution
+ type: net\authorize\api\contract\v1\SolutionType
+ callId:
+ expose: true
+ access_type: public_method
+ serialized_name: callId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCallId
+ setter: setCallId
+ type: string
+ terminalNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: terminalNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTerminalNumber
+ setter: setTerminalNumber
+ type: string
+ authCode:
+ expose: true
+ access_type: public_method
+ serialized_name: authCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuthCode
+ setter: setAuthCode
+ type: string
+ refTransId:
+ expose: true
+ access_type: public_method
+ serialized_name: refTransId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefTransId
+ setter: setRefTransId
+ type: string
+ splitTenderId:
+ expose: true
+ access_type: public_method
+ serialized_name: splitTenderId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSplitTenderId
+ setter: setSplitTenderId
+ type: string
+ order:
+ expose: true
+ access_type: public_method
+ serialized_name: order
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getOrder
+ setter: setOrder
+ type: net\authorize\api\contract\v1\OrderType
+ lineItems:
+ expose: true
+ access_type: public_method
+ serialized_name: lineItems
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLineItems
+ setter: setLineItems
+ type: array<net\authorize\api\contract\v1\LineItemType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: lineItem
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ tax:
+ expose: true
+ access_type: public_method
+ serialized_name: tax
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTax
+ setter: setTax
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ duty:
+ expose: true
+ access_type: public_method
+ serialized_name: duty
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDuty
+ setter: setDuty
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ shipping:
+ expose: true
+ access_type: public_method
+ serialized_name: shipping
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShipping
+ setter: setShipping
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ taxExempt:
+ expose: true
+ access_type: public_method
+ serialized_name: taxExempt
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTaxExempt
+ setter: setTaxExempt
+ type: boolean
+ poNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: poNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPoNumber
+ setter: setPoNumber
+ type: string
+ customer:
+ expose: true
+ access_type: public_method
+ serialized_name: customer
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomer
+ setter: setCustomer
+ type: net\authorize\api\contract\v1\CustomerDataType
+ billTo:
+ expose: true
+ access_type: public_method
+ serialized_name: billTo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBillTo
+ setter: setBillTo
+ type: net\authorize\api\contract\v1\CustomerAddressType
+ shipTo:
+ expose: true
+ access_type: public_method
+ serialized_name: shipTo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShipTo
+ setter: setShipTo
+ type: net\authorize\api\contract\v1\NameAndAddressType
+ customerIP:
+ expose: true
+ access_type: public_method
+ serialized_name: customerIP
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerIP
+ setter: setCustomerIP
+ type: string
+ cardholderAuthentication:
+ expose: true
+ access_type: public_method
+ serialized_name: cardholderAuthentication
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardholderAuthentication
+ setter: setCardholderAuthentication
+ type: net\authorize\api\contract\v1\CcAuthenticationType
+ retail:
+ expose: true
+ access_type: public_method
+ serialized_name: retail
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRetail
+ setter: setRetail
+ type: net\authorize\api\contract\v1\TransRetailInfoType
+ employeeId:
+ expose: true
+ access_type: public_method
+ serialized_name: employeeId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmployeeId
+ setter: setEmployeeId
+ type: string
+ transactionSettings:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionSettings
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionSettings
+ setter: setTransactionSettings
+ type: array<net\authorize\api\contract\v1\SettingType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: setting
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ userFields:
+ expose: true
+ access_type: public_method
+ serialized_name: userFields
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUserFields
+ setter: setUserFields
+ type: array<net\authorize\api\contract\v1\UserFieldType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: userField
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ surcharge:
+ expose: true
+ access_type: public_method
+ serialized_name: surcharge
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSurcharge
+ setter: setSurcharge
+ type: net\authorize\api\contract\v1\ExtendedAmountType
+ merchantDescriptor:
+ expose: true
+ access_type: public_method
+ serialized_name: merchantDescriptor
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMerchantDescriptor
+ setter: setMerchantDescriptor
+ type: string
+ subMerchant:
+ expose: true
+ access_type: public_method
+ serialized_name: subMerchant
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubMerchant
+ setter: setSubMerchant
+ type: net\authorize\api\contract\v1\SubMerchantType
+ tip:
+ expose: true
+ access_type: public_method
+ serialized_name: tip
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTip
+ setter: setTip
+ type: net\authorize\api\contract\v1\ExtendedAmountType
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\EmvResponseAType\TagsAType:
+ properties:
+ tag:
+ expose: true
+ access_type: public_method
+ serialized_name: tag
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTag
+ setter: setTag
+ xml_list:
+ inline: true
+ entry_name: tag
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\EmvTagType>
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\EmvResponseAType:
+ properties:
+ tlvData:
+ expose: true
+ access_type: public_method
+ serialized_name: tlvData
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTlvData
+ setter: setTlvData
+ type: string
+ tags:
+ expose: true
+ access_type: public_method
+ serialized_name: tags
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTags
+ setter: setTags
+ type: array<net\authorize\api\contract\v1\EmvTagType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: tag
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType:
+ properties:
+ errorCode:
+ expose: true
+ access_type: public_method
+ serialized_name: errorCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getErrorCode
+ setter: setErrorCode
+ type: string
+ errorText:
+ expose: true
+ access_type: public_method
+ serialized_name: errorText
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getErrorText
+ setter: setErrorText
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType:
+ properties:
+ error:
+ expose: true
+ access_type: public_method
+ serialized_name: error
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getError
+ setter: setError
+ xml_list:
+ inline: true
+ entry_name: error
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType>
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType:
+ properties:
+ code:
+ expose: true
+ access_type: public_method
+ serialized_name: code
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCode
+ setter: setCode
+ type: string
+ description:
+ expose: true
+ access_type: public_method
+ serialized_name: description
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDescription
+ setter: setDescription
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\MessagesAType:
+ properties:
+ message:
+ expose: true
+ access_type: public_method
+ serialized_name: message
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMessage
+ setter: setMessage
+ xml_list:
+ inline: true
+ entry_name: message
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType>
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\PrePaidCardAType:
+ properties:
+ requestedAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: requestedAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRequestedAmount
+ setter: setRequestedAmount
+ type: string
+ approvedAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: approvedAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getApprovedAmount
+ setter: setApprovedAmount
+ type: string
+ balanceOnCard:
+ expose: true
+ access_type: public_method
+ serialized_name: balanceOnCard
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBalanceOnCard
+ setter: setBalanceOnCard
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\SecureAcceptanceAType:
+ properties:
+ secureAcceptanceUrl:
+ expose: true
+ access_type: public_method
+ serialized_name: SecureAcceptanceUrl
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSecureAcceptanceUrl
+ setter: setSecureAcceptanceUrl
+ type: string
+ payerID:
+ expose: true
+ access_type: public_method
+ serialized_name: PayerID
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayerID
+ setter: setPayerID
+ type: string
+ payerEmail:
+ expose: true
+ access_type: public_method
+ serialized_name: PayerEmail
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPayerEmail
+ setter: setPayerEmail
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType:
+ properties:
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
+ responseCode:
+ expose: true
+ access_type: public_method
+ serialized_name: responseCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getResponseCode
+ setter: setResponseCode
+ type: string
+ responseToCustomer:
+ expose: true
+ access_type: public_method
+ serialized_name: responseToCustomer
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getResponseToCustomer
+ setter: setResponseToCustomer
+ type: string
+ authCode:
+ expose: true
+ access_type: public_method
+ serialized_name: authCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuthCode
+ setter: setAuthCode
+ type: string
+ accountNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: accountNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountNumber
+ setter: setAccountNumber
+ type: string
+ accountType:
+ expose: true
+ access_type: public_method
+ serialized_name: accountType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountType
+ setter: setAccountType
+ type: string
+ requestedAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: requestedAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRequestedAmount
+ setter: setRequestedAmount
+ type: string
+ approvedAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: approvedAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getApprovedAmount
+ setter: setApprovedAmount
+ type: string
+ balanceOnCard:
+ expose: true
+ access_type: public_method
+ serialized_name: balanceOnCard
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getBalanceOnCard
+ setter: setBalanceOnCard
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType:
+ properties:
+ splitTenderPayment:
+ expose: true
+ access_type: public_method
+ serialized_name: splitTenderPayment
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSplitTenderPayment
+ setter: setSplitTenderPayment
+ xml_list:
+ inline: true
+ entry_name: splitTenderPayment
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType>
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType\UserFieldsAType:
+ properties:
+ userField:
+ expose: true
+ access_type: public_method
+ serialized_name: userField
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUserField
+ setter: setUserField
+ xml_list:
+ inline: true
+ entry_name: userField
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ type: array<net\authorize\api\contract\v1\UserFieldType>
--- /dev/null
+net\authorize\api\contract\v1\TransactionResponseType:
+ properties:
+ responseCode:
+ expose: true
+ access_type: public_method
+ serialized_name: responseCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getResponseCode
+ setter: setResponseCode
+ type: string
+ rawResponseCode:
+ expose: true
+ access_type: public_method
+ serialized_name: rawResponseCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRawResponseCode
+ setter: setRawResponseCode
+ type: string
+ authCode:
+ expose: true
+ access_type: public_method
+ serialized_name: authCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAuthCode
+ setter: setAuthCode
+ type: string
+ avsResultCode:
+ expose: true
+ access_type: public_method
+ serialized_name: avsResultCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAvsResultCode
+ setter: setAvsResultCode
+ type: string
+ cvvResultCode:
+ expose: true
+ access_type: public_method
+ serialized_name: cvvResultCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCvvResultCode
+ setter: setCvvResultCode
+ type: string
+ cavvResultCode:
+ expose: true
+ access_type: public_method
+ serialized_name: cavvResultCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCavvResultCode
+ setter: setCavvResultCode
+ type: string
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
+ refTransID:
+ expose: true
+ access_type: public_method
+ serialized_name: refTransID
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getRefTransID
+ setter: setRefTransID
+ type: string
+ transHash:
+ expose: true
+ access_type: public_method
+ serialized_name: transHash
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransHash
+ setter: setTransHash
+ type: string
+ testRequest:
+ expose: true
+ access_type: public_method
+ serialized_name: testRequest
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTestRequest
+ setter: setTestRequest
+ type: string
+ accountNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: accountNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountNumber
+ setter: setAccountNumber
+ type: string
+ entryMode:
+ expose: true
+ access_type: public_method
+ serialized_name: entryMode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEntryMode
+ setter: setEntryMode
+ type: string
+ accountType:
+ expose: true
+ access_type: public_method
+ serialized_name: accountType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountType
+ setter: setAccountType
+ type: string
+ splitTenderId:
+ expose: true
+ access_type: public_method
+ serialized_name: splitTenderId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSplitTenderId
+ setter: setSplitTenderId
+ type: string
+ prePaidCard:
+ expose: true
+ access_type: public_method
+ serialized_name: prePaidCard
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPrePaidCard
+ setter: setPrePaidCard
+ type: net\authorize\api\contract\v1\TransactionResponseType\PrePaidCardAType
+ messages:
+ expose: true
+ access_type: public_method
+ serialized_name: messages
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMessages
+ setter: setMessages
+ type: array<net\authorize\api\contract\v1\TransactionResponseType\MessagesAType\MessageAType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: message
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ errors:
+ expose: true
+ access_type: public_method
+ serialized_name: errors
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getErrors
+ setter: setErrors
+ type: array<net\authorize\api\contract\v1\TransactionResponseType\ErrorsAType\ErrorAType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: error
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ splitTenderPayments:
+ expose: true
+ access_type: public_method
+ serialized_name: splitTenderPayments
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSplitTenderPayments
+ setter: setSplitTenderPayments
+ type: array<net\authorize\api\contract\v1\TransactionResponseType\SplitTenderPaymentsAType\SplitTenderPaymentAType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: splitTenderPayment
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ userFields:
+ expose: true
+ access_type: public_method
+ serialized_name: userFields
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getUserFields
+ setter: setUserFields
+ type: array<net\authorize\api\contract\v1\UserFieldType>
+ xml_list:
+ inline: false
+ skip_when_empty: true
+ entry_name: userField
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ shipTo:
+ expose: true
+ access_type: public_method
+ serialized_name: shipTo
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getShipTo
+ setter: setShipTo
+ type: net\authorize\api\contract\v1\NameAndAddressType
+ secureAcceptance:
+ expose: true
+ access_type: public_method
+ serialized_name: secureAcceptance
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSecureAcceptance
+ setter: setSecureAcceptance
+ type: net\authorize\api\contract\v1\TransactionResponseType\SecureAcceptanceAType
+ emvResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: emvResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getEmvResponse
+ setter: setEmvResponse
+ type: net\authorize\api\contract\v1\TransactionResponseType\EmvResponseAType
+ transHashSha2:
+ expose: true
+ access_type: public_method
+ serialized_name: transHashSha2
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransHashSha2
+ setter: setTransHashSha2
+ type: string
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfileIdType
--- /dev/null
+net\authorize\api\contract\v1\TransactionSummaryType:
+ properties:
+ transId:
+ expose: true
+ access_type: public_method
+ serialized_name: transId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransId
+ setter: setTransId
+ type: string
+ submitTimeUTC:
+ expose: true
+ access_type: public_method
+ serialized_name: submitTimeUTC
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubmitTimeUTC
+ setter: setSubmitTimeUTC
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ submitTimeLocal:
+ expose: true
+ access_type: public_method
+ serialized_name: submitTimeLocal
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubmitTimeLocal
+ setter: setSubmitTimeLocal
+ type: GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime
+ transactionStatus:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionStatus
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionStatus
+ setter: setTransactionStatus
+ type: string
+ invoiceNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: invoiceNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getInvoiceNumber
+ setter: setInvoiceNumber
+ type: string
+ firstName:
+ expose: true
+ access_type: public_method
+ serialized_name: firstName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFirstName
+ setter: setFirstName
+ type: string
+ lastName:
+ expose: true
+ access_type: public_method
+ serialized_name: lastName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getLastName
+ setter: setLastName
+ type: string
+ accountType:
+ expose: true
+ access_type: public_method
+ serialized_name: accountType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountType
+ setter: setAccountType
+ type: string
+ accountNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: accountNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAccountNumber
+ setter: setAccountNumber
+ type: string
+ settleAmount:
+ expose: true
+ access_type: public_method
+ serialized_name: settleAmount
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSettleAmount
+ setter: setSettleAmount
+ type: float
+ marketType:
+ expose: true
+ access_type: public_method
+ serialized_name: marketType
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMarketType
+ setter: setMarketType
+ type: string
+ product:
+ expose: true
+ access_type: public_method
+ serialized_name: product
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProduct
+ setter: setProduct
+ type: string
+ mobileDeviceId:
+ expose: true
+ access_type: public_method
+ serialized_name: mobileDeviceId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getMobileDeviceId
+ setter: setMobileDeviceId
+ type: string
+ subscription:
+ expose: true
+ access_type: public_method
+ serialized_name: subscription
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSubscription
+ setter: setSubscription
+ type: net\authorize\api\contract\v1\SubscriptionPaymentType
+ hasReturnedItems:
+ expose: true
+ access_type: public_method
+ serialized_name: hasReturnedItems
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getHasReturnedItems
+ setter: setHasReturnedItems
+ type: boolean
+ fraudInformation:
+ expose: true
+ access_type: public_method
+ serialized_name: fraudInformation
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFraudInformation
+ setter: setFraudInformation
+ type: net\authorize\api\contract\v1\FraudInformationType
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfileIdType
--- /dev/null
+net\authorize\api\contract\v1\UpdateCustomerPaymentProfileRequest:
+ xml_root_name: updateCustomerPaymentProfileRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ paymentProfile:
+ expose: true
+ access_type: public_method
+ serialized_name: paymentProfile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getPaymentProfile
+ setter: setPaymentProfile
+ type: net\authorize\api\contract\v1\CustomerPaymentProfileExType
+ validationMode:
+ expose: true
+ access_type: public_method
+ serialized_name: validationMode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValidationMode
+ setter: setValidationMode
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\UpdateCustomerPaymentProfileResponse:
+ xml_root_name: updateCustomerPaymentProfileResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ validationDirectResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: validationDirectResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValidationDirectResponse
+ setter: setValidationDirectResponse
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\UpdateCustomerProfileRequest:
+ xml_root_name: updateCustomerProfileRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ profile:
+ expose: true
+ access_type: public_method
+ serialized_name: profile
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getProfile
+ setter: setProfile
+ type: net\authorize\api\contract\v1\CustomerProfileExType
--- /dev/null
+net\authorize\api\contract\v1\UpdateCustomerProfileResponse:
+ xml_root_name: updateCustomerProfileResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\UpdateCustomerShippingAddressRequest:
+ xml_root_name: updateCustomerShippingAddressRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ address:
+ expose: true
+ access_type: public_method
+ serialized_name: address
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getAddress
+ setter: setAddress
+ type: net\authorize\api\contract\v1\CustomerAddressExType
+ defaultShippingAddress:
+ expose: true
+ access_type: public_method
+ serialized_name: defaultShippingAddress
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDefaultShippingAddress
+ setter: setDefaultShippingAddress
+ type: boolean
--- /dev/null
+net\authorize\api\contract\v1\UpdateCustomerShippingAddressResponse:
+ xml_root_name: updateCustomerShippingAddressResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\UpdateHeldTransactionRequest:
+ xml_root_name: updateHeldTransactionRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ heldTransactionRequest:
+ expose: true
+ access_type: public_method
+ serialized_name: heldTransactionRequest
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getHeldTransactionRequest
+ setter: setHeldTransactionRequest
+ type: net\authorize\api\contract\v1\HeldTransactionRequestType
--- /dev/null
+net\authorize\api\contract\v1\UpdateHeldTransactionResponse:
+ xml_root_name: updateHeldTransactionResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ transactionResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: transactionResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getTransactionResponse
+ setter: setTransactionResponse
+ type: net\authorize\api\contract\v1\TransactionResponseType
--- /dev/null
+net\authorize\api\contract\v1\UpdateSplitTenderGroupRequest:
+ xml_root_name: updateSplitTenderGroupRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ splitTenderId:
+ expose: true
+ access_type: public_method
+ serialized_name: splitTenderId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSplitTenderId
+ setter: setSplitTenderId
+ type: string
+ splitTenderStatus:
+ expose: true
+ access_type: public_method
+ serialized_name: splitTenderStatus
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getSplitTenderStatus
+ setter: setSplitTenderStatus
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\UpdateSplitTenderGroupResponse:
+ xml_root_name: updateSplitTenderGroupResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties: { }
--- /dev/null
+net\authorize\api\contract\v1\UserFieldType:
+ properties:
+ name:
+ expose: true
+ access_type: public_method
+ serialized_name: name
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getName
+ setter: setName
+ type: string
+ value:
+ expose: true
+ access_type: public_method
+ serialized_name: value
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValue
+ setter: setValue
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ValidateCustomerPaymentProfileRequest:
+ xml_root_name: validateCustomerPaymentProfileRequest
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ customerProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerProfileId
+ setter: setCustomerProfileId
+ type: string
+ customerPaymentProfileId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerPaymentProfileId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerPaymentProfileId
+ setter: setCustomerPaymentProfileId
+ type: string
+ customerShippingAddressId:
+ expose: true
+ access_type: public_method
+ serialized_name: customerShippingAddressId
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCustomerShippingAddressId
+ setter: setCustomerShippingAddressId
+ type: string
+ cardCode:
+ expose: true
+ access_type: public_method
+ serialized_name: cardCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardCode
+ setter: setCardCode
+ type: string
+ validationMode:
+ expose: true
+ access_type: public_method
+ serialized_name: validationMode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getValidationMode
+ setter: setValidationMode
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\ValidateCustomerPaymentProfileResponse:
+ xml_root_name: validateCustomerPaymentProfileResponse
+ xml_root_namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ properties:
+ directResponse:
+ expose: true
+ access_type: public_method
+ serialized_name: directResponse
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getDirectResponse
+ setter: setDirectResponse
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\WebCheckOutDataType\TokenAType:
+ properties:
+ cardNumber:
+ expose: true
+ access_type: public_method
+ serialized_name: cardNumber
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardNumber
+ setter: setCardNumber
+ type: string
+ expirationDate:
+ expose: true
+ access_type: public_method
+ serialized_name: expirationDate
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getExpirationDate
+ setter: setExpirationDate
+ type: string
+ cardCode:
+ expose: true
+ access_type: public_method
+ serialized_name: cardCode
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getCardCode
+ setter: setCardCode
+ type: string
+ zip:
+ expose: true
+ access_type: public_method
+ serialized_name: zip
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getZip
+ setter: setZip
+ type: string
+ fullName:
+ expose: true
+ access_type: public_method
+ serialized_name: fullName
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getFullName
+ setter: setFullName
+ type: string
--- /dev/null
+net\authorize\api\contract\v1\WebCheckOutDataType:
+ properties:
+ type:
+ expose: true
+ access_type: public_method
+ serialized_name: type
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getType
+ setter: setType
+ type: string
+ id:
+ expose: true
+ access_type: public_method
+ serialized_name: id
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getId
+ setter: setId
+ type: string
+ token:
+ expose: true
+ access_type: public_method
+ serialized_name: token
+ xml_element:
+ namespace: AnetApi/xml/v1/schema/AnetApiSchema.xsd
+ accessor:
+ getter: getToken
+ setter: setToken
+ type: net\authorize\api\contract\v1\WebCheckOutDataType\TokenAType
--- /dev/null
+<?php
+namespace net\authorize\util;
+
+use JMS\Serializer\SerializerBuilder;
+
+define("ANET_SENSITIVE_XMLTAGS_JSON_FILE","AuthorizedNetSensitiveTagsConfig.json");
+define("ANET_SENSITIVE_DATE_CONFIG_CLASS",'net\authorize\util\SensitiveDataConfigType');
+
+class ANetSensitiveFields
+{
+ private static $applySensitiveTags = NULL;
+ private static $sensitiveStringRegexes = NULL;
+
+ private static function fetchFromConfigFiles(){
+ if(!class_exists(ANET_SENSITIVE_DATE_CONFIG_CLASS))
+ exit("Class (".ANET_SENSITIVE_DATE_CONFIG_CLASS.") doesn't exist; can't deserialize json; can't log. Exiting.");
+
+ $serializer = SerializerBuilder::create()->build();
+
+ $userConfigFilePath = ANET_SENSITIVE_XMLTAGS_JSON_FILE;
+ $presentUserConfigFile = file_exists($userConfigFilePath);
+
+ $configFilePath = dirname(__FILE__) . "/" . ANET_SENSITIVE_XMLTAGS_JSON_FILE;
+ $useDefaultConfigFile = !$presentUserConfigFile;
+
+ if ($presentUserConfigFile) { //client config for tags
+ //read list of tags (and associated regex-patterns and replacements) from .json file
+ try{
+ $jsonFileData=file_get_contents($userConfigFilePath);
+ $sensitiveDataConfig = $serializer->deserialize($jsonFileData, ANET_SENSITIVE_DATE_CONFIG_CLASS, 'json');
+
+ $sensitiveTags = $sensitiveDataConfig->sensitiveTags;
+ self::$sensitiveStringRegexes = $sensitiveDataConfig->sensitiveStringRegexes;
+ }
+
+ catch(Exception $e){
+ echo "ERROR deserializing json from : " . $userConfigFilePath . "; Exception : " . $e->getMessage();
+ $useDefaultConfigFile = true;
+ }
+ }
+
+ if ($useDefaultConfigFile) { //default sdk config for tags
+ if(!file_exists($configFilePath)){
+ exit("ERROR: No config file: " . $configFilePath);
+ }
+
+ //read list of tags (and associated regex-patterns and replacements) from .json file
+ try{
+ $jsonFileData=file_get_contents($configFilePath);
+ $sensitiveDataConfig = $serializer->deserialize($jsonFileData, ANET_SENSITIVE_DATE_CONFIG_CLASS, 'json');
+
+ $sensitiveTags = $sensitiveDataConfig->sensitiveTags;
+ self::$sensitiveStringRegexes = $sensitiveDataConfig->sensitiveStringRegexes;
+ }
+
+ catch(Exception $e){
+ exit( "ERROR deserializing json from : " . $configFilePath . "; Exception : " . $e->getMessage());
+ }
+ }
+
+ //Check for disableMask flag in case of client json.
+ self::$applySensitiveTags = array();
+ foreach($sensitiveTags as $sensitiveTag){
+ if($sensitiveTag->disableMask){
+ //skip masking continue;
+ }
+ else{
+ array_push(self::$applySensitiveTags,$sensitiveTag);
+ }
+ }
+ }
+
+ public static function getSensitiveStringRegexes(){
+ if(NULL == self::$sensitiveStringRegexes) {
+ self::fetchFromConfigFiles();
+ }
+ return self::$sensitiveStringRegexes;
+ }
+
+ public static function getSensitiveXmlTags(){
+ if(NULL == self::$applySensitiveTags) {
+ self::fetchFromConfigFiles();
+ }
+ return self::$applySensitiveTags;
+ }
+}
--- /dev/null
+{
+ "sensitiveTags": [
+ {
+ "tagName": "cardCode",
+ "pattern": "",
+ "replacement": "",
+ "disableMask": false
+ },
+ {
+ "tagName": "cardNumber",
+ "pattern": "(\\p{N}+)(\\p{N}{4})",
+ "replacement": "xxxx-$2",
+ "disableMask": false
+ },
+ {
+ "tagName": "expirationDate",
+ "pattern": "",
+ "replacement": "",
+ "disableMask": false
+ },
+ {
+ "tagName": "accountNumber",
+ "pattern": "(\\p{N}+)(\\p{N}{4})",
+ "replacement": "xxxx-$2",
+ "disableMask": false
+ },
+ {
+ "tagName": "nameOnAccount",
+ "pattern": "",
+ "replacement": "",
+ "disableMask": false
+ },
+ {
+ "tagName": "transactionKey",
+ "pattern": "",
+ "replacement": "",
+ "disableMask": false
+ }
+ ],
+ "sensitiveStringRegexes": [
+ "4\\p{N}{3}([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
+ "4\\p{N}{3}([\\ \\-]?)(?:\\p{N}{4}\\1){2}\\p{N}(?:\\p{N}{3})?",
+ "5[1-5]\\p{N}{2}([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
+ "6(?:011|22(?:1(?=[\\ \\-]?(?:2[6-9]|[3-9]))|[2-8]|9(?=[\\ \\-]?(?:[01]|2[0-5])))|4[4-9]\\p{N}|5\\p{N}\\p{N})([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
+ "35(?:2[89]|[3-8]\\p{N})([\\ \\-]?)\\p{N}{4}\\1\\p{N}{4}\\1\\p{N}{4}",
+ "3[47]\\p{N}\\p{N}([\\ \\-]?)\\p{N}{6}\\1\\p{N}{5}"
+ ]
+}
+
--- /dev/null
+<?php
+namespace net\authorize\util;
+
+/**
+ * A class defining helpers
+ *
+ * @package AuthorizeNet
+ * @subpackage net\authorize\util
+ */
+class Helpers
+{
+ private static $initialized = false;
+
+ /**
+ * @return string current date-time
+ */
+ public static function now()
+ {
+ //init only once
+ if ( ! self::$initialized)
+ {
+ self::$initialized = true;
+ }
+ return date( DATE_RFC2822);
+ }
+}
--- /dev/null
+<?php
+namespace net\authorize\util;
+
+use net\authorize\util\LogFactory;
+use net\authorize\util\Log;
+
+/**
+ * A class to send a request to the XML API.
+ *
+ * @package AuthorizeNet
+ * @subpackage net\authorize\util
+ */
+class HttpClient
+{
+ private $_Url = "";
+
+ public $VERIFY_PEER = true; // attempt trust validation of SSL certificates when establishing secure connections.
+ private $logger = NULL;
+ /**
+ * Constructor.
+ *
+ */
+ public function __construct()
+ {
+ $this->logger = LogFactory::getLog(get_class($this));
+ }
+
+ /**
+ * Set a log file.
+ *
+ * @param string $endPoint end point to hit from \net\authorize\api\constants\ANetEnvironment
+ */
+ public function setPostUrl( $endPoint = \net\authorize\api\constants\ANetEnvironment::CUSTOM)
+ {
+ $this->_Url = sprintf( "%s/xml/v1/request.api", $endPoint);
+ }
+
+ /**
+ * @return string
+ */
+ public function _getPostUrl()
+ {
+ //return (self::URL);
+ return ($this->_Url);
+ }
+
+ /**
+ * Set a log file.
+ *
+ * @param string $filepath Path to log file.
+ */
+ public function setLogFile($filepath)
+ {
+ $this->logger->setLogFile($filepath);
+ }
+
+ /**
+ * Posts the request to AuthorizeNet endpoint using Curl & returns response.
+ *
+ * @param string $xmlRequest
+ * @return string $xmlResponse The response.
+ */
+ public function _sendRequest($xmlRequest)
+ {
+ $xmlResponse = "";
+
+ $post_url = $this->_getPostUrl();
+ $curl_request = curl_init($post_url);
+ curl_setopt($curl_request, CURLOPT_POSTFIELDS, $xmlRequest);
+ curl_setopt($curl_request, CURLOPT_HEADER, 0);
+ curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
+ curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
+
+ $this->logger->info(sprintf(" Url: %s", $post_url));
+ // Do not log requests that could contain CC info.
+ $this->logger->info(sprintf("Request to AnetApi: \n%s", $xmlRequest));
+
+ if ($this->VERIFY_PEER) {
+ curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)) . '/../../ssl/cert.pem');
+ } else {
+ $this->logger->error("Invalid SSL option for the request");
+ return false;
+ }
+
+ if (preg_match('/xml/',$post_url)) {
+ curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
+// file_put_contents($this->_log_file, "\nSending 'XML' Request type", FILE_APPEND);
+ $this->logger->info("Sending 'XML' Request type");
+ }
+
+ try
+ {
+ $this->logger->info("Sending http request via Curl");
+ $xmlResponse = curl_exec($curl_request);
+ $this->logger->info("Response from AnetApi: $xmlResponse");
+
+ } catch (\Exception $ex)
+ {
+ $errorMessage = sprintf("\n%s:Error making http request via curl: Code:'%s', Message:'%s', Trace:'%s', File:'%s':'%s'",
+ $this->now(), $ex->getCode(), $ex->getMessage(), $ex->getTraceAsString(), $ex->getFile(), $ex->getLine() );
+ $this->logger->error($errorMessage);
+ }
+ if ($this->logger && $this->logger->getLogFile()) {
+ if ($curl_error = curl_error($curl_request)) {
+ $this->logger->error("CURL ERROR: $curl_error");
+ }
+
+ }
+ curl_close($curl_request);
+
+ return $xmlResponse;
+ }
+
+ private function now()
+ {
+ return date( DATE_RFC2822);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\util;
+
+use net\authorize\util\ANetSensitiveFields;
+
+define ("ANET_LOG_FILES_APPEND",true);
+
+define("ANET_LOG_DEBUG_PREFIX","DEBUG");
+define("ANET_LOG_INFO_PREFIX","INFO");
+define("ANET_LOG_WARN_PREFIX","WARN");
+define("ANET_LOG_ERROR_PREFIX","ERROR");
+
+//log levels
+define('ANET_LOG_DEBUG',1);
+define("ANET_LOG_INFO",2);
+define("ANET_LOG_WARN",3);
+define("ANET_LOG_ERROR",4);
+
+//set level
+define("ANET_LOG_LEVEL",ANET_LOG_DEBUG);
+
+/**
+ * A class to implement logging.
+ *
+ * @package AuthorizeNet
+ * @subpackage net\authorize\util
+ */
+
+class Log
+{
+ private $sensitiveXmlTags = NULL;
+ private $logFile = '';
+ private $logLevel = ANET_LOG_LEVEL;
+
+ /**
+ * Takes a regex pattern (string) as argument and adds the forward slash delimiter.
+ * Also adds the u flag to enable Unicode mode regex.
+ *
+ * @param string $regexPattern
+ *
+ * @return string
+ */
+ private function addDelimiterFwdSlash($regexPattern)
+ {
+ return '/'.$regexPattern.'/u';
+ }
+
+ /**
+ * Takes an xml as string and masks the sensitive fields.
+ *
+ * @param string $rawString The xml as a string.
+ *
+ * @return string The xml as a string after masking sensitive fields
+ */
+ private function maskSensitiveXmlString($rawString){
+ $patterns=array();
+ $replacements=array();
+
+ foreach ($this->sensitiveXmlTags as $i => $sensitiveTag){
+ $tag = $sensitiveTag->tagName;
+ $inputPattern = "(.+)"; //no need to mask null data
+ $inputReplacement = "xxxx";
+
+ if(trim($sensitiveTag->pattern)) {
+ $inputPattern = $sensitiveTag->pattern;
+ }
+ $pattern = "<" . $tag . ">(?:.*)". $inputPattern ."(?:.*)<\/" . $tag . ">";
+ $pattern = $this->addDelimiterFwdSlash($pattern);
+
+ if(trim($sensitiveTag->replacement)) {
+ $inputReplacement = $sensitiveTag->replacement;
+ }
+ $replacement = "<" . $tag . ">" . $inputReplacement . "</" . $tag . ">";
+
+ $patterns [$i] = $pattern;
+ $replacements[$i] = $replacement;
+ }
+ $maskedString = preg_replace($patterns, $replacements, $rawString);
+ return $maskedString;
+ }
+
+ /**
+ * Takes a string and masks credit card regex matching parts.
+ *
+ * @param string $rawString The string.
+ *
+ * @return string The string after masking credit card regex matching parts.
+ */
+ private function maskCreditCards($rawString){
+ $patterns=array();
+ $replacements=array();
+
+ foreach ($this->sensitiveStringRegexes as $i => $creditCardRegex){
+ $pattern = $creditCardRegex;
+ $pattern = $this->addDelimiterFwdSlash($pattern);
+
+ $replacement = "xxxx";
+ $patterns [$i] = $pattern;
+ $replacements[$i] = $replacement;
+ }
+ $maskedString = preg_replace($patterns, $replacements, $rawString);
+ return $maskedString;
+ }
+
+ /**
+ * Object data masking related functions START
+ */
+
+ /**
+ * private function getPropertiesInclBase($reflClass).
+ *
+ * Receives a ReflectionObject, ...
+ * iteratively fetches the properties of the object (including from the base classes up the hierarchy), ...
+ * collects them in an array of ReflectionProperty and returns the array.
+ *
+ * @param ReflectionObject $reflClass
+ *
+ * @return \ReflectionProperty[]
+ */
+ private function getPropertiesInclBase($reflClass)
+ {
+ $properties = array();
+ try {
+ do {
+ $curClassPropList = $reflClass->getProperties();
+ foreach ($curClassPropList as $p) {
+ $p->setAccessible(true);
+ }
+ $properties = array_merge($curClassPropList, $properties);
+ } while ($reflClass = $reflClass->getParentClass());
+ } catch (\ReflectionException $e) { }
+ return $properties;
+ }
+
+ /**
+ * private function checkPropertyAndMask($prop, $obj).
+ *
+ * Receives a ReflectionProperty and an object, and returns a masked object if the ReflectionProperty corresponds to a sensitive field, else returns false.
+ *
+ * @param ReflectionProperty $prop
+ * @param object $obj
+ *
+ * @return string|bool
+ */
+ private function checkPropertyAndMask($prop, $obj){
+ foreach($this->sensitiveXmlTags as $i => $sensitiveField)
+ {
+ $inputPattern = "(.+)";
+ $inputReplacement = "xxxx";
+
+ if(trim($sensitiveField->pattern)) {
+ $inputPattern = $sensitiveField->pattern;
+ }
+ $inputPattern = $this->addDelimiterFwdSlash($inputPattern);
+
+ if(trim($sensitiveField->replacement)) {
+ $inputReplacement = $sensitiveField->replacement;
+ }
+
+ if(strcmp($prop->getName(),$sensitiveField->tagName)==0)
+ {
+ $prop->setValue($obj,preg_replace($inputPattern,$inputReplacement,$prop->getValue($obj)));
+ return $prop->getValue($obj);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * called by getMasked() to mask sensitive fields of an object.
+ *
+ * @param object $obj
+ *
+ * @return object
+ */
+ private function maskSensitiveProperties ($obj)
+ {
+ // first retrieve all properties of the passed object
+ $reflectObj = new \ReflectionObject($obj);
+ $props = $this->getPropertiesInclBase($reflectObj);
+
+ // for composite property recursively execute; for scalars, do a check and mask
+ foreach($props as $i => $prop){
+ $propValue=$prop->getValue($obj);
+
+ // for object and arrays, recursively call for inner elements
+ if(is_object($propValue)){
+ $prop->setValue($obj, $this->maskSensitiveProperties($propValue));
+ }
+ else if(is_array($propValue)){
+ $newVals=array();
+ foreach($propValue as $i=>$arrEle)
+ {
+ $newVals[]=$this->maskSensitiveProperties($arrEle);
+ }
+ $prop->setValue($obj, $newVals);
+ }
+ // else check if the property represents a sensitive field. If so, mask.
+ else{
+ $res=$this->checkPropertyAndMask($prop, $obj);
+ if($res)
+ $prop->setValue($obj, $res);
+ }
+ }
+
+ return $obj;
+ }
+
+ /**
+ * Object data masking related functions END
+ */
+
+ /**
+ * private function getMasked($raw).
+ *
+ * called by log()
+ *
+ * @param mixed $raw
+ *
+ * @return string
+ */
+ private function getMasked($raw)
+ { //always returns string
+ $messageType = gettype($raw);
+ $message="";
+ if($messageType == "object"){
+ $obj = unserialize(serialize($raw)); // deep copying the object
+ $message = print_r($this->maskSensitiveProperties($obj), true); //object to string
+ }
+ else if($messageType == "array"){
+ $copyArray = unserialize(serialize($raw));
+ foreach($copyArray as $i => $element){
+ $copyArray[$i] = $this->getMasked($element);
+ }
+ $message = print_r($copyArray, true); // returns string
+ }
+ else { //$messageType == "string")
+ $primtiveTypeAsString = strval($raw);
+
+ $maskedXml = $primtiveTypeAsString;
+ if($messageType == "string") {
+ $maskedXml = $this->maskSensitiveXmlString($primtiveTypeAsString);
+ }
+ //mask credit card numbers
+ $message = $this->maskCreditCards($maskedXml);
+ }
+ return $message;
+ }
+
+ private function log($logLevelPrefix, $logMessage, $flags){
+ if (!$this->logFile) return;
+ //masking
+ $logMessage = $this->getMasked($logMessage);
+
+ //debug_backtrace
+ $fileName = 'n/a';
+ $methodName = 'n/a';
+ $lineNumber = 'n/a';
+ $debugTrace = debug_backtrace();
+ if (isset($debugTrace[1])) {
+ $fileName = $debugTrace[1]['file'] ? $debugTrace[1]['file'] : 'n/a';
+ $lineNumber = $debugTrace[1]['line'] ? $debugTrace[1]['line'] : 'n/a';
+ }
+ if (isset($debugTrace[2])) $methodName = $debugTrace[2]['function'] ? $debugTrace[2]['function'] : 'n/a';
+
+ //Add timestamp, log level, method, file, line
+ $logString = sprintf("\n %s %s : [%s] (%s : %s) - %s", \net\authorize\util\Helpers::now(), $logLevelPrefix,
+ $methodName, $fileName, $lineNumber, $logMessage);
+ file_put_contents($this->logFile, $logString, $flags);
+ }
+
+ public function debug($logMessage, $flags=FILE_APPEND)
+ {
+ if(ANET_LOG_DEBUG >= $this->logLevel){
+ $this->log(ANET_LOG_DEBUG_PREFIX, $logMessage,$flags);
+ }
+ }
+
+ public function info($logMessage, $flags=FILE_APPEND){
+ if(ANET_LOG_INFO >= $this->logLevel) {
+ $this->log(ANET_LOG_INFO_PREFIX, $logMessage,$flags);
+ }
+ }
+
+ public function warn($logMessage, $flags=FILE_APPEND){
+ if(ANET_LOG_WARN >= $this->logLevel) {
+ $this->log(ANET_LOG_WARN_PREFIX, $logMessage,$flags);
+ }
+ }
+
+ public function error($logMessage, $flags=FILE_APPEND){
+ if(ANET_LOG_ERROR >= $this->logLevel) {
+ $this->log(ANET_LOG_ERROR_PREFIX, $logMessage,$flags);
+ }
+ }
+
+ private function logFormat($logLevelPrefix, $format, $objects, $flags){
+ try {
+ foreach($objects as $i => $testObject){
+ $objects[$i] = $this->getMasked($testObject);
+ }
+ $logMessage = vsprintf($format, $objects);
+ $this->log($logLevelPrefix, $logMessage, $flags);
+ }
+ catch(\Exception $e){
+ $this->debug("Incorrect log message format: " . $e->getMessage());
+ }
+ }
+
+ public function debugFormat($format, $args=array(), $flags=FILE_APPEND)
+ {
+ if(ANET_LOG_DEBUG >= $this->logLevel){
+ $this->logFormat(ANET_LOG_DEBUG_PREFIX, $format, $args , $flags);
+ }
+ }
+
+ public function infoFormat($format, $args=array(), $flags=FILE_APPEND){
+ if(ANET_LOG_INFO >= $this->logLevel) {
+ $this->logFormat(ANET_LOG_INFO_PREFIX, $format, $args , $flags);
+ }
+ }
+
+ public function warnFormat($format, $args=array(), $flags=FILE_APPEND){
+ if(ANET_LOG_WARN >= $this->logLevel) {
+ $this->logFormat(ANET_LOG_WARN_PREFIX, $format, $args , $flags);
+ }
+ }
+
+ public function errorFormat($format, $args=array(), $flags=FILE_APPEND){
+ if(ANET_LOG_ERROR >= $this->logLevel) {
+ $this->logFormat(ANET_LOG_ERROR_PREFIX, $format, $args , $flags);
+ }
+ }
+
+ /**
+ * @param string $logLevel
+ * possible values = ANET_LOG_DEBUG, ANET_LOG_INFO, ANET_LOG_WARN, ANET_LOG_ERROR
+ */
+ public function setLogLevel($logLevel){
+ $this->logLevel = $logLevel;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLogLevel(){
+ return $this->logLevel;
+ }
+
+ /**
+ * @param string $logFile
+ */
+ public function setLogFile($logFile){
+ $this->logFile = $logFile;
+ }
+
+ /**
+ * @return string
+ */
+ public function getLogFile(){
+ return $this->logFile;
+ }
+
+ public function __construct(){
+ $this->sensitiveXmlTags = ANetSensitiveFields::getSensitiveXmlTags();
+ $this->sensitiveStringRegexes = ANetSensitiveFields::getSensitiveStringRegexes();
+ }
+}
+?>
--- /dev/null
+<?php
+namespace net\authorize\util;
+
+class LogFactory
+{
+ private static $logger = NULL;
+ public static function getLog($classType){
+ if(NULL == self::$logger){
+ self::$logger = new Log();
+ if(defined('AUTHORIZENET_LOG_FILE')){
+ self::$logger->setLogFile(AUTHORIZENET_LOG_FILE);
+ }
+ }
+ return self::$logger;
+ }
+}
+?>
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\util;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\SerializedName;
+
+$type=new Type;
+$serializedName=new SerializedName(array("value"=>"Loading-SerializedName-Class"));
+//to do: use Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace to auto load classes
+
+class SensitiveDataConfigType
+{
+ /**
+ * @Type("array<net\authorize\util\SensitiveTag>")
+ * @SerializedName("sensitiveTags")
+ */
+ public $sensitiveTags;
+
+ /**
+ * @Type("array<string>")
+ * @SerializedName("sensitiveStringRegexes")
+ */
+ public $sensitiveStringRegexes;
+}
+?>
\ No newline at end of file
--- /dev/null
+<?php
+namespace net\authorize\util;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\SerializedName;
+
+$type=new Type;
+$serializedName=new SerializedName(array("value"=>"Loading-SerializedName-Class"));
+//to do: use Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace to auto load classes
+
+class SensitiveTag
+{
+ /**
+ * @Type("string")
+ * @SerializedName("tagName")
+ */
+ public $tagName;
+
+ /**
+ * @Type("string")
+ * @SerializedName("pattern")
+ */
+ public $pattern;
+
+ /**
+ * @Type("string")
+ * @SerializedName("replacement")
+ */
+ public $replacement;
+
+ /**
+ * @Type("boolean")
+ * @SerializedName("disableMask")
+ */
+ public $disableMask;
+
+ public function __construct($tagName, $pattern="", $replace="",$disableMask = false){
+ $this->tagName = $tagName;
+ $this->pattern=$pattern;
+ $this->replacement = $replace;
+ $this->disableMask = $disableMask;
+ }
+}
+?>
\ No newline at end of file
--- /dev/null
+<?php
+/**
+ * AuthorizeNetException.php
+ *
+ * @package AuthorizeNet
+ */
+
+/**
+ * Exception class for AuthorizeNet PHP SDK.
+ *
+ * @package AuthorizeNet
+ */
+class AuthorizeNetException extends Exception
+{
+}
--- /dev/null
+<?php
+use net\authorize\util\LogFactory;
+
+/**
+ * Sends requests to the Authorize.Net gateways.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetRequest
+ */
+abstract class AuthorizeNetRequest
+{
+
+ protected $_api_login;
+ protected $_transaction_key;
+ protected $_post_string;
+ public $VERIFY_PEER = true; // attempt trust validation of SSL certificates when establishing secure connections.
+ protected $_sandbox = true;
+ protected $_logger = null;
+
+ /**
+ * Set the _post_string
+ */
+ abstract protected function _setPostString();
+
+ /**
+ * Handle the response string
+ */
+ abstract protected function _handleResponse($string);
+
+ /**
+ * Get the post url. We need this because until 5.3 you
+ * you could not access child constants in a parent class.
+ */
+ abstract protected function _getPostUrl();
+
+ /**
+ * Constructor.
+ *
+ * @param string $api_login_id The Merchant's API Login ID.
+ * @param string $transaction_key The Merchant's Transaction Key.
+ */
+ public function __construct($api_login_id = false, $transaction_key = false)
+ {
+ $this->_api_login = ($api_login_id ? $api_login_id : (defined('AUTHORIZENET_API_LOGIN_ID') ? AUTHORIZENET_API_LOGIN_ID : ""));
+ $this->_transaction_key = ($transaction_key ? $transaction_key : (defined('AUTHORIZENET_TRANSACTION_KEY') ? AUTHORIZENET_TRANSACTION_KEY : ""));
+ $this->_sandbox = (defined('AUTHORIZENET_SANDBOX') ? AUTHORIZENET_SANDBOX : true);
+ $this->_logger = LogFactory::getLog(get_class($this));
+ }
+
+ /**
+ * Alter the gateway url.
+ *
+ * @param bool $bool Use the Sandbox.
+ */
+ public function setSandbox($bool)
+ {
+ $this->_sandbox = $bool;
+ }
+
+ /**
+ * Set a log file.
+ *
+ * @param string $filepath Path to log file.
+ */
+ public function setLogFile($filepath)
+ {
+ $this->_logger->setLogFile($filepath);
+ }
+
+ /**
+ * Return the post string.
+ *
+ * @return string
+ */
+ public function getPostString()
+ {
+ return $this->_post_string;
+ }
+
+ /**
+ * Posts the request to AuthorizeNet & returns response.
+ *
+ * @return AuthorizeNetARB_Response The response.
+ */
+ protected function _sendRequest()
+ {
+ $this->_setPostString();
+ $post_url = $this->_getPostUrl();
+ $curl_request = curl_init($post_url);
+ curl_setopt($curl_request, CURLOPT_POSTFIELDS, $this->_post_string);
+ curl_setopt($curl_request, CURLOPT_HEADER, 0);
+ curl_setopt($curl_request, CURLOPT_TIMEOUT, 45);
+ curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, 1);
+ curl_setopt($curl_request, CURLOPT_SSL_VERIFYHOST, 2);
+
+ if ($this->VERIFY_PEER) {
+ curl_setopt($curl_request, CURLOPT_CAINFO, dirname(dirname(__FILE__)) . '/ssl/cert.pem');
+ } else {
+ if ($this->_logger) {
+ $this->_logger->error("----Request----\nInvalid SSL option\n");
+ }
+ return false;
+ }
+
+ if (preg_match('/xml/',$post_url)) {
+ curl_setopt($curl_request, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
+ }
+
+ $response = curl_exec($curl_request);
+
+ if ($this->_logger) {
+ if ($curl_error = curl_error($curl_request)) {
+ $this->_logger->error("----CURL ERROR----\n$curl_error\n\n");
+ }
+ // Do not log requests that could contain CC info.
+ $this->_logger->info("----Request----\n{$this->_post_string}\n");
+ $this->_logger->info("----Response----\n$response\n\n");
+ }
+ curl_close($curl_request);
+
+ return $this->_handleResponse($response);
+ }
+
+}
--- /dev/null
+<?php
+/**
+ * Base class for the AuthorizeNet AIM & SIM Responses.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetResponse
+ */
+
+
+/**
+ * Parses an AuthorizeNet Response.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetResponse
+ */
+class AuthorizeNetResponse
+{
+
+ const APPROVED = 1;
+ const DECLINED = 2;
+ const ERROR = 3;
+ const HELD = 4;
+
+ public $approved;
+ public $declined;
+ public $error;
+ public $held;
+ public $response_code;
+ public $response_subcode;
+ public $response_reason_code;
+ public $response_reason_text;
+ public $authorization_code;
+ public $avs_response;
+ public $transaction_id;
+ public $invoice_number;
+ public $description;
+ public $amount;
+ public $method;
+ public $transaction_type;
+ public $customer_id;
+ public $first_name;
+ public $last_name;
+ public $company;
+ public $address;
+ public $city;
+ public $state;
+ public $zip_code;
+ public $country;
+ public $phone;
+ public $fax;
+ public $email_address;
+ public $ship_to_first_name;
+ public $ship_to_last_name;
+ public $ship_to_company;
+ public $ship_to_address;
+ public $ship_to_city;
+ public $ship_to_state;
+ public $ship_to_zip_code;
+ public $ship_to_country;
+ public $tax;
+ public $duty;
+ public $freight;
+ public $tax_exempt;
+ public $purchase_order_number;
+ public $md5_hash;
+ public $card_code_response;
+ public $cavv_response; // cardholder_authentication_verification_response
+ public $account_number;
+ public $card_type;
+ public $split_tender_id;
+ public $requested_amount;
+ public $balance_on_card;
+ public $response; // The response string from AuthorizeNet.
+
+}
--- /dev/null
+<?php
+/**
+ * Classes for the various AuthorizeNet data types.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+
+
+/**
+ * A class that contains all fields for a CIM Customer Profile.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetCustomer
+{
+ public $merchantCustomerId;
+ public $description;
+ public $email;
+ public $paymentProfiles = array();
+ public $shipToList = array();
+ public $customerProfileId;
+
+}
+
+/**
+ * A class that contains all fields for a CIM Address.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetAddress
+{
+ public $firstName;
+ public $lastName;
+ public $company;
+ public $address;
+ public $city;
+ public $state;
+ public $zip;
+ public $country;
+ public $phoneNumber;
+ public $faxNumber;
+ public $customerAddressId;
+}
+
+/**
+ * A class that contains all fields for a CIM Payment Profile.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetPaymentProfile
+{
+
+ public $customerType;
+ public $billTo;
+ public $payment;
+ public $customerPaymentProfileId;
+
+ public function __construct()
+ {
+ $this->billTo = new AuthorizeNetAddress;
+ $this->payment = new AuthorizeNetPayment;
+ }
+
+}
+
+/**
+ * A class that contains all fields for a CIM Payment Type.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetPayment
+{
+ public $creditCard;
+ public $bankAccount;
+
+ public function __construct()
+ {
+ $this->creditCard = new AuthorizeNetCreditCard;
+ $this->bankAccount = new AuthorizeNetBankAccount;
+ }
+}
+
+/**
+ * A class that contains all fields for a CIM Transaction.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetTransaction
+{
+ public $amount;
+ public $tax;
+ public $shipping;
+ public $duty;
+ public $lineItems = array();
+ public $customerProfileId;
+ public $customerPaymentProfileId;
+ public $customerShippingAddressId;
+ public $creditCardNumberMasked;
+ public $bankRoutingNumberMasked;
+ public $bankAccountNumberMasked;
+ public $order;
+ public $taxExempt;
+ public $recurringBilling;
+ public $cardCode;
+ public $splitTenderId;
+ public $approvalCode;
+ public $transId;
+
+ public function __construct()
+ {
+ $this->tax = (object)array();
+ $this->tax->amount = "";
+ $this->tax->name = "";
+ $this->tax->description = "";
+
+ $this->shipping = (object)array();
+ $this->shipping->amount = "";
+ $this->shipping->name = "";
+ $this->shipping->description = "";
+
+ $this->duty = (object)array();
+ $this->duty->amount = "";
+ $this->duty->name = "";
+ $this->duty->description = "";
+
+ // line items
+
+ $this->order = (object)array();
+ $this->order->invoiceNumber = "";
+ $this->order->description = "";
+ $this->order->purchaseOrderNumber = "";
+ }
+
+}
+
+/**
+ * A class that contains all fields for a CIM Transaction Line Item.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetLineItem
+{
+ public $itemId;
+ public $name;
+ public $description;
+ public $quantity;
+ public $unitPrice;
+ public $taxable;
+
+}
+
+/**
+ * A class that contains all fields for a CIM Credit Card.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetCreditCard
+{
+ public $cardNumber;
+ public $expirationDate;
+ public $cardCode;
+}
+
+/**
+ * A class that contains all fields for a CIM Bank Account.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetCIM
+ */
+class AuthorizeNetBankAccount
+{
+ public $accountType;
+ public $routingNumber;
+ public $accountNumber;
+ public $nameOnAccount;
+ public $echeckType;
+ public $bankName;
+}
+
+/**
+ * A class that contains all fields for an AuthorizeNet ARB Subscription.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetARB
+ */
+class AuthorizeNet_Subscription
+{
+
+ public $name;
+ public $intervalLength;
+ public $intervalUnit;
+ public $startDate;
+ public $totalOccurrences;
+ public $trialOccurrences;
+ public $amount;
+ public $trialAmount;
+ public $creditCardCardNumber;
+ public $creditCardExpirationDate;
+ public $creditCardCardCode;
+ public $bankAccountAccountType;
+ public $bankAccountRoutingNumber;
+ public $bankAccountAccountNumber;
+ public $bankAccountNameOnAccount;
+ public $bankAccountEcheckType;
+ public $bankAccountBankName;
+ public $orderInvoiceNumber;
+ public $orderDescription;
+ public $customerId;
+ public $customerEmail;
+ public $customerPhoneNumber;
+ public $customerFaxNumber;
+ public $billToFirstName;
+ public $billToLastName;
+ public $billToCompany;
+ public $billToAddress;
+ public $billToCity;
+ public $billToState;
+ public $billToZip;
+ public $billToCountry;
+ public $shipToFirstName;
+ public $shipToLastName;
+ public $shipToCompany;
+ public $shipToAddress;
+ public $shipToCity;
+ public $shipToState;
+ public $shipToZip;
+ public $shipToCountry;
+
+ public function getXml()
+ {
+ $xml = "<subscription>
+ <name>{$this->name}</name>
+ <paymentSchedule>
+ <interval>
+ <length>{$this->intervalLength}</length>
+ <unit>{$this->intervalUnit}</unit>
+ </interval>
+ <startDate>{$this->startDate}</startDate>
+ <totalOccurrences>{$this->totalOccurrences}</totalOccurrences>
+ <trialOccurrences>{$this->trialOccurrences}</trialOccurrences>
+ </paymentSchedule>
+ <amount>{$this->amount}</amount>
+ <trialAmount>{$this->trialAmount}</trialAmount>
+ <payment>
+ <creditCard>
+ <cardNumber>{$this->creditCardCardNumber}</cardNumber>
+ <expirationDate>{$this->creditCardExpirationDate}</expirationDate>
+ <cardCode>{$this->creditCardCardCode}</cardCode>
+ </creditCard>
+ <bankAccount>
+ <accountType>{$this->bankAccountAccountType}</accountType>
+ <routingNumber>{$this->bankAccountRoutingNumber}</routingNumber>
+ <accountNumber>{$this->bankAccountAccountNumber}</accountNumber>
+ <nameOnAccount>{$this->bankAccountNameOnAccount}</nameOnAccount>
+ <echeckType>{$this->bankAccountEcheckType}</echeckType>
+ <bankName>{$this->bankAccountBankName}</bankName>
+ </bankAccount>
+ </payment>
+ <order>
+ <invoiceNumber>{$this->orderInvoiceNumber}</invoiceNumber>
+ <description>{$this->orderDescription}</description>
+ </order>
+ <customer>
+ <id>{$this->customerId}</id>
+ <email>{$this->customerEmail}</email>
+ <phoneNumber>{$this->customerPhoneNumber}</phoneNumber>
+ <faxNumber>{$this->customerFaxNumber}</faxNumber>
+ </customer>
+ <billTo>
+ <firstName>{$this->billToFirstName}</firstName>
+ <lastName>{$this->billToLastName}</lastName>
+ <company>{$this->billToCompany}</company>
+ <address>{$this->billToAddress}</address>
+ <city>{$this->billToCity}</city>
+ <state>{$this->billToState}</state>
+ <zip>{$this->billToZip}</zip>
+ <country>{$this->billToCountry}</country>
+ </billTo>
+ <shipTo>
+ <firstName>{$this->shipToFirstName}</firstName>
+ <lastName>{$this->shipToLastName}</lastName>
+ <company>{$this->shipToCompany}</company>
+ <address>{$this->shipToAddress}</address>
+ <city>{$this->shipToCity}</city>
+ <state>{$this->shipToState}</state>
+ <zip>{$this->shipToZip}</zip>
+ <country>{$this->shipToCountry}</country>
+ </shipTo>
+</subscription>";
+
+ $xml_clean = "";
+ // Remove any blank child elements
+ foreach (preg_split("/(\r?\n)/", $xml) as $key => $line) {
+ if (!preg_match('/><\//', $line)) {
+ $xml_clean .= $line . "\n";
+ }
+ }
+
+ // Remove any blank parent elements
+ $element_removed = 1;
+ // Recursively repeat if a change is made
+ while ($element_removed) {
+ $element_removed = 0;
+ if (preg_match('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', $xml_clean)) {
+ $xml_clean = preg_replace('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', '', $xml_clean);
+ $element_removed = 1;
+ }
+ }
+
+ // Remove any blank lines
+ // $xml_clean = preg_replace('/\r\n[\s]+\r\n/','',$xml_clean);
+ return $xml_clean;
+ }
+}
+
+/**
+ * A class that contains all fields for an AuthorizeNet ARB SubscriptionList.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetARB
+ */
+class AuthorizeNetGetSubscriptionList
+{
+ public $searchType;
+ public $sorting;
+ public $paging;
+
+ public function getXml()
+ {
+ $emptyString = "";
+ $sortingXml = (is_null($this->sorting)) ? $emptyString : $this->sorting->getXml();
+ $pagingXml = (is_null($this->paging)) ? $emptyString : $this->paging->getXml();
+
+ $xml = "
+ <searchType>{$this->searchType}</searchType>"
+ .$sortingXml
+ .$pagingXml
+ ;
+
+ $xml_clean = "";
+ // Remove any blank child elements
+ foreach (preg_split("/(\r?\n)/", $xml) as $key => $line) {
+ if (!preg_match('/><\//', $line)) {
+ $xml_clean .= $line . "\n";
+ }
+ }
+
+ // Remove any blank parent elements
+ $element_removed = 1;
+ // Recursively repeat if a change is made
+ while ($element_removed) {
+ $element_removed = 0;
+ if (preg_match('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', $xml_clean)) {
+ $xml_clean = preg_replace('/<[a-z]+>[\r?\n]+\s*<\/[a-z]+>/i', '', $xml_clean);
+ $element_removed = 1;
+ }
+ }
+
+ // Remove any blank lines
+ // $xml_clean = preg_replace('/\r\n[\s]+\r\n/','',$xml_clean);
+ return $xml_clean;
+ }
+}
+
+class AuthorizeNetSubscriptionListPaging
+{
+ public $limit;
+ public $offset;
+
+ public function getXml()
+ {
+ $xml = "<paging>
+ <limit>{$this->limit}</limit>
+ <offset>{$this->offset}</offset>
+ </paging>";
+
+ return $xml;
+ }
+}
+
+class AuthorizeNetSubscriptionListSorting
+{
+ public $orderBy;
+ public $orderDescending;
+
+ public function getXml()
+ {
+ $xml = "
+ <sorting>
+ <orderBy>{$this->orderBy}</orderBy>
+ <orderDescending>{$this->orderDescending}</orderDescending>
+ </sorting>";
+
+ return $xml;
+ }
+}
--- /dev/null
+<?php
+/**
+ * Base class for the AuthorizeNet ARB & CIM Responses.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetXML
+ */
+
+/**
+ * Base class for the AuthorizeNet ARB & CIM Responses.
+ *
+ * @package AuthorizeNet
+ * @subpackage AuthorizeNetXML
+ */
+class AuthorizeNetXMLResponse
+{
+
+ public $xml; // Holds a SimpleXML Element with response.
+
+ /**
+ * Constructor. Parses the AuthorizeNet response string.
+ *
+ * @param string $response The response from the AuthNet server.
+ */
+ public function __construct($response)
+ {
+ $this->response = $response;
+ if ($response) {
+ $this->xml = @simplexml_load_string($response);
+
+ // Remove namespaces for use with XPath.
+ $this->xpath_xml = @simplexml_load_string(preg_replace('/ xmlns:xsi[^>]+/','',$response));
+ }
+ }
+
+ /**
+ * Was the transaction successful?
+ *
+ * @return bool
+ */
+ public function isOk()
+ {
+ return ($this->getResultCode() == "Ok");
+ }
+
+ /**
+ * Run an xpath query on the cleaned XML response
+ *
+ * @param string $path
+ * @return array Returns an array of SimpleXMLElement objects or FALSE in case of an error.
+ */
+ public function xpath($path)
+ {
+ return $this->xpath_xml->xpath($path);
+ }
+
+ /**
+ * Was there an error?
+ *
+ * @return bool
+ */
+ public function isError()
+ {
+ return ($this->getResultCode() == "Error");
+ }
+
+ /**
+ * @return string
+ */
+ public function getErrorMessage()
+ {
+ return "Error: {$this->getResultCode()}
+ Message: {$this->getMessageText()}
+ {$this->getMessageCode()}";
+ }
+
+ /**
+ * @return string
+ */
+ public function getRefID()
+ {
+ return $this->_getElementContents("refId");
+ }
+
+ /**
+ * @return string
+ */
+ public function getResultCode()
+ {
+ return $this->_getElementContents("resultCode");
+ }
+
+ /**
+ * @return string
+ */
+ public function getMessageCode()
+ {
+ return $this->_getElementContents("code");
+ }
+
+ /**
+ * @return string
+ */
+ public function getMessageText()
+ {
+ return $this->_getElementContents("text");
+ }
+
+ /**
+ * Grabs the contents of a unique element.
+ *
+ * @param string
+ * @return string
+ */
+ protected function _getElementContents($elementName)
+ {
+ $start = "<$elementName>";
+ $end = "</$elementName>";
+ if (strpos($this->response,$start) === false || strpos($this->response,$end) === false) {
+ return false;
+ } else {
+ $start_position = strpos($this->response, $start)+strlen($start);
+ $end_position = strpos($this->response, $end);
+ return substr($this->response, $start_position, $end_position-$start_position);
+ }
+ }
+
+}
\ No newline at end of file
--- /dev/null
+Common Name: GeoTrust Global CA\r
+Organization: GeoTrust Inc.\r
+Valid From: May 20, 2002\r
+Valid To: May 20, 2022\r
+Issuer: GeoTrust Global CA, GeoTrust Inc.\r
+Thumbprint (SHA-1): DE28 F4A4 FFE5 B92F A3C5 03D1 A349 A7F9 962A 8212\r
+-----BEGIN CERTIFICATE-----\r
+MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT\r
+MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i\r
+YWwgQ0EwHhcNMDIwNTIxMDQwMDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQG\r
+EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg\r
+R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9\r
+9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq\r
+fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv\r
+iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU\r
+1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+\r
+bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW\r
+MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA\r
+ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l\r
+uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn\r
+Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS\r
+tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF\r
+PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un\r
+hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV\r
+5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw==\r
+-----END CERTIFICATE-----\r
+\r
+\r
+Common Name: Entrust.net Secure Server Certification Authority\r
+Organization: Entrust.net\r
+Valid From: May 25, 1999\r
+Valid To: May 25, 2019\r
+Issuer: Entrust.net Secure Server Certification Authority, Entrust.net\r
+Thumbprint (SHA-1): 99A6 9BE6 1AFE 886B 4D2B 8200 7CB8 54FC 317E 1539\r
+-----BEGIN CERTIFICATE-----\r
+MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC\r
+VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u\r
+ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc\r
+KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u\r
+ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1\r
+MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE\r
+ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j\r
+b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF\r
+bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg\r
+U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA\r
+A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/\r
+I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3\r
+wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC\r
+AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb\r
+oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5\r
+BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p\r
+dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk\r
+MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp\r
+b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu\r
+dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0\r
+MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi\r
+E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa\r
+MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI\r
+hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN\r
+95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd\r
+2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI=\r
+-----END CERTIFICATE-----\r
+\r
+\r
+Common Name: Entrust.net Certification Authority (2048)\r
+Organization: Entrust.net\r
+Valid From: December 24, 1999\r
+Valid To: July 24, 2029\r
+Issuer: Entrust.net Certification Authority (2048), Entrust.net\r
+Thumbprint (SHA-1): 5030 0609 1D97 D4F5 AE39 F7CB E792 7D7D 652D 3431\r
+-----BEGIN CERTIFICATE-----\r
+MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u\r
+ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp\r
+bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV\r
+BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx\r
+NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3\r
+d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl\r
+MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u\r
+ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\r
+MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL\r
+Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr\r
+hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW\r
+nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi\r
+VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E\r
+BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ\r
+KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy\r
+T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf\r
+zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT\r
+J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e\r
+nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=\r
+-----END CERTIFICATE-----\r
+\r
+\r
+Common Name: Entrust Root Certification Authority\r
+Organization: Entrust, Inc.\r
+Valid From: November 27, 2006\r
+Valid To: November 27, 2026\r
+Issuer: Entrust Root Certification Authority, Entrust, Inc.\r
+Thumbprint (SHA-1): B31E B1B7 40E3 6C84 02DA DC37 D44D F5D4 6749 52F9\r
+-----BEGIN CERTIFICATE-----\r
+MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMC\r
+VVMxFjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0\r
+Lm5ldC9DUFMgaXMgaW5jb3Jwb3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMW\r
+KGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsGA1UEAxMkRW50cnVzdCBSb290IENl\r
+cnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0MloXDTI2MTEyNzIw\r
+NTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMTkw\r
+NwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSBy\r
+ZWZlcmVuY2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNV\r
+BAMTJEVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJ\r
+KoZIhvcNAQEBBQADggEPADCCAQoCggEBALaVtkNC+sZtKm9I35RMOVcF7sN5EUFo\r
+Nu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYszA9u3g3s+IIRe7bJWKKf4\r
+4LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOwwCj0Yzfv9\r
+KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGI\r
+rb68j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi\r
+94DkZfs0Nw4pgHBNrziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOB\r
+sDCBrTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAi\r
+gA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1MzQyWjAfBgNVHSMEGDAWgBRo\r
+kORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DHhmak8fdLQ/uE\r
+vW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA\r
+A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9t\r
+O1KzKtvn1ISMY/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6Zua\r
+AGAT/3B+XxFNSRuzFVJ7yVTav52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP\r
+9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTSW3iDVuycNsMm4hH2Z0kdkquM++v/\r
+eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0tHuu2guQOHXvgR1m\r
+0vdXcDazv/wor3ElhVsT/h5/WrQ8\r
+-----END CERTIFICATE-----\r
+\r
+\r
+Common Name: Baltimore CyberTrust Root\r
+Organization: Baltimore\r
+Valid From: May 12, 2000\r
+Valid To: May 12, 2025\r
+Issuer: Baltimore CyberTrust Root, Baltimore\r
+Thumbprint: D4DE 20D0 5E66 FC53 FE1A 5088 2C78 DB28 52CA E474\r
+-----BEGIN CERTIFICATE-----\r
+MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\r
+RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\r
+VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\r
+DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\r
+ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\r
+VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\r
+mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\r
+IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\r
+mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\r
+XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\r
+dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\r
+jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\r
+BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\r
+DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\r
+9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\r
+jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\r
+Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\r
+ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\r
+R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\r
+-----END CERTIFICATE-----\r
+\r
+\r
+Common Name: GeoTrust RSA CA 2018\r
+Organization: DigiCert Inc\r
+Valid From: November 06, 2017\r
+Valid To: November 06, 2027\r
+Issuer: DigiCert Global Root CA\r
+Thumbprint: 7CCC 2A87 E394 9F20 572B 1848 2980 505F A90C AC3B\r
+-----BEGIN CERTIFICATE-----\r
+MIIEizCCA3OgAwIBAgIQBUb+GCP34ZQdo5/OFMRhczANBgkqhkiG9w0BAQsFADBh\r
+MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\r
+d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\r
+QTAeFw0xNzExMDYxMjIzNDVaFw0yNzExMDYxMjIzNDVaMF4xCzAJBgNVBAYTAlVT\r
+MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\r
+b20xHTAbBgNVBAMTFEdlb1RydXN0IFJTQSBDQSAyMDE4MIIBIjANBgkqhkiG9w0B\r
+AQEFAAOCAQ8AMIIBCgKCAQEAv4rRY03hGOqHXegWPI9/tr6HFzekDPgxP59FVEAh\r
+150Hm8oDI0q9m+2FAmM/n4W57Cjv8oYi2/hNVEHFtEJ/zzMXAQ6CkFLTxzSkwaEB\r
+2jKgQK0fWeQz/KDDlqxobNPomXOMJhB3y7c/OTLo0lko7geG4gk7hfiqafapa59Y\r
+rXLIW4dmrgjgdPstU0Nigz2PhUwRl9we/FAwuIMIMl5cXMThdSBK66XWdS3cLX18\r
+4ND+fHWhTkAChJrZDVouoKzzNYoq6tZaWmyOLKv23v14RyZ5eqoi6qnmcRID0/i6\r
+U9J5nL1krPYbY7tNjzgC+PBXXcWqJVoMXcUw/iBTGWzpwwIDAQABo4IBQDCCATww\r
+HQYDVR0OBBYEFJBY/7CcdahRVHex7fKjQxY4nmzFMB8GA1UdIwQYMBaAFAPeUDVW\r
+0Uy7ZvCj4hsbw5eyPdFVMA4GA1UdDwEB/wQEAwIBhjAdBgNVHSUEFjAUBggrBgEF\r
+BQcDAQYIKwYBBQUHAwIwEgYDVR0TAQH/BAgwBgEB/wIBADA0BggrBgEFBQcBAQQo\r
+MCYwJAYIKwYBBQUHMAGGGGh0dHA6Ly9vY3NwLmRpZ2ljZXJ0LmNvbTBCBgNVHR8E\r
+OzA5MDegNaAzhjFodHRwOi8vY3JsMy5kaWdpY2VydC5jb20vRGlnaUNlcnRHbG9i\r
+YWxSb290Q0EuY3JsMD0GA1UdIAQ2MDQwMgYEVR0gADAqMCgGCCsGAQUFBwIBFhxo\r
+dHRwczovL3d3dy5kaWdpY2VydC5jb20vQ1BTMA0GCSqGSIb3DQEBCwUAA4IBAQAw\r
+8YdVPYQI/C5earp80s3VLOO+AtpdiXft9OlWwJLwKlUtRfccKj8QW/Pp4b7h6QAl\r
+ufejwQMb455OjpIbCZVS+awY/R8pAYsXCnM09GcSVe4ivMswyoCZP/vPEn/LPRhH\r
+hdgUPk8MlD979RGoUWz7qGAwqJChi28uRds3thx+vRZZIbEyZ62No0tJPzsSGSz8\r
+nQ//jP8BIwrzBAUH5WcBAbmvgWfrKcuv+PyGPqRcc4T55TlzrBnzAzZ3oClo9fTv\r
+O9PuiHMKrC6V6mgi0s2sa/gbXlPCD9Z24XUMxJElwIVTDuKB0Q4YMMlnpN/QChJ4\r
+B0AFsQ+DU0NCO+f78Xf7\r
+-----END CERTIFICATE-----\r
+\r
+\r
+Common Name: DigiCert Global Root CA\r
+Organization: DigiCert Inc\r
+Valid From: November 09, 2006\r
+Valid To: November 09, 2031\r
+Issuer: DigiCert Global Root CA\r
+Thumbprint: A898 5D3A 65E5 E5C4 B2D7 D66D 40C6 DD2F B19C 5436\r
+-----BEGIN CERTIFICATE-----\r
+MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBh\r
+MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3\r
+d3cuZGlnaWNlcnQuY29tMSAwHgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBD\r
+QTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAwMDAwMDBaMGExCzAJBgNVBAYTAlVT\r
+MRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5kaWdpY2VydC5j\r
+b20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkqhkiG\r
+9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsB\r
+CSDMAZOnTjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97\r
+nh6Vfe63SKMI2tavegw5BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt\r
+43C/dxC//AH2hdmoRBBYMql1GNXRor5H4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7P\r
+T19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y7vrTC0LUq7dBMtoM1O/4\r
+gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQABo2MwYTAO\r
+BgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbR\r
+TLtm8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUw\r
+DQYJKoZIhvcNAQEFBQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/Esr\r
+hMAtudXH/vTBH1jLuG2cenTnmCmrEbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg\r
+06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIttep3Sp+dWOIrWcBAI+0tKIJF\r
+PnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886UAb3LujEV0ls\r
+YSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk\r
+CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=\r
+-----END CERTIFICATE-----\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://phpunit.de/phpunit.xsd"
+ bootstrap="./tests/bootstrap.php" backupGlobals="false"
+ verbose="true" colors="true">
+
+ <testsuites>
+ <testsuite name="AuthorizeNet Integration Tests">
+ <directory suffix="Test.php">./tests</directory>
+ </testsuite>
+ </testsuites>
+
+ <logging>
+ <log type="coverage-text" target="php://stdout" showUncoveredFiles="false"
+ lowUpperBound="50" highLowerBound="80" />
+ <log type="coverage-clover" target="./build/logs/clover.xml" />
+ </logging>
+
+ <filter>
+ <whitelist processUncoveredFilesFromWhitelist="true">
+ <directory suffix=".php">./lib</directory>
+ <exclude>
+ <directory>./vendor</directory>
+ <directory>./tests</directory>
+ <directory>./build</directory>
+ </exclude>
+ </whitelist>
+ </filter>
+
+ <php>
+ <const name="PHPUNIT_TESTSUITE" value="true" />
+
+ <!-- Enter your test account credentials to run tests against sandbox. -->
+ <const name="AUTHORIZENET_API_LOGIN_ID" value="5KP3u95bQpv" />
+ <const name="AUTHORIZENET_TRANSACTION_KEY" value="346HZ32z3fP4hTG2" />
+ <const name="AUTHORIZENET_MD5_SETTING" value="" />
+
+ <!-- Enter your live account credentials to run tests against production gateway. -->
+ <const name="MERCHANT_LIVE_API_LOGIN_ID" value="" />
+ <const name="MERCHANT_LIVE_TRANSACTION_KEY" value="" />
+
+ <!-- Card Present Sandbox Credentials -->
+ <const name="CP_API_LOGIN_ID" value="" />
+ <const name="CP_TRANSACTION_KEY" value="" />
+
+ <const name="AUTHORIZENET_LOG_FILE" value="./tests/log" />
+ </php>
+
+</phpunit>
--- /dev/null
+<?php
+namespace net\authorize\api\controller;
+
+use net\authorize\api\contract\v1\AnetApiRequestType;
+use net\authorize\api\controller\base\ApiOperationBase;
+
+class APICONTROLLERNAMEController extends ApiOperationBase
+{
+ public function __construct(AnetApiRequestType $request)
+ {
+ $responseType = 'net\authorize\api\contract\v1\APICONTROLLERNAMEResponse';
+ parent::__construct($request, $responseType);
+ }
+
+ protected function validateRequest()
+ {
+ //validate required fields of $this->apiRequest->
+
+ //validate non-required fields of $this->apiRequest->
+ }
+}
\ No newline at end of file
--- /dev/null
+{
+ "name": "authorizenet/authorizenet",
+ "type": "library",
+ "description": "Official PHP SDK for Authorize.Net",
+ "keywords": ["authorizenet", "authorize.net", "payment", "ecommerce"],
+ "license": "proprietary",
+ "homepage": "http://developer.authorize.net",
+ "require": {
+ "php": ">=5.6",
+ "ext-curl": "*",
+ "ext-json": "*",
+ "ext-simplexml": "*",
+ "ext-xmlwriter": "*",
+ "goetas-webservices/xsd2php-runtime":"^0.2.2",
+ "goetas/xsd2php": "^2.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.0",
+ "phpmd/phpmd": "~2.0"
+ },
+ "autoload": {
+ "classmap": ["lib"]
+ },
+ "autoload-dev": {
+ "classmap": ["tests"]
+ }
+}
--- /dev/null
+#!/bin/bash
+
+echo "Starting `date`"
+CDIR=`pwd`
+SRCDIR=lib
+GENFOLDER=net/authorize/api/contract/v1
+CONTROLLERFOLDER=net/authorize/api/controller
+CNTNAMESPACE=${CONTROLLERFOLDER//\//\\}
+CLASSMAP=./ControllerClassMap.php
+echo "Using CNTNAMESPACE: ${CNTNAMESPACE}"
+
+GENLOG=$CDIR/log/generator.log
+SRCLOG=$CDIR/log/Sources
+CNTLOG=$CDIR/log/Controllers
+if [ -d $CDIR/log ];then
+ rm -r $CDIR/log/*.* 1> /dev/null 2>&1
+else
+ mkdir $CDIR/log
+fi
+if [ ! -d $SRCDIR ]; then
+ echo "Unable to find $SRCDIR"
+ exit 1
+fi
+if [ -f ${CLASSMAP} ];then
+ rm ${CLASSMAP}
+fi
+GENFULL=${SRCDIR}/${GENFOLDER}
+CNTFULL=${SRCDIR}/${CONTROLLERFOLDER}
+echo "Generated Controller load map for Controllers on `date`" > ${CLASSMAP} | tee > ${GENLOG}
+if [ ! -d ${CNTFULL} ]; then
+ mkdir ${CNTFULL}
+fi
+
+echo "Identifying Request/Responses to process from $SRCDIR" | tee >> ${GENLOG}
+touch ${SRCLOG}0.log
+touch ${CNTLOG}0.log
+ls ${GENFULL}/*.php | grep -i -e "request\.php" -e "response\.php" > ${SRCLOG}0.log
+ls ${CNTFULL}/*Controller.php > ${CNTLOG}0.log 2>/dev/null
+
+echo "Cleaning up paths in Sources and Controllers" | tee >> ${GENLOG}
+GENLEN=${#GENFULL}
+CNTLEN=${#CNTFULL}
+GENLEN=$(( $GENLEN + 2 ))
+CNTLEN=$(( $CNTLEN + 2 ))
+cut -c${GENLEN}- ${SRCLOG}0.log | cut -d. -f1 | sort -u > ${SRCLOG}1.log
+cut -c${CNTLEN}- ${CNTLOG}0.log | cut -d. -f1 | sort -u > ${CNTLOG}.log
+
+echo "Getting Unique Requests/Responses" | tee >> ${GENLOG}
+grep -i -e "request *$" -e "response *$" ${SRCLOG}1.log > ${SRCLOG}2.log
+
+echo "Identifying Object names" | tee >> ${GENLOG}
+perl -pi -w -e "s/Request *$//g;" ${SRCLOG}2.log
+perl -pi -w -e "s/Response *$//g;" ${SRCLOG}2.log
+sort -u ${SRCLOG}2.log > ${SRCLOG}3.log
+
+echo "Fixing Controllers" | tee >> ${GENLOG}
+perl -pi -w -e "s/Controller *$//g;" ${CNTLOG}.log
+perl -pi -w -e 's/^ *\n//g;' ${CNTLOG}.log
+
+echo "Creating backup for later comparison" | tee >> ${GENLOG}
+cp ${SRCLOG}3.log ${SRCLOG}4.log > /dev/null
+cp ${CNTLOG}.log ${CNTLOG}9.log > /dev/null
+
+echo "Removing ExistingControllers From Request/Response List" | tee >> ${GENLOG}
+# echo "From File" | tee >> ${GENLOG}
+# while read aLine; do
+ # echo Processing removal of existing controller "${aLine}" >> ${GENLOG}
+ # perl -pi -w -e "s/^\b${aLine}\b *$//g;" ${SRCLOG}3.log
+# done < ${CNTLOG}.log
+
+echo From BlackList | tee >> ${GENLOG}
+ blackList="ANetApi Error Ids XXDoNotUseDummy"
+for blackLine in $blackList ; do
+ echo Processing removal of Blacklisted controllers "$blackLine" | tee >> ${GENLOG}
+ perl -pi -w -e "s/^\b${blackLine}\b *$//g;" ${SRCLOG}3.log
+done
+perl -pi -w -e 's/^ *\n//g;' ${SRCLOG}3.log
+
+echo Creating Final List of Request/Response to generate code | tee >> ${GENLOG}
+sort -u ${SRCLOG}3.log > ${SRCLOG}.log
+
+while read aLine; do
+ CNTNAME=${CNTFULL}/${aLine}Controller.php
+ echo "'${CNTNAMESPACE}\\${aLine}Controller' => \$libDir . '${CONTROLLERFOLDER}/${aLine}Controller.php'," | tee >> ${CLASSMAP}
+
+ echo "Processing Controller for Request/Respose: ${aLine}, Controller=${CNTNAME}" | tee >> ${GENLOG}
+ if [ -f ${CNTNAME} ]; then
+ echo "${CNTNAME} exists, Creating New" | tee >> ${GENLOG}
+ cp resources/ControllerTemplate.phpt "${CNTNAME}.new"
+ perl -pi -w -e "s/APICONTROLLERNAME/${aLine}/g;" "${CNTNAME}.new"
+ #else
+ fi
+ if [ ! -f ${CNTNAME} ]; then
+ echo "Generating Code for ${CNTNAME}" | tee >> ${GENLOG}
+ cp resources/ControllerTemplate.phpt "${CNTNAME}"
+ perl -pi -w -e "s/APICONTROLLERNAME/${aLine}/g;" "${CNTNAME}"
+ fi
+
+done < ${SRCLOG}.log
+echo "Controller generated ClassMap is in file: ${CLASSMAP}" | tee >> ${GENLOG}
+
+echo "Identify Obsolete Controllers, from request/response list" | tee >> ${GENLOG}
+while read aLine; do
+ echo "Processing obsolete Controller ${aLine}" | tee >> ${GENLOG}
+ perl -pi -w -e "s/${aLine} *$//g;" "${CNTLOG}9.log"
+done < ${SRCLOG}.log
+sort -u "${CNTLOG}9.log" > /dev/null
+rm -r *.bak 2> /dev/null
+
+echo "Finished `date`"
--- /dev/null
+#!/bin/bash
+
+logfile=./xsdgen.log
+echo `date` > $logfile
+# sudo apt-get install php5-curl
+# composer install
+
+echo Getting latest XSD
+XSDURL=https://apitest.authorize.net/xml/v1/schema/AnetApiSchema.xsd
+if [ -f AnetApiSchema.xsd ]; then
+ echo "Renaming existing schema file"
+ mv AnetApiSchema.xsd AnetApiSchema.xsd.old
+fi
+wget $XSDURL 1>> $logfile 2>&1
+ERRORCODE=$?
+if [ $ERRORCODE -ne 0 ];then
+ echo "Unable to download XSD from $XSDURL"
+ exit $ERRORCODE
+fi
+if [ ! -f AnetApiSchema.xsd ]; then
+ echo "SchemaFile not found"
+ exit 1
+fi
+
+#create directories that do not exist
+apidir=lib/net/authorize/api/contract/v1
+#net.authorize.api.contract.v1.
+if [ -d "$apidir" ]; then
+ rm -r "$apidir"
+fi
+mkdir -p "$apidir"
+echo Make sure the ns-dest uses destination as: $apidir
+echo Generating PHP Classes >> $logfile
+vendor/goetas/xsd2php/bin/xsd2php convert:php \
+ --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/contract/v1' \
+ --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \
+ --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \
+ ./AnetApiSchema.xsd >> $logfile 2>> $logfile
+echo Generation of PHP Classes complete >> $logfile
+
+jmsdir=lib/net/authorize/api/yml/v1
+if [ -d "$jmsdir" ]; then
+ rm -r "$jmsdir"
+fi
+mkdir -p "$jmsdir"
+echo Generating Serializers for Classes >> $logfile
+vendor/goetas/xsd2php/bin/xsd2php convert:jms-yaml \
+ --ns-dest='net.authorize.api.contract.v1.;lib/net/authorize/api/yml/v1' \
+ --ns-map='http://www.w3.org/2001/XMLSchema;W3/XMLSchema/2001/' \
+ --ns-map='AnetApi/xml/v1/schema/AnetApiSchema.xsd;net.authorize.api.contract.v1' \
+ ./AnetApiSchema.xsd >> $logfile
+echo Generator output is in file: $logfile
+
--- /dev/null
+#!/bin/bash
+
+echo Started at `date`
+echo This script will update the generated code
+echo
+
+currdir=`pwd`
+cmdlist="generateObjectsFromXsd.sh generateControllersFromTemplate.sh"
+for cmd in $cmdlist ; do
+ echo Executing Script "$cmd"
+ if [ ! -f $currdir/scripts/$cmd ];then
+ echo "Script $currdir/scripts/$cmd not found"
+ exit 1
+ fi
+ $currdir/scripts/$cmd
+ # echo ***FIXME*** $currdir/scripts/$cmd
+ ERRORCODE=$?
+ if [ $ERRORCODE -ne 0 ];then
+ echo "########################################################################"
+ echo "Encountered error during execution of $cmd"
+ echo "See logs or output above."
+ echo "Exiting, Update ***NOT*** complete."
+ exit $ERRORCODE
+ fi
+done
+echo Exiting, Update completed successfully.
+echo Compile, run tests and commit to git-hub.
+echo Completed at `date`
+
--- /dev/null
+#!/bin/bash
+
+for file in $(find sample-code-php/ -name '*.php')
+do
+ php $file
+done
\ No newline at end of file
--- /dev/null
+<?php
+
+class AuthorizeNetAIM_Sandbox_Test extends PHPUnit_Framework_TestCase
+{
+ private $alternateApiLoginId = "22Pav9kBpn";
+ private $alternateTransactionKey = "35vB2T6kkZZW582q";
+
+ public function testAuthCapture()
+ {
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '4111111111111111',
+ 'exp_date' => '1220'
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCaptureSingleDigitMonth()
+ {
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '4111111111111111',
+ 'exp_date' => '420'
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCaptureSingleDigitMonthWithSlash()
+ {
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '4111111111111111',
+ 'exp_date' => '4/20'
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCaptureTwoDigitMonthWithSlash()
+ {
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '4111111111111111',
+ 'exp_date' => '04/20'
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCaptureAlternate()
+ {
+ $sale = new AuthorizeNetAIM;
+ $sale->amount = rand(1, 10000);
+ $sale->card_num = '6011000000000012';
+ $sale->exp_date = '04/20';
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCaptureShort()
+ {
+ $sale = new AuthorizeNetAIM;
+ $response = $sale->authorizeAndCapture(rand(1, 100), '6011000000000012', '04/16');
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCapturePartial()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $amount = 3.69;
+
+ $sale = new AuthorizeNetAIM;
+ $sale->amount = $amount;
+ $sale->card_num = '4222222222222';
+ $sale->zip = "46225";
+ $sale->exp_date = '04/20';
+ $sale->allow_partial_auth = true;
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->held);
+ $this->assertEquals("1.23", $response->amount);
+ $this->assertEquals($amount, $response->requested_amount);
+ $split_tender_id = $response->split_tender_id;
+
+ // Pay the balance with a different card
+ $sale = new AuthorizeNetAIM;
+ $sale->amount = $amount - $response->amount;
+ $sale->card_num = '6011000000000012';
+ $sale->exp_date = '04/20';
+ $sale->split_tender_id = $split_tender_id;
+ $sale->allow_partial_auth = true;
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+
+
+ }
+
+ public function testAuthCaptureShortNoVerify()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $sale = new AuthorizeNetAIM;
+ $sale->VERIFY_PEER = false;
+ $response = $sale->authorizeAndCapture(rand(1, 100), '6011000000000012', '04/20');
+ $this->assertTrue($response->approved);
+ }
+
+ // public function testVisaVerify()
+ // {
+ // return; // Remove to enable test
+ // $verify = new AuthorizeNetAIM;
+ // $verify->amount = "0.00";
+ // $verify->card_num = '4012888818888';
+ // $verify->exp_date = "0517";
+ // $verify->address = "123 Main Street";
+ // $verify->zip = "94110";
+ // $verify->authentication_indicator = "5";
+ // $verify->cardholder_authentication_value = "512";
+ // $response = $verify->authorizeOnly();
+ // $this->assertTrue($response->approved);
+ // }
+ //
+ // public function testVisaVerifyFail()
+ // {
+ // return; // Remove to enable test
+ // $verify = new AuthorizeNetAIM;
+ // $verify->amount = "0.00";
+ // $verify->card_num = '4012888818888';
+ // $verify->exp_date = "0517";
+ // $verify->address = "123 Main Street";
+ // $verify->zip = "94110";
+ // $verify->authentication_indicator = "5";
+ // $verify->cardholder_authentication_value = "";
+ // $response = $verify->authorizeOnly();
+ // $this->assertTrue($response->declined);
+ // }
+ //
+ // public function testMastercardVerify()
+ // {
+ // return; // Remove to enable test
+ // $verify = new AuthorizeNetAIM;
+ // $verify->amount = "0.00";
+ // $verify->card_num = '5424000000000015';
+ // $verify->exp_date = "0517";
+ // $verify->address = "123 Main Street";
+ // $verify->zip = "94110";
+ // $verify->authentication_indicator = "2";
+ // $verify->cardholder_authentication_value = "512";
+ // $response = $verify->authorizeOnly();
+ // $this->assertTrue($response->approved);
+ // }
+ //
+ // public function testMastercardVerifyFail()
+ // {
+ // return; // Remove to enable test
+ // $verify = new AuthorizeNetAIM;
+ // $verify->amount = "0.00";
+ // $verify->card_num = '5424000000000015';
+ // $verify->exp_date = "0517";
+ // $verify->address = "123 Main Street";
+ // $verify->zip = "94110";
+ // $verify->authentication_indicator = "2";
+ // $verify->cardholder_authentication_value = "";
+ // $response = $verify->authorizeOnly();
+ // $this->assertTrue($response->declined);
+ // }
+
+ public function testAimResponseFields()
+ {
+
+ $sale = new AuthorizeNetAIM;
+ $sale->card_num = '4111111111111111';
+ $sale->exp_date = '04/20';
+ $sale->amount = $amount = rand(1,99);
+ $sale->description = $description = "Sale description";
+ $sale->first_name = $first_name = "Jane";
+ $sale->last_name = $last_name = "Smith";
+ $sale->company = $company = "Jane Smith Enterprises Inc.";
+ $sale->address = $address = "20 Main Street";
+ $sale->city = $city = "San Francisco";
+ $sale->state = $state = "CA";
+ $sale->zip = $zip = "94110";
+ $sale->country = $country = "US";
+ $sale->phone = $phone = "415-555-5557";
+ $sale->fax = $fax = "415-555-5556";
+ $sale->email = $email = "foo@example.com";
+ $sale->cust_id = $customer_id = "55";
+ $sale->customer_ip = "98.5.5.5";
+ $sale->invoice_num = $invoice_number = "123";
+ $sale->ship_to_first_name = $ship_to_first_name = "John";
+ $sale->ship_to_last_name = $ship_to_last_name = "Smith";
+ $sale->ship_to_company = $ship_to_company = "Smith Enterprises Inc.";
+ $sale->ship_to_address = $ship_to_address = "10 Main Street";
+ $sale->ship_to_city = $ship_to_city = "San Francisco";
+ $sale->ship_to_state = $ship_to_state = "CA";
+ $sale->ship_to_zip = $ship_to_zip_code = "94110";
+ $sale->ship_to_country = $ship_to_country = "US";
+ $sale->tax = $tax = "0.00";
+ $sale->freight = $freight = "Freight<|>ground overnight<|>12.95";
+ $sale->duty = $duty = "Duty1<|>export<|>15.00";
+ $sale->tax_exempt = $tax_exempt = "FALSE";
+ $sale->po_num = $po_num = "12";
+
+
+
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ $this->assertEquals("1", $response->response_code);
+ $this->assertEquals("1", $response->response_subcode);
+ $this->assertEquals("1", $response->response_reason_code);
+ $this->assertEquals("This transaction has been approved.", $response->response_reason_text);
+ $this->assertGreaterThan(1, strlen($response->authorization_code));
+ $this->assertEquals("Y", $response->avs_response);
+ $this->assertGreaterThan(1, strlen($response->transaction_id));
+ $this->assertEquals($invoice_number, $response->invoice_number);
+ $this->assertEquals($description, $response->description);
+ $this->assertEquals($amount, $response->amount);
+ $this->assertEquals("CC", $response->method);
+ $this->assertEquals("auth_capture", $response->transaction_type);
+ $this->assertEquals($customer_id, $response->customer_id);
+ $this->assertEquals($first_name, $response->first_name);
+ $this->assertEquals($last_name, $response->last_name);
+ $this->assertEquals($company, $response->company);
+ $this->assertEquals($address, $response->address);
+ $this->assertEquals($city, $response->city);
+ $this->assertEquals($state, $response->state);
+ $this->assertEquals($zip, $response->zip_code);
+ $this->assertEquals($country, $response->country);
+ $this->assertEquals($phone, $response->phone);
+ $this->assertEquals($fax, $response->fax);
+ $this->assertEquals($email, $response->email_address);
+ $this->assertEquals($ship_to_first_name, $response->ship_to_first_name);
+ $this->assertEquals($ship_to_last_name, $response->ship_to_last_name);
+ $this->assertEquals($ship_to_company, $response->ship_to_company);
+ $this->assertEquals($ship_to_address, $response->ship_to_address);
+ $this->assertEquals($ship_to_city, $response->ship_to_city);
+ $this->assertEquals($ship_to_state, $response->ship_to_state);
+ $this->assertEquals($ship_to_zip_code, $response->ship_to_zip_code);
+ $this->assertEquals($ship_to_country, $response->ship_to_country);
+ $this->assertEquals($tax, $response->tax);
+ $this->assertEquals("15.00", $response->duty);
+ $this->assertEquals("12.95", $response->freight);
+ $this->assertEquals($tax_exempt, $response->tax_exempt);
+ $this->assertEquals($po_num, $response->purchase_order_number);
+ $this->assertGreaterThan(1, strlen($response->md5_hash));
+ $this->assertEquals("P", $response->card_code_response);
+ $this->assertEquals("2", $response->cavv_response);
+ $this->assertEquals("XXXX1111", $response->account_number);
+ $this->assertEquals("Visa", $response->card_type);
+ $this->assertEquals("", $response->split_tender_id);
+ $this->assertEquals("", $response->requested_amount);
+ $this->assertEquals("", $response->balance_on_card);
+
+
+ }
+
+
+ public function testVoid()
+ {
+ // First create transaction to void.
+ $amount = rand(1, 100000);
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => $amount,
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420'
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+
+ $void = new AuthorizeNetAIM;
+ $void->setFields(
+ array(
+ 'amount' => $amount,
+ 'card_num' => '6011000000000012',
+ 'trans_id' => $response->transaction_id,
+ )
+ );
+ $void_response = $void->Void();
+ $this->assertTrue($void_response->approved);
+ }
+
+ public function testVoidShort()
+ {
+ // First create transaction to void.
+ $amount = rand(1, 1000);
+ $card_num = '6011000000000012';
+ $exp_date = '0420';
+ $sale = new AuthorizeNetAIM;
+ $response = $sale->authorizeAndCapture($amount, $card_num, $exp_date);
+ $this->assertTrue($response->approved);
+
+ $void = new AuthorizeNetAIM;
+ $void_response = $void->void($response->transaction_id);
+ $this->assertTrue($void_response->approved);
+ }
+
+ public function testAuthCaptureECheckSandbox()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'method' => 'echeck',
+ 'bank_aba_code' => '121042882',
+ 'bank_acct_num' => '123456789123',
+ 'bank_acct_type' => 'CHECKING',
+ 'bank_name' => 'Bank of Earth',
+ 'bank_acct_name' => 'Jane Doe',
+ 'echeck_type' => 'WEB',
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertEquals("ECHECK", $response->method);
+ $this->assertTrue($response->approved);
+
+ }
+
+ public function testAmex()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $sale = new AuthorizeNetAIM;
+ $response = $sale->authorizeAndCapture(rand(1, 100), '370000000000002', '04/20');
+ $this->assertTrue($response->approved);
+ }
+
+ public function testDiscover()
+ {
+ $sale = new AuthorizeNetAIM;
+ $response = $sale->authorizeAndCapture(rand(1, 100), '6011000000000012', '04/20');
+ $this->assertTrue($response->approved);
+ }
+
+ public function testVisa()
+ {
+ $sale = new AuthorizeNetAIM;
+ $response = $sale->authorizeAndCapture(rand(1, 100), '4012888818888', '04/20');
+ $this->assertTrue($response->approved);
+ }
+
+ // public function testJCB()
+ // {
+ // return; // Remove to enable test
+ // $sale = new AuthorizeNetAIM;
+ // $response = $sale->authorizeAndCapture(rand(1, 100), '3088000000000017', '0905');
+ // $this->assertTrue($response->approved);
+ // }
+ //
+ // public function testDinersClub()
+ // {
+ // return; // Remove to enable test
+ // $sale = new AuthorizeNetAIM;
+ // $response = $sale->authorizeAndCapture(rand(1, 100), '38000000000006', '0905');
+ // $this->assertTrue($response->approved);
+ // }
+
+ public function testAuthOnly()
+ {
+ $auth = new AuthorizeNetAIM;
+ $auth->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420'
+ )
+ );
+ $response = $auth->authorizeOnly();
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCaptureVoid()
+ {
+ $amount = rand(1, 1000);
+ $auth = new AuthorizeNetAIM;
+ $auth->setFields(
+ array(
+ 'amount' => $amount,
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420'
+ )
+ );
+ $auth_response = $auth->authorizeOnly();
+ $this->assertTrue($auth_response->approved);
+
+ // Now capture.
+ $capture = new AuthorizeNetAIM;
+ $capture->setFields(
+ array(
+ 'amount' => $amount,
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420',
+ 'trans_id' => $auth_response->transaction_id,
+ )
+ );
+ $capture_response = $capture->priorAuthCapture();
+ $this->assertTrue($capture_response->approved);
+
+ // Now void
+ $void = new AuthorizeNetAIM;
+ $void->setFields(
+ array(
+ 'amount' => $amount,
+ 'card_num' => '0012',
+ 'trans_id' => $auth_response->transaction_id,
+ )
+ );
+ $void_response = $void->void();
+ $this->assertTrue($void_response->approved);
+ }
+
+ // public function testCredit()
+ // {
+ //
+ // }
+ //
+ // public function testPriorAuthCapture()
+ // {
+ //
+ // }
+ //
+ // public function testCaptureOnly()
+ // {
+ //
+ // }
+
+ public function testAdvancedAIM()
+ {
+ $auth = new AuthorizeNetAIM($this->alternateApiLoginId, $this->alternateTransactionKey);
+ $auth->amount = "50.00";
+
+ // Use eCheck:
+ $auth->setECheck(
+ '125000024',
+ '123456789123',
+ 'CHECKING',
+ 'Bank of Earth',
+ 'Jane Doe',
+ 'WEB'
+ );
+
+ // Set multiple line items:
+ $auth->addLineItem('item1', 'Golf tees', 'Blue tees', '2', '5.00', 'N');
+ $auth->addLineItem('item2', 'Golf shirt', 'XL', '1', '40.00', 'N');
+
+ // Set Invoice Number:
+ $auth->invoice_num = time();
+
+ // Set a Merchant Defined Field:
+ $auth->setCustomField("entrance_source", "Search Engine");
+
+ // Authorize Only:
+ $response = $auth->authorizeOnly();
+ $this->assertTrue($response->approved);
+ if ($response->approved) {
+ $auth_code = $response->transaction_id;
+
+ // Now capture:
+ $capture = new AuthorizeNetAIM($this->alternateApiLoginId, $this->alternateTransactionKey);
+ $capture_response = $capture->priorAuthCapture($auth_code);
+ $this->assertTrue($capture_response->approved);
+
+ // Now void:
+ $void = new AuthorizeNetAIM($this->alternateApiLoginId, $this->alternateTransactionKey);
+ $void_response = $void->void($capture_response->transaction_id);
+ $this->assertTrue($void_response->approved);
+ }
+ }
+
+ public function testAuthCaptureCustomFields()
+ {
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 90000),
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420'
+ )
+ );
+ $sale->setCustomField("foo", "bar");
+ $sale->setCustomField("foo2", "bar2");
+ $sale->setCustomField("foo3", "bar3");
+ $sale->setCustomField("foo4", "bar4");
+ $sale->setCustomField("foo5", "bar5");
+ $sale->setCustomField("My_MerchantField6", "My Merchant Value6");
+ $sale->setCustomField("foo7", "bar7");
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ $this->assertEquals("bar", $response->foo);
+ $this->assertEquals("bar2", $response->foo2);
+ }
+
+ public function testEncapCharacter()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $description = "john doe's present, with comma";
+ $amount = rand(1, 1000);
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => $amount,
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420',
+ 'encap_char' => '$',
+ 'description' => $description,
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ $this->assertEquals($amount, $response->amount);
+ $this->assertEquals($description, $response->description);
+ }
+
+ public function testAuthCaptureSetMultipleCustomFields()
+ {
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420'
+ )
+ );
+ $sale->setCustomFields(array("foo" => "bar", "foo2" => "bar2"));
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ $this->assertEquals("bar", $response->foo);
+ $this->assertEquals("bar2", $response->foo2);
+ }
+
+ public function testInvalidMerchantCredentials()
+ {
+ $auth = new AuthorizeNetAIM('d', 'd');
+ $response = $auth->AuthorizeOnly();
+ $this->assertTrue($response->error);
+ $this->assertEquals($response->response_subcode, 2);
+ $this->assertEquals($response->response_reason_code, 13);
+ }
+
+ public function testInvalidCreditCard()
+ {
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '123',
+ 'exp_date' => '0420'
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertFalse($response->approved);
+ $this->assertTrue($response->error);
+ }
+
+ public function testError()
+ {
+ $sale = new AuthorizeNetAIM;
+ $sale->unsetField("login");
+ $sale->unsetField("tran_key");
+ $sale->unsetField("delim_data");
+
+ $sale->unsetField("version");
+ $sale->unsetField("relay_response");
+
+ $response = $sale->authorizeAndCapture();
+ // An exception should have been thrown.
+ $this->assertFalse($response->approved);
+ $this->assertTrue($response->error);
+
+ }
+
+ public function testMultipleLineItems()
+ {
+ $merchant = (object)array();
+ $merchant->login = AUTHORIZENET_API_LOGIN_ID;
+ $merchant->tran_key = AUTHORIZENET_TRANSACTION_KEY;
+ $merchant->allow_partial_auth = "false";
+
+ $creditCard = array(
+ 'exp_date' => '02/2020',
+ 'card_num' => '6011000000000012',
+ 'card_code' => '452',
+ );
+
+ $transaction = array(
+ 'amount' => rand(100, 1000),
+ 'duplicate_window' => '10',
+ // 'email_customer' => 'true',
+ 'footer_email_receipt' => 'thank you for your business!',
+ 'header_email_receipt' => 'a copy of your receipt is below',
+ );
+
+ $order = array(
+ 'description' => 'Johns Bday Gift',
+ 'invoice_num' => '3123',
+ 'line_item' => 'item1<|>golf balls<|><|>2<|>18.95<|>Y',
+ );
+
+ $customer = (object)array();
+ $customer->first_name = "Jane";
+ $customer->last_name = "Smith";
+ $customer->company = "Jane Smith Enterprises Inc.";
+ $customer->address = "20 Main Street";
+ $customer->city = "San Francisco";
+ $customer->state = "CA";
+ $customer->zip = "94110";
+ $customer->country = "US";
+ $customer->phone = "415-555-5557";
+ $customer->fax = "415-555-5556";
+ $customer->email = "foo@example.com";
+ $customer->cust_id = "55";
+ $customer->customer_ip = "98.5.5.5";
+
+ $shipping_info = (object)array();
+ $shipping_info->ship_to_first_name = "John";
+ $shipping_info->ship_to_last_name = "Smith";
+ $shipping_info->ship_to_company = "Smith Enterprises Inc.";
+ $shipping_info->ship_to_address = "10 Main Street";
+ $shipping_info->ship_to_city = "San Francisco";
+ $shipping_info->ship_to_state = "CA";
+ $shipping_info->ship_to_zip = "94110";
+ $shipping_info->ship_to_country = "US";
+ $shipping_info->tax = "CA";
+ $shipping_info->freight = "Freight<|>ground overnight<|>12.95";
+ $shipping_info->duty = "Duty1<|>export<|>15.00";
+ $shipping_info->tax_exempt = "false";
+ $shipping_info->po_num = "12";
+
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields($creditCard);
+ $sale->setFields($shipping_info);
+ $sale->setFields($customer);
+ $sale->setFields($order);
+ $sale->setFields($merchant);
+ $sale->setFields($transaction);
+
+ $sale->addLineItem('item2', 'golf tees', 'titanium tees', '2', '2.95', 'Y');
+ $sale->addLineItem('item3', 'golf shirt', 'red, large', '2', '3.95', 'Y');
+
+ $response = $sale->authorizeAndCapture();
+
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAllFieldsLongMethod()
+ {
+ $merchant = (object)array();
+ $merchant->login = AUTHORIZENET_API_LOGIN_ID;
+ $merchant->tran_key = AUTHORIZENET_TRANSACTION_KEY;
+ $merchant->allow_partial_auth = "false";
+
+ $creditCard = array(
+ 'exp_date' => '02/2020',
+ 'card_num' => '6011000000000012',
+ 'card_code' => '452',
+ );
+
+ $transaction = array(
+ 'amount' => rand(100, 1000),
+ 'duplicate_window' => '10',
+ // 'email_customer' => 'true',
+ 'footer_email_receipt' => 'thank you for your business!',
+ 'header_email_receipt' => 'a copy of your receipt is below',
+ );
+
+ $order = array(
+ 'description' => 'Johns Bday Gift',
+ 'invoice_num' => '3123',
+ 'line_item' => 'item1<|>golf balls<|><|>2<|>18.95<|>Y',
+ );
+
+ $customer = (object)array();
+ $customer->first_name = "Jane";
+ $customer->last_name = "Smith";
+ $customer->company = "Jane Smith Enterprises Inc.";
+ $customer->address = "20 Main Street";
+ $customer->city = "San Francisco";
+ $customer->state = "CA";
+ $customer->zip = "94110";
+ $customer->country = "US";
+ $customer->phone = "415-555-5557";
+ $customer->fax = "415-555-5556";
+ $customer->email = "foo@example.com";
+ $customer->cust_id = "55";
+ $customer->customer_ip = "98.5.5.5";
+
+ $shipping_info = (object)array();
+ $shipping_info->ship_to_first_name = "John";
+ $shipping_info->ship_to_last_name = "Smith";
+ $shipping_info->ship_to_company = "Smith Enterprises Inc.";
+ $shipping_info->ship_to_address = "10 Main Street";
+ $shipping_info->ship_to_city = "San Francisco";
+ $shipping_info->ship_to_state = "CA";
+ $shipping_info->ship_to_zip = "94110";
+ $shipping_info->ship_to_country = "US";
+ $shipping_info->tax = "CA";
+ $shipping_info->freight = "Freight<|>ground overnight<|>12.95";
+ $shipping_info->duty = "Duty1<|>export<|>15.00";
+ $shipping_info->tax_exempt = "false";
+ $shipping_info->po_num = "12";
+
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields($creditCard);
+ $sale->setFields($shipping_info);
+ $sale->setFields($customer);
+ $sale->setFields($order);
+ $sale->setFields($merchant);
+ $sale->setFields($transaction);
+ $response = $sale->authorizeAndCapture();
+
+ $this->assertTrue($response->approved);
+ }
+
+ public function testResponseMethods()
+ {
+ $amount = rand(1, 1000);
+ $zipcode = "02301";
+
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => $amount,
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420',
+ 'zip' => $zipcode,
+ )
+ );
+
+ $sale->setCustomField("custom1", "custom1value");
+ $sale->setCustomField("custom2", "custom2value");
+ $result = $sale->authorizeAndCapture();
+ $this->assertTrue($result->approved);
+
+ $this->assertEquals("custom2value", $result->custom2);
+ $this->assertEquals($amount, $result->amount);
+ $this->assertEquals("CC", $result->method);
+ $this->assertEquals("auth_capture", $result->transaction_type);
+ $this->assertEquals("Discover", $result->card_type);
+ $this->assertEquals($zipcode, $result->zip_code);
+ }
+
+ public function testSetBadField()
+ {
+ try {
+ $amount = rand(1, 1000);
+ $zipcode = "02301";
+
+ $sale = new AuthorizeNetAIM;
+ $sale->setFields(
+ array(
+ 'amount' => $amount,
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420',
+ 'zipcode' => $zipcode, // Should actually be just "zip"
+ )
+ );
+
+ $result = $sale->authorizeAndCapture();
+ $this->assertTrue($result->approved);
+ // should have thrown an exception by now
+ $this->assertFalse(true);
+ }
+ catch (AuthorizeNetException $e){
+ $this->assertTrue(true);
+
+ }
+ }
+
+}
+
+
+class AuthorizeNetAIM_Live_Test extends PHPUnit_Framework_TestCase
+{
+
+ public function testAuthCaptureSetECheckMethod()
+ {
+ if (MERCHANT_LIVE_API_LOGIN_ID) {
+ // $this->markTestIncomplete('Depends on whether eChecks is enabled');
+ $sale = new AuthorizeNetAIM(MERCHANT_LIVE_API_LOGIN_ID,MERCHANT_LIVE_TRANSACTION_KEY);
+ $sale->setSandbox(false);
+ $sale->test_request = 'TRUE';
+ $sale->amount = "4.99";
+ $sale->setECheck(
+ '121042882',
+ '123456789123',
+ 'CHECKING',
+ 'Bank of Earth',
+ 'Jane Doe',
+ 'WEB'
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertEquals("ECHECK", $response->method);
+ $this->assertEquals("18", $response->response_reason_code);
+ // $this->assertTrue($response->approved);
+ }
+ }
+
+ public function testAuthCaptureECheck()
+ {
+ if (MERCHANT_LIVE_API_LOGIN_ID) {
+ // $this->markTestIncomplete('Depends on whether eChecks is enabled');
+ $sale = new AuthorizeNetAIM(MERCHANT_LIVE_API_LOGIN_ID,MERCHANT_LIVE_TRANSACTION_KEY);
+ $sale->setSandbox(false);
+ $sale->test_request = 'TRUE';
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'method' => 'echeck',
+ 'bank_aba_code' => '121042882',
+ 'bank_acct_num' => '123456789123',
+ 'bank_acct_type' => 'CHECKING',
+ 'bank_name' => 'Bank of Earth',
+ 'bank_acct_name' => 'Jane Doe',
+ 'echeck_type' => 'WEB',
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertEquals("ECHECK", $response->method);
+ $this->assertEquals("18", $response->response_reason_code);
+ // $this->assertTrue($response->approved);
+ }
+ }
+
+ public function testAuthCaptureLiveServerTestRequest()
+ {
+ if (MERCHANT_LIVE_API_LOGIN_ID) {
+ $sale = new AuthorizeNetAIM(MERCHANT_LIVE_API_LOGIN_ID,MERCHANT_LIVE_TRANSACTION_KEY);
+ $sale->setSandbox(false);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420'
+ )
+ );
+ $sale->setField('test_request', 'TRUE');
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+ }
+
+ public function testAuthCaptureLiveServer()
+ {
+ if (MERCHANT_LIVE_API_LOGIN_ID) {
+ $sale = new AuthorizeNetAIM(MERCHANT_LIVE_API_LOGIN_ID,MERCHANT_LIVE_TRANSACTION_KEY);
+ $sale->setSandbox(false);
+ $sale->test_request = 'TRUE';
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420'
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+ }
+
+ public function testInvalidCredentials()
+ {
+ if (MERCHANT_LIVE_API_LOGIN_ID) {
+ // Post a response to live server using invalid credentials.
+ $sale = new AuthorizeNetAIM('a','a');
+ $sale->setSandbox(false);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '6011000000000012',
+ 'exp_date' => '0420'
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->error);
+ $this->assertEquals("13", $response->response_reason_code);
+ }
+ }
+
+}
--- /dev/null
+<?php
+
+//include if tests/bootstrap.php is not loaded automatically
+//require_once __DIR__ . '/bootstrap.php';
+
+class AuthorizeNetARB_Test extends PHPUnit_Framework_TestCase
+{
+
+ public function testAllMethods()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ // Set the subscription fields.
+ $subscription = new AuthorizeNet_Subscription;
+ $subscription->name = "Short subscription";
+ $subscription->intervalLength = "1";
+ $subscription->intervalUnit = "months";
+ $subscription->startDate = "2020-03-12";
+ $subscription->totalOccurrences = "14";
+ $subscription->amount = rand(1,100);
+ $subscription->creditCardCardNumber = "6011000000000012";
+ $subscription->creditCardExpirationDate = "2018-10";
+ $subscription->creditCardCardCode = "123";
+ $subscription->billToFirstName = "john";
+ $subscription->billToLastName = "doe";
+
+ // Create the subscription.
+ $request = new AuthorizeNetARB;
+ $response = $request->createSubscription($subscription);
+ $this->assertTrue($response->isOk());
+ $subscription_id = $response->getSubscriptionId();
+
+ // Get the subscription status
+ $status_request = new AuthorizeNetARB;
+ $status_response = $status_request->getSubscriptionStatus($subscription_id);
+ $this->assertEquals("active",$status_response->getSubscriptionStatus());
+
+ // Update the subscription
+ $update_request = new AuthorizeNetARB;
+ $updated_subscription_info = new AuthorizeNet_Subscription;
+ $updated_subscription_info->billToFirstName = "jane";
+ $updated_subscription_info->billToLastName = "smith";
+ $updated_subscription_info->creditCardCardNumber = "6011000000000012";
+ $updated_subscription_info->creditCardExpirationDate = "2019-10";
+ $updated_subscription_info->creditCardCardCode = "423";
+ $update_response = $update_request->updateSubscription($subscription_id, $updated_subscription_info);
+ $this->assertTrue($update_response->isOk());
+
+ // Cancel the subscription
+ $cancellation = new AuthorizeNetARB;
+ $cancel_response = $cancellation->cancelSubscription($subscription_id);
+ $this->assertTrue($cancel_response->isOk());
+
+ // Get the subscription status
+ $status_request = new AuthorizeNetARB;
+ $status_response = $status_request->getSubscriptionStatus($subscription_id);
+ $this->assertEquals("canceled", $status_response->getSubscriptionStatus());
+
+ }
+
+
+ public function testCreateSubscriptionLong()
+ {
+
+ $subscription = new AuthorizeNet_Subscription;
+ $subscription->name = "test subscription";
+ $subscription->intervalLength = "1";
+ $subscription->intervalUnit = "months";
+ $subscription->startDate = "2018-03-12";
+ $subscription->totalOccurrences = "14";
+ $subscription->trialOccurrences = "";
+ $subscription->amount = "6.99";
+ $subscription->trialAmount = "";
+ $subscription->creditCardCardNumber = "6011000000000012";
+ $subscription->creditCardExpirationDate = "2018-10";
+ $subscription->creditCardCardCode = "123";
+ $subscription->bankAccountAccountType = "";
+ $subscription->bankAccountRoutingNumber = "";
+ $subscription->bankAccountAccountNumber = "";
+ $subscription->bankAccountNameOnAccount = "";
+ $subscription->bankAccountEcheckType = "";
+ $subscription->bankAccountBankName = "";
+ $subscription->orderInvoiceNumber = "";
+ $subscription->orderDescription = "";
+ $subscription->customerId = rand(1, 1000000);
+ $subscription->customerEmail = rand(1, 1000000) . "foo@domain.com";
+ $subscription->customerPhoneNumber = "";
+ $subscription->customerFaxNumber = "";
+ $subscription->billToFirstName = "john";
+ $subscription->billToLastName = "doe";
+ $subscription->billToCompany = "";
+ $subscription->billToAddress = "";
+ $subscription->billToCity = "";
+ $subscription->billToState = "";
+ $subscription->billToZip = "";
+ $subscription->billToCountry = "";
+ $subscription->shipToFirstName = "";
+ $subscription->shipToLastName = "";
+ $subscription->shipToCompany = "";
+ $subscription->shipToAddress = "";
+ $subscription->shipToCity = "";
+ $subscription->shipToState = "";
+ $subscription->shipToZip = "";
+ $subscription->shipToCountry = "";
+
+ $refId = "ref" . time();
+
+ // Create the request and send it.
+ $request = new AuthorizeNetARB;
+ $request->setRefId($refId);
+ $response = $request->createSubscription($subscription);
+
+
+ // Handle the response.
+
+ $this->assertTrue($response->isOk());
+ $this->assertEquals($response->getMessageCode(), "I00001");
+ $this->assertEquals($response->getMessageText(), "Successful.");
+ $this->assertEquals($response->getRefId(), $refId);
+ $this->assertEquals($response->getResultCode(), "Ok");
+
+ // Cancel the subscription to avoid duplicate errors in future
+
+ $cancellation = new AuthorizeNetARB;
+ $cancellation->setRefId($refId);
+ $cancel_response = $cancellation->cancelSubscription($response->getSubscriptionId());
+
+
+
+ $this->assertTrue($cancel_response->isOk());
+
+ }
+
+ public function testCreateSubscriptionECheck()
+ {
+
+ $subscription = new AuthorizeNet_Subscription;
+ $subscription->name = "my test echeck subscription";
+ $subscription->intervalLength = "1";
+ $subscription->intervalUnit = "months";
+ $subscription->startDate = "2019-04-12";
+ $subscription->totalOccurrences = "2";
+ $subscription->trialOccurrences = "";
+ $subscription->amount = "11.99";
+ $subscription->trialAmount = "";
+ $subscription->bankAccountAccountType = "checking";
+ $subscription->bankAccountRoutingNumber = "121000248";
+ $subscription->bankAccountAccountNumber = "12345678";
+ $subscription->bankAccountNameOnAccount = "John Doe";
+ $subscription->bankAccountEcheckType = "WEB";
+ $subscription->bankAccountBankName = "Bank of Earth";
+ $subscription->orderInvoiceNumber = "";
+ $subscription->orderDescription = "";
+ $subscription->customerId = rand(1, 1000000);
+ $subscription->customerEmail = rand(1, 1000000) . "foo@domain.com";
+ $subscription->customerPhoneNumber = "";
+ $subscription->customerFaxNumber = "";
+ $subscription->billToFirstName = "john";
+ $subscription->billToLastName = "doe";
+ $subscription->billToCompany = "";
+ $subscription->billToAddress = "";
+ $subscription->billToCity = "";
+ $subscription->billToState = "";
+ $subscription->billToZip = "";
+ $subscription->billToCountry = "";
+ $subscription->shipToFirstName = "";
+ $subscription->shipToLastName = "";
+ $subscription->shipToCompany = "";
+ $subscription->shipToAddress = "";
+ $subscription->shipToCity = "";
+ $subscription->shipToState = "";
+ $subscription->shipToZip = "";
+ $subscription->shipToCountry = "";
+
+ $refId = "ref" . time();
+
+ // Create the request and send it.
+ $request = new AuthorizeNetARB;
+ $request->setRefId($refId);
+
+ $response = $request->createSubscription($subscription);
+
+
+ // Handle the response.
+
+ $this->assertTrue($response->isOk());
+ $this->assertEquals($response->getMessageCode(), "I00001");
+ $this->assertEquals($response->getMessageText(), "Successful.");
+ $this->assertEquals($response->getRefId(), $refId);
+ $this->assertEquals($response->getResultCode(), "Ok");
+
+
+ // Cancel the subscription to avoid duplicate errors in future
+
+
+ $cancellation = new AuthorizeNetARB;
+ $cancellation->setRefId($refId);
+ $cancel_response = $cancellation->cancelSubscription($response->getSubscriptionId());
+
+ $this->assertTrue($cancel_response->isOk());
+
+ }
+
+ public function testGetSubscriptionList()
+ {
+ $refId = "ref" . time();
+
+ $paging = new AuthorizeNetSubscriptionListPaging();
+ $paging->limit=10;
+ $paging->offset=1;
+ $sorting=new AuthorizeNetSubscriptionListSorting();
+ $sorting->orderBy="firstName";
+ $sorting->orderDescending="false";
+
+ $getSubscriptionList = new AuthorizeNetGetSubscriptionList;
+ $getSubscriptionList->searchType = "subscriptionActive";
+ $getSubscriptionList->paging = $paging;
+ $getSubscriptionList->sorting = $sorting;
+
+ // Create the request and send it.
+ $request = new AuthorizeNetARB;
+ $request->setRefId($refId);
+ $response = $request->getSubscriptionList($getSubscriptionList);
+ // Handle the response.
+ $this->assertTrue($response->isOk());
+ $this->assertEquals($response->getMessageCode(), "I00001");
+ $this->assertEquals($response->getMessageText(), "Successful.");
+ $this->assertEquals($response->getRefId(), $refId);
+ $this->assertEquals($response->getResultCode(), "Ok");
+ }
+}
--- /dev/null
+<?php
+
+class AuthorizeNetCIM_Test extends PHPUnit_Framework_TestCase
+{
+
+ public function testDeleteAllCustomerProfiles()
+ {
+ $this->markTestSkipped('This test was taking much too long, need to revisit BM 20160615'); //TODO
+ $request = new AuthorizeNetCIM;
+ $response = $request->getCustomerProfileIds();
+ $customers = $response->getCustomerProfileIds();
+
+
+ foreach ($customers as $customer) {
+ $response = $request->deleteCustomerProfile($customer);
+ // Not all profiles can be deleted, they could be linked to subscriptions
+ //$this->assertTrue($response->isOk());
+ }
+
+
+ }
+
+ public function testXPath()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+
+ // Create new customer profile
+ $request = new AuthorizeNetCIM;
+ $customerProfile = new AuthorizeNetCustomer;
+ $customerProfile->description = $description = "Some Description of customer 2";
+ $customerProfile->merchantCustomerId = $merchantCustomerId = time().rand(1,150);
+ $customerProfile->email = $email = "test2@domain.com";
+
+ // Add payment profile.
+ $paymentProfile = new AuthorizeNetPaymentProfile;
+ $paymentProfile->customerType = "individual";
+ $paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
+ $paymentProfile->payment->creditCard->expirationDate = "2021-04";
+ $customerProfile->paymentProfiles[] = $paymentProfile;
+
+ $response = $request->createCustomerProfile($customerProfile);
+ $this->assertTrue($response->isOk());
+ $array = $response->xpath('customerProfileId');
+ $this->assertEquals($response->getCustomerProfileId(), "{$array[0]}");
+
+ $profile = $request->getCustomerProfile($response->getCustomerProfileId());
+
+ $this->assertEquals($email, (string)array_pop($profile->xpath('profile/email')));
+ $this->assertEquals($description, (string)array_pop($profile->xpath('profile/description')));
+ $this->assertEquals($merchantCustomerId, (string)array_pop($profile->xpath('profile/merchantCustomerId')));
+
+ }
+
+ public function testCreateCustomerProfile()
+ {
+ // Create new customer profile
+ $request = new AuthorizeNetCIM;
+ $customerProfile = new AuthorizeNetCustomer;
+ $customerProfile->description = "Description of customer";
+ $customerProfile->merchantCustomerId = time().rand(1,100);
+ $customerProfile->email = "blahbla@domain.com";
+
+ // Add payment profile.
+ $paymentProfile = new AuthorizeNetPaymentProfile;
+ $paymentProfile->customerType = "individual";
+ $paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
+ $paymentProfile->payment->creditCard->expirationDate = "2015-10";
+ $customerProfile->paymentProfiles[] = $paymentProfile;
+
+ // Add another payment profile.
+ $paymentProfile2 = new AuthorizeNetPaymentProfile;
+ $paymentProfile2->customerType = "business";
+ $paymentProfile2->payment->bankAccount->accountType = "businessChecking";
+ $paymentProfile2->payment->bankAccount->routingNumber = "121042882";
+ $paymentProfile2->payment->bankAccount->accountNumber = "123456789123";
+ $paymentProfile2->payment->bankAccount->nameOnAccount = "Jane Doe";
+ $paymentProfile2->payment->bankAccount->echeckType = "WEB";
+ $paymentProfile2->payment->bankAccount->bankName = "Pandora Bank";
+ $customerProfile->paymentProfiles[] = $paymentProfile2;
+
+
+ // Add shipping address.
+ $address = new AuthorizeNetAddress;
+ $address->firstName = "john";
+ $address->lastName = "Doe";
+ $address->company = "John Doe Company";
+ $address->address = "1 Main Street";
+ $address->city = "Boston";
+ $address->state = "MA";
+ $address->zip = "02412";
+ $address->country = "USA";
+ $address->phoneNumber = "555-555-5555";
+ $address->faxNumber = "555-555-5556";
+ $customerProfile->shipToList[] = $address;
+
+ // Add another shipping address.
+ $address2 = new AuthorizeNetAddress;
+ $address2->firstName = "jane";
+ $address2->lastName = "Doe";
+ $address2->address = "11 Main Street";
+ $address2->city = "Boston";
+ $address2->state = "MA";
+ $address2->zip = "02412";
+ $address2->country = "USA";
+ $address2->phoneNumber = "555-512-5555";
+ $address2->faxNumber = "555-523-5556";
+ $customerProfile->shipToList[] = $address2;
+
+ $response = $request->createCustomerProfile($customerProfile);
+ $this->assertTrue($response->isOk());
+ $this->assertEquals(2, count($response->getCustomerShippingAddressIds()));
+ $this->assertEquals(2, count($response->getCustomerPaymentProfileIds()));
+ $customerProfileId = $response->getCustomerProfileId();
+
+ $this->assertEquals($response->getCustomerProfileId(), "{$response->xml->customerProfileId}");
+
+
+
+ $response = $request->getCustomerProfile($customerProfileId);
+ $this->assertEquals($customerProfile->description, (string)$response->xml->profile->description);
+ $this->assertEquals($customerProfile->merchantCustomerId, (string)$response->xml->profile->merchantCustomerId);
+ $this->assertEquals($customerProfile->email, (string)$response->xml->profile->email);
+ $testPayment = ($response->xml->profile->paymentProfiles[0]->payment->creditCard)?($response->xml->profile->paymentProfiles[0]->payment):
+ ($response->xml->profile->paymentProfiles[1]->payment);
+ $this->assertEquals(substr($customerProfile->paymentProfiles[0]->payment->creditCard->cardNumber, -4, 4), substr((string)$testPayment->creditCard->cardNumber, -4, 4));
+ $this->assertTrue($response->isOk());
+
+
+ }
+
+ public function testGetCustomerProfile()
+ {
+ // Create new customer profile
+ $request = new AuthorizeNetCIM;
+ $customerProfile = new AuthorizeNetCustomer;
+ $customerProfile->description = "Description of customer";
+ $customerProfile->merchantCustomerId = time().rand(1,10);
+ $customerProfile->email = "blahlah@domain.com";
+ $response = $request->createCustomerProfile($customerProfile);
+ $this->assertTrue($response->isOk());
+ $customerProfileId = $response->getCustomerProfileId();
+
+ $response = $request->getCustomerProfile($customerProfileId);
+
+ $this->assertTrue($response->isOk());
+
+ }
+/*
+ * test case added for: Invalid child element in PHP CIM SDK when updating payment profile.
+ * 02/24/2014
+ */
+ public function testUpdateCustomerPaymentProfile()
+ {
+ // Create new customer profile
+ $request = new AuthorizeNetCIM;
+ $customerProfile = new AuthorizeNetCustomer;
+ $customerProfile->description = "Description of customer";
+ $customerProfile->merchantCustomerId = time().rand(1,100000);
+ $customerProfile->email = "blahlah@domain.com";
+ $response = $request->createCustomerProfile($customerProfile);
+ $this->assertTrue($response->isOk());
+ $customerProfileId = $response->getCustomerProfileId();
+
+ // Add payment profile.
+ $paymentProfile = new AuthorizeNetPaymentProfile;
+ $paymentProfile->customerType = "individual";
+ $paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
+ $paymentProfile->payment->creditCard->expirationDate = "2015-10";
+ $response = $request->createCustomerPaymentProfile($customerProfileId, $paymentProfile);
+ $this->assertTrue($response->isOk());
+ $paymentProfileId = $response->getPaymentProfileId();
+
+
+
+ $request = new AuthorizeNetCIM;
+ $response = $request->getCustomerPaymentProfile($customerProfileId, $paymentProfileId);
+ if ($response->isOk()) {
+ $ppp = $response->getPaymentProfileId();
+
+ $newPaymentProfile = new AuthorizeNetPaymentProfile;
+ $newPaymentProfile->customerType = "individual";
+ $newPaymentProfile->payment->creditCard->cardNumber = "4007000000000027";
+ $newPaymentProfile->payment->creditCard->expirationDate = "2018-08";
+
+ $request = new AuthorizeNetCIM;
+ $response = $request->updateCustomerPaymentProfile($customerProfileId, $paymentProfileId, $newPaymentProfile);
+ }
+
+ $this->assertTrue($response->isOk());
+
+ }
+
+ public function testGetCustomerPaymentProfile()
+ {
+ $expirationDate = "2015-10";
+ $cardNumber = "4111111111111111";
+ $expectedCardNumber = 'XXXX' . substr($cardNumber, -4);
+ $expectedExpiration = 'XXXX';
+
+ // Create new customer profile
+ $request = new AuthorizeNetCIM;
+ $customerProfile = new AuthorizeNetCustomer;
+ $customerProfile->description = "Description of customer";
+ $customerProfile->merchantCustomerId = time().rand(1,100000);
+ $customerProfile->email = "blahlah@domain.com";
+ $response = $request->createCustomerProfile($customerProfile);
+ $this->assertTrue($response->isOk());
+ $customerProfileId = $response->getCustomerProfileId();
+
+ // Add payment profile.
+ $paymentProfile = new AuthorizeNetPaymentProfile;
+ $paymentProfile->customerType = "individual";
+ $paymentProfile->payment->creditCard->cardNumber = $cardNumber;
+ $paymentProfile->payment->creditCard->expirationDate = $expirationDate;
+ $response = $request->createCustomerPaymentProfile($customerProfileId, $paymentProfile);
+ $this->assertTrue($response->isOk());
+ $paymentProfileId = $response->getPaymentProfileId();
+
+ $request = new AuthorizeNetCIM;
+ $response = $request->getCustomerPaymentProfile($customerProfileId, $paymentProfileId);
+ if ($response->isOk()) {
+ $recdCardNumber = (string)$response->xml->paymentProfile->payment->creditCard->cardNumber;
+ $recdExpiration = (string)$response->xml->paymentProfile->payment->creditCard->expirationDate;
+ $this->assertEquals($expectedCardNumber, $recdCardNumber);
+ $this->assertEquals($expectedExpiration, $recdExpiration);
+ }
+ }
+
+ public function testGetCustomerPaymentProfileWithUnmaskedExpiration()
+ {
+ $expirationDate = "2015-10";
+ $cardNumber = "4111111111111111";
+ $expectedCardNumber = 'XXXX' . substr($cardNumber, -4);
+
+ // Create new customer profile
+ $request = new AuthorizeNetCIM;
+ $customerProfile = new AuthorizeNetCustomer;
+ $customerProfile->description = "Description of customer";
+ $customerProfile->merchantCustomerId = time().rand(1,100000);
+ $customerProfile->email = "blahlah@domain.com";
+ $response = $request->createCustomerProfile($customerProfile);
+ $this->assertTrue($response->isOk());
+ $customerProfileId = $response->getCustomerProfileId();
+
+ // Add payment profile.
+ $paymentProfile = new AuthorizeNetPaymentProfile;
+ $paymentProfile->customerType = "individual";
+ $paymentProfile->payment->creditCard->cardNumber = $cardNumber;
+ $paymentProfile->payment->creditCard->expirationDate = $expirationDate;
+ $response = $request->createCustomerPaymentProfile($customerProfileId, $paymentProfile, true);
+ $this->assertTrue($response->isOk());
+ $paymentProfileId = $response->getPaymentProfileId();
+
+ $request = new AuthorizeNetCIM;
+ $response = $request->getCustomerPaymentProfile($customerProfileId, $paymentProfileId, true);
+ if ($response->isOk()) {
+ $recdCardNumber = (string)$response->xml->paymentProfile->payment->creditCard->cardNumber;
+ $recdExpiration = (string)$response->xml->paymentProfile->payment->creditCard->expirationDate;
+ $this->assertEquals($expectedCardNumber, $recdCardNumber);
+ $this->assertEquals($expirationDate, $recdExpiration);
+ }
+ }
+
+ public function testCreateCustomerProfileWithValidationMode()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ // Create new customer profile
+ $request = new AuthorizeNetCIM;
+ $customerProfile = new AuthorizeNetCustomer;
+ $customerProfile->description = "Some Description of customer 2";
+ $customerProfile->merchantCustomerId = time().rand(1,10);
+ $customerProfile->email = "test2@domain.com";
+
+ // Add payment profile.
+ $paymentProfile = new AuthorizeNetPaymentProfile;
+ $paymentProfile->customerType = "individual";
+ $paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
+ $paymentProfile->payment->creditCard->expirationDate = "2015-04";
+ $customerProfile->paymentProfiles[] = $paymentProfile;
+
+ // Add another payment profile.
+ $paymentProfile2 = new AuthorizeNetPaymentProfile;
+ $paymentProfile2->customerType = "individual";
+ $paymentProfile2->payment->creditCard->cardNumber = "4007000000000027";
+ $paymentProfile2->payment->creditCard->expirationDate = "2019-10";
+ $customerProfile->paymentProfiles[] = $paymentProfile2;
+
+ $response = $request->createCustomerProfile($customerProfile, "testMode");
+
+ $this->assertTrue($response->isOk(), 'Response should be ok');
+
+ $validationResponses = $response->getValidationResponses();
+ foreach ($validationResponses as $vr) {
+ $this->assertTrue($vr->approved, 'Validation response should be approved');
+ }
+
+ }
+
+ public function testUpdateSplitTenderGroup()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ // Create a partial auth test transaction
+ $amount = 4.92;
+
+ $sale = new AuthorizeNetAIM;
+ $sale->amount = $amount;
+ $sale->card_num = '4222222222222';
+ $sale->zip = "46225";
+ $sale->exp_date = '04/24';
+ $sale->allow_partial_auth = true;
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->held);
+ $this->assertEquals("1.23", $response->amount);
+ $this->assertEquals($amount, $response->requested_amount);
+ $split_tender_id = $response->split_tender_id;
+
+ // Charge a bit more
+ $sale = new AuthorizeNetAIM;
+ $sale->amount = 1.23;
+ $sale->card_num = '6011000000000012';
+ $sale->exp_date = '04/26';
+ $sale->split_tender_id = $split_tender_id;
+ $sale->allow_partial_auth = true;
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+
+ // Void the group of partial auths.
+
+ $request = new AuthorizeNetCIM;
+ $response = $request->updateSplitTenderGroup($split_tender_id, "voided");
+ $this->assertTrue($response->isOk());
+ }
+
+ public function testAll()
+ {
+ // Create new customer profile
+ $request = new AuthorizeNetCIM;
+ $customerProfile = new AuthorizeNetCustomer;
+ $customerProfile->description = "Description of customer";
+ $customerProfile->merchantCustomerId = time().rand(1,100);
+ $customerProfile->email = "blahblahblah@domain.com";
+ $response = $request->createCustomerProfile($customerProfile);
+ $this->assertTrue($response->isOk());
+ $customerProfileId = $response->getCustomerProfileId();
+
+ // Update customer profile
+ $customerProfile->description = "New description";
+ $customerProfile->email = "newemail@domain.com";
+ $response = $request->updateCustomerProfile($customerProfileId, $customerProfile);
+ $this->assertTrue($response->isOk());
+
+ // Add payment profile.
+ $paymentProfile = new AuthorizeNetPaymentProfile;
+ $paymentProfile->customerType = "individual";
+ $paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
+ $paymentProfile->payment->creditCard->expirationDate = "2015-10";
+ $response = $request->createCustomerPaymentProfile($customerProfileId, $paymentProfile);
+ $this->assertTrue($response->isOk());
+ $paymentProfileId = $response->getPaymentProfileId();
+
+ // Update payment profile.
+ $paymentProfile->payment->creditCard->cardNumber = "4111111111111111";
+ $paymentProfile->payment->creditCard->expirationDate = "2017-11";
+ $response = $request->updateCustomerPaymentProfile($customerProfileId,$paymentProfileId, $paymentProfile);
+ $this->assertTrue($response->isOk());
+
+ // Add shipping address.
+ $address = new AuthorizeNetAddress;
+ $address->firstName = "john";
+ $address->lastName = "Doe";
+ $address->company = "John Doe Company";
+ $address->address = "1 Main Street";
+ $address->city = "Boston";
+ $address->state = "MA";
+ $address->zip = "02412";
+ $address->country = "USA";
+ $address->phoneNumber = "555-555-5555";
+ $address->faxNumber = "555-555-5556";
+ $response = $request->createCustomerShippingAddress($customerProfileId, $address);
+ $this->assertTrue($response->isOk());
+ $customerAddressId = $response->getCustomerAddressId();
+
+ // Update shipping address.
+ $address->address = "2 First Street, with, comma";
+ $response = $request->updateCustomerShippingAddress($customerProfileId, $customerAddressId, $address);
+ $this->assertTrue($response->isOk());
+
+ // Create Auth & Capture Transaction
+ $transaction = new AuthorizeNetTransaction;
+ $transaction->amount = "9.79";
+ $transaction->customerProfileId = $customerProfileId;
+ $transaction->customerPaymentProfileId = $paymentProfileId;
+ $transaction->customerShippingAddressId = $customerAddressId;
+
+ $lineItem = new AuthorizeNetLineItem;
+ $lineItem->itemId = "4";
+ $lineItem->name = "Cookies";
+ $lineItem->description = "Chocolate Chip";
+ $lineItem->quantity = "4";
+ $lineItem->unitPrice = "1.00";
+ $lineItem->taxable = "true";
+
+ $lineItem2 = new AuthorizeNetLineItem;
+ $lineItem2->itemId = "4";
+ $lineItem2->name = "Cookies";
+ $lineItem2->description= "Peanut Butter";
+ $lineItem2->quantity = "4";
+ $lineItem2->unitPrice = "1.00";
+ $lineItem2->taxable = "true";
+
+ $transaction->lineItems[] = $lineItem;
+ $transaction->lineItems[] = $lineItem2;
+
+
+ $response = $request->createCustomerProfileTransaction("AuthCapture", $transaction);
+ $this->assertTrue($response->isOk());
+ $transactionResponse = $response->getTransactionResponse();
+ $this->assertTrue($transactionResponse->approved);
+ $transactionId = $transactionResponse->transaction_id;
+
+ // Void the transaction
+ $transaction = new AuthorizeNetTransaction;
+ $transaction->transId = $transactionId;
+ $response = $request->createCustomerProfileTransaction("Void", $transaction);
+ $this->assertTrue($response->isOk());
+ $transactionResponse = $response->getTransactionResponse();
+ $this->assertTrue($transactionResponse->approved);
+
+
+ // Delete Shipping Address
+ $response = $request->deleteCustomerShippingAddress($customerProfileId, $customerAddressId);
+ $this->assertTrue($response->isOk());
+
+ // Delete payment profile.
+ $response = $request->deleteCustomerPaymentProfile($customerProfileId, $paymentProfileId);
+ $this->assertTrue($response->isOk());
+
+
+ // Delete the profile id for future testing.
+ $response = $request->deleteCustomerProfile($customerProfileId);
+ $this->assertTrue($response->isOk());
+ }
+
+
+
+
+ public function testGetCustomerProfileIds()
+ {
+ // A valid response should be received when a merchant has zero customer profiles...
+ // Hence, first testing using specific credentials for a merchant which has zero customer profiles...
+ $request = new AuthorizeNetCIM('5KP3u95bQpv','346HZ32z3fP4hTG2');
+ $response = $request->getCustomerProfileIds();
+
+
+ // Create new customer profile
+ $request = new AuthorizeNetCIM;
+ $customerProfile = new AuthorizeNetCustomer;
+ $customerProfile->description = "Description of customer";
+ $customerProfile->merchantCustomerId = time().rand(1,100);
+ $customerProfile->email = "blahblahblah@domain.com";
+ $response = $request->createCustomerProfile($customerProfile);
+ $this->assertTrue($response->isOk());
+ $customerProfileId = $response->getCustomerProfileId();
+
+ $response = $request->getCustomerProfileIds();
+ $this->assertTrue($response->isOk());
+ $this->assertTrue(in_array($customerProfileId, $response->getCustomerProfileIds()));
+
+
+ }
+
+
+
+
+}
--- /dev/null
+<?php
+
+class AuthorizeNetCP_Test extends PHPUnit_Framework_TestCase
+{
+ public function testAuthOnly()
+ {
+ $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '4111111111111111',
+ 'exp_date' => '0420',
+ 'duplicate_window' => '5',
+ 'device_type' => '4',
+ )
+ );
+ $response = $sale->authorizeOnly();
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCapture()
+ {
+ $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'card_num' => '4111111111111111',
+ 'exp_date' => '0420',
+ 'device_type' => '4',
+ )
+ );
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+
+ // public function testMd5()
+ // {
+ // return;
+ // $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+ // $sale->setFields(
+ // array(
+ // 'amount' => rand(1, 1000),
+ // 'card_num' => '4111111111111111',
+ // 'exp_date' => '0415',
+ // 'device_type' => '4',
+ // )
+ // );
+ // $response = $sale->authorizeAndCapture();
+ // $this->assertTrue($response->approved);
+ // $this->assertTrue($response->isAuthorizeNet(CP_API_LOGIN_ID));
+ // }
+
+ public function testAuthCaptureTrack1()
+ {
+ $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'device_type' => '4',
+ )
+ );
+ $sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?');
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCaptureTrack2()
+ {
+ $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'device_type' => '4',
+ )
+ );
+ $sale->setTrack2Data('4111111111111111=1803101000020000831?');
+ $response = $sale->authorizeAndCapture();
+ $this->assertTrue($response->approved);
+ }
+
+ public function testAuthCaptureTrack2Error()
+ {
+ $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'device_type' => '4',
+ )
+ );
+ $sale->setTrack2Data('4411111111111111=1803101000020000831?');
+ $response = $sale->authorizeAndCapture();
+ $this->assertFalse($response->approved);
+ $this->assertTrue($response->error);
+ $this->assertEquals(6, $response->response_reason_code);
+ }
+
+ public function testResponseFields()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'device_type' => '4',
+ )
+ );
+ $sale->user_ref = $user_ref = "someCustomVariable123";
+ $sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?');
+ $response = $sale->authorizeAndCapture();
+
+
+ $this->assertTrue($response->approved);
+ $this->assertEquals('1.0',$response->version);
+ $this->assertEquals('1',$response->response_code);
+ $this->assertEquals('1',$response->response_reason_code);
+ $this->assertEquals('This transaction has been approved.',$response->response_reason_text);
+ $this->assertEquals('000000',$response->authorization_code);
+ $this->assertEquals('P',$response->avs_code);
+ $this->assertEquals('',$response->card_code_response);
+ $this->assertEquals('0',$response->transaction_id);
+ $this->assertStringMatchesFormat('%x',$response->md5_hash);
+ $this->assertEquals($user_ref, $response->user_ref);
+ $this->assertEquals('XXXX1111',$response->card_num);
+ $this->assertEquals('Visa',$response->card_type);
+
+
+ }
+
+ public function testXmlResponse()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'device_type' => '4',
+ 'response_format' => '0',
+ )
+ );
+ $sale->user_ref = $user_ref = "dummyvalue323";
+ $sale->setTrack1Data('%B4111111111111111^CARDUSER/JOHN^1803101000000000020000831000000?');
+ $response = $sale->authorizeAndCapture();
+
+
+ $this->assertTrue($response->approved);
+ $this->assertEquals('1.0',$response->version);
+ $this->assertEquals('1',$response->response_code);
+ $this->assertEquals('1',$response->response_reason_code);
+ $this->assertEquals('This transaction has been approved.',$response->response_reason_text);
+ $this->assertEquals('000000',$response->authorization_code);
+ $this->assertEquals('P',$response->avs_code);
+ $this->assertEquals('',$response->card_code_response);
+ $this->assertEquals('0',$response->transaction_id);
+ $this->assertStringMatchesFormat('%x',$response->md5_hash);
+ $this->assertEquals($user_ref, $response->user_ref);
+ $this->assertEquals('XXXX1111',$response->card_num);
+ $this->assertEquals('Visa',$response->card_type);
+
+
+ }
+
+ public function testXmlResponseFailure()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+
+ $sale = new AuthorizeNetCP(CP_API_LOGIN_ID, CP_TRANSACTION_KEY);
+ $sale->setFields(
+ array(
+ 'amount' => rand(1, 1000),
+ 'device_type' => '4',
+ 'response_format' => '0',
+ )
+ );
+ $sale->user_ref = $user_ref = "dummyvalue323";
+ $sale->setTrack1Data('%B4111111111111^CARDUSER/JOHN^1803101000000000020000831000000?');
+ $response = $sale->authorizeAndCapture();
+
+
+ $this->assertTrue($response->error);
+ $this->assertEquals('1.0',$response->version);
+ $this->assertEquals('3',$response->response_code);
+ $this->assertEquals('6',$response->response_reason_code);
+ $this->assertEquals('The credit card number is invalid.',$response->response_reason_text);
+ $this->assertEquals('000000',$response->authorization_code);
+ $this->assertEquals('P',$response->avs_code);
+ $this->assertEquals('',$response->card_code_response);
+ $this->assertEquals('0',$response->transaction_id);
+ $this->assertStringMatchesFormat('%x',$response->md5_hash);
+ $this->assertEquals($user_ref, $response->user_ref);
+ $this->assertEquals('XXXX1111',$response->card_num);
+
+
+ }
+
+
+}
--- /dev/null
+<?php
+
+class AuthorizeNetDPM_Test extends PHPUnit_Framework_TestCase
+{
+ public function testGenerateFingerprint()
+ {
+ $this->assertEquals("db88bbebb8f699acdbe70daad897a68a",AuthorizeNetDPM::getFingerprint("123","123","123","123","123"));
+ }
+
+ public function testGetCreditCardForm()
+ {
+ $fp_sequence = "12345";
+ $this->assertContains('<input type="hidden" name="x_fp_sequence" value="'.$fp_sequence.'">',AuthorizeNetDPM::getCreditCardForm('2', $fp_sequence, 'ht', '2', '1', true));
+ }
+
+ public function testRelayResponseUrl()
+ {
+ $return_url = 'http://yourdomain.com';
+
+ $this->assertContains('window.location="'.$return_url.'";', AuthorizeNetDPM::getRelayResponseSnippet($return_url));
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+class AuthorizeNetSIM_Test extends PHPUnit_Framework_TestCase
+{
+
+ public function testGenerateHash()
+ {
+ $_POST['x_amount'] = "4.12";
+ $_POST['x_trans_id'] = "123";
+ $message = new AuthorizeNetSIM("528udYYwz","test");
+ $this->assertEquals("8FC33C32ABB3EDD8BBC4BE3E904CB47E",$message->generateHash());
+ }
+
+ public function testAmount()
+ {
+ $_POST['x_amount'] = "4.12";
+ $_POST['x_response_code'] = "1";
+ $message = new AuthorizeNetSIM("528udYYwz","test");
+ $this->assertEquals("4.12",$message->amount);
+ $this->assertTrue($message->approved);
+ }
+
+ public function testIsAuthNet()
+ {
+ $_POST['x_amount'] = "4.12";
+ $_POST['x_trans_id'] = "123";
+ $_POST['x_MD5_Hash'] = "8FC33C32ABB3EDD8BBC4BE3E904CB47E";
+ $message = new AuthorizeNetSIM("528udYYwz","test");
+ $this->assertTrue($message->isAuthorizeNet());
+
+
+ $_POST['x_amount'] = "4.12";
+ $_POST['x_trans_id'] = "123";
+ $_POST['x_MD5_Hash'] = "8FC33C32BB3EDD8BBC4BE3E904CB47E";
+ $message = new AuthorizeNetSIM("528udYYwz","test");
+ $this->assertFalse($message->isAuthorizeNet());
+ }
+
+ public function testIsError()
+ {
+ $_POST['x_amount'] = "4.12";
+ $_POST['x_response_code'] = "3";
+ $_POST['x_ship_to_state'] = "CA";
+ $message = new AuthorizeNetSIM("528udYYwz","test");
+ $this->assertEquals("3",$message->response_code);
+ $this->assertTrue($message->error);
+ $this->assertFalse($message->approved);
+ $this->assertEquals("CA",$message->ship_to_state);
+ }
+
+
+
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+class AuthorizeNetSSL_Test extends PHPUnit_Framework_TestCase {
+ public function testSandboxSSLCertIsValid()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ exec("echo | openssl s_client -connect test.authorize.net:443 -showcerts -verify 10 -CAfile ../lib/ssl/cert.pem 2>&1", $output, $return_value);
+ $this->assertEquals(0, $return_value);
+ $this->assertTrue(in_array('Verify return code: 0 (ok)', array_map('trim', $output)));
+ exec("echo | openssl s_client -connect apitest.authorize.net:443 -showcerts -verify 10 -CAfile ../lib/ssl/cert.pem 2>&1", $output, $return_value);
+ $this->assertEquals(0, $return_value);
+ $this->assertTrue(in_array('Verify return code: 0 (ok)', array_map('trim', $output)));
+ }
+
+ public function testLiveSSLCertIsValid()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ exec("echo | openssl s_client -connect secure2.authorize.net:443 -showcerts -verify 10 -CAfile ../lib/ssl/cert.pem 2>&1", $output, $return_value);
+ $this->assertEquals(0, $return_value);
+ $this->assertTrue(in_array('Verify return code: 0 (ok)', array_map('trim', $output)));
+ exec("echo | openssl s_client -connect api2.authorize.net:443 -showcerts -verify 10 -CAfile ../lib/ssl/cert.pem 2>&1", $output, $return_value);
+ $this->assertEquals(0, $return_value);
+ $this->assertTrue(in_array('Verify return code: 0 (ok)', array_map('trim', $output)));
+ }
+}
--- /dev/null
+<?php
+
+class AuthorizeNetTD_Test extends PHPUnit_Framework_TestCase
+{
+
+
+ public function testGetSettledBatchList()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $request = new AuthorizeNetTD;
+ $response = $request->getSettledBatchList();
+ $this->assertTrue($response->isOk());
+ $this->assertEquals("I00001",(string)array_pop($response->xpath("messages/message/code")));
+ }
+
+ public function testGetSettledBatchListIncludeStatistics()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $request = new AuthorizeNetTD;
+ $response = $request->getSettledBatchList(true);
+ $this->assertTrue($response->isOk());
+ }
+
+ public function testGetSettledBatchListForMonth()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $request = new AuthorizeNetTD;
+ $response = $request->getSettledBatchListForMonth();
+ $this->assertTrue($response->isOk());
+ }
+
+ public function testGetTransactionsForDay()
+ {
+ $request = new AuthorizeNetTD;
+ $transactions = $request->getTransactionsForDay(12, 8, 2010);
+ $this->assertTrue(is_array($transactions));
+ }
+
+ public function testGetTransactionList()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $request = new AuthorizeNetTD;
+ $response = $request->getSettledBatchList();
+ $this->assertTrue($response->isOk());
+ $batches = $response->xpath("batchList/batch");
+ $batch_id = (string)$batches[0]->batchId;
+ $response = $request->getTransactionList($batch_id);
+ $this->assertTrue($response->isOk());
+ }
+
+ public function testGetTransactionListReturnedItems()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $request = new AuthorizeNetTD;
+ $batchId = 0; // Set your $batchId here
+ $response = $request->getTransactionList($batchId);
+ $this->assertTrue($response->isOk());
+ $transactions = $response->xpath("transactions/transaction");
+ $transId = $transactions[0]->transId;
+
+ $details = new AuthorizeNetTD;
+ $response = $details->getTransactionDetails($transId);
+ $this->assertTrue($response->isOk());
+ $transaction = $response->xml->transaction[0];
+ $this->assertFalse(empty($transaction->returnedItems));
+
+ }
+
+
+ public function testGetTransactionListSubscription()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $transId = 0; // Set your $transId here
+
+ $details = new AuthorizeNetTD;
+ $response = $details->getTransactionDetails($transId);
+ $this->assertTrue($response->isOk());
+ $transaction = $response->xml->transaction[0];
+
+ $this->assertFalse(empty($transaction->subscription));
+ }
+
+ public function testGetTransactionDetails()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $sale = new AuthorizeNetAIM;
+ $amount = rand(1, 100);
+ $response = $sale->authorizeAndCapture($amount, '4012888818888', '04/17');
+ $this->assertTrue($response->approved);
+
+ $transId = $response->transaction_id;
+
+ $request = new AuthorizeNetTD;
+ $response = $request->getTransactionDetails($transId);
+ $this->assertTrue($response->isOk());
+
+ $this->assertEquals($transId, (string)$response->xml->transaction->transId);
+ $this->assertEquals($amount, (string)$response->xml->transaction->authAmount);
+ $this->assertEquals("Visa", (string)$response->xml->transaction->payment->creditCard->cardType);
+
+ }
+
+
+ public function testGetTransactionDetailsWithSolutionId()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $sale = new AuthorizeNetAIM;
+ $amount = rand(1, 100);
+ $sale->setCustomField('x_solution_id', 'A1000002');
+ $response = $sale->authorizeAndCapture($amount, '4012888818888', '04/17');
+ $this->assertTrue($response->approved);
+
+ $transId = $response->transaction_id;
+
+ $request = new AuthorizeNetTD;
+ $response = $request->getTransactionDetails($transId);
+ $this->assertTrue($response->isOk());
+
+ $this->assertEquals($transId, (string)$response->xml->transaction->transId);
+ $this->assertEquals($amount, (string)$response->xml->transaction->authAmount);
+ $this->assertEquals("Visa", (string)$response->xml->transaction->payment->creditCard->cardType);
+ $this->assertEquals("A1000002", (string)$response->xml->transaction->solution->id);
+ }
+
+ public function testGetUnsettledTransactionList()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $sale = new AuthorizeNetAIM;
+ $amount = rand(1, 100);
+ $response = $sale->authorizeAndCapture($amount, '4012888818888', '04/17');
+ $this->assertTrue($response->approved);
+
+ $request = new AuthorizeNetTD;
+ $response = $request->getUnsettledTransactionList();
+ $this->assertTrue($response->isOk());
+ $this->assertTrue($response->xml->transactions->count() >= 1);
+ }
+
+ public function testGetUnsettledTransactionListHasNoReturnedItems()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $request = new AuthorizeNetTD;
+ $response = $request->getUnsettledTransactionList();
+ $this->assertTrue($response->isOk());
+ $this->assertTrue($response->xml->transactions->count() >= 1);
+
+ foreach($response->xml->transactions->transaction as $transaction)
+ {
+ if($transaction->hasReturnedItems)
+ {
+ $this->assertEquals("false", $transaction->hasReturnedItems);
+ }
+ }
+ }
+
+
+ public function testGetBatchStatistics()
+ {
+ $this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+ $request = new AuthorizeNetTD;
+ $response = $request->getSettledBatchList();
+ $this->assertTrue($response->isOk());
+ $this->assertTrue($response->xml->batchList->count() >= 1);
+ $batchId = $response->xml->batchList->batch[0]->batchId;
+
+ $request = new AuthorizeNetTD;
+ $response = $request->getBatchStatistics($batchId);
+ $this->assertTrue($response->isOk());
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+class AuthorizeNet_SOAP_Test extends PHPUnit_Framework_TestCase
+{
+
+ public function testSaveSoapDoc ()
+ {
+ $filepath = dirname(__FILE__) . "/soap_doc.php";
+ $client = new AuthorizeNetSOAP;
+ $this->assertTrue($client->saveSoapDocumentation($filepath) > 1);
+ unlink($filepath);
+ }
+
+ public function testGetCustomerIds ()
+ {
+ $client = new AuthorizeNetSOAP;
+ $result = $client->GetCustomerProfileIds(
+ array(
+ 'merchantAuthentication' => array(
+ 'name' => AUTHORIZENET_API_LOGIN_ID,
+ 'transactionKey' => AUTHORIZENET_TRANSACTION_KEY,
+ ),
+ )
+ );
+ $customer_ids = $result->GetCustomerProfileIdsResult->ids->long;
+ $this->assertTrue(is_array($customer_ids));
+ }
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+use \net\authorize\api\controller\base\ApiOperationBase;
+
+require_once __DIR__ . '/../autoload.php';
+//include if tests/bootstrap.php is not loaded automatically
+require_once __DIR__ . '/bootstrap.php';
+
+class Controller_Test extends PHPUnit_Framework_TestCase
+{
+ public function testARBGetSubscriptionList()
+ {
+ //$this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+
+ $name = (defined('AUTHORIZENET_API_LOGIN_ID') && ''!=AUTHORIZENET_API_LOGIN_ID) ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
+ $transactionKey = (defined('AUTHORIZENET_TRANSACTION_KEY') && ''!=AUTHORIZENET_TRANSACTION_KEY) ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
+
+ $merchantAuthentication = new net\authorize\api\contract\v1\MerchantAuthenticationType();
+ $merchantAuthentication->setName($name);
+ $merchantAuthentication->setTransactionKey($transactionKey);
+ //$merchantAuthentication->setMobileDeviceId()
+
+ $refId = 'ref' . time();
+
+ $sorting = new net\authorize\api\contract\v1\ARBGetSubscriptionListSortingType();
+ $sorting->setOrderBy('firstName');
+ $sorting->setOrderDescending(false);
+
+ $paging = new net\authorize\api\contract\v1\PagingType();
+ $paging->setLimit(10);
+ $paging->setOffset(1);
+
+ $request = new net\authorize\api\contract\v1\ARBGetSubscriptionListRequest();
+ $request->setSearchType('subscriptionActive');
+ $request->setRefId( $refId);
+ $request->setSorting($sorting);
+ $request->setPaging($paging);
+ $request->setMerchantAuthentication($merchantAuthentication);
+
+ //$controller = new ApiOperationBase($request, 'net\authorize\api\contract\v1\ARBGetSubscriptionListResponse');
+ $controller = new net\authorize\api\controller\ARBGetSubscriptionListController( $request);
+ $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
+
+ // Handle the response.
+ $this->assertNotNull($response, "null response");
+ $this->assertNotNull($response->getMessages());
+
+ $this->assertEquals("Ok", $response->getMessages()->getResultCode());
+ $this->assertEquals($response->getRefId(), $refId);
+ $this->assertTrue(0 < count($response->getMessages()));
+ foreach ($response->getMessages() as $message)
+ {
+ $this->assertEquals("I00001", $message->getCode());
+ $this->assertEquals("Successful.", $response->getText());
+ }
+ }
+
+ public function testARBGetSubscription()
+ {
+ $name = (defined('AUTHORIZENET_API_LOGIN_ID') && ''!=AUTHORIZENET_API_LOGIN_ID) ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
+ $transactionKey = (defined('AUTHORIZENET_TRANSACTION_KEY') && ''!=AUTHORIZENET_TRANSACTION_KEY) ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
+
+ $merchantAuthentication = new net\authorize\api\contract\v1\MerchantAuthenticationType();
+ $merchantAuthentication->setName($name);
+ $merchantAuthentication->setTransactionKey($transactionKey);
+
+ $refId = 'ref' . time();
+
+ $request = new net\authorize\api\contract\v1\ARBGetSubscriptionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId($refId);
+ $request->setSubscriptionId("2930242");
+
+ $controller = new net\authorize\api\controller\ARBGetSubscriptionController($request);
+
+ $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
+
+ $this->assertNotNull($response, "null response");
+ $this->assertNotNull($response->getMessages());
+
+ $this->assertEquals("Ok", $response->getMessages()->getResultCode());
+ $this->assertEquals($response->getRefId(), $refId);
+ $this->assertTrue(0 < count($response->getMessages()));
+
+ foreach ($response->getMessages() as $message)
+ {
+ $this->assertEquals("I00001", $message->getCode());
+ $this->assertEquals("Successful.", $response->getText());
+ }
+ }
+
+ public function testGetCustomerPaymentProfileList()
+ {
+ $name = (defined('AUTHORIZENET_API_LOGIN_ID') && ''!=AUTHORIZENET_API_LOGIN_ID) ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
+ $transactionKey = (defined('AUTHORIZENET_TRANSACTION_KEY') && ''!=AUTHORIZENET_TRANSACTION_KEY) ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
+
+ $merchantAuthentication = new net\authorize\api\contract\v1\MerchantAuthenticationType();
+ $merchantAuthentication->setName($name);
+ $merchantAuthentication->setTransactionKey($transactionKey);
+
+ $refId = 'ref' . time();
+
+ $paging = new net\authorize\api\contract\v1\PagingType();
+ $paging->setLimit("1000");
+ $paging->setOffset("1");
+
+
+ $sorting = new net\authorize\api\contract\v1\CustomerPaymentProfileSortingType();
+ $sorting->setOrderBy("id");
+ $sorting->setOrderDescending("false");
+
+ $request = new net\authorize\api\contract\v1\GetCustomerPaymentProfileListRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId($refId);
+ $request->setPaging($paging);
+ $request->setSorting($sorting);
+ $request->setSearchType("cardsExpiringInMonth");
+ $request->setMonth("2020-12");
+
+ $controller = new net\authorize\api\controller\GetCustomerPaymentProfileListController($request);
+ $response = $controller->executeWithApiResponse( \net\authorize\api\constants\ANetEnvironment::SANDBOX);
+
+ $this->assertNotNull($response, "null response");
+ $this->assertNotNull($response->getMessages());
+
+ $this->assertEquals("Ok", $response->getMessages()->getResultCode());
+ $this->assertEquals($response->getRefId(), $refId);
+ $this->assertTrue(0 < count($response->getMessages()));
+
+ foreach ($response->getMessages() as $message)
+ {
+ $this->assertEquals("I00001", $message->getCode());
+ $this->assertEquals("Successful.", $response->getText());
+ }
+ }
+
+ public function testDecryptPaymentData()
+ {
+ //$this->markTestSkipped('Ignoring for Travis. Will fix after release.'); //TODO
+
+ //using sandbox account log in to mint and enable visa checkout
+ //You'll get a VCO api key.
+ //on web page you can create and grab (from the JS console) Visa Checkout Payment Data
+ //http://brianmc.github.io/checkout.html
+
+ $name = (defined('AUTHORIZENET_API_LOGIN_ID') && ''!=AUTHORIZENET_API_LOGIN_ID) ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
+ $transactionKey = (defined('AUTHORIZENET_TRANSACTION_KEY') && ''!=AUTHORIZENET_TRANSACTION_KEY) ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
+
+ $merchantAuthentication = new net\authorize\api\contract\v1\MerchantAuthenticationType();
+ $merchantAuthentication->setName($name);
+ $merchantAuthentication->setTransactionKey($transactionKey);
+
+ $refId = 'ref' . time();
+ $callId = "8880580142324354001";
+
+ $opaqueData = new net\authorize\api\contract\v1\OpaqueDataType();
+ $opaqueData->setDataDescriptor("COMMON.VCO.ONLINE.PAYMENT");
+ $opaqueData->setDataKey("TD3LP3/b2IGMVDAxcAq8414q6L/6mKZ3RItyemrW4BAEIx3GQYOa52cduN1FIU7PQC/Ie4RHQZyp+amY4BTzPg485tn5lJTib++K1IuWbN+LaSCKQ/37g4b47mw02MFr");
+ $opaqueData->setDataValue("aRHcm1omUMYnVPE6DMRFbPiJm0u87k6QCFHvndmuIHU0WU4+hzro/WY69rBz6kb257Ns5ekXLkbv2YZ6aNIdYJR0M64XgVXnzgcuXaqePoRVPxjX1ko/Ab/qPSVRiDoBr9eOilxxuY0g3OG2IRVUWulHocSdCDoY0VArYcjme8eOD79d7b67q+bZ6MJPD7OBwaHaiy0JoMYBZc8BrMD2H3rsGb6eFpk8URLiZazZXus1gec00KU75sIDDlIFjSIKmBD3hrolsLIrNwiEdKGVSadAV2FXF2Mohxz9zOt1q2HssoyaK645PFy/Y0l6c3l3CxVYi1qjb9q23XafNUDg0xTEDZMnSTU7CudB0GifKFowokb56UOZ+OwyxWyPHNVhStWRhZbsWsDY1GAoyAr5HkXgS1XReWC8PPLB+ZP/tpOqDyocs6wBW/Ych8ht6IG/xdrzPmWRYvAWG6rK5/Weko4f0XSiX7oGS9jRdOR+6Xkllbm75KTXD+X0nJOvLsb6o5ZTe6wzTwUbckSASFVbFC4ViFSehdoyFI58P9byNMNI7NNN7Drs7vVDeT6l6bC4WumPEg24HqyKelMNuKzfWcG2kbgLuHBLaOoC0g2hMbKVYA0uVHMkf07kWgCpr/38SnAjfsI9Owo+EmBH4OJpXxqvQg5RGtaWSa0fOmckrKyfE90tx/aLAl6+DuWbi2yb4RNB9UWRCpEHcTlnQ89oOIZdxvAYIMZzl1IwkpwmQMul26ztcaKgbZXayRcUHzqSpYRnfibjec3Tdmz90IjyUK54qz87YwoCu4kX2u8pu5NcAMV9bBACsda+1hRG5WERKtNdJLiCoShZhWhypAh/yYU15uOHrCSk0FZRiFi3Ey56yZBNQ5owY7LTYRQbmKgmxcvmbOPf1/1OOFrNx6EljBns76TjePP5165sQOsDYNc0oZugcGpe3R9vMG6uESD9wzCyiJ/+AKqbHO0p5SO0FQexl+pKtMFqaOlynBmgNG1yKLPLHrVjgMiHXaITJ+59FA3YmqTO7k1gzyywMovUFCdCHFskGXeb4YLjA7qxseK+gc8X3eqo+0gujLp9yLwjuKJxQKJVAN2KqzMWJLT1o3C61HzHjxkkd7VnwDJRNc9mTmzF0v/E8pQ1WFl2DNjYAnYgeoP3Xvw0mOjeV4OFccDjfwSd/8pBNmHHLjDkGpNlCI7mPvrKHvIVlZMTOkP6xoiCf/je5BMblZ1GZ2E52Ed872HUnQ2ZNh97YMtaGWr+MzPdZ4ecRKQ+FeJWylbapQURtWgO3hfJi/Cq8luZXBSAwoTt5L31cOSqHyvb/XO2ZitRTUCHuU/+AhCPRWgIZQfqgpFRffrNM2vjHnFRCUIBq75uSI94GDjUHej95Y6LAR6/+9AcZV7fphOwy8q/YomANZ7DXfY68j5YM9CTSb19iSHfyQTd2rJ8Cq+dfpFO7KituAxP1UONiFRTNa9azmkpBgqo9IxRFbqOMkuqgzVjcTQkCCTaGRjow8pOLPmMnFD+qGvub56YTv8YFCHObBYYCKe4b8I7aSxT69/d6R3aNGcHzNwT/OdL02hM3AnDV+2WVGpV24kqXbs69oWEbbFPmOvVQrZJlWnFOg0N85DnZSvz5kc22Llpt2GWzyMw+9hMCDmYNrpxewUIRWym3Q+JV34I+o6b7tQgO5rQYrYSd1ONvhfGztHzP43MMi/5LLx0Hl/CYDeqaduY5hiUZftRJPTgwuDhwZfv0NWEswb8hWkymwYp7Gmxhf+sxi/GyCyUZbpQxRd4d3fX5VYRO1i0k6n1t1vkOgg/oYzTh7oOwyzuEhJqcSk0wdG++qsJw4J04qpoua6gRWs/j7n2732OgzRt1RFd7e5nwJRHGRwBvaqqXWpmqhrtPiaJRNf0vlZtmNvk+eZQpd501C22EjOBFtJg8lewG5CyG6dEX+RhIfqLAT1oobnaxLYoDfw4s5kNgtKj9MRzVGo6tbCfNMELHwC3/GMAStkci7tglkDLFKV/IG7cRtEZ0wEYVVIcX/HzL8M8IoaNQKVkRGb7/cnIiE8zi1uUZjnTXrNIKf0PdIVrr2JHgfw5az2tj921O7v/BwP8vyEl2IoCD5fYZpwBU8JAmGLhtMTFExOBDsQsJWp5w+cdJJ8VJg1w1bXt6NxcZ9U9qfkpf4wJ8TYROF349Zgcl0gjBjCRlTaQnisySXcZBfpweYCVuwKKHXw=");
+ //"partialShippingAddress":{"countryCode":"US","postalCode":"98103"},"callid":"8880580142324354001","vInitRequest":{"apikey":"GY3CQNLRHKE63GWCVLHH13Ff12umyj4ZglGhGdCM6y6Liy0YE","paymentRequest":{"currencyCode":"USD","total":"16.00"},"parentUrl":"http://brianmc.github.io/checkout.html","browserLocale":"en_US","clientId":"848a93dc-8d84-48fe-9d88-e7d1e9e50abb","allowEnrollment":true,"settings":{}}}
+
+ $request = new net\authorize\api\contract\v1\DecryptPaymentDataRequest();
+ $request->setRefId( $refId);
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setOpaqueData($opaqueData);
+ $request->setCallId($callId);
+
+ $controller = new net\authorize\api\controller\DecryptPaymentDataController( $request);
+ $response = $controller->executeWithApiResponse(\net\authorize\api\constants\ANetEnvironment::SANDBOX);
+
+ // Handle the response.
+ $this->assertNotNull($response, "null response");
+ $this->assertNotNull($response->getMessages());
+
+ $this->assertEquals("Ok", $response->getMessages()->getResultCode());
+ //$this->assertEquals($response->getRefId(), $refId);
+ $this->assertTrue(0 < count($response->getMessages()));
+ foreach ($response->getMessages() as $message)
+ {
+ $this->assertEquals("I00001", $message->getCode());
+ $this->assertEquals("Successful.", $response->getText());
+ }
+ }
+}
--- /dev/null
+<?php
+/**
+ * Bootstraps the AuthorizeNet PHP SDK test suite
+ */
+
+//properties set in file take precedence over environment
+//default the value to use
+$global_api_login_id = (defined('AUTHORIZENET_API_LOGIN_ID') && ''!=AUTHORIZENET_API_LOGIN_ID) ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
+$global_transaction_key = (defined('AUTHORIZENET_TRANSACTION_KEY') && ''!=AUTHORIZENET_TRANSACTION_KEY) ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
+if (!defined('AUTHORIZENET_LOG_FILE'))
+{
+ define( "AUTHORIZENET_LOG_FILE", "./authorize-net.log");
+}
+
+// Append to log file
+$logMessage = sprintf("Logging Started: %s\n", date(DATE_RFC2822));
+if (AUTHORIZENET_LOG_FILE)
+{
+ file_put_contents(AUTHORIZENET_LOG_FILE, $logMessage, FILE_APPEND);
+} else {
+ echo $logMessage;
+}
+
+// validate existence of available extensions
+if (!function_exists('simplexml_load_file'))
+{
+ $errorMessage = 'The AuthorizeNet SDK requires the SimpleXML PHP extension.';
+ throw new RuntimeException( $errorMessage );
+}
+
+if (!function_exists('curl_init'))
+{
+ $errorMessage = 'The AuthorizeNet SDK requires the cURL PHP extension.';
+ throw new RuntimeException( $errorMessage );
+}
+
+// validate existence of credentials
+if (null == $global_api_login_id || "" == $global_api_login_id)
+{
+ $errorMessage = "Property 'AUTHORIZENET_API_LOGIN_ID' not found. Define the property value or set the environment 'api_login_id'";
+ throw new RuntimeException( $errorMessage );
+}
+
+if (null == $global_transaction_key || "" == $global_transaction_key)
+{
+ $errorMessage = "Property 'AUTHORIZENET_TRANSACTION_KEY' not found. Define the property value or set the environment 'transaction_key'";
+ throw new RuntimeException( $errorMessage );
+}
+
+ini_set('error_reporting', E_ALL);
+
+/*
+$loader = require '../vendor/autoload.php';
+if (!isset($loader))
+{
+ $errorMessage = 'vendor/autoload.php could not be found.';
+ throw new RuntimeException( $errorMessage );
+}
+*/
--- /dev/null
+CONNECTED(00000003)
+---
+Certificate chain
+ 0 s:/C=US/ST=Utah/L=American Fork/O=Authorize.Net Corp./OU=AUTHORIZE.NET CORP./CN=secure.authorize.net
+ i:/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
+ 1 s:/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
+ i:/C=US/O=VeriSign, Inc./OU=Class 3 Public Primary Certification Authority
+---
+Server certificate
+-----BEGIN CERTIFICATE-----
+MIIDSTCCArKgAwIBAgIQfmO9EP9/fYY45sRzhqgfGzANBgkqhkiG9w0BAQUFADBM
+MQswCQYDVQQGEwJaQTElMCMGA1UEChMcVGhhd3RlIENvbnN1bHRpbmcgKFB0eSkg
+THRkLjEWMBQGA1UEAxMNVGhhd3RlIFNHQyBDQTAeFw0wOTA0MDkwMDAwMDBaFw0x
+MTA0MTEyMzU5NTlaMIGPMQswCQYDVQQGEwJVUzENMAsGA1UECBMEVXRhaDEWMBQG
+A1UEBxMNQW1lcmljYW4gRm9yazEcMBoGA1UEChMTQXV0aG9yaXplLk5ldCBDb3Jw
+LjEcMBoGA1UECxMTQVVUSE9SSVpFLk5FVCBDT1JQLjEdMBsGA1UEAxMUc2VjdXJl
+LmF1dGhvcml6ZS5uZXQwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAN0dh86L
+70MHbun7wTNGV0pNXsnebt3z9mCpndLUiBp5J/b57hQO5/HvevkhkDyCrky/Dn7y
+4SEJh6RHYuP4ZBk30DS8iH5dWCRHqSQgpMKhUl/+D7KHbVqgPzOpOR44TiSa1P5m
+Fv0qicvRR3iwSK/6ESywNvEJk1iiYPnpnnlvAgMBAAGjgecwgeQwDAYDVR0TAQH/
+BAIwADA2BgNVHR8ELzAtMCugKaAnhiVodHRwOi8vY3JsLnRoYXd0ZS5jb20vVGhh
+d3RlU0dDQ0EuY3JsMCgGA1UdJQQhMB8GCCsGAQUFBwMBBggrBgEFBQcDAgYJYIZI
+AYb4QgQBMHIGCCsGAQUFBwEBBGYwZDAiBggrBgEFBQcwAYYWaHR0cDovL29jc3Au
+dGhhd3RlLmNvbTA+BggrBgEFBQcwAoYyaHR0cDovL3d3dy50aGF3dGUuY29tL3Jl
+cG9zaXRvcnkvVGhhd3RlX1NHQ19DQS5jcnQwDQYJKoZIhvcNAQEFBQADgYEARa0l
+PaGn4TOw3KOMVu8eiSdho4Nmal6u9AWE3rWHDakO2/a1AkZTM2/Wpt6KI3fp6WWK
+LSsa9wLoVYSJ6pI7bmiJTvyx42yPP0PZXQSz05PHgTEGyW2jAn4N1hFvbTj28mZT
+jv2jd12xgrmX34nulLdydNaM8J7CauhMvqwwvZ0=
+-----END CERTIFICATE-----
+subject=/C=US/ST=Utah/L=American Fork/O=Authorize.Net Corp./OU=AUTHORIZE.NET CORP./CN=secure.authorize.net
+issuer=/C=ZA/O=Thawte Consulting (Pty) Ltd./CN=Thawte SGC CA
+---
+No client certificate CA names sent
+---
+SSL handshake has read 1791 bytes and written 306 bytes
+---
+New, TLSv1/SSLv3, Cipher is RC4-MD5
+Server public key is 1024 bit
+Compression: NONE
+Expansion: NONE
+SSL-Session:
+ Protocol : TLSv1
+ Cipher : RC4-MD5
+ Session-ID: 03130000B43AEDC6A4B731EB5FA519E70B6CAC52856869A8593521601F677C28
+ Session-ID-ctx:
+ Master-Key: C92AA33E812EFC279AAFF16922CFB3519F94FDA820ED3158A72BD97D3BB2D0EC938E7E71817958DB545EA2E147CCC84A
+ Key-Arg : None
+ Start Time: 1297707939
+ Timeout : 300 (sec)
+ Verify return code: 20 (unable to get local issuer certificate)
+---
--- /dev/null
+<?php
+namespace net\authorize\api\controller\test;
+
+use net\authorize\api\contract\v1 AS apiContract;
+use net\authorize\api\controller AS apiController;
+
+require_once __DIR__ . '/../../../../../autoload.php';
+//include if tests/bootstrap.php is not loaded automatically
+//require_once __DIR__ . '/../../../../bootstrap.php';
+
+class ApiCoreTestBase extends \PHPUnit_Framework_TestCase
+{
+ protected $paymentOne = null;
+ protected $orderType = null;
+ protected $customerDataOne = null;
+ protected $customerAddressOne = null;
+ protected $payPalOne = null;
+
+ protected $counter = 0;
+ protected $counterStr = "0";
+ protected $refId = '';
+
+ protected static $LoginName = '';
+ protected static $TransactionKey = '';
+
+ protected static $TestEnvironment = \net\authorize\api\constants\ANetEnvironment::SANDBOX;
+ protected static $log_file = false;
+
+ public static function setUpBeforeClass()
+ {
+ if (!defined('AUTHORIZENET_LOG_FILE'))
+ {
+ define( "AUTHORIZENET_LOG_FILE", __DIR__ . "/../../../../../log/authorize-net.log");
+ }
+ self::$LoginName = (defined('AUTHORIZENET_API_LOGIN_ID') && ''!=AUTHORIZENET_API_LOGIN_ID) ? AUTHORIZENET_API_LOGIN_ID : getenv("api_login_id");
+ self::$TransactionKey = (defined('AUTHORIZENET_TRANSACTION_KEY') && ''!=AUTHORIZENET_TRANSACTION_KEY) ? AUTHORIZENET_TRANSACTION_KEY : getenv("transaction_key");
+ self::$log_file = (defined('AUTHORIZENET_LOG_FILE') ? AUTHORIZENET_LOG_FILE : false);
+ }
+
+ public static function tearDownAfterClass()
+ {
+ }
+
+ public function __construct()
+ {
+ }
+
+ protected function setUp()
+ {
+ $logMessage = sprintf("\n%s: Test '%s' Starting.", \net\authorize\util\Helpers::now(), $this->getName());
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+
+ $this->refId = 'ref' . time();
+
+ $this->counter = rand();
+ $this->counterStr = sprintf("%s", $this->counter);
+
+ $driversLicenseOne = new apiContract\DriversLicenseType();
+ $driversLicenseOne->setNumber( $this->getRandomString( "DL-" ));
+ $driversLicenseOne->setState( "WA");
+ $driversLicenseOne->setDateOfBirth( "01/01/1960");
+
+ $customerOne = new apiContract\CustomerType();
+ $customerOne->setType("individual"); //TODO: CHANGE TO ENUM
+ $customerOne->setId( $this->getRandomString( "Id" ));
+ $customerOne->setEmail ( $this->counterStr . ".customerOne@test.anet.net");
+ $customerOne->setPhoneNumber("1234567890");
+ $customerOne->setFaxNumber("1234567891");
+ //$customerOne->setDriversLicense( $driversLicenseOne);
+ $customerOne->setTaxId( "911011011");
+
+ $creditCardOne = new apiContract\CreditCardType();
+ $creditCardOne->setCardNumber( "4111111111111111" );
+ $creditCardOne->setExpirationDate( "2038-12");
+
+ $this->paymentOne = new apiContract\PaymentType();
+ $this->paymentOne->setCreditCard( $creditCardOne);
+
+ $this->orderType = new apiContract\OrderType();
+ $this->orderType->setInvoiceNumber( $this->getRandomString( "Inv:" ));
+ $this->orderType->setDescription( $this->getRandomString( "Description" ));
+
+ $this->customerDataOne = new apiContract\CustomerDataType();
+ //$this->customerDataOne->setDriversLicense( $customerOne->getDriversLicense());
+ $this->customerDataOne->setEmail( $customerOne->getEmail());
+ $this->customerDataOne->setId( $customerOne->getId());
+ $this->customerDataOne->setTaxId( $customerOne->getTaxId());
+ $this->customerDataOne->setType( $customerOne->getType());
+
+ $this->customerAddressOne = new apiContract\CustomerAddressType();
+ $this->customerAddressOne->setFirstName( $this->getRandomString( "FName" ));
+ $this->customerAddressOne->setLastName( $this->getRandomString( "LName" ));
+ $this->customerAddressOne->setCompany( $this->getRandomString( "Company" ));
+ $this->customerAddressOne->setAddress( $this->getRandomString( "StreetAdd" ));
+ $this->customerAddressOne->setCity( "Bellevue");
+ $this->customerAddressOne->setState( "WA");
+ $this->customerAddressOne->setZip( "98004");
+ $this->customerAddressOne->setCountry( "USA");
+ $this->customerAddressOne->setPhoneNumber( $customerOne->getPhoneNumber());
+ $this->customerAddressOne->setFaxNumber( $customerOne->getFaxNumber());
+
+ $this->payPalOne = new apiContract\PayPalType();
+ $this->payPalOne->setPaypalLc( "IT" );
+ $this->payPalOne->setPaypalPayflowcolor( "FFFFF0");
+ $this->payPalOne->setSuccessUrl( $this->getRandomString( "http://success.anet.net"));
+ $this->payPalOne->setCancelUrl( $this->getRandomString( "http://cancel.anet.net"));
+ //payPalHdrImg = GetRandomString("Hdr"),
+ //payerID = GetRandomString("PayerId"),
+ }
+
+ protected function tearDown()
+ {
+ $logMessage = sprintf("\n%s: Test '%s' Completed.\n", \net\authorize\util\Helpers::now(), $this->getName());
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+ }
+
+ protected function getRandomString( $title)
+ {
+ return sprintf( "%s%s", $title, $this->counterStr);
+ }
+
+ protected function setValidAmount( $number)
+ {
+ $amount = $number;
+ if ( self::MaxTransactionAmount < $amount)
+ {
+ $amount = rand(1, self::MaxTransactionAmount); //generate between 1 and MaxTransactionAmount, inclusive
+ }
+ return $amount;
+ }
+
+ /**
+ * @param apiContract\ANetApiResponseType $response
+ */
+ protected static function displayMessages( apiContract\ANetApiResponseType $response)
+ {
+ if ( null != $response)
+ {
+ $logMessage = sprintf("\n%s: Controller Response is not null, iterating messages.", \net\authorize\util\Helpers::now());
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+ $msgCount = 0;
+ $allMessages = $response->getMessages();
+ if ( null != $allMessages )
+ {
+ $logMessage = sprintf("\n%s: Controller ResultCode: '%s'.", \net\authorize\util\Helpers::now(), $allMessages->getResultCode());
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+ if (null != $allMessages->getMessage())
+ {
+ foreach ($allMessages->getMessage() as $message)
+ {
+ $msgCount++;
+ $logMessage = sprintf("\n%d - Message, Code: '%s', Text: '%s'", $msgCount, $message->getCode(), $message->getText());
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+ }
+ }
+ }
+ $logMessage = sprintf("\n%s: Controller Response contains '%d' messages.", \net\authorize\util\Helpers::now(), $msgCount);
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+ }
+ else
+ {
+ $logMessage = sprintf("\n%s: Response is null.", \net\authorize\util\Helpers::now());
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+ }
+ }
+
+ const MaxTransactionAmount = 10000; //214747;
+}
--- /dev/null
+<?php
+namespace net\authorize\api\controller\test;
+
+use net\authorize\api\contract\v1 AS apiContract;
+use net\authorize\api\controller AS apiController;
+
+require_once __DIR__ . '/ApiCoreTestBase.php';
+
+class CreateTransactionControllerTest extends ApiCoreTestBase
+{
+ public function testCreateTransactionCreditCard()
+ {
+ $merchantAuthentication = new apiContract\MerchantAuthenticationType();
+ $merchantAuthentication->setName(self::$LoginName);
+ $merchantAuthentication->setTransactionKey(self::$TransactionKey);
+
+ //create a transaction
+ $transactionRequestType = new apiContract\TransactionRequestType();
+ $transactionRequestType->setTransactionType( "authCaptureTransaction"); // TODO Change to Enum
+ $transactionRequestType->setAmount( $this->setValidAmount( $this->counter));
+ $transactionRequestType->setPayment( $this->paymentOne);
+ $transactionRequestType->setOrder( $this->orderType);
+ $transactionRequestType->setCustomer( $this->customerDataOne);
+ $transactionRequestType->setBillTo( $this->customerAddressOne);
+
+ $request = new apiContract\CreateTransactionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId( $this->refId);
+ $request->setTransactionRequest( $transactionRequestType);
+
+ $controller = new apiController\CreateTransactionController($request);
+ $controller->execute( self::$TestEnvironment);
+ $response = $controller->getApiResponse();
+
+ // Handle and validate the response
+ self::displayMessages( $response);
+ $this->assertNotNull($response, "null response");
+ $this->assertNotNull($response->getMessages());
+ $logMessage = sprintf("\n%s: Controller Response ResultCode: '%s'.", \net\authorize\util\Helpers::now(), $response->getMessages()->getResultCode());
+ if (self::$log_file) {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ } else {
+ echo $logMessage;
+ }
+ $this->assertEquals("Ok", $response->getMessages()->getResultCode());
+ $this->assertEquals( $this->refId, $response->getRefId());
+ $this->assertTrue(0 < count($response->getMessages()));
+ foreach ($response->getMessages() as $message)
+ {
+ $this->assertEquals("I00001", $message->getCode());
+ $this->assertEquals("Successful.", $response->getText());
+ }
+ }
+
+ public function testCreateTransactionPayPal()
+ {
+ $merchantAuthentication = new apiContract\MerchantAuthenticationType();
+ $merchantAuthentication->setName(self::$LoginName);
+ $merchantAuthentication->setTransactionKey(self::$TransactionKey);
+
+ $paymentType = new apiContract\PaymentType();
+ $paymentType->setPayPal($this->payPalOne);
+
+ //create a transaction
+ $transactionRequestType = new apiContract\TransactionRequestType();
+ $transactionRequestType->setTransactionType( "authOnlyTransaction"); // TODO Change to Enum
+ $transactionRequestType->setAmount( $this->setValidAmount( $this->counter));
+ $transactionRequestType->setPayment( $paymentType);
+
+ $request = new apiContract\CreateTransactionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setTransactionRequest( $transactionRequestType);
+
+ $controller = new apiController\CreateTransactionController($request);
+ $response = $controller->executeWithApiResponse( self::$TestEnvironment);
+
+ // Handle the response.
+ $this->assertNotNull($response, "null response");
+ $this->assertNotNull($response->getMessages());
+
+ self::displayMessages( $response);
+ if ( "Ok" != $response->getMessages()->getResultCode())
+ {
+ $this->displayTransactionMessages( $response);
+ //Ignore assertion for now
+ //$this->assertTrue( false, "Should not reach here.");
+ }
+ else
+ {
+ $this->assertEquals("Ok", $response->getMessages()->getResultCode());
+ $this->assertTrue(0 < count($response->getMessages()));
+ foreach ($response->getMessages() as $message)
+ {
+ $this->assertEquals("I00001", $message->getCode());
+ $this->assertEquals("Successful.", $response->getText());
+ }
+ }
+ }
+
+ public function testCreateTransactionApplePay()
+ {
+ $merchantAuthentication = new apiContract\MerchantAuthenticationType();
+ $merchantAuthentication->setName(self::$LoginName);
+ $merchantAuthentication->setTransactionKey(self::$TransactionKey);
+
+ $OpaqueData = new apiContract\OpaqueDataType();
+ $OpaqueData->setDataDescriptor("COMMON.APPLE.INAPP.PAYMENT");
+ $OpaqueData->setDataValue("eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS3V0WGY2YWpcL284WkliS25yS1E4U2gwb3VMQUtsb1VNbit2UHU0K0E3V0tycXJhdXo5SnZPUXA2dmhJcStIS2pVY1VOQ0lUUHlGaG1PRXRxK0grdzB2UmExQ0U2V2hGQk5uQ0hxenpXS2NrQlwvMG5xTFpSVFliRjBwK3Z5QmlWYVdIZWdoRVJmSHhSdGJ6cGVjelJQUHVGc2ZwSFZzNDhvUExDXC9rXC8xTU5kNDdrelwvcEhEY1JcL0R5NmFVTStsTmZvaWx5XC9RSk4rdFMzbTBIZk90SVNBUHFPbVhlbXZyNnhKQ2pDWmxDdXcwQzltWHpcL29iSHBvZnVJRVM4cjljcUdHc1VBUERwdzdnNjQybTRQendLRitIQnVZVW5lV0RCTlNEMnU2amJBRzMiLCJ2ZXJzaW9uIjoiRUNfdjEiLCJoZWFkZXIiOnsiYXBwbGljYXRpb25EYXRhIjoiOTRlZTA1OTMzNWU1ODdlNTAxY2M0YmY5MDYxM2UwODE0ZjAwYTdiMDhiYzdjNjQ4ZmQ4NjVhMmFmNmEyMmNjMiIsInRyYW5zYWN0aW9uSWQiOiJjMWNhZjVhZTcyZjAwMzlhODJiYWQ5MmI4MjgzNjM3MzRmODViZjJmOWNhZGYxOTNkMWJhZDlkZGNiNjBhNzk1IiwiZXBoZW1lcmFsUHVibGljS2V5IjoiTUlJQlN6Q0NBUU1HQnlxR1NNNDlBZ0V3Z2ZjQ0FRRXdMQVlIS29aSXpqMEJBUUloQVBcL1wvXC9cLzhBQUFBQkFBQUFBQUFBQUFBQUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL01Gc0VJUFwvXC9cL1wvOEFBQUFCQUFBQUFBQUFBQUFBQUFBQVwvXC9cL1wvXC9cL1wvXC9cL1wvXC9cL1wvXC9cLzhCQ0JheGpYWXFqcVQ1N1BydlZWMm1JYThaUjBHc014VHNQWTd6ancrSjlKZ1N3TVZBTVNkTmdpRzV3U1RhbVo0NFJPZEpyZUJuMzZRQkVFRWF4ZlI4dUVzUWtmNHZPYmxZNlJBOG5jRGZZRXQ2ek9nOUtFNVJkaVl3cFpQNDBMaVwvaHBcL200N242MHA4RDU0V0s4NHpWMnN4WHM3THRrQm9ONzlSOVFJaEFQXC9cL1wvXC84QUFBQUFcL1wvXC9cL1wvXC9cL1wvXC9cLys4NXZxdHB4ZWVoUE81eXNMOFl5VlJBZ0VCQTBJQUJHbStnc2wwUFpGVFwva0RkVVNreHd5Zm84SnB3VFFRekJtOWxKSm5tVGw0REdVdkFENEdzZUdqXC9wc2hCWjBLM1RldXFEdFwvdERMYkUrOFwvbTB5Q21veHc9IiwicHVibGljS2V5SGFzaCI6IlwvYmI5Q05DMzZ1QmhlSEZQYm1vaEI3T28xT3NYMkora0pxdjQ4ek9WVmlRPSJ9LCJzaWduYXR1cmUiOiJNSUlEUWdZSktvWklodmNOQVFjQ29JSURNekNDQXk4Q0FRRXhDekFKQmdVckRnTUNHZ1VBTUFzR0NTcUdTSWIzRFFFSEFhQ0NBaXN3Z2dJbk1JSUJsS0FEQWdFQ0FoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQXdKekVsTUNNR0ExVUVBeDRjQUdNQWFBQnRBR0VBYVFCQUFIWUFhUUJ6QUdFQUxnQmpBRzhBYlRBZUZ3MHhOREF4TURFd05qQXdNREJhRncweU5EQXhNREV3TmpBd01EQmFNQ2N4SlRBakJnTlZCQU1lSEFCakFHZ0FiUUJoQUdrQVFBQjJBR2tBY3dCaEFDNEFZd0J2QUcwd2daOHdEUVlKS29aSWh2Y05BUUVCQlFBRGdZMEFNSUdKQW9HQkFOQzgra2d0Z212V0YxT3pqZ0ROcmpURUJSdW9cLzVNS3ZsTTE0NnBBZjdHeDQxYmxFOXc0ZklYSkFEN0ZmTzdRS2pJWFlOdDM5ckx5eTd4RHdiXC81SWtaTTYwVFoyaUkxcGo1NVVjOGZkNGZ6T3BrM2Z0WmFRR1hOTFlwdEcxZDlWN0lTODJPdXA5TU1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0=");
+
+ $paymentType = new apiContract\PaymentType();
+ $paymentType->setOpaqueData( $OpaqueData);
+
+ //create a transaction
+ $transactionRequestType = new apiContract\TransactionRequestType();
+ $transactionRequestType->setTransactionType( "authCaptureTransaction"); // TODO Change to Enum
+ $transactionRequestType->setAmount( $this->setValidAmount( $this->counter));
+ $transactionRequestType->setPayment( $paymentType);
+
+ $request = new apiContract\CreateTransactionRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setTransactionRequest( $transactionRequestType);
+
+ $controller = new apiController\CreateTransactionController($request);
+ $response = $controller->executeWithApiResponse( self::$TestEnvironment);
+
+ // Handle the response.
+ $this->assertNotNull($response, "null response");
+ $this->assertNotNull($response->getMessages());
+
+ self::displayMessages( $response);
+ if ( "Ok" != $response->getMessages()->getResultCode())
+ {
+ $this->displayTransactionMessages( $response);
+ //Ignore assertion for now
+ //$this->assertTrue( false, "Should not reach here.");
+ }
+ else
+ {
+ $this->assertEquals("Ok", $response->getMessages()->getResultCode());
+ $this->assertTrue(0 < count($response->getMessages()));
+ foreach ($response->getMessages() as $message)
+ {
+ $this->assertEquals("I00001", $message->getCode());
+ $this->assertEquals("Successful.", $response->getText());
+ }
+ }
+ }
+
+
+ function displayTransactionMessages( apiContract\CreateTransactionResponse $response)
+ {
+ if ( null != $response)
+ {
+ $logMessage = sprintf("\n%s: Displaying Transaction Response.", \net\authorize\util\Helpers::now());
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+
+ if ( null != $response->getTransactionResponse())
+ {
+ $logMessage = sprintf("\n%s: Transaction Response Code: '%s'.", \net\authorize\util\Helpers::now(), $response->getTransactionResponse()->getResponseCode());
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+
+ $allMessages = $response->getTransactionResponse()->getMessages();
+ $allErrors = $response->getTransactionResponse()->getErrors();
+ $errorCount = 0;
+ if ( null != $allErrors)
+ {
+ foreach ( $allErrors as $error)
+ {
+ $errorCount++;
+ $logMessage = sprintf("\n%s: %d - Error: Code:'%s', Text:'%s'", \net\authorize\util\Helpers::now(), $errorCount, $error->getErrorCode(), $error->getErrorText());
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+ }
+ }
+ $messageCount = 0;
+ if ( null != $allMessages)
+ {
+ foreach ( $allMessages as $message)
+ {
+ $messageCount++;
+ //$logMessage = sprintf("\n%s: %d - Message: Code:'%s', Description:'%s'", \net\authorize\util\Helpers::now(), $errorCount, $message->getCode(), $message->getDescription());
+ $logMessage = sprintf("\n%s: %d - Message: ", \net\authorize\util\Helpers::now(), $messageCount);
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+ }
+ }
+ $logMessage = sprintf("\n%s: Transaction Response, Errors: '%d', Messages: '%d'.", \net\authorize\util\Helpers::now(), $errorCount, $messageCount);
+ echo $logMessage;
+ if (self::$log_file)
+ {
+ file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
+ }
+ }
+ }
+ }
+}
--- /dev/null
+<?php
+namespace net\authorize\api\controller\test;
+
+use net\authorize\api\contract\v1 AS apiContract;
+use net\authorize\api\controller AS apiController;
+
+require_once __DIR__ . '/ApiCoreTestBase.php';
+
+class LogoutControllerTest extends ApiCoreTestBase
+{
+ public function testLogout()
+ {
+ $merchantAuthentication = new apiContract\MerchantAuthenticationType();
+ $merchantAuthentication->setName(self::$LoginName);
+ $merchantAuthentication->setTransactionKey(self::$TransactionKey);
+
+ $request = new apiContract\LogoutRequest();
+ $request->setMerchantAuthentication($merchantAuthentication);
+ $request->setRefId( $this->refId);
+
+ $controller = new apiController\LogoutController($request);
+ $response = $controller->executeWithApiResponse( self::$TestEnvironment);
+ // Handle the response.
+ $this->assertNotNull($response, "null response");
+ $this->assertNotNull($response->getMessages());
+
+ $this->assertEquals("Ok", $response->getMessages()->getResultCode());
+ $this->assertEquals( $this->refId, $response->getRefId());
+ $this->assertTrue(0 < count($response->getMessages()));
+ foreach ($response->getMessages() as $message)
+ {
+ $this->assertEquals("I00001", $message->getCode());
+ $this->assertEquals("Successful.", $response->getText());
+ }
+ }
+}
--- /dev/null
+<html><body><h2 id="AuthorizeNet_SOAP_Test">AuthorizeNet_SOAP_</h2><ul><li>Save soap doc</li><li>Get customer ids</li></ul><h2 id="AuthorizeNetAIM_Sandbox_Test">AuthorizeNetAIM_Sandbox_</h2><ul><li>Auth capture</li><li>Auth capture alternate</li><li>Auth capture short</li><li>Auth capture partial</li><li>Auth capture short no verify</li><li>Aim response fields</li><li>Void</li><li>Void short</li><li>Auth capture e check sandbox</li><li>Amex</li><li>Discover</li><li>Visa</li><li>Auth only</li><li>Auth capture void</li><li>Advanced a i m</li><li>Auth capture custom fields</li><li>Encap character</li><li>Auth capture set multiple custom fields</li><li>Invalid merchant credentials</li><li>Invalid credit card</li><li>Error</li><li>Multiple line items</li><li>All fields long method</li><li>Response methods</li><li>Set bad field</li></ul><h2 id="AuthorizeNetAIM_Live_Test">AuthorizeNetAIM_Live_</h2><ul><li>Auth capture set e check method</li><li>Auth capture e check</li><li>Auth capture live server test request</li><li>Auth capture live server</li><li>Invalid credentials</li></ul><h2 id="AuthorizeNetARB_Test">AuthorizeNetARB_</h2><ul><li><strike>All methods</strike></li><li>Create subscription long</li><li>Create subscription e check</li></ul><h2 id="AuthorizeNetCIM_Test">AuthorizeNetCIM_</h2><ul><li>Delete all customer profiles</li><li>X path</li><li>Create customer profile</li><li>Get customer profile</li><li>Create customer profile with validation mode</li><li>Update split tender group</li><li>All</li><li>Get customer profile ids</li></ul><h2 id="AuthorizeNetCP_Test">AuthorizeNetCP_</h2><ul><li>Auth capture</li><li>Auth capture track 1</li><li>Auth capture track</li><li>Auth capture track 2 error</li><li>Response fields</li><li>Xml response</li><li>Xml response failure</li></ul><h2 id="AuthorizeNetDPM_Test">AuthorizeNetDPM_</h2><ul><li>Generate fingerprint</li><li>Get credit card form</li><li>Relay response url</li></ul><h2 id="AuthorizeNetSIM_Test">AuthorizeNetSIM_</h2><ul><li>Generate hash</li><li>Amount</li><li>Is auth net</li><li>Is error</li></ul><h2 id="AuthorizeNetTD_Test">AuthorizeNetTD_</h2><ul><li>Get settled batch list</li><li>Get settled batch list include statistics</li><li>Get settled batch list for month</li><li>Get transactions for day</li><li>Get transaction list</li><li>Get transaction details</li></ul></body></html>
\ No newline at end of file
--- /dev/null
+<?php
+
+// autoload.php @generated by Composer
+
+require_once __DIR__ . '/composer' . '/autoload_real.php';
+
+return ComposerAutoloaderInitafd44b6f62840ab562c37aa2abd6f1ad::getLoader();
--- /dev/null
+<?php
+
+/*
+ * This file is part of Composer.
+ *
+ * (c) Nils Adermann <naderman@naderman.de>
+ * Jordi Boggiano <j.boggiano@seld.be>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Composer\Autoload;
+
+/**
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
+ *
+ * $loader = new \Composer\Autoload\ClassLoader();
+ *
+ * // register classes with namespaces
+ * $loader->add('Symfony\Component', __DIR__.'/component');
+ * $loader->add('Symfony', __DIR__.'/framework');
+ *
+ * // activate the autoloader
+ * $loader->register();
+ *
+ * // to enable searching the include path (eg. for PEAR packages)
+ * $loader->setUseIncludePath(true);
+ *
+ * In this example, if you try to use a class in the Symfony\Component
+ * namespace or one of its children (Symfony\Component\Console for instance),
+ * the autoloader will first look for the class under the component/
+ * directory, and it will then fallback to the framework/ directory if not
+ * found before giving up.
+ *
+ * This class is loosely based on the Symfony UniversalClassLoader.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ * @author Jordi Boggiano <j.boggiano@seld.be>
+ * @see http://www.php-fig.org/psr/psr-0/
+ * @see http://www.php-fig.org/psr/psr-4/
+ */
+class ClassLoader
+{
+ // PSR-4
+ private $prefixLengthsPsr4 = array();
+ private $prefixDirsPsr4 = array();
+ private $fallbackDirsPsr4 = array();
+
+ // PSR-0
+ private $prefixesPsr0 = array();
+ private $fallbackDirsPsr0 = array();
+
+ private $useIncludePath = false;
+ private $classMap = array();
+
+ private $classMapAuthoritative = false;
+
+ public function getPrefixes()
+ {
+ if (!empty($this->prefixesPsr0)) {
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
+ }
+
+ return array();
+ }
+
+ public function getPrefixesPsr4()
+ {
+ return $this->prefixDirsPsr4;
+ }
+
+ public function getFallbackDirs()
+ {
+ return $this->fallbackDirsPsr0;
+ }
+
+ public function getFallbackDirsPsr4()
+ {
+ return $this->fallbackDirsPsr4;
+ }
+
+ public function getClassMap()
+ {
+ return $this->classMap;
+ }
+
+ /**
+ * @param array $classMap Class to filename map
+ */
+ public function addClassMap(array $classMap)
+ {
+ if ($this->classMap) {
+ $this->classMap = array_merge($this->classMap, $classMap);
+ } else {
+ $this->classMap = $classMap;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix, either
+ * appending or prepending to the ones previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param array|string $paths The PSR-0 root directories
+ * @param bool $prepend Whether to prepend the directories
+ */
+ public function add($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ if ($prepend) {
+ $this->fallbackDirsPsr0 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr0
+ );
+ } else {
+ $this->fallbackDirsPsr0 = array_merge(
+ $this->fallbackDirsPsr0,
+ (array) $paths
+ );
+ }
+
+ return;
+ }
+
+ $first = $prefix[0];
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
+
+ return;
+ }
+ if ($prepend) {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixesPsr0[$first][$prefix]
+ );
+ } else {
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
+ $this->prefixesPsr0[$first][$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace, either
+ * appending or prepending to the ones previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param array|string $paths The PSR-4 base directories
+ * @param bool $prepend Whether to prepend the directories
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function addPsr4($prefix, $paths, $prepend = false)
+ {
+ if (!$prefix) {
+ // Register directories for the root namespace.
+ if ($prepend) {
+ $this->fallbackDirsPsr4 = array_merge(
+ (array) $paths,
+ $this->fallbackDirsPsr4
+ );
+ } else {
+ $this->fallbackDirsPsr4 = array_merge(
+ $this->fallbackDirsPsr4,
+ (array) $paths
+ );
+ }
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
+ // Register directories for a new namespace.
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ } elseif ($prepend) {
+ // Prepend directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ (array) $paths,
+ $this->prefixDirsPsr4[$prefix]
+ );
+ } else {
+ // Append directories for an already registered namespace.
+ $this->prefixDirsPsr4[$prefix] = array_merge(
+ $this->prefixDirsPsr4[$prefix],
+ (array) $paths
+ );
+ }
+ }
+
+ /**
+ * Registers a set of PSR-0 directories for a given prefix,
+ * replacing any others previously set for this prefix.
+ *
+ * @param string $prefix The prefix
+ * @param array|string $paths The PSR-0 base directories
+ */
+ public function set($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr0 = (array) $paths;
+ } else {
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Registers a set of PSR-4 directories for a given namespace,
+ * replacing any others previously set for this namespace.
+ *
+ * @param string $prefix The prefix/namespace, with trailing '\\'
+ * @param array|string $paths The PSR-4 base directories
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function setPsr4($prefix, $paths)
+ {
+ if (!$prefix) {
+ $this->fallbackDirsPsr4 = (array) $paths;
+ } else {
+ $length = strlen($prefix);
+ if ('\\' !== $prefix[$length - 1]) {
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
+ }
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
+ }
+ }
+
+ /**
+ * Turns on searching the include path for class files.
+ *
+ * @param bool $useIncludePath
+ */
+ public function setUseIncludePath($useIncludePath)
+ {
+ $this->useIncludePath = $useIncludePath;
+ }
+
+ /**
+ * Can be used to check if the autoloader uses the include path to check
+ * for classes.
+ *
+ * @return bool
+ */
+ public function getUseIncludePath()
+ {
+ return $this->useIncludePath;
+ }
+
+ /**
+ * Turns off searching the prefix and fallback directories for classes
+ * that have not been registered with the class map.
+ *
+ * @param bool $classMapAuthoritative
+ */
+ public function setClassMapAuthoritative($classMapAuthoritative)
+ {
+ $this->classMapAuthoritative = $classMapAuthoritative;
+ }
+
+ /**
+ * Should class lookup fail if not found in the current class map?
+ *
+ * @return bool
+ */
+ public function isClassMapAuthoritative()
+ {
+ return $this->classMapAuthoritative;
+ }
+
+ /**
+ * Registers this instance as an autoloader.
+ *
+ * @param bool $prepend Whether to prepend the autoloader or not
+ */
+ public function register($prepend = false)
+ {
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
+ }
+
+ /**
+ * Unregisters this instance as an autoloader.
+ */
+ public function unregister()
+ {
+ spl_autoload_unregister(array($this, 'loadClass'));
+ }
+
+ /**
+ * Loads the given class or interface.
+ *
+ * @param string $class The name of the class
+ * @return bool|null True if loaded, null otherwise
+ */
+ public function loadClass($class)
+ {
+ if ($file = $this->findFile($class)) {
+ includeFile($file);
+
+ return true;
+ }
+ }
+
+ /**
+ * Finds the path to the file where the class is defined.
+ *
+ * @param string $class The name of the class
+ *
+ * @return string|false The path if found, false otherwise
+ */
+ public function findFile($class)
+ {
+ // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
+ if ('\\' == $class[0]) {
+ $class = substr($class, 1);
+ }
+
+ // class map lookup
+ if (isset($this->classMap[$class])) {
+ return $this->classMap[$class];
+ }
+ if ($this->classMapAuthoritative) {
+ return false;
+ }
+
+ $file = $this->findFileWithExtension($class, '.php');
+
+ // Search for Hack files if we are running on HHVM
+ if ($file === null && defined('HHVM_VERSION')) {
+ $file = $this->findFileWithExtension($class, '.hh');
+ }
+
+ if ($file === null) {
+ // Remember that this class does not exist.
+ return $this->classMap[$class] = false;
+ }
+
+ return $file;
+ }
+
+ private function findFileWithExtension($class, $ext)
+ {
+ // PSR-4 lookup
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
+
+ $first = $class[0];
+ if (isset($this->prefixLengthsPsr4[$first])) {
+ foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
+ if (0 === strpos($class, $prefix)) {
+ foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-4 fallback dirs
+ foreach ($this->fallbackDirsPsr4 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 lookup
+ if (false !== $pos = strrpos($class, '\\')) {
+ // namespaced class name
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
+ } else {
+ // PEAR-like class name
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
+ }
+
+ if (isset($this->prefixesPsr0[$first])) {
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
+ if (0 === strpos($class, $prefix)) {
+ foreach ($dirs as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+ }
+ }
+ }
+
+ // PSR-0 fallback dirs
+ foreach ($this->fallbackDirsPsr0 as $dir) {
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
+ return $file;
+ }
+ }
+
+ // PSR-0 include paths.
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
+ return $file;
+ }
+ }
+}
+
+/**
+ * Scope isolated include.
+ *
+ * Prevents access to $this/self from included files.
+ */
+function includeFile($file)
+{
+ include $file;
+}
--- /dev/null
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: Composer
+Upstream-Contact: Jordi Boggiano <j.boggiano@seld.be>
+Source: https://github.com/composer/composer
+
+Files: *
+Copyright: 2016, Nils Adermann <naderman@naderman.de>
+ 2016, Jordi Boggiano <j.boggiano@seld.be>
+License: Expat
+
+Files: res/cacert.pem
+Copyright: 2015, Mozilla Foundation
+License: MPL-2.0
+
+Files: src/Composer/Util/RemoteFilesystem.php
+ src/Composer/Util/TlsHelper.php
+Copyright: 2016, Nils Adermann <naderman@naderman.de>
+ 2016, Jordi Boggiano <j.boggiano@seld.be>
+ 2013, Evan Coury <me@evancoury.com>
+License: Expat and BSD-2-Clause
+
+License: BSD-2-Clause
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+ .
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ .
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ .
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+License: Expat
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is furnished
+ to do so, subject to the following conditions:
+ .
+ The above copyright notice and this permission notice shall be included in all
+ copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+License: MPL-2.0
+ 1. Definitions
+ --------------
+ .
+ 1.1. "Contributor"
+ means each individual or legal entity that creates, contributes to
+ the creation of, or owns Covered Software.
+ .
+ 1.2. "Contributor Version"
+ means the combination of the Contributions of others (if any) used
+ by a Contributor and that particular Contributor's Contribution.
+ .
+ 1.3. "Contribution"
+ means Covered Software of a particular Contributor.
+ .
+ 1.4. "Covered Software"
+ means Source Code Form to which the initial Contributor has attached
+ the notice in Exhibit A, the Executable Form of such Source Code
+ Form, and Modifications of such Source Code Form, in each case
+ including portions thereof.
+ .
+ 1.5. "Incompatible With Secondary Licenses"
+ means
+ .
+ (a) that the initial Contributor has attached the notice described
+ in Exhibit B to the Covered Software; or
+ .
+ (b) that the Covered Software was made available under the terms of
+ version 1.1 or earlier of the License, but not also under the
+ terms of a Secondary License.
+ .
+ 1.6. "Executable Form"
+ means any form of the work other than Source Code Form.
+ .
+ 1.7. "Larger Work"
+ means a work that combines Covered Software with other material, in
+ a separate file or files, that is not Covered Software.
+ .
+ 1.8. "License"
+ means this document.
+ .
+ 1.9. "Licensable"
+ means having the right to grant, to the maximum extent possible,
+ whether at the time of the initial grant or subsequently, any and
+ all of the rights conveyed by this License.
+ .
+ 1.10. "Modifications"
+ means any of the following:
+ .
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+ .
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+ .
+ 1.11. "Patent Claims" of a Contributor
+ means any patent claim(s), including without limitation, method,
+ process, and apparatus claims, in any patent Licensable by such
+ Contributor that would be infringed, but for the grant of the
+ License, by the making, using, selling, offering for sale, having
+ made, import, or transfer of either its Contributions or its
+ Contributor Version.
+ .
+ 1.12. "Secondary License"
+ means either the GNU General Public License, Version 2.0, the GNU
+ Lesser General Public License, Version 2.1, the GNU Affero General
+ Public License, Version 3.0, or any later versions of those
+ licenses.
+ .
+ 1.13. "Source Code Form"
+ means the form of the work preferred for making modifications.
+ .
+ 1.14. "You" (or "Your")
+ means an individual or a legal entity exercising rights under this
+ License. For legal entities, "You" includes any entity that
+ controls, is controlled by, or is under common control with You. For
+ purposes of this definition, "control" means (a) the power, direct
+ or indirect, to cause the direction or management of such entity,
+ whether by contract or otherwise, or (b) ownership of more than
+ fifty percent (50%) of the outstanding shares or beneficial
+ ownership of such entity.
+ .
+ 2. License Grants and Conditions
+ --------------------------------
+ .
+ 2.1. Grants
+ .
+ Each Contributor hereby grants You a world-wide, royalty-free,
+ non-exclusive license:
+ .
+ (a) under intellectual property rights (other than patent or trademark)
+ Licensable by such Contributor to use, reproduce, make available,
+ modify, display, perform, distribute, and otherwise exploit its
+ Contributions, either on an unmodified basis, with Modifications, or
+ as part of a Larger Work; and
+ .
+ (b) under Patent Claims of such Contributor to make, use, sell, offer
+ for sale, have made, import, and otherwise transfer either its
+ Contributions or its Contributor Version.
+ .
+ 2.2. Effective Date
+ .
+ The licenses granted in Section 2.1 with respect to any Contribution
+ become effective for each Contribution on the date the Contributor first
+ distributes such Contribution.
+ .
+ 2.3. Limitations on Grant Scope
+ .
+ The licenses granted in this Section 2 are the only rights granted under
+ this License. No additional rights or licenses will be implied from the
+ distribution or licensing of Covered Software under this License.
+ Notwithstanding Section 2.1(b) above, no patent license is granted by a
+ Contributor:
+ .
+ (a) for any code that a Contributor has removed from Covered Software;
+ or
+ .
+ (b) for infringements caused by: (i) Your and any other third party's
+ modifications of Covered Software, or (ii) the combination of its
+ Contributions with other software (except as part of its Contributor
+ Version); or
+ .
+ (c) under Patent Claims infringed by Covered Software in the absence of
+ its Contributions.
+ .
+ This License does not grant any rights in the trademarks, service marks,
+ or logos of any Contributor (except as may be necessary to comply with
+ the notice requirements in Section 3.4).
+ .
+ 2.4. Subsequent Licenses
+ .
+ No Contributor makes additional grants as a result of Your choice to
+ distribute the Covered Software under a subsequent version of this
+ License (see Section 10.2) or under the terms of a Secondary License (if
+ permitted under the terms of Section 3.3).
+ .
+ 2.5. Representation
+ .
+ Each Contributor represents that the Contributor believes its
+ Contributions are its original creation(s) or it has sufficient rights
+ to grant the rights to its Contributions conveyed by this License.
+ .
+ 2.6. Fair Use
+ .
+ This License is not intended to limit any rights You have under
+ applicable copyright doctrines of fair use, fair dealing, or other
+ equivalents.
+ .
+ 2.7. Conditions
+ .
+ Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+ in Section 2.1.
+ .
+ 3. Responsibilities
+ -------------------
+ .
+ 3.1. Distribution of Source Form
+ .
+ All distribution of Covered Software in Source Code Form, including any
+ Modifications that You create or to which You contribute, must be under
+ the terms of this License. You must inform recipients that the Source
+ Code Form of the Covered Software is governed by the terms of this
+ License, and how they can obtain a copy of this License. You may not
+ attempt to alter or restrict the recipients' rights in the Source Code
+ Form.
+ .
+ 3.2. Distribution of Executable Form
+ .
+ If You distribute Covered Software in Executable Form then:
+ .
+ (a) such Covered Software must also be made available in Source Code
+ Form, as described in Section 3.1, and You must inform recipients of
+ the Executable Form how they can obtain a copy of such Source Code
+ Form by reasonable means in a timely manner, at a charge no more
+ than the cost of distribution to the recipient; and
+ .
+ (b) You may distribute such Executable Form under the terms of this
+ License, or sublicense it under different terms, provided that the
+ license for the Executable Form does not attempt to limit or alter
+ the recipients' rights in the Source Code Form under this License.
+ .
+ 3.3. Distribution of a Larger Work
+ .
+ You may create and distribute a Larger Work under terms of Your choice,
+ provided that You also comply with the requirements of this License for
+ the Covered Software. If the Larger Work is a combination of Covered
+ Software with a work governed by one or more Secondary Licenses, and the
+ Covered Software is not Incompatible With Secondary Licenses, this
+ License permits You to additionally distribute such Covered Software
+ under the terms of such Secondary License(s), so that the recipient of
+ the Larger Work may, at their option, further distribute the Covered
+ Software under the terms of either this License or such Secondary
+ License(s).
+ .
+ 3.4. Notices
+ .
+ You may not remove or alter the substance of any license notices
+ (including copyright notices, patent notices, disclaimers of warranty,
+ or limitations of liability) contained within the Source Code Form of
+ the Covered Software, except that You may alter any license notices to
+ the extent required to remedy known factual inaccuracies.
+ .
+ 3.5. Application of Additional Terms
+ .
+ You may choose to offer, and to charge a fee for, warranty, support,
+ indemnity or liability obligations to one or more recipients of Covered
+ Software. However, You may do so only on Your own behalf, and not on
+ behalf of any Contributor. You must make it absolutely clear that any
+ such warranty, support, indemnity, or liability obligation is offered by
+ You alone, and You hereby agree to indemnify every Contributor for any
+ liability incurred by such Contributor as a result of warranty, support,
+ indemnity or liability terms You offer. You may include additional
+ disclaimers of warranty and limitations of liability specific to any
+ jurisdiction.
+ .
+ 4. Inability to Comply Due to Statute or Regulation
+ ---------------------------------------------------
+ .
+ If it is impossible for You to comply with any of the terms of this
+ License with respect to some or all of the Covered Software due to
+ statute, judicial order, or regulation then You must: (a) comply with
+ the terms of this License to the maximum extent possible; and (b)
+ describe the limitations and the code they affect. Such description must
+ be placed in a text file included with all distributions of the Covered
+ Software under this License. Except to the extent prohibited by statute
+ or regulation, such description must be sufficiently detailed for a
+ recipient of ordinary skill to be able to understand it.
+ .
+ 5. Termination
+ --------------
+ .
+ 5.1. The rights granted under this License will terminate automatically
+ if You fail to comply with any of its terms. However, if You become
+ compliant, then the rights granted under this License from a particular
+ Contributor are reinstated (a) provisionally, unless and until such
+ Contributor explicitly and finally terminates Your grants, and (b) on an
+ ongoing basis, if such Contributor fails to notify You of the
+ non-compliance by some reasonable means prior to 60 days after You have
+ come back into compliance. Moreover, Your grants from a particular
+ Contributor are reinstated on an ongoing basis if such Contributor
+ notifies You of the non-compliance by some reasonable means, this is the
+ first time You have received notice of non-compliance with this License
+ from such Contributor, and You become compliant prior to 30 days after
+ Your receipt of the notice.
+ .
+ 5.2. If You initiate litigation against any entity by asserting a patent
+ infringement claim (excluding declaratory judgment actions,
+ counter-claims, and cross-claims) alleging that a Contributor Version
+ directly or indirectly infringes any patent, then the rights granted to
+ You by any and all Contributors for the Covered Software under Section
+ 2.1 of this License shall terminate.
+ .
+ 5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+ end user license agreements (excluding distributors and resellers) which
+ have been validly granted by You or Your distributors under this License
+ prior to termination shall survive termination.
+ .
+ ************************************************************************
+ * *
+ * 6. Disclaimer of Warranty *
+ * ------------------------- *
+ * *
+ * Covered Software is provided under this License on an "as is" *
+ * basis, without warranty of any kind, either expressed, implied, or *
+ * statutory, including, without limitation, warranties that the *
+ * Covered Software is free of defects, merchantable, fit for a *
+ * particular purpose or non-infringing. The entire risk as to the *
+ * quality and performance of the Covered Software is with You. *
+ * Should any Covered Software prove defective in any respect, You *
+ * (not any Contributor) assume the cost of any necessary servicing, *
+ * repair, or correction. This disclaimer of warranty constitutes an *
+ * essential part of this License. No use of any Covered Software is *
+ * authorized under this License except under this disclaimer. *
+ * *
+ ************************************************************************
+ .
+ ************************************************************************
+ * *
+ * 7. Limitation of Liability *
+ * -------------------------- *
+ * *
+ * Under no circumstances and under no legal theory, whether tort *
+ * (including negligence), contract, or otherwise, shall any *
+ * Contributor, or anyone who distributes Covered Software as *
+ * permitted above, be liable to You for any direct, indirect, *
+ * special, incidental, or consequential damages of any character *
+ * including, without limitation, damages for lost profits, loss of *
+ * goodwill, work stoppage, computer failure or malfunction, or any *
+ * and all other commercial damages or losses, even if such party *
+ * shall have been informed of the possibility of such damages. This *
+ * limitation of liability shall not apply to liability for death or *
+ * personal injury resulting from such party's negligence to the *
+ * extent applicable law prohibits such limitation. Some *
+ * jurisdictions do not allow the exclusion or limitation of *
+ * incidental or consequential damages, so this exclusion and *
+ * limitation may not apply to You. *
+ * *
+ ************************************************************************
+ .
+ 8. Litigation
+ -------------
+ .
+ Any litigation relating to this License may be brought only in the
+ courts of a jurisdiction where the defendant maintains its principal
+ place of business and such litigation shall be governed by laws of that
+ jurisdiction, without reference to its conflict-of-law provisions.
+ Nothing in this Section shall prevent a party's ability to bring
+ cross-claims or counter-claims.
+ .
+ 9. Miscellaneous
+ ----------------
+ .
+ This License represents the complete agreement concerning the subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. Any law or regulation which provides
+ that the language of a contract shall be construed against the drafter
+ shall not be used to construe this License against a Contributor.
+ .
+ 10. Versions of the License
+ ---------------------------
+ .
+ 10.1. New Versions
+ .
+ Mozilla Foundation is the license steward. Except as provided in Section
+ 10.3, no one other than the license steward has the right to modify or
+ publish new versions of this License. Each version will be given a
+ distinguishing version number.
+ .
+ 10.2. Effect of New Versions
+ .
+ You may distribute the Covered Software under the terms of the version
+ of the License under which You originally received the Covered Software,
+ or under the terms of any subsequent version published by the license
+ steward.
+ .
+ 10.3. Modified Versions
+ .
+ If you create software not governed by this License, and you want to
+ create a new license for such software, you may create and use a
+ modified version of this License if you rename the license and remove
+ any references to the name of the license steward (except to note that
+ such modified license differs from this License).
+ .
+ 10.4. Distributing Source Code Form that is Incompatible With Secondary
+ Licenses
+ .
+ If You choose to distribute Source Code Form that is Incompatible With
+ Secondary Licenses under the terms of this version of the License, the
+ notice described in Exhibit B of this License must be attached.
+ .
+ Exhibit A - Source Code Form License Notice
+ -------------------------------------------
+ .
+ This Source Code Form is subject to the terms of the Mozilla Public
+ License, v. 2.0. If a copy of the MPL was not distributed with this
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ .
+ If it is not possible or desirable to put the notice in a particular
+ file, then You may include the notice in a location (such as a LICENSE
+ file in a relevant directory) where a recipient would be likely to look
+ for such a notice.
+ .
+ You may add additional accurate notices of copyright ownership.
+ .
+ Exhibit B - "Incompatible With Secondary Licenses" Notice
+ ---------------------------------------------------------
+ .
+ This Source Code Form is "Incompatible With Secondary Licenses", as
+ defined by the Mozilla Public License, v. 2.0.
--- /dev/null
+<?php
+
+// autoload_classmap.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+ 'AuthorizeNetAIM' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetAIM.php',
+ 'AuthorizeNetAIM_Response' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetAIM.php',
+ 'AuthorizeNetARB' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetARB.php',
+ 'AuthorizeNetARB_Response' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetARB.php',
+ 'AuthorizeNetAddress' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetBankAccount' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetCIM' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetCIM.php',
+ 'AuthorizeNetCIM_Response' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetCIM.php',
+ 'AuthorizeNetCP' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetCP.php',
+ 'AuthorizeNetCP_Response' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetCP.php',
+ 'AuthorizeNetCreditCard' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetCustomer' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetDPM' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetDPM.php',
+ 'AuthorizeNetException' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetException.php',
+ 'AuthorizeNetGetSubscriptionList' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetLineItem' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetPayment' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetPaymentProfile' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetRequest' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetRequest.php',
+ 'AuthorizeNetResponse' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetResponse.php',
+ 'AuthorizeNetSIM' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetSIM.php',
+ 'AuthorizeNetSIM_Form' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetSIM.php',
+ 'AuthorizeNetSOAP' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetSOAP.php',
+ 'AuthorizeNetSubscriptionListPaging' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetSubscriptionListSorting' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetTD' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetTD.php',
+ 'AuthorizeNetTD_Response' => $vendorDir . '/authorizenet/authorizenet/lib/AuthorizeNetTD.php',
+ 'AuthorizeNetTransaction' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'AuthorizeNetXMLResponse' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetXMLResponse.php',
+ 'AuthorizeNet_Subscription' => $vendorDir . '/authorizenet/authorizenet/lib/shared/AuthorizeNetTypes.php',
+ 'net\\authorize\\api\\constants\\ANetEnvironment' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/constants/ANetEnvironment.php',
+ 'net\\authorize\\api\\contract\\v1\\ANetApiRequestType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ANetApiRequestType.php',
+ 'net\\authorize\\api\\contract\\v1\\ANetApiResponseType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ANetApiResponseType.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBCancelSubscriptionRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBCancelSubscriptionRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBCancelSubscriptionResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBCancelSubscriptionResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBCreateSubscriptionRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBCreateSubscriptionRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBCreateSubscriptionResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBCreateSubscriptionResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBGetSubscriptionListRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBGetSubscriptionListRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBGetSubscriptionListResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBGetSubscriptionListResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBGetSubscriptionListSortingType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBGetSubscriptionListSortingType.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBGetSubscriptionRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBGetSubscriptionRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBGetSubscriptionResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBGetSubscriptionResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBGetSubscriptionStatusRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBGetSubscriptionStatusRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBGetSubscriptionStatusResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBGetSubscriptionStatusResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBSubscriptionMaskedType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBSubscriptionMaskedType.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBSubscriptionType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBSubscriptionType.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBUpdateSubscriptionRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBUpdateSubscriptionRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\ARBUpdateSubscriptionResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ARBUpdateSubscriptionResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\ArbTransactionType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ArbTransactionType.php',
+ 'net\\authorize\\api\\contract\\v1\\ArrayOfSettingType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ArrayOfSettingType.php',
+ 'net\\authorize\\api\\contract\\v1\\AuDeleteType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/AuDeleteType.php',
+ 'net\\authorize\\api\\contract\\v1\\AuDetailsType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/AuDetailsType.php',
+ 'net\\authorize\\api\\contract\\v1\\AuResponseType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/AuResponseType.php',
+ 'net\\authorize\\api\\contract\\v1\\AuUpdateType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/AuUpdateType.php',
+ 'net\\authorize\\api\\contract\\v1\\AuthenticateTestRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/AuthenticateTestRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\AuthenticateTestResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/AuthenticateTestResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\BankAccountMaskedType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/BankAccountMaskedType.php',
+ 'net\\authorize\\api\\contract\\v1\\BankAccountType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/BankAccountType.php',
+ 'net\\authorize\\api\\contract\\v1\\BatchDetailsType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/BatchDetailsType.php',
+ 'net\\authorize\\api\\contract\\v1\\BatchStatisticType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/BatchStatisticType.php',
+ 'net\\authorize\\api\\contract\\v1\\CardArtType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CardArtType.php',
+ 'net\\authorize\\api\\contract\\v1\\CcAuthenticationType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CcAuthenticationType.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateCustomerPaymentProfileRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateCustomerPaymentProfileRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateCustomerPaymentProfileResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateCustomerPaymentProfileResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateCustomerProfileFromTransactionRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateCustomerProfileFromTransactionRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateCustomerProfileRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateCustomerProfileRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateCustomerProfileResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateCustomerProfileResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateCustomerProfileTransactionRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateCustomerProfileTransactionRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateCustomerProfileTransactionResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateCustomerProfileTransactionResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateCustomerShippingAddressRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateCustomerShippingAddressRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateCustomerShippingAddressResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateCustomerShippingAddressResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateProfileResponseType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateProfileResponseType.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateTransactionRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateTransactionRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\CreateTransactionResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreateTransactionResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\CreditCardMaskedType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreditCardMaskedType.php',
+ 'net\\authorize\\api\\contract\\v1\\CreditCardSimpleType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreditCardSimpleType.php',
+ 'net\\authorize\\api\\contract\\v1\\CreditCardTrackType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreditCardTrackType.php',
+ 'net\\authorize\\api\\contract\\v1\\CreditCardType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CreditCardType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerAddressExType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerAddressExType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerAddressType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerAddressType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerDataType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerDataType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerPaymentProfileBaseType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerPaymentProfileBaseType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerPaymentProfileExType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerPaymentProfileExType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerPaymentProfileListItemType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerPaymentProfileListItemType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerPaymentProfileMaskedType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerPaymentProfileMaskedType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerPaymentProfileSortingType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerPaymentProfileSortingType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerPaymentProfileType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerPaymentProfileType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerProfileBaseType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerProfileBaseType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerProfileExType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerProfileExType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerProfileIdType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerProfileIdType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerProfileMaskedType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerProfileMaskedType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerProfilePaymentType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerProfilePaymentType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerProfileSummaryType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerProfileSummaryType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerProfileType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerProfileType.php',
+ 'net\\authorize\\api\\contract\\v1\\CustomerType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/CustomerType.php',
+ 'net\\authorize\\api\\contract\\v1\\DecryptPaymentDataRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DecryptPaymentDataRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\DecryptPaymentDataResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DecryptPaymentDataResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\DeleteCustomerPaymentProfileRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DeleteCustomerPaymentProfileRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\DeleteCustomerPaymentProfileResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DeleteCustomerPaymentProfileResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\DeleteCustomerProfileRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DeleteCustomerProfileRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\DeleteCustomerProfileResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DeleteCustomerProfileResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\DeleteCustomerShippingAddressRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DeleteCustomerShippingAddressRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\DeleteCustomerShippingAddressResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DeleteCustomerShippingAddressResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\DriversLicenseMaskedType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DriversLicenseMaskedType.php',
+ 'net\\authorize\\api\\contract\\v1\\DriversLicenseType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/DriversLicenseType.php',
+ 'net\\authorize\\api\\contract\\v1\\EmailSettingsType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/EmailSettingsType.php',
+ 'net\\authorize\\api\\contract\\v1\\EmvTagType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/EmvTagType.php',
+ 'net\\authorize\\api\\contract\\v1\\EncryptedTrackDataType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/EncryptedTrackDataType.php',
+ 'net\\authorize\\api\\contract\\v1\\EnumCollection' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/EnumCollection.php',
+ 'net\\authorize\\api\\contract\\v1\\ErrorResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ErrorResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\ExtendedAmountType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ExtendedAmountType.php',
+ 'net\\authorize\\api\\contract\\v1\\FDSFilterType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/FDSFilterType.php',
+ 'net\\authorize\\api\\contract\\v1\\FingerPrintType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/FingerPrintType.php',
+ 'net\\authorize\\api\\contract\\v1\\FraudInformationType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/FraudInformationType.php',
+ 'net\\authorize\\api\\contract\\v1\\GetAUJobDetailsRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetAUJobDetailsRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetAUJobDetailsResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetAUJobDetailsResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetAUJobSummaryRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetAUJobSummaryRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetAUJobSummaryResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetAUJobSummaryResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetBatchStatisticsRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetBatchStatisticsRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetBatchStatisticsResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetBatchStatisticsResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerPaymentProfileListRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerPaymentProfileListRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerPaymentProfileListResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerPaymentProfileListResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerPaymentProfileRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerPaymentProfileRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerPaymentProfileResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerPaymentProfileResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerProfileIdsRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerProfileIdsRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerProfileIdsResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerProfileIdsResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerProfileRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerProfileRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerProfileResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerProfileResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerShippingAddressRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerShippingAddressRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetCustomerShippingAddressResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetCustomerShippingAddressResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetHostedPaymentPageRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetHostedPaymentPageRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetHostedPaymentPageResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetHostedPaymentPageResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetHostedProfilePageRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetHostedProfilePageRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetHostedProfilePageResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetHostedProfilePageResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetMerchantDetailsRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetMerchantDetailsRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetMerchantDetailsResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetMerchantDetailsResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetSettledBatchListRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetSettledBatchListRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetSettledBatchListResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetSettledBatchListResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetTransactionDetailsRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetTransactionDetailsRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetTransactionDetailsResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetTransactionDetailsResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetTransactionListForCustomerRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetTransactionListForCustomerRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetTransactionListRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetTransactionListRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetTransactionListResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetTransactionListResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\GetUnsettledTransactionListRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetUnsettledTransactionListRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\GetUnsettledTransactionListResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/GetUnsettledTransactionListResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\HeldTransactionRequestType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/HeldTransactionRequestType.php',
+ 'net\\authorize\\api\\contract\\v1\\ImpersonationAuthenticationType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ImpersonationAuthenticationType.php',
+ 'net\\authorize\\api\\contract\\v1\\IsAliveRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/IsAliveRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\IsAliveResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/IsAliveResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\KeyBlockType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/KeyBlockType.php',
+ 'net\\authorize\\api\\contract\\v1\\KeyManagementSchemeType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/KeyManagementSchemeType.php',
+ 'net\\authorize\\api\\contract\\v1\\KeyManagementSchemeType\\DUKPTAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType.php',
+ 'net\\authorize\\api\\contract\\v1\\KeyManagementSchemeType\\DUKPTAType\\DeviceInfoAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType/DeviceInfoAType.php',
+ 'net\\authorize\\api\\contract\\v1\\KeyManagementSchemeType\\DUKPTAType\\EncryptedDataAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType/EncryptedDataAType.php',
+ 'net\\authorize\\api\\contract\\v1\\KeyManagementSchemeType\\DUKPTAType\\ModeAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/KeyManagementSchemeType/DUKPTAType/ModeAType.php',
+ 'net\\authorize\\api\\contract\\v1\\KeyValueType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/KeyValueType.php',
+ 'net\\authorize\\api\\contract\\v1\\LineItemType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/LineItemType.php',
+ 'net\\authorize\\api\\contract\\v1\\ListOfAUDetailsType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ListOfAUDetailsType.php',
+ 'net\\authorize\\api\\contract\\v1\\LogoutRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/LogoutRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\LogoutResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/LogoutResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\MerchantAuthenticationType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MerchantAuthenticationType.php',
+ 'net\\authorize\\api\\contract\\v1\\MerchantContactType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MerchantContactType.php',
+ 'net\\authorize\\api\\contract\\v1\\MessagesType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MessagesType.php',
+ 'net\\authorize\\api\\contract\\v1\\MessagesType\\MessageAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MessagesType/MessageAType.php',
+ 'net\\authorize\\api\\contract\\v1\\MobileDeviceLoginRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MobileDeviceLoginRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\MobileDeviceLoginResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MobileDeviceLoginResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\MobileDeviceRegistrationRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MobileDeviceRegistrationRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\MobileDeviceRegistrationResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MobileDeviceRegistrationResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\MobileDeviceType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/MobileDeviceType.php',
+ 'net\\authorize\\api\\contract\\v1\\NameAndAddressType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/NameAndAddressType.php',
+ 'net\\authorize\\api\\contract\\v1\\OpaqueDataType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/OpaqueDataType.php',
+ 'net\\authorize\\api\\contract\\v1\\OrderExType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/OrderExType.php',
+ 'net\\authorize\\api\\contract\\v1\\OrderType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/OrderType.php',
+ 'net\\authorize\\api\\contract\\v1\\PagingType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PagingType.php',
+ 'net\\authorize\\api\\contract\\v1\\PayPalType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PayPalType.php',
+ 'net\\authorize\\api\\contract\\v1\\PaymentDetailsType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PaymentDetailsType.php',
+ 'net\\authorize\\api\\contract\\v1\\PaymentEmvType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PaymentEmvType.php',
+ 'net\\authorize\\api\\contract\\v1\\PaymentMaskedType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PaymentMaskedType.php',
+ 'net\\authorize\\api\\contract\\v1\\PaymentProfileType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PaymentProfileType.php',
+ 'net\\authorize\\api\\contract\\v1\\PaymentScheduleType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PaymentScheduleType.php',
+ 'net\\authorize\\api\\contract\\v1\\PaymentScheduleType\\IntervalAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PaymentScheduleType/IntervalAType.php',
+ 'net\\authorize\\api\\contract\\v1\\PaymentSimpleType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PaymentSimpleType.php',
+ 'net\\authorize\\api\\contract\\v1\\PaymentType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PaymentType.php',
+ 'net\\authorize\\api\\contract\\v1\\PermissionType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/PermissionType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProcessorType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProcessorType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProfileTransAmountType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProfileTransAmountType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProfileTransAuthCaptureType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProfileTransAuthCaptureType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProfileTransAuthOnlyType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProfileTransAuthOnlyType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProfileTransCaptureOnlyType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProfileTransCaptureOnlyType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProfileTransOrderType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProfileTransOrderType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProfileTransPriorAuthCaptureType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProfileTransPriorAuthCaptureType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProfileTransRefundType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProfileTransRefundType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProfileTransVoidType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProfileTransVoidType.php',
+ 'net\\authorize\\api\\contract\\v1\\ProfileTransactionType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ProfileTransactionType.php',
+ 'net\\authorize\\api\\contract\\v1\\ReturnedItemType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ReturnedItemType.php',
+ 'net\\authorize\\api\\contract\\v1\\SecurePaymentContainerErrorType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SecurePaymentContainerErrorType.php',
+ 'net\\authorize\\api\\contract\\v1\\SecurePaymentContainerRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SecurePaymentContainerRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\SecurePaymentContainerResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SecurePaymentContainerResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\SendCustomerTransactionReceiptRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SendCustomerTransactionReceiptRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\SendCustomerTransactionReceiptResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SendCustomerTransactionReceiptResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\SettingType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SettingType.php',
+ 'net\\authorize\\api\\contract\\v1\\SolutionType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SolutionType.php',
+ 'net\\authorize\\api\\contract\\v1\\SubMerchantType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SubMerchantType.php',
+ 'net\\authorize\\api\\contract\\v1\\SubscriptionCustomerProfileType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SubscriptionCustomerProfileType.php',
+ 'net\\authorize\\api\\contract\\v1\\SubscriptionDetailType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SubscriptionDetailType.php',
+ 'net\\authorize\\api\\contract\\v1\\SubscriptionPaymentType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/SubscriptionPaymentType.php',
+ 'net\\authorize\\api\\contract\\v1\\TokenMaskedType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TokenMaskedType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransRetailInfoType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransRetailInfoType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionDetailsType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionDetailsType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionDetailsType\\EmvDetailsAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionDetailsType/EmvDetailsAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionDetailsType\\EmvDetailsAType\\TagAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionDetailsType/EmvDetailsAType/TagAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionListSortingType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionListSortingType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionRequestType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionRequestType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionRequestType\\UserFieldsAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionRequestType/UserFieldsAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\EmvResponseAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/EmvResponseAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\EmvResponseAType\\TagsAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/EmvResponseAType/TagsAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\ErrorsAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/ErrorsAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\ErrorsAType\\ErrorAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/ErrorsAType/ErrorAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\MessagesAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/MessagesAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\MessagesAType\\MessageAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/MessagesAType/MessageAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\PrePaidCardAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/PrePaidCardAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\SecureAcceptanceAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/SecureAcceptanceAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\SplitTenderPaymentsAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/SplitTenderPaymentsAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\SplitTenderPaymentsAType\\SplitTenderPaymentAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/SplitTenderPaymentsAType/SplitTenderPaymentAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionResponseType\\UserFieldsAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionResponseType/UserFieldsAType.php',
+ 'net\\authorize\\api\\contract\\v1\\TransactionSummaryType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/TransactionSummaryType.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateCustomerPaymentProfileRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateCustomerPaymentProfileRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateCustomerPaymentProfileResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateCustomerPaymentProfileResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateCustomerProfileRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateCustomerProfileRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateCustomerProfileResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateCustomerProfileResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateCustomerShippingAddressRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateCustomerShippingAddressRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateCustomerShippingAddressResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateCustomerShippingAddressResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateHeldTransactionRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateHeldTransactionRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateHeldTransactionResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateHeldTransactionResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateSplitTenderGroupRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateSplitTenderGroupRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\UpdateSplitTenderGroupResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UpdateSplitTenderGroupResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\UserFieldType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/UserFieldType.php',
+ 'net\\authorize\\api\\contract\\v1\\ValidateCustomerPaymentProfileRequest' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ValidateCustomerPaymentProfileRequest.php',
+ 'net\\authorize\\api\\contract\\v1\\ValidateCustomerPaymentProfileResponse' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/ValidateCustomerPaymentProfileResponse.php',
+ 'net\\authorize\\api\\contract\\v1\\WebCheckOutDataType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/WebCheckOutDataType.php',
+ 'net\\authorize\\api\\contract\\v1\\WebCheckOutDataType\\TokenAType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/contract/v1/WebCheckOutDataType/TokenAType.php',
+ 'net\\authorize\\api\\controller\\ARBCancelSubscriptionController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/ARBCancelSubscriptionController.php',
+ 'net\\authorize\\api\\controller\\ARBCreateSubscriptionController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/ARBCreateSubscriptionController.php',
+ 'net\\authorize\\api\\controller\\ARBGetSubscriptionController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/ARBGetSubscriptionController.php',
+ 'net\\authorize\\api\\controller\\ARBGetSubscriptionListController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/ARBGetSubscriptionListController.php',
+ 'net\\authorize\\api\\controller\\ARBGetSubscriptionStatusController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/ARBGetSubscriptionStatusController.php',
+ 'net\\authorize\\api\\controller\\ARBUpdateSubscriptionController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/ARBUpdateSubscriptionController.php',
+ 'net\\authorize\\api\\controller\\AuthenticateTestController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/AuthenticateTestController.php',
+ 'net\\authorize\\api\\controller\\CreateCustomerPaymentProfileController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/CreateCustomerPaymentProfileController.php',
+ 'net\\authorize\\api\\controller\\CreateCustomerProfileController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/CreateCustomerProfileController.php',
+ 'net\\authorize\\api\\controller\\CreateCustomerProfileFromTransactionController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/CreateCustomerProfileFromTransactionController.php',
+ 'net\\authorize\\api\\controller\\CreateCustomerProfileTransactionController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/CreateCustomerProfileTransactionController.php',
+ 'net\\authorize\\api\\controller\\CreateCustomerShippingAddressController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/CreateCustomerShippingAddressController.php',
+ 'net\\authorize\\api\\controller\\CreateTransactionController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/CreateTransactionController.php',
+ 'net\\authorize\\api\\controller\\DecryptPaymentDataController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/DecryptPaymentDataController.php',
+ 'net\\authorize\\api\\controller\\DeleteCustomerPaymentProfileController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/DeleteCustomerPaymentProfileController.php',
+ 'net\\authorize\\api\\controller\\DeleteCustomerProfileController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/DeleteCustomerProfileController.php',
+ 'net\\authorize\\api\\controller\\DeleteCustomerShippingAddressController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/DeleteCustomerShippingAddressController.php',
+ 'net\\authorize\\api\\controller\\GetAUJobDetailsController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetAUJobDetailsController.php',
+ 'net\\authorize\\api\\controller\\GetAUJobSummaryController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetAUJobSummaryController.php',
+ 'net\\authorize\\api\\controller\\GetBatchStatisticsController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetBatchStatisticsController.php',
+ 'net\\authorize\\api\\controller\\GetCustomerPaymentProfileController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetCustomerPaymentProfileController.php',
+ 'net\\authorize\\api\\controller\\GetCustomerPaymentProfileListController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetCustomerPaymentProfileListController.php',
+ 'net\\authorize\\api\\controller\\GetCustomerProfileController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetCustomerProfileController.php',
+ 'net\\authorize\\api\\controller\\GetCustomerProfileIdsController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetCustomerProfileIdsController.php',
+ 'net\\authorize\\api\\controller\\GetCustomerShippingAddressController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetCustomerShippingAddressController.php',
+ 'net\\authorize\\api\\controller\\GetHostedPaymentPageController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetHostedPaymentPageController.php',
+ 'net\\authorize\\api\\controller\\GetHostedProfilePageController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetHostedProfilePageController.php',
+ 'net\\authorize\\api\\controller\\GetMerchantDetailsController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetMerchantDetailsController.php',
+ 'net\\authorize\\api\\controller\\GetSettledBatchListController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetSettledBatchListController.php',
+ 'net\\authorize\\api\\controller\\GetTransactionDetailsController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetTransactionDetailsController.php',
+ 'net\\authorize\\api\\controller\\GetTransactionListController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetTransactionListController.php',
+ 'net\\authorize\\api\\controller\\GetTransactionListForCustomerController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetTransactionListForCustomerController.php',
+ 'net\\authorize\\api\\controller\\GetUnsettledTransactionListController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/GetUnsettledTransactionListController.php',
+ 'net\\authorize\\api\\controller\\IsAliveController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/IsAliveController.php',
+ 'net\\authorize\\api\\controller\\LogoutController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/LogoutController.php',
+ 'net\\authorize\\api\\controller\\MobileDeviceLoginController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/MobileDeviceLoginController.php',
+ 'net\\authorize\\api\\controller\\MobileDeviceRegistrationController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/MobileDeviceRegistrationController.php',
+ 'net\\authorize\\api\\controller\\SecurePaymentContainerController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/SecurePaymentContainerController.php',
+ 'net\\authorize\\api\\controller\\SendCustomerTransactionReceiptController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/SendCustomerTransactionReceiptController.php',
+ 'net\\authorize\\api\\controller\\UpdateCustomerPaymentProfileController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/UpdateCustomerPaymentProfileController.php',
+ 'net\\authorize\\api\\controller\\UpdateCustomerProfileController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/UpdateCustomerProfileController.php',
+ 'net\\authorize\\api\\controller\\UpdateCustomerShippingAddressController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/UpdateCustomerShippingAddressController.php',
+ 'net\\authorize\\api\\controller\\UpdateHeldTransactionController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/UpdateHeldTransactionController.php',
+ 'net\\authorize\\api\\controller\\UpdateSplitTenderGroupController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/UpdateSplitTenderGroupController.php',
+ 'net\\authorize\\api\\controller\\ValidateCustomerPaymentProfileController' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/ValidateCustomerPaymentProfileController.php',
+ 'net\\authorize\\api\\controller\\base\\ApiOperationBase' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/base/ApiOperationBase.php',
+ 'net\\authorize\\api\\controller\\base\\IApiOperation' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/api/controller/base/IApiOperation.php',
+ 'net\\authorize\\util\\ANetSensitiveFields' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/util/ANetSensitiveFields.php',
+ 'net\\authorize\\util\\Helpers' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/util/Helpers.php',
+ 'net\\authorize\\util\\HttpClient' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/util/HttpClient.php',
+ 'net\\authorize\\util\\Log' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/util/Log.php',
+ 'net\\authorize\\util\\LogFactory' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/util/LogFactory.php',
+ 'net\\authorize\\util\\SensitiveDataConfigType' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/util/SensitiveDataConfigType.php',
+ 'net\\authorize\\util\\SensitiveTag' => $vendorDir . '/authorizenet/authorizenet/lib/net/authorize/util/SensitiveTag.php',
+);
--- /dev/null
+<?php
+
+// autoload_namespaces.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+ 'PhpOption\\' => array($vendorDir . '/phpoption/phpoption/src'),
+ 'PhpCollection' => array($vendorDir . '/phpcollection/phpcollection/src'),
+ 'Metadata\\' => array($vendorDir . '/jms/metadata/src'),
+ 'JMS\\Serializer' => array($vendorDir . '/jms/serializer/src'),
+ 'JMS\\' => array($vendorDir . '/jms/parser-lib/src'),
+ 'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
+);
--- /dev/null
+<?php
+
+// autoload_psr4.php @generated by Composer
+
+$vendorDir = dirname(dirname(__FILE__));
+$baseDir = dirname($vendorDir);
+
+return array(
+ 'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
+ 'GoetasWebservices\\Xsd\\XsdToPhpRuntime\\' => array($vendorDir . '/goetas-webservices/xsd2php-runtime/src'),
+ 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
+ 'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations'),
+);
--- /dev/null
+<?php
+
+// autoload_real.php @generated by Composer
+
+class ComposerAutoloaderInitafd44b6f62840ab562c37aa2abd6f1ad
+{
+ private static $loader;
+
+ public static function loadClassLoader($class)
+ {
+ if ('Composer\Autoload\ClassLoader' === $class) {
+ require __DIR__ . '/ClassLoader.php';
+ }
+ }
+
+ public static function getLoader()
+ {
+ if (null !== self::$loader) {
+ return self::$loader;
+ }
+
+ spl_autoload_register(array('ComposerAutoloaderInitafd44b6f62840ab562c37aa2abd6f1ad', 'loadClassLoader'), true, true);
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
+ spl_autoload_unregister(array('ComposerAutoloaderInitafd44b6f62840ab562c37aa2abd6f1ad', 'loadClassLoader'));
+
+ $map = require __DIR__ . '/autoload_namespaces.php';
+ foreach ($map as $namespace => $path) {
+ $loader->set($namespace, $path);
+ }
+
+ $map = require __DIR__ . '/autoload_psr4.php';
+ foreach ($map as $namespace => $path) {
+ $loader->setPsr4($namespace, $path);
+ }
+
+ $classMap = require __DIR__ . '/autoload_classmap.php';
+ if ($classMap) {
+ $loader->addClassMap($classMap);
+ }
+
+ $loader->register(true);
+
+ return $loader;
+ }
+}
--- /dev/null
+[
+ {
+ "name": "symfony/yaml",
+ "version": "v3.4.6",
+ "version_normalized": "3.4.6.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/yaml.git",
+ "reference": "6af42631dcf89e9c616242c900d6c52bd53bd1bb"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/6af42631dcf89e9c616242c900d6c52bd53bd1bb",
+ "reference": "6af42631dcf89e9c616242c900d6c52bd53bd1bb",
+ "shasum": ""
+ },
+ "require": {
+ "php": "^5.5.9|>=7.0.8"
+ },
+ "conflict": {
+ "symfony/console": "<3.4"
+ },
+ "require-dev": {
+ "symfony/console": "~3.4|~4.0"
+ },
+ "suggest": {
+ "symfony/console": "For validating YAML files using the lint command"
+ },
+ "time": "2018-02-16 09:50:28",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.4-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "Symfony\\Component\\Yaml\\": ""
+ },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Yaml Component",
+ "homepage": "https://symfony.com"
+ },
+ {
+ "name": "doctrine/instantiator",
+ "version": "1.0.5",
+ "version_normalized": "1.0.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/instantiator.git",
+ "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
+ "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3,<8.0-DEV"
+ },
+ "require-dev": {
+ "athletic/athletic": "~0.1.8",
+ "ext-pdo": "*",
+ "ext-phar": "*",
+ "phpunit/phpunit": "~4.0",
+ "squizlabs/php_codesniffer": "~2.0"
+ },
+ "time": "2015-06-14 21:17:01",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Marco Pivetta",
+ "email": "ocramius@gmail.com",
+ "homepage": "http://ocramius.github.com/"
+ }
+ ],
+ "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
+ "homepage": "https://github.com/doctrine/instantiator",
+ "keywords": [
+ "constructor",
+ "instantiate"
+ ]
+ },
+ {
+ "name": "doctrine/lexer",
+ "version": "v1.0.1",
+ "version_normalized": "1.0.1.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/lexer.git",
+ "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c",
+ "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "time": "2014-09-09 13:34:57",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Doctrine\\Common\\Lexer\\": "lib/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com"
+ },
+ {
+ "name": "Johannes Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "lexer",
+ "parser"
+ ]
+ },
+ {
+ "name": "doctrine/annotations",
+ "version": "v1.4.0",
+ "version_normalized": "1.4.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/doctrine/annotations.git",
+ "reference": "54cacc9b81758b14e3ce750f205a393d52339e97"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97",
+ "reference": "54cacc9b81758b14e3ce750f205a393d52339e97",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/lexer": "1.*",
+ "php": "^5.6 || ^7.0"
+ },
+ "require-dev": {
+ "doctrine/cache": "1.*",
+ "phpunit/phpunit": "^5.7"
+ },
+ "time": "2017-02-24 16:22:25",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.4.x-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
+ {
+ "name": "Benjamin Eberlei",
+ "email": "kontakt@beberlei.de"
+ },
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com"
+ },
+ {
+ "name": "Jonathan Wage",
+ "email": "jonwage@gmail.com"
+ },
+ {
+ "name": "Johannes Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Docblock Annotations Parser",
+ "homepage": "http://www.doctrine-project.org",
+ "keywords": [
+ "annotations",
+ "docblock",
+ "parser"
+ ]
+ },
+ {
+ "name": "phpoption/phpoption",
+ "version": "1.5.0",
+ "version_normalized": "1.5.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/schmittjoh/php-option.git",
+ "reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/94e644f7d2051a5f0fcf77d81605f152eecff0ed",
+ "reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "4.7.*"
+ },
+ "time": "2015-07-25 16:39:46",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.3-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "PhpOption\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache2"
+ ],
+ "authors": [
+ {
+ "name": "Johannes M. Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Option Type for PHP",
+ "keywords": [
+ "language",
+ "option",
+ "php",
+ "type"
+ ]
+ },
+ {
+ "name": "phpcollection/phpcollection",
+ "version": "0.5.0",
+ "version_normalized": "0.5.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/schmittjoh/php-collection.git",
+ "reference": "f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/schmittjoh/php-collection/zipball/f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6",
+ "reference": "f2bcff45c0da7c27991bbc1f90f47c4b7fb434a6",
+ "shasum": ""
+ },
+ "require": {
+ "phpoption/phpoption": "1.*"
+ },
+ "time": "2015-05-17 12:39:23",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.4-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "PhpCollection": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache2"
+ ],
+ "authors": [
+ {
+ "name": "Johannes M. Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "General-Purpose Collection Library for PHP",
+ "keywords": [
+ "collection",
+ "list",
+ "map",
+ "sequence",
+ "set"
+ ]
+ },
+ {
+ "name": "jms/parser-lib",
+ "version": "1.0.0",
+ "version_normalized": "1.0.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/schmittjoh/parser-lib.git",
+ "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/schmittjoh/parser-lib/zipball/c509473bc1b4866415627af0e1c6cc8ac97fa51d",
+ "reference": "c509473bc1b4866415627af0e1c6cc8ac97fa51d",
+ "shasum": ""
+ },
+ "require": {
+ "phpoption/phpoption": ">=0.9,<2.0-dev"
+ },
+ "time": "2012-11-18 18:08:43",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "JMS\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache2"
+ ],
+ "description": "A library for easily creating recursive-descent parsers."
+ },
+ {
+ "name": "jms/metadata",
+ "version": "1.6.0",
+ "version_normalized": "1.6.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/schmittjoh/metadata.git",
+ "reference": "6a06970a10e0a532fb52d3959547123b84a3b3ab"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/6a06970a10e0a532fb52d3959547123b84a3b3ab",
+ "reference": "6a06970a10e0a532fb52d3959547123b84a3b3ab",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "doctrine/cache": "~1.0",
+ "symfony/cache": "~3.1"
+ },
+ "time": "2016-12-05 10:18:33",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.5.x-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "Metadata\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "Johannes M. Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Class/method/property metadata management in PHP",
+ "keywords": [
+ "annotations",
+ "metadata",
+ "xml",
+ "yaml"
+ ]
+ },
+ {
+ "name": "jms/serializer",
+ "version": "1.11.0",
+ "version_normalized": "1.11.0.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/schmittjoh/serializer.git",
+ "reference": "e7c53477ff55c21d1b1db7d062edc050a24f465f"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/e7c53477ff55c21d1b1db7d062edc050a24f465f",
+ "reference": "e7c53477ff55c21d1b1db7d062edc050a24f465f",
+ "shasum": ""
+ },
+ "require": {
+ "doctrine/annotations": "^1.0",
+ "doctrine/instantiator": "^1.0.3",
+ "jms/metadata": "~1.1",
+ "jms/parser-lib": "1.*",
+ "php": "^5.5|^7.0",
+ "phpcollection/phpcollection": "~0.1",
+ "phpoption/phpoption": "^1.1"
+ },
+ "conflict": {
+ "twig/twig": "<1.12"
+ },
+ "require-dev": {
+ "doctrine/orm": "~2.1",
+ "doctrine/phpcr-odm": "^1.3|^2.0",
+ "ext-pdo_sqlite": "*",
+ "jackalope/jackalope-doctrine-dbal": "^1.1.5",
+ "phpunit/phpunit": "^4.8|^5.0",
+ "propel/propel1": "~1.7",
+ "psr/container": "^1.0",
+ "symfony/dependency-injection": "^2.7|^3.3|^4.0",
+ "symfony/expression-language": "^2.6|^3.0",
+ "symfony/filesystem": "^2.1",
+ "symfony/form": "~2.1|^3.0",
+ "symfony/translation": "^2.1|^3.0",
+ "symfony/validator": "^2.2|^3.0",
+ "symfony/yaml": "^2.1|^3.0",
+ "twig/twig": "~1.12|~2.0"
+ },
+ "suggest": {
+ "doctrine/cache": "Required if you like to use cache functionality.",
+ "doctrine/collections": "Required if you like to use doctrine collection types as ArrayCollection.",
+ "symfony/yaml": "Required if you'd like to serialize data to YAML format."
+ },
+ "time": "2018-02-04 17:48:54",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.11-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-0": {
+ "JMS\\Serializer": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "authors": [
+ {
+ "name": "Asmir Mustafic",
+ "email": "goetas@gmail.com"
+ },
+ {
+ "name": "Johannes M. Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "description": "Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.",
+ "homepage": "http://jmsyst.com/libs/serializer",
+ "keywords": [
+ "deserialization",
+ "jaxb",
+ "json",
+ "serialization",
+ "xml"
+ ]
+ },
+ {
+ "name": "goetas-webservices/xsd2php-runtime",
+ "version": "v0.2.8",
+ "version_normalized": "0.2.8.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/goetas-webservices/xsd2php-runtime.git",
+ "reference": "18a9e25e89b719fa5417dcbd6515604723df957d"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/goetas-webservices/xsd2php-runtime/zipball/18a9e25e89b719fa5417dcbd6515604723df957d",
+ "reference": "18a9e25e89b719fa5417dcbd6515604723df957d",
+ "shasum": ""
+ },
+ "require": {
+ "jms/serializer": "^1.2",
+ "php": ">=5.5",
+ "symfony/yaml": "^2.2|^3.0|^4.0"
+ },
+ "conflict": {
+ "jms/serializer": "1.4.1|1.6.1|1.6.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8|^5.0"
+ },
+ "time": "2018-03-16 09:41:04",
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.2-dev"
+ }
+ },
+ "installation-source": "dist",
+ "autoload": {
+ "psr-4": {
+ "GoetasWebservices\\Xsd\\XsdToPhpRuntime\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-3.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Asmir Mustafic"
+ }
+ ],
+ "description": "Convert XSD (XML Schema) definitions into PHP classes",
+ "keywords": [
+ "converter",
+ "jms",
+ "php",
+ "serializer",
+ "xml",
+ "xsd"
+ ]
+ },
+ {
+ "name": "authorizenet/authorizenet",
+ "version": "1.9.6",
+ "version_normalized": "1.9.6.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/AuthorizeNet/sdk-php.git",
+ "reference": "de06148a987b20070d34922f1754bbb1dbaf37d2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/AuthorizeNet/sdk-php/zipball/de06148a987b20070d34922f1754bbb1dbaf37d2",
+ "reference": "de06148a987b20070d34922f1754bbb1dbaf37d2",
+ "shasum": ""
+ },
+ "require": {
+ "ext-curl": "*",
+ "ext-json": "*",
+ "ext-simplexml": "*",
+ "ext-xmlwriter": "*",
+ "goetas-webservices/xsd2php-runtime": "^0.2.2",
+ "php": ">=5.6"
+ },
+ "require-dev": {
+ "phpmd/phpmd": "~2.0",
+ "phpunit/phpunit": "~4.0"
+ },
+ "time": "2018-03-24 19:32:25",
+ "type": "library",
+ "installation-source": "dist",
+ "autoload": {
+ "classmap": [
+ "lib"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "proprietary"
+ ],
+ "description": "Official PHP SDK for Authorize.Net",
+ "homepage": "http://developer.authorize.net",
+ "keywords": [
+ "authorize.net",
+ "authorizenet",
+ "ecommerce",
+ "payment"
+ ]
+ }
+]
--- /dev/null
+## Changelog
+
+
+### 1.4.0
+
+This release fix an issue were some annotations could be not loaded if the namespace in the use statement started with a backslash.
+It also update the tests and drop the support for php 5.X
+
+- [115: Missing annotations with the latest composer version](https://github.com/doctrine/annotations/issues/115) thanks to @pascalporedda
+- [120: Missing annotations with the latest composer version](https://github.com/doctrine/annotations/pull/120) thanks to @gnat42
+- [121: Adding a more detailed explanation of the test](https://github.com/doctrine/annotations/pull/121) thanks to @mikeSimonson
+- [101: Test annotation parameters containing space](https://github.com/doctrine/annotations/pull/101) thanks to @mikeSimonson
+- [111: Cleanup: move to correct phpunit assertions](https://github.com/doctrine/annotations/pull/111) thanks to @Ocramius
+- [112: Removes support for PHP 5.x](https://github.com/doctrine/annotations/pull/112) thanks to @railto
+- [113: bumped phpunit version to 5.7](https://github.com/doctrine/annotations/pull/113) thanks to @gabbydgab
+- [114: Enhancement: Use SVG Travis build badge](https://github.com/doctrine/annotations/pull/114) thanks to @localheinz
+- [118: Integrating PHPStan](https://github.com/doctrine/annotations/pull/118) thanks to @ondrejmirtes
+
+### 1.3.1 - 2016-12-30
+
+This release fixes an issue with ignored annotations that were already
+autoloaded, causing the `SimpleAnnotationReader` to pick them up
+anyway. [#110](https://github.com/doctrine/annotations/pull/110)
+
+Additionally, an issue was fixed in the `CachedReader`, which was
+not correctly checking the freshness of cached annotations when
+traits were defined on a class. [#105](https://github.com/doctrine/annotations/pull/105)
+
+Total issues resolved: **2**
+
+- [105: Return single max timestamp](https://github.com/doctrine/annotations/pull/105)
+- [110: setIgnoreNotImportedAnnotations(true) didn’t work for existing classes](https://github.com/doctrine/annotations/pull/110)
+
+### 1.3.0
+
+This release introduces a PHP version bump. `doctrine/annotations` now requires PHP
+5.6 or later to be installed.
+
+A series of additional improvements have been introduced:
+
+ * support for PHP 7 "grouped use statements"
+ * support for ignoring entire namespace names
+ via `Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredNamespace()` and
+ `Doctrine\Common\Annotations\DocParser::setIgnoredAnnotationNamespaces()`. This will
+ allow you to ignore annotations from namespaces that you cannot autoload
+ * testing all parent classes and interfaces when checking if the annotation cache
+ in the `CachedReader` is fresh
+ * simplifying the cache keys used by the `CachedReader`: keys are no longer artificially
+ namespaced, since `Doctrine\Common\Cache` already supports that
+ * corrected parsing of multibyte strings when `mbstring.func_overload` is enabled
+ * corrected parsing of annotations when `"\t"` is put before the first annotation
+ in a docblock
+ * allow skipping non-imported annotations when a custom `DocParser` is passed to
+ the `AnnotationReader` constructor
+
+Total issues resolved: **15**
+
+- [45: DocParser can now ignore whole namespaces](https://github.com/doctrine/annotations/pull/45)
+- [57: Switch to the docker-based infrastructure on Travis](https://github.com/doctrine/annotations/pull/57)
+- [59: opcache.load_comments has been removed from PHP 7](https://github.com/doctrine/annotations/pull/59)
+- [62: [CachedReader\ Test traits and parent class to see if cache is fresh](https://github.com/doctrine/annotations/pull/62)
+- [65: Remove cache salt making key unnecessarily long](https://github.com/doctrine/annotations/pull/65)
+- [66: Fix of incorrect parsing multibyte strings](https://github.com/doctrine/annotations/pull/66)
+- [68: Annotations that are indented by tab are not processed.](https://github.com/doctrine/annotations/issues/68)
+- [69: Support for Group Use Statements](https://github.com/doctrine/annotations/pull/69)
+- [70: Allow tab character before first annotation in DocBlock](https://github.com/doctrine/annotations/pull/70)
+- [74: Ignore not registered annotations fix](https://github.com/doctrine/annotations/pull/74)
+- [92: Added tests for AnnotationRegistry class.](https://github.com/doctrine/annotations/pull/92)
+- [96: Fix/#62 check trait and parent class ttl in annotations](https://github.com/doctrine/annotations/pull/96)
+- [97: Feature - #45 - allow ignoring entire namespaces](https://github.com/doctrine/annotations/pull/97)
+- [98: Enhancement/#65 remove cache salt from cached reader](https://github.com/doctrine/annotations/pull/98)
+- [99: Fix - #70 - allow tab character before first annotation in docblock](https://github.com/doctrine/annotations/pull/99)
+
+### 1.2.4
+
+Total issues resolved: **1**
+
+- [51: FileCacheReader::saveCacheFile::unlink fix](https://github.com/doctrine/annotations/pull/51)
+
+### 1.2.3
+
+Total issues resolved: [**2**](https://github.com/doctrine/annotations/milestones/v1.2.3)
+
+- [49: #46 - applying correct `chmod()` to generated cache file](https://github.com/doctrine/annotations/pull/49)
+- [50: Hotfix: match escaped quotes (revert #44)](https://github.com/doctrine/annotations/pull/50)
+
+### 1.2.2
+
+Total issues resolved: **4**
+
+- [43: Exclude files from distribution with .gitattributes](https://github.com/doctrine/annotations/pull/43)
+- [44: Update DocLexer.php](https://github.com/doctrine/annotations/pull/44)
+- [46: A plain "file_put_contents" can cause havoc](https://github.com/doctrine/annotations/pull/46)
+- [48: Deprecating the `FileCacheReader` in 1.2.2: will be removed in 2.0.0](https://github.com/doctrine/annotations/pull/48)
+
+### 1.2.1
+
+Total issues resolved: **4**
+
+- [38: fixes doctrine/common#326](https://github.com/doctrine/annotations/pull/38)
+- [39: Remove superfluous NS](https://github.com/doctrine/annotations/pull/39)
+- [41: Warn if load_comments is not enabled.](https://github.com/doctrine/annotations/pull/41)
+- [42: Clean up unused uses](https://github.com/doctrine/annotations/pull/42)
+
+### 1.2.0
+
+ * HHVM support
+ * Allowing dangling comma in annotations
+ * Excluded annotations are no longer autoloaded
+ * Importing namespaces also in traits
+ * Added support for `::class` 5.5-style constant, works also in 5.3 and 5.4
+
+### 1.1.0
+
+ * Add Exception when ZendOptimizer+ or Opcache is configured to drop comments
--- /dev/null
+Copyright (c) 2006-2013 Doctrine Project
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
--- /dev/null
+# Doctrine Annotations
+
+[](https://travis-ci.org/doctrine/annotations)
+[](https://www.versioneye.com/package/php--doctrine--annotations)
+[](https://www.versioneye.com/php/doctrine:annotations/references)
+[](https://packagist.org/packages/doctrine/annotations)
+[](https://packagist.org/packages/doctrine/annotations)
+
+Docblock Annotations Parser library (extracted from [Doctrine Common](https://github.com/doctrine/common)).
+
+## Documentation
+
+See the [doctrine-project website](http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html).
+
+## Changelog
+
+See [CHANGELOG.md](CHANGELOG.md).
--- /dev/null
+{
+ "name": "doctrine/annotations",
+ "type": "library",
+ "description": "Docblock Annotations Parser",
+ "keywords": ["annotations", "docblock", "parser"],
+ "homepage": "http://www.doctrine-project.org",
+ "license": "MIT",
+ "authors": [
+ {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
+ {"name": "Roman Borschel", "email": "roman@code-factory.org"},
+ {"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
+ {"name": "Jonathan Wage", "email": "jonwage@gmail.com"},
+ {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
+ ],
+ "require": {
+ "php": "^5.6 || ^7.0",
+ "doctrine/lexer": "1.*"
+ },
+ "require-dev": {
+ "doctrine/cache": "1.*",
+ "phpunit/phpunit": "^5.7"
+ },
+ "autoload": {
+ "psr-4": { "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" }
+ },
+ "autoload-dev": {
+ "psr-4": { "Doctrine\\Tests\\Common\\Annotations\\": "tests/Doctrine/Tests/Common/Annotations" }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.4.x-dev"
+ }
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+/**
+ * Annotations class.
+ *
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
+ * @author Jonathan Wage <jonwage@gmail.com>
+ * @author Roman Borschel <roman@code-factory.org>
+ */
+class Annotation
+{
+ /**
+ * Value property. Common among all derived classes.
+ *
+ * @var string
+ */
+ public $value;
+
+ /**
+ * Constructor.
+ *
+ * @param array $data Key-value for properties to be defined in this class.
+ */
+ public final function __construct(array $data)
+ {
+ foreach ($data as $key => $value) {
+ $this->$key = $value;
+ }
+ }
+
+ /**
+ * Error handler for unknown property accessor in Annotation class.
+ *
+ * @param string $name Unknown property name.
+ *
+ * @throws \BadMethodCallException
+ */
+ public function __get($name)
+ {
+ throw new \BadMethodCallException(
+ sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
+ );
+ }
+
+ /**
+ * Error handler for unknown property mutator in Annotation class.
+ *
+ * @param string $name Unknown property name.
+ * @param mixed $value Property value.
+ *
+ * @throws \BadMethodCallException
+ */
+ public function __set($name, $value)
+ {
+ throw new \BadMethodCallException(
+ sprintf("Unknown property '%s' on annotation '%s'.", $name, get_class($this))
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations\Annotation;
+
+/**
+ * Annotation that can be used to signal to the parser
+ * to check the attribute type during the parsing process.
+ *
+ * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
+ *
+ * @Annotation
+ */
+final class Attribute
+{
+ /**
+ * @var string
+ */
+ public $name;
+
+ /**
+ * @var string
+ */
+ public $type;
+
+ /**
+ * @var boolean
+ */
+ public $required = false;
+}
--- /dev/null
+<?php
+
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations\Annotation;
+
+/**
+ * Annotation that can be used to signal to the parser
+ * to check the types of all declared attributes during the parsing process.
+ *
+ * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
+ *
+ * @Annotation
+ */
+final class Attributes
+{
+ /**
+ * @var array<Doctrine\Common\Annotations\Annotation\Attribute>
+ */
+ public $value;
+}
--- /dev/null
+<?php
+
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations\Annotation;
+
+/**
+ * Annotation that can be used to signal to the parser
+ * to check the available values during the parsing process.
+ *
+ * @since 2.4
+ * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
+ *
+ * @Annotation
+ * @Attributes({
+ * @Attribute("value", required = true, type = "array"),
+ * @Attribute("literal", required = false, type = "array")
+ * })
+ */
+final class Enum
+{
+ /**
+ * @var array
+ */
+ public $value;
+
+ /**
+ * Literal target declaration.
+ *
+ * @var array
+ */
+ public $literal;
+
+ /**
+ * Annotation constructor.
+ *
+ * @param array $values
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function __construct(array $values)
+ {
+ if ( ! isset($values['literal'])) {
+ $values['literal'] = array();
+ }
+
+ foreach ($values['value'] as $var) {
+ if( ! is_scalar($var)) {
+ throw new \InvalidArgumentException(sprintf(
+ '@Enum supports only scalar values "%s" given.',
+ is_object($var) ? get_class($var) : gettype($var)
+ ));
+ }
+ }
+
+ foreach ($values['literal'] as $key => $var) {
+ if( ! in_array($key, $values['value'])) {
+ throw new \InvalidArgumentException(sprintf(
+ 'Undefined enumerator value "%s" for literal "%s".',
+ $key , $var
+ ));
+ }
+ }
+
+ $this->value = $values['value'];
+ $this->literal = $values['literal'];
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations\Annotation;
+
+/**
+ * Annotation that can be used to signal to the parser to ignore specific
+ * annotations during the parsing process.
+ *
+ * @Annotation
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class IgnoreAnnotation
+{
+ /**
+ * @var array
+ */
+ public $names;
+
+ /**
+ * Constructor.
+ *
+ * @param array $values
+ *
+ * @throws \RuntimeException
+ */
+ public function __construct(array $values)
+ {
+ if (is_string($values['value'])) {
+ $values['value'] = array($values['value']);
+ }
+ if (!is_array($values['value'])) {
+ throw new \RuntimeException(sprintf('@IgnoreAnnotation expects either a string name, or an array of strings, but got %s.', json_encode($values['value'])));
+ }
+
+ $this->names = $values['value'];
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations\Annotation;
+
+/**
+ * Annotation that can be used to signal to the parser
+ * to check if that attribute is required during the parsing process.
+ *
+ * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
+ *
+ * @Annotation
+ */
+final class Required
+{
+}
--- /dev/null
+<?php
+
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations\Annotation;
+
+/**
+ * Annotation that can be used to signal to the parser
+ * to check the annotation target during the parsing process.
+ *
+ * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
+ *
+ * @Annotation
+ */
+final class Target
+{
+ const TARGET_CLASS = 1;
+ const TARGET_METHOD = 2;
+ const TARGET_PROPERTY = 4;
+ const TARGET_ANNOTATION = 8;
+ const TARGET_ALL = 15;
+
+ /**
+ * @var array
+ */
+ private static $map = array(
+ 'ALL' => self::TARGET_ALL,
+ 'CLASS' => self::TARGET_CLASS,
+ 'METHOD' => self::TARGET_METHOD,
+ 'PROPERTY' => self::TARGET_PROPERTY,
+ 'ANNOTATION' => self::TARGET_ANNOTATION,
+ );
+
+ /**
+ * @var array
+ */
+ public $value;
+
+ /**
+ * Targets as bitmask.
+ *
+ * @var integer
+ */
+ public $targets;
+
+ /**
+ * Literal target declaration.
+ *
+ * @var integer
+ */
+ public $literal;
+
+ /**
+ * Annotation constructor.
+ *
+ * @param array $values
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function __construct(array $values)
+ {
+ if (!isset($values['value'])){
+ $values['value'] = null;
+ }
+ if (is_string($values['value'])){
+ $values['value'] = array($values['value']);
+ }
+ if (!is_array($values['value'])){
+ throw new \InvalidArgumentException(
+ sprintf('@Target expects either a string value, or an array of strings, "%s" given.',
+ is_object($values['value']) ? get_class($values['value']) : gettype($values['value'])
+ )
+ );
+ }
+
+ $bitmask = 0;
+ foreach ($values['value'] as $literal) {
+ if(!isset(self::$map[$literal])){
+ throw new \InvalidArgumentException(
+ sprintf('Invalid Target "%s". Available targets: [%s]',
+ $literal, implode(', ', array_keys(self::$map)))
+ );
+ }
+ $bitmask |= self::$map[$literal];
+ }
+
+ $this->targets = $bitmask;
+ $this->value = $values['value'];
+ $this->literal = implode(', ', $this->value);
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+/**
+ * Description of AnnotationException
+ *
+ * @since 2.0
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
+ * @author Jonathan Wage <jonwage@gmail.com>
+ * @author Roman Borschel <roman@code-factory.org>
+ */
+class AnnotationException extends \Exception
+{
+ /**
+ * Creates a new AnnotationException describing a Syntax error.
+ *
+ * @param string $message Exception message
+ *
+ * @return AnnotationException
+ */
+ public static function syntaxError($message)
+ {
+ return new self('[Syntax Error] ' . $message);
+ }
+
+ /**
+ * Creates a new AnnotationException describing a Semantical error.
+ *
+ * @param string $message Exception message
+ *
+ * @return AnnotationException
+ */
+ public static function semanticalError($message)
+ {
+ return new self('[Semantical Error] ' . $message);
+ }
+
+ /**
+ * Creates a new AnnotationException describing an error which occurred during
+ * the creation of the annotation.
+ *
+ * @since 2.2
+ *
+ * @param string $message
+ *
+ * @return AnnotationException
+ */
+ public static function creationError($message)
+ {
+ return new self('[Creation Error] ' . $message);
+ }
+
+ /**
+ * Creates a new AnnotationException describing a type error.
+ *
+ * @since 1.1
+ *
+ * @param string $message
+ *
+ * @return AnnotationException
+ */
+ public static function typeError($message)
+ {
+ return new self('[Type Error] ' . $message);
+ }
+
+ /**
+ * Creates a new AnnotationException describing a constant semantical error.
+ *
+ * @since 2.3
+ *
+ * @param string $identifier
+ * @param string $context
+ *
+ * @return AnnotationException
+ */
+ public static function semanticalErrorConstants($identifier, $context = null)
+ {
+ return self::semanticalError(sprintf(
+ "Couldn't find constant %s%s.",
+ $identifier,
+ $context ? ', ' . $context : ''
+ ));
+ }
+
+ /**
+ * Creates a new AnnotationException describing an type error of an attribute.
+ *
+ * @since 2.2
+ *
+ * @param string $attributeName
+ * @param string $annotationName
+ * @param string $context
+ * @param string $expected
+ * @param mixed $actual
+ *
+ * @return AnnotationException
+ */
+ public static function attributeTypeError($attributeName, $annotationName, $context, $expected, $actual)
+ {
+ return self::typeError(sprintf(
+ 'Attribute "%s" of @%s declared on %s expects %s, but got %s.',
+ $attributeName,
+ $annotationName,
+ $context,
+ $expected,
+ is_object($actual) ? 'an instance of ' . get_class($actual) : gettype($actual)
+ ));
+ }
+
+ /**
+ * Creates a new AnnotationException describing an required error of an attribute.
+ *
+ * @since 2.2
+ *
+ * @param string $attributeName
+ * @param string $annotationName
+ * @param string $context
+ * @param string $expected
+ *
+ * @return AnnotationException
+ */
+ public static function requiredError($attributeName, $annotationName, $context, $expected)
+ {
+ return self::typeError(sprintf(
+ 'Attribute "%s" of @%s declared on %s expects %s. This value should not be null.',
+ $attributeName,
+ $annotationName,
+ $context,
+ $expected
+ ));
+ }
+
+ /**
+ * Creates a new AnnotationException describing a invalid enummerator.
+ *
+ * @since 2.4
+ *
+ * @param string $attributeName
+ * @param string $annotationName
+ * @param string $context
+ * @param array $available
+ * @param mixed $given
+ *
+ * @return AnnotationException
+ */
+ public static function enumeratorError($attributeName, $annotationName, $context, $available, $given)
+ {
+ return new self(sprintf(
+ '[Enum Error] Attribute "%s" of @%s declared on %s accept only [%s], but got %s.',
+ $attributeName,
+ $annotationName,
+ $context,
+ implode(', ', $available),
+ is_object($given) ? get_class($given) : $given
+ ));
+ }
+
+ /**
+ * @return AnnotationException
+ */
+ public static function optimizerPlusSaveComments()
+ {
+ return new self(
+ "You have to enable opcache.save_comments=1 or zend_optimizerplus.save_comments=1."
+ );
+ }
+
+ /**
+ * @return AnnotationException
+ */
+ public static function optimizerPlusLoadComments()
+ {
+ return new self(
+ "You have to enable opcache.load_comments=1 or zend_optimizerplus.load_comments=1."
+ );
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+use Doctrine\Common\Annotations\Annotation\IgnoreAnnotation;
+use Doctrine\Common\Annotations\Annotation\Target;
+use ReflectionClass;
+use ReflectionMethod;
+use ReflectionProperty;
+
+/**
+ * A reader for docblock annotations.
+ *
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
+ * @author Jonathan Wage <jonwage@gmail.com>
+ * @author Roman Borschel <roman@code-factory.org>
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class AnnotationReader implements Reader
+{
+ /**
+ * Global map for imports.
+ *
+ * @var array
+ */
+ private static $globalImports = array(
+ 'ignoreannotation' => 'Doctrine\Common\Annotations\Annotation\IgnoreAnnotation',
+ );
+
+ /**
+ * A list with annotations that are not causing exceptions when not resolved to an annotation class.
+ *
+ * The names are case sensitive.
+ *
+ * @var array
+ */
+ private static $globalIgnoredNames = array(
+ // Annotation tags
+ 'Annotation' => true, 'Attribute' => true, 'Attributes' => true,
+ /* Can we enable this? 'Enum' => true, */
+ 'Required' => true,
+ 'Target' => true,
+ // Widely used tags (but not existent in phpdoc)
+ 'fix' => true , 'fixme' => true,
+ 'override' => true,
+ // PHPDocumentor 1 tags
+ 'abstract'=> true, 'access'=> true,
+ 'code' => true,
+ 'deprec'=> true,
+ 'endcode' => true, 'exception'=> true,
+ 'final'=> true,
+ 'ingroup' => true, 'inheritdoc'=> true, 'inheritDoc'=> true,
+ 'magic' => true,
+ 'name'=> true,
+ 'toc' => true, 'tutorial'=> true,
+ 'private' => true,
+ 'static'=> true, 'staticvar'=> true, 'staticVar'=> true,
+ 'throw' => true,
+ // PHPDocumentor 2 tags.
+ 'api' => true, 'author'=> true,
+ 'category'=> true, 'copyright'=> true,
+ 'deprecated'=> true,
+ 'example'=> true,
+ 'filesource'=> true,
+ 'global'=> true,
+ 'ignore'=> true, /* Can we enable this? 'index' => true, */ 'internal'=> true,
+ 'license'=> true, 'link'=> true,
+ 'method' => true,
+ 'package'=> true, 'param'=> true, 'property' => true, 'property-read' => true, 'property-write' => true,
+ 'return'=> true,
+ 'see'=> true, 'since'=> true, 'source' => true, 'subpackage'=> true,
+ 'throws'=> true, 'todo'=> true, 'TODO'=> true,
+ 'usedby'=> true, 'uses' => true,
+ 'var'=> true, 'version'=> true,
+ // PHPUnit tags
+ 'codeCoverageIgnore' => true, 'codeCoverageIgnoreStart' => true, 'codeCoverageIgnoreEnd' => true,
+ // PHPCheckStyle
+ 'SuppressWarnings' => true,
+ // PHPStorm
+ 'noinspection' => true,
+ // PEAR
+ 'package_version' => true,
+ // PlantUML
+ 'startuml' => true, 'enduml' => true,
+ );
+
+ /**
+ * A list with annotations that are not causing exceptions when not resolved to an annotation class.
+ *
+ * The names are case sensitive.
+ *
+ * @var array
+ */
+ private static $globalIgnoredNamespaces = array();
+
+ /**
+ * Add a new annotation to the globally ignored annotation names with regard to exception handling.
+ *
+ * @param string $name
+ */
+ static public function addGlobalIgnoredName($name)
+ {
+ self::$globalIgnoredNames[$name] = true;
+ }
+
+ /**
+ * Add a new annotation to the globally ignored annotation namespaces with regard to exception handling.
+ *
+ * @param string $namespace
+ */
+ static public function addGlobalIgnoredNamespace($namespace)
+ {
+ self::$globalIgnoredNamespaces[$namespace] = true;
+ }
+
+ /**
+ * Annotations parser.
+ *
+ * @var \Doctrine\Common\Annotations\DocParser
+ */
+ private $parser;
+
+ /**
+ * Annotations parser used to collect parsing metadata.
+ *
+ * @var \Doctrine\Common\Annotations\DocParser
+ */
+ private $preParser;
+
+ /**
+ * PHP parser used to collect imports.
+ *
+ * @var \Doctrine\Common\Annotations\PhpParser
+ */
+ private $phpParser;
+
+ /**
+ * In-memory cache mechanism to store imported annotations per class.
+ *
+ * @var array
+ */
+ private $imports = array();
+
+ /**
+ * In-memory cache mechanism to store ignored annotations per class.
+ *
+ * @var array
+ */
+ private $ignoredAnnotationNames = array();
+
+ /**
+ * Constructor.
+ *
+ * Initializes a new AnnotationReader.
+ *
+ * @param DocParser $parser
+ */
+ public function __construct(DocParser $parser = null)
+ {
+ if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.save_comments') === "0" || ini_get('opcache.save_comments') === "0")) {
+ throw AnnotationException::optimizerPlusSaveComments();
+ }
+
+ if (extension_loaded('Zend OPcache') && ini_get('opcache.save_comments') == 0) {
+ throw AnnotationException::optimizerPlusSaveComments();
+ }
+
+ if (PHP_VERSION_ID < 70000) {
+ if (extension_loaded('Zend Optimizer+') && (ini_get('zend_optimizerplus.load_comments') === "0" || ini_get('opcache.load_comments') === "0")) {
+ throw AnnotationException::optimizerPlusLoadComments();
+ }
+
+ if (extension_loaded('Zend OPcache') && ini_get('opcache.load_comments') == 0) {
+ throw AnnotationException::optimizerPlusLoadComments();
+ }
+ }
+
+ AnnotationRegistry::registerFile(__DIR__ . '/Annotation/IgnoreAnnotation.php');
+
+ $this->parser = $parser ?: new DocParser();
+
+ $this->preParser = new DocParser;
+
+ $this->preParser->setImports(self::$globalImports);
+ $this->preParser->setIgnoreNotImportedAnnotations(true);
+
+ $this->phpParser = new PhpParser;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotations(ReflectionClass $class)
+ {
+ $this->parser->setTarget(Target::TARGET_CLASS);
+ $this->parser->setImports($this->getClassImports($class));
+ $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
+ $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
+
+ return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotation(ReflectionClass $class, $annotationName)
+ {
+ $annotations = $this->getClassAnnotations($class);
+
+ foreach ($annotations as $annotation) {
+ if ($annotation instanceof $annotationName) {
+ return $annotation;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotations(ReflectionProperty $property)
+ {
+ $class = $property->getDeclaringClass();
+ $context = 'property ' . $class->getName() . "::\$" . $property->getName();
+
+ $this->parser->setTarget(Target::TARGET_PROPERTY);
+ $this->parser->setImports($this->getPropertyImports($property));
+ $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
+ $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
+
+ return $this->parser->parse($property->getDocComment(), $context);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotation(ReflectionProperty $property, $annotationName)
+ {
+ $annotations = $this->getPropertyAnnotations($property);
+
+ foreach ($annotations as $annotation) {
+ if ($annotation instanceof $annotationName) {
+ return $annotation;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotations(ReflectionMethod $method)
+ {
+ $class = $method->getDeclaringClass();
+ $context = 'method ' . $class->getName() . '::' . $method->getName() . '()';
+
+ $this->parser->setTarget(Target::TARGET_METHOD);
+ $this->parser->setImports($this->getMethodImports($method));
+ $this->parser->setIgnoredAnnotationNames($this->getIgnoredAnnotationNames($class));
+ $this->parser->setIgnoredAnnotationNamespaces(self::$globalIgnoredNamespaces);
+
+ return $this->parser->parse($method->getDocComment(), $context);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotation(ReflectionMethod $method, $annotationName)
+ {
+ $annotations = $this->getMethodAnnotations($method);
+
+ foreach ($annotations as $annotation) {
+ if ($annotation instanceof $annotationName) {
+ return $annotation;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the ignored annotations for the given class.
+ *
+ * @param \ReflectionClass $class
+ *
+ * @return array
+ */
+ private function getIgnoredAnnotationNames(ReflectionClass $class)
+ {
+ $name = $class->getName();
+ if (isset($this->ignoredAnnotationNames[$name])) {
+ return $this->ignoredAnnotationNames[$name];
+ }
+
+ $this->collectParsingMetadata($class);
+
+ return $this->ignoredAnnotationNames[$name];
+ }
+
+ /**
+ * Retrieves imports.
+ *
+ * @param \ReflectionClass $class
+ *
+ * @return array
+ */
+ private function getClassImports(ReflectionClass $class)
+ {
+ $name = $class->getName();
+ if (isset($this->imports[$name])) {
+ return $this->imports[$name];
+ }
+
+ $this->collectParsingMetadata($class);
+
+ return $this->imports[$name];
+ }
+
+ /**
+ * Retrieves imports for methods.
+ *
+ * @param \ReflectionMethod $method
+ *
+ * @return array
+ */
+ private function getMethodImports(ReflectionMethod $method)
+ {
+ $class = $method->getDeclaringClass();
+ $classImports = $this->getClassImports($class);
+ if (!method_exists($class, 'getTraits')) {
+ return $classImports;
+ }
+
+ $traitImports = array();
+
+ foreach ($class->getTraits() as $trait) {
+ if ($trait->hasMethod($method->getName())
+ && $trait->getFileName() === $method->getFileName()
+ ) {
+ $traitImports = array_merge($traitImports, $this->phpParser->parseClass($trait));
+ }
+ }
+
+ return array_merge($classImports, $traitImports);
+ }
+
+ /**
+ * Retrieves imports for properties.
+ *
+ * @param \ReflectionProperty $property
+ *
+ * @return array
+ */
+ private function getPropertyImports(ReflectionProperty $property)
+ {
+ $class = $property->getDeclaringClass();
+ $classImports = $this->getClassImports($class);
+ if (!method_exists($class, 'getTraits')) {
+ return $classImports;
+ }
+
+ $traitImports = array();
+
+ foreach ($class->getTraits() as $trait) {
+ if ($trait->hasProperty($property->getName())) {
+ $traitImports = array_merge($traitImports, $this->phpParser->parseClass($trait));
+ }
+ }
+
+ return array_merge($classImports, $traitImports);
+ }
+
+ /**
+ * Collects parsing metadata for a given class.
+ *
+ * @param \ReflectionClass $class
+ */
+ private function collectParsingMetadata(ReflectionClass $class)
+ {
+ $ignoredAnnotationNames = self::$globalIgnoredNames;
+ $annotations = $this->preParser->parse($class->getDocComment(), 'class ' . $class->name);
+
+ foreach ($annotations as $annotation) {
+ if ($annotation instanceof IgnoreAnnotation) {
+ foreach ($annotation->names AS $annot) {
+ $ignoredAnnotationNames[$annot] = true;
+ }
+ }
+ }
+
+ $name = $class->getName();
+
+ $this->imports[$name] = array_merge(
+ self::$globalImports,
+ $this->phpParser->parseClass($class),
+ array('__NAMESPACE__' => $class->getNamespaceName())
+ );
+
+ $this->ignoredAnnotationNames[$name] = $ignoredAnnotationNames;
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+/**
+ * AnnotationRegistry.
+ */
+final class AnnotationRegistry
+{
+ /**
+ * A map of namespaces to use for autoloading purposes based on a PSR-0 convention.
+ *
+ * Contains the namespace as key and an array of directories as value. If the value is NULL
+ * the include path is used for checking for the corresponding file.
+ *
+ * This autoloading mechanism does not utilize the PHP autoloading but implements autoloading on its own.
+ *
+ * @var array
+ */
+ static private $autoloadNamespaces = array();
+
+ /**
+ * A map of autoloader callables.
+ *
+ * @var array
+ */
+ static private $loaders = array();
+
+ /**
+ * @return void
+ */
+ static public function reset()
+ {
+ self::$autoloadNamespaces = array();
+ self::$loaders = array();
+ }
+
+ /**
+ * Registers file.
+ *
+ * @param string $file
+ *
+ * @return void
+ */
+ static public function registerFile($file)
+ {
+ require_once $file;
+ }
+
+ /**
+ * Adds a namespace with one or many directories to look for files or null for the include path.
+ *
+ * Loading of this namespaces will be done with a PSR-0 namespace loading algorithm.
+ *
+ * @param string $namespace
+ * @param string|array|null $dirs
+ *
+ * @return void
+ */
+ static public function registerAutoloadNamespace($namespace, $dirs = null)
+ {
+ self::$autoloadNamespaces[$namespace] = $dirs;
+ }
+
+ /**
+ * Registers multiple namespaces.
+ *
+ * Loading of this namespaces will be done with a PSR-0 namespace loading algorithm.
+ *
+ * @param array $namespaces
+ *
+ * @return void
+ */
+ static public function registerAutoloadNamespaces(array $namespaces)
+ {
+ self::$autoloadNamespaces = array_merge(self::$autoloadNamespaces, $namespaces);
+ }
+
+ /**
+ * Registers an autoloading callable for annotations, much like spl_autoload_register().
+ *
+ * NOTE: These class loaders HAVE to be silent when a class was not found!
+ * IMPORTANT: Loaders have to return true if they loaded a class that could contain the searched annotation class.
+ *
+ * @param callable $callable
+ *
+ * @return void
+ *
+ * @throws \InvalidArgumentException
+ */
+ static public function registerLoader($callable)
+ {
+ if (!is_callable($callable)) {
+ throw new \InvalidArgumentException("A callable is expected in AnnotationRegistry::registerLoader().");
+ }
+ self::$loaders[] = $callable;
+ }
+
+ /**
+ * Autoloads an annotation class silently.
+ *
+ * @param string $class
+ *
+ * @return boolean
+ */
+ static public function loadAnnotationClass($class)
+ {
+ foreach (self::$autoloadNamespaces AS $namespace => $dirs) {
+ if (strpos($class, $namespace) === 0) {
+ $file = str_replace("\\", DIRECTORY_SEPARATOR, $class) . ".php";
+ if ($dirs === null) {
+ if ($path = stream_resolve_include_path($file)) {
+ require $path;
+ return true;
+ }
+ } else {
+ foreach((array)$dirs AS $dir) {
+ if (is_file($dir . DIRECTORY_SEPARATOR . $file)) {
+ require $dir . DIRECTORY_SEPARATOR . $file;
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ foreach (self::$loaders AS $loader) {
+ if (call_user_func($loader, $class) === true) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+use Doctrine\Common\Cache\Cache;
+use ReflectionClass;
+
+/**
+ * A cache aware annotation reader.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ */
+final class CachedReader implements Reader
+{
+ /**
+ * @var Reader
+ */
+ private $delegate;
+
+ /**
+ * @var Cache
+ */
+ private $cache;
+
+ /**
+ * @var boolean
+ */
+ private $debug;
+
+ /**
+ * @var array
+ */
+ private $loadedAnnotations = array();
+
+ /**
+ * Constructor.
+ *
+ * @param Reader $reader
+ * @param Cache $cache
+ * @param bool $debug
+ */
+ public function __construct(Reader $reader, Cache $cache, $debug = false)
+ {
+ $this->delegate = $reader;
+ $this->cache = $cache;
+ $this->debug = (boolean) $debug;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotations(ReflectionClass $class)
+ {
+ $cacheKey = $class->getName();
+
+ if (isset($this->loadedAnnotations[$cacheKey])) {
+ return $this->loadedAnnotations[$cacheKey];
+ }
+
+ if (false === ($annots = $this->fetchFromCache($cacheKey, $class))) {
+ $annots = $this->delegate->getClassAnnotations($class);
+ $this->saveToCache($cacheKey, $annots);
+ }
+
+ return $this->loadedAnnotations[$cacheKey] = $annots;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotation(ReflectionClass $class, $annotationName)
+ {
+ foreach ($this->getClassAnnotations($class) as $annot) {
+ if ($annot instanceof $annotationName) {
+ return $annot;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotations(\ReflectionProperty $property)
+ {
+ $class = $property->getDeclaringClass();
+ $cacheKey = $class->getName().'$'.$property->getName();
+
+ if (isset($this->loadedAnnotations[$cacheKey])) {
+ return $this->loadedAnnotations[$cacheKey];
+ }
+
+ if (false === ($annots = $this->fetchFromCache($cacheKey, $class))) {
+ $annots = $this->delegate->getPropertyAnnotations($property);
+ $this->saveToCache($cacheKey, $annots);
+ }
+
+ return $this->loadedAnnotations[$cacheKey] = $annots;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName)
+ {
+ foreach ($this->getPropertyAnnotations($property) as $annot) {
+ if ($annot instanceof $annotationName) {
+ return $annot;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotations(\ReflectionMethod $method)
+ {
+ $class = $method->getDeclaringClass();
+ $cacheKey = $class->getName().'#'.$method->getName();
+
+ if (isset($this->loadedAnnotations[$cacheKey])) {
+ return $this->loadedAnnotations[$cacheKey];
+ }
+
+ if (false === ($annots = $this->fetchFromCache($cacheKey, $class))) {
+ $annots = $this->delegate->getMethodAnnotations($method);
+ $this->saveToCache($cacheKey, $annots);
+ }
+
+ return $this->loadedAnnotations[$cacheKey] = $annots;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotation(\ReflectionMethod $method, $annotationName)
+ {
+ foreach ($this->getMethodAnnotations($method) as $annot) {
+ if ($annot instanceof $annotationName) {
+ return $annot;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Clears loaded annotations.
+ *
+ * @return void
+ */
+ public function clearLoadedAnnotations()
+ {
+ $this->loadedAnnotations = array();
+ }
+
+ /**
+ * Fetches a value from the cache.
+ *
+ * @param string $cacheKey The cache key.
+ * @param ReflectionClass $class The related class.
+ *
+ * @return mixed The cached value or false when the value is not in cache.
+ */
+ private function fetchFromCache($cacheKey, ReflectionClass $class)
+ {
+ if (($data = $this->cache->fetch($cacheKey)) !== false) {
+ if (!$this->debug || $this->isCacheFresh($cacheKey, $class)) {
+ return $data;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Saves a value to the cache.
+ *
+ * @param string $cacheKey The cache key.
+ * @param mixed $value The value.
+ *
+ * @return void
+ */
+ private function saveToCache($cacheKey, $value)
+ {
+ $this->cache->save($cacheKey, $value);
+ if ($this->debug) {
+ $this->cache->save('[C]'.$cacheKey, time());
+ }
+ }
+
+ /**
+ * Checks if the cache is fresh.
+ *
+ * @param string $cacheKey
+ * @param ReflectionClass $class
+ *
+ * @return boolean
+ */
+ private function isCacheFresh($cacheKey, ReflectionClass $class)
+ {
+ if (null === $lastModification = $this->getLastModification($class)) {
+ return true;
+ }
+
+ return $this->cache->fetch('[C]'.$cacheKey) >= $lastModification;
+ }
+
+ /**
+ * Returns the time the class was last modified, testing traits and parents
+ *
+ * @param ReflectionClass $class
+ * @return int
+ */
+ private function getLastModification(ReflectionClass $class)
+ {
+ $filename = $class->getFileName();
+ $parent = $class->getParentClass();
+
+ return max(array_merge(
+ [$filename ? filemtime($filename) : 0],
+ array_map([$this, 'getTraitLastModificationTime'], $class->getTraits()),
+ array_map([$this, 'getLastModification'], $class->getInterfaces()),
+ $parent ? [$this->getLastModification($parent)] : []
+ ));
+ }
+
+ /**
+ * @param ReflectionClass $reflectionTrait
+ * @return int
+ */
+ private function getTraitLastModificationTime(ReflectionClass $reflectionTrait)
+ {
+ $fileName = $reflectionTrait->getFileName();
+
+ return max(array_merge(
+ [$fileName ? filemtime($fileName) : 0],
+ array_map([$this, 'getTraitLastModificationTime'], $reflectionTrait->getTraits())
+ ));
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+use Doctrine\Common\Lexer\AbstractLexer;
+
+/**
+ * Simple lexer for docblock annotations.
+ *
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
+ * @author Jonathan Wage <jonwage@gmail.com>
+ * @author Roman Borschel <roman@code-factory.org>
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class DocLexer extends AbstractLexer
+{
+ const T_NONE = 1;
+ const T_INTEGER = 2;
+ const T_STRING = 3;
+ const T_FLOAT = 4;
+
+ // All tokens that are also identifiers should be >= 100
+ const T_IDENTIFIER = 100;
+ const T_AT = 101;
+ const T_CLOSE_CURLY_BRACES = 102;
+ const T_CLOSE_PARENTHESIS = 103;
+ const T_COMMA = 104;
+ const T_EQUALS = 105;
+ const T_FALSE = 106;
+ const T_NAMESPACE_SEPARATOR = 107;
+ const T_OPEN_CURLY_BRACES = 108;
+ const T_OPEN_PARENTHESIS = 109;
+ const T_TRUE = 110;
+ const T_NULL = 111;
+ const T_COLON = 112;
+
+ /**
+ * @var array
+ */
+ protected $noCase = array(
+ '@' => self::T_AT,
+ ',' => self::T_COMMA,
+ '(' => self::T_OPEN_PARENTHESIS,
+ ')' => self::T_CLOSE_PARENTHESIS,
+ '{' => self::T_OPEN_CURLY_BRACES,
+ '}' => self::T_CLOSE_CURLY_BRACES,
+ '=' => self::T_EQUALS,
+ ':' => self::T_COLON,
+ '\\' => self::T_NAMESPACE_SEPARATOR
+ );
+
+ /**
+ * @var array
+ */
+ protected $withCase = array(
+ 'true' => self::T_TRUE,
+ 'false' => self::T_FALSE,
+ 'null' => self::T_NULL
+ );
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getCatchablePatterns()
+ {
+ return array(
+ '[a-z_\\\][a-z0-9_\:\\\]*[a-z_][a-z0-9_]*',
+ '(?:[+-]?[0-9]+(?:[\.][0-9]+)*)(?:[eE][+-]?[0-9]+)?',
+ '"(?:""|[^"])*+"',
+ );
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getNonCatchablePatterns()
+ {
+ return array('\s+', '\*+', '(.)');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getType(&$value)
+ {
+ $type = self::T_NONE;
+
+ if ($value[0] === '"') {
+ $value = str_replace('""', '"', substr($value, 1, strlen($value) - 2));
+
+ return self::T_STRING;
+ }
+
+ if (isset($this->noCase[$value])) {
+ return $this->noCase[$value];
+ }
+
+ if ($value[0] === '_' || $value[0] === '\\' || ctype_alpha($value[0])) {
+ return self::T_IDENTIFIER;
+ }
+
+ $lowerValue = strtolower($value);
+
+ if (isset($this->withCase[$lowerValue])) {
+ return $this->withCase[$lowerValue];
+ }
+
+ // Checking numeric value
+ if (is_numeric($value)) {
+ return (strpos($value, '.') !== false || stripos($value, 'e') !== false)
+ ? self::T_FLOAT : self::T_INTEGER;
+ }
+
+ return $type;
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+use Doctrine\Common\Annotations\Annotation\Attribute;
+use ReflectionClass;
+use Doctrine\Common\Annotations\Annotation\Enum;
+use Doctrine\Common\Annotations\Annotation\Target;
+use Doctrine\Common\Annotations\Annotation\Attributes;
+
+/**
+ * A parser for docblock annotations.
+ *
+ * It is strongly discouraged to change the default annotation parsing process.
+ *
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
+ * @author Jonathan Wage <jonwage@gmail.com>
+ * @author Roman Borschel <roman@code-factory.org>
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
+ */
+final class DocParser
+{
+ /**
+ * An array of all valid tokens for a class name.
+ *
+ * @var array
+ */
+ private static $classIdentifiers = array(
+ DocLexer::T_IDENTIFIER,
+ DocLexer::T_TRUE,
+ DocLexer::T_FALSE,
+ DocLexer::T_NULL
+ );
+
+ /**
+ * The lexer.
+ *
+ * @var \Doctrine\Common\Annotations\DocLexer
+ */
+ private $lexer;
+
+ /**
+ * Current target context.
+ *
+ * @var integer
+ */
+ private $target;
+
+ /**
+ * Doc parser used to collect annotation target.
+ *
+ * @var \Doctrine\Common\Annotations\DocParser
+ */
+ private static $metadataParser;
+
+ /**
+ * Flag to control if the current annotation is nested or not.
+ *
+ * @var boolean
+ */
+ private $isNestedAnnotation = false;
+
+ /**
+ * Hashmap containing all use-statements that are to be used when parsing
+ * the given doc block.
+ *
+ * @var array
+ */
+ private $imports = array();
+
+ /**
+ * This hashmap is used internally to cache results of class_exists()
+ * look-ups.
+ *
+ * @var array
+ */
+ private $classExists = array();
+
+ /**
+ * Whether annotations that have not been imported should be ignored.
+ *
+ * @var boolean
+ */
+ private $ignoreNotImportedAnnotations = false;
+
+ /**
+ * An array of default namespaces if operating in simple mode.
+ *
+ * @var string[]
+ */
+ private $namespaces = array();
+
+ /**
+ * A list with annotations that are not causing exceptions when not resolved to an annotation class.
+ *
+ * The names must be the raw names as used in the class, not the fully qualified
+ * class names.
+ *
+ * @var bool[] indexed by annotation name
+ */
+ private $ignoredAnnotationNames = array();
+
+ /**
+ * A list with annotations in namespaced format
+ * that are not causing exceptions when not resolved to an annotation class.
+ *
+ * @var bool[] indexed by namespace name
+ */
+ private $ignoredAnnotationNamespaces = array();
+
+ /**
+ * @var string
+ */
+ private $context = '';
+
+ /**
+ * Hash-map for caching annotation metadata.
+ *
+ * @var array
+ */
+ private static $annotationMetadata = array(
+ 'Doctrine\Common\Annotations\Annotation\Target' => array(
+ 'is_annotation' => true,
+ 'has_constructor' => true,
+ 'properties' => array(),
+ 'targets_literal' => 'ANNOTATION_CLASS',
+ 'targets' => Target::TARGET_CLASS,
+ 'default_property' => 'value',
+ 'attribute_types' => array(
+ 'value' => array(
+ 'required' => false,
+ 'type' =>'array',
+ 'array_type'=>'string',
+ 'value' =>'array<string>'
+ )
+ ),
+ ),
+ 'Doctrine\Common\Annotations\Annotation\Attribute' => array(
+ 'is_annotation' => true,
+ 'has_constructor' => false,
+ 'targets_literal' => 'ANNOTATION_ANNOTATION',
+ 'targets' => Target::TARGET_ANNOTATION,
+ 'default_property' => 'name',
+ 'properties' => array(
+ 'name' => 'name',
+ 'type' => 'type',
+ 'required' => 'required'
+ ),
+ 'attribute_types' => array(
+ 'value' => array(
+ 'required' => true,
+ 'type' =>'string',
+ 'value' =>'string'
+ ),
+ 'type' => array(
+ 'required' =>true,
+ 'type' =>'string',
+ 'value' =>'string'
+ ),
+ 'required' => array(
+ 'required' =>false,
+ 'type' =>'boolean',
+ 'value' =>'boolean'
+ )
+ ),
+ ),
+ 'Doctrine\Common\Annotations\Annotation\Attributes' => array(
+ 'is_annotation' => true,
+ 'has_constructor' => false,
+ 'targets_literal' => 'ANNOTATION_CLASS',
+ 'targets' => Target::TARGET_CLASS,
+ 'default_property' => 'value',
+ 'properties' => array(
+ 'value' => 'value'
+ ),
+ 'attribute_types' => array(
+ 'value' => array(
+ 'type' =>'array',
+ 'required' =>true,
+ 'array_type'=>'Doctrine\Common\Annotations\Annotation\Attribute',
+ 'value' =>'array<Doctrine\Common\Annotations\Annotation\Attribute>'
+ )
+ ),
+ ),
+ 'Doctrine\Common\Annotations\Annotation\Enum' => array(
+ 'is_annotation' => true,
+ 'has_constructor' => true,
+ 'targets_literal' => 'ANNOTATION_PROPERTY',
+ 'targets' => Target::TARGET_PROPERTY,
+ 'default_property' => 'value',
+ 'properties' => array(
+ 'value' => 'value'
+ ),
+ 'attribute_types' => array(
+ 'value' => array(
+ 'type' => 'array',
+ 'required' => true,
+ ),
+ 'literal' => array(
+ 'type' => 'array',
+ 'required' => false,
+ ),
+ ),
+ ),
+ );
+
+ /**
+ * Hash-map for handle types declaration.
+ *
+ * @var array
+ */
+ private static $typeMap = array(
+ 'float' => 'double',
+ 'bool' => 'boolean',
+ // allow uppercase Boolean in honor of George Boole
+ 'Boolean' => 'boolean',
+ 'int' => 'integer',
+ );
+
+ /**
+ * Constructs a new DocParser.
+ */
+ public function __construct()
+ {
+ $this->lexer = new DocLexer;
+ }
+
+ /**
+ * Sets the annotation names that are ignored during the parsing process.
+ *
+ * The names are supposed to be the raw names as used in the class, not the
+ * fully qualified class names.
+ *
+ * @param bool[] $names indexed by annotation name
+ *
+ * @return void
+ */
+ public function setIgnoredAnnotationNames(array $names)
+ {
+ $this->ignoredAnnotationNames = $names;
+ }
+
+ /**
+ * Sets the annotation namespaces that are ignored during the parsing process.
+ *
+ * @param bool[] $ignoredAnnotationNamespaces indexed by annotation namespace name
+ *
+ * @return void
+ */
+ public function setIgnoredAnnotationNamespaces($ignoredAnnotationNamespaces)
+ {
+ $this->ignoredAnnotationNamespaces = $ignoredAnnotationNamespaces;
+ }
+
+ /**
+ * Sets ignore on not-imported annotations.
+ *
+ * @param boolean $bool
+ *
+ * @return void
+ */
+ public function setIgnoreNotImportedAnnotations($bool)
+ {
+ $this->ignoreNotImportedAnnotations = (boolean) $bool;
+ }
+
+ /**
+ * Sets the default namespaces.
+ *
+ * @param string $namespace
+ *
+ * @return void
+ *
+ * @throws \RuntimeException
+ */
+ public function addNamespace($namespace)
+ {
+ if ($this->imports) {
+ throw new \RuntimeException('You must either use addNamespace(), or setImports(), but not both.');
+ }
+
+ $this->namespaces[] = $namespace;
+ }
+
+ /**
+ * Sets the imports.
+ *
+ * @param array $imports
+ *
+ * @return void
+ *
+ * @throws \RuntimeException
+ */
+ public function setImports(array $imports)
+ {
+ if ($this->namespaces) {
+ throw new \RuntimeException('You must either use addNamespace(), or setImports(), but not both.');
+ }
+
+ $this->imports = $imports;
+ }
+
+ /**
+ * Sets current target context as bitmask.
+ *
+ * @param integer $target
+ *
+ * @return void
+ */
+ public function setTarget($target)
+ {
+ $this->target = $target;
+ }
+
+ /**
+ * Parses the given docblock string for annotations.
+ *
+ * @param string $input The docblock string to parse.
+ * @param string $context The parsing context.
+ *
+ * @return array Array of annotations. If no annotations are found, an empty array is returned.
+ */
+ public function parse($input, $context = '')
+ {
+ $pos = $this->findInitialTokenPosition($input);
+ if ($pos === null) {
+ return array();
+ }
+
+ $this->context = $context;
+
+ $this->lexer->setInput(trim(substr($input, $pos), '* /'));
+ $this->lexer->moveNext();
+
+ return $this->Annotations();
+ }
+
+ /**
+ * Finds the first valid annotation
+ *
+ * @param string $input The docblock string to parse
+ *
+ * @return int|null
+ */
+ private function findInitialTokenPosition($input)
+ {
+ $pos = 0;
+
+ // search for first valid annotation
+ while (($pos = strpos($input, '@', $pos)) !== false) {
+ $preceding = substr($input, $pos - 1, 1);
+
+ // if the @ is preceded by a space, a tab or * it is valid
+ if ($pos === 0 || $preceding === ' ' || $preceding === '*' || $preceding === "\t") {
+ return $pos;
+ }
+
+ $pos++;
+ }
+
+ return null;
+ }
+
+ /**
+ * Attempts to match the given token with the current lookahead token.
+ * If they match, updates the lookahead token; otherwise raises a syntax error.
+ *
+ * @param integer $token Type of token.
+ *
+ * @return boolean True if tokens match; false otherwise.
+ */
+ private function match($token)
+ {
+ if ( ! $this->lexer->isNextToken($token) ) {
+ $this->syntaxError($this->lexer->getLiteral($token));
+ }
+
+ return $this->lexer->moveNext();
+ }
+
+ /**
+ * Attempts to match the current lookahead token with any of the given tokens.
+ *
+ * If any of them matches, this method updates the lookahead token; otherwise
+ * a syntax error is raised.
+ *
+ * @param array $tokens
+ *
+ * @return boolean
+ */
+ private function matchAny(array $tokens)
+ {
+ if ( ! $this->lexer->isNextTokenAny($tokens)) {
+ $this->syntaxError(implode(' or ', array_map(array($this->lexer, 'getLiteral'), $tokens)));
+ }
+
+ return $this->lexer->moveNext();
+ }
+
+ /**
+ * Generates a new syntax error.
+ *
+ * @param string $expected Expected string.
+ * @param array|null $token Optional token.
+ *
+ * @return void
+ *
+ * @throws AnnotationException
+ */
+ private function syntaxError($expected, $token = null)
+ {
+ if ($token === null) {
+ $token = $this->lexer->lookahead;
+ }
+
+ $message = sprintf('Expected %s, got ', $expected);
+ $message .= ($this->lexer->lookahead === null)
+ ? 'end of string'
+ : sprintf("'%s' at position %s", $token['value'], $token['position']);
+
+ if (strlen($this->context)) {
+ $message .= ' in ' . $this->context;
+ }
+
+ $message .= '.';
+
+ throw AnnotationException::syntaxError($message);
+ }
+
+ /**
+ * Attempts to check if a class exists or not. This never goes through the PHP autoloading mechanism
+ * but uses the {@link AnnotationRegistry} to load classes.
+ *
+ * @param string $fqcn
+ *
+ * @return boolean
+ */
+ private function classExists($fqcn)
+ {
+ if (isset($this->classExists[$fqcn])) {
+ return $this->classExists[$fqcn];
+ }
+
+ // first check if the class already exists, maybe loaded through another AnnotationReader
+ if (class_exists($fqcn, false)) {
+ return $this->classExists[$fqcn] = true;
+ }
+
+ // final check, does this class exist?
+ return $this->classExists[$fqcn] = AnnotationRegistry::loadAnnotationClass($fqcn);
+ }
+
+ /**
+ * Collects parsing metadata for a given annotation class
+ *
+ * @param string $name The annotation name
+ *
+ * @return void
+ */
+ private function collectAnnotationMetadata($name)
+ {
+ if (self::$metadataParser === null) {
+ self::$metadataParser = new self();
+
+ self::$metadataParser->setIgnoreNotImportedAnnotations(true);
+ self::$metadataParser->setIgnoredAnnotationNames($this->ignoredAnnotationNames);
+ self::$metadataParser->setImports(array(
+ 'enum' => 'Doctrine\Common\Annotations\Annotation\Enum',
+ 'target' => 'Doctrine\Common\Annotations\Annotation\Target',
+ 'attribute' => 'Doctrine\Common\Annotations\Annotation\Attribute',
+ 'attributes' => 'Doctrine\Common\Annotations\Annotation\Attributes'
+ ));
+
+ AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Enum.php');
+ AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Target.php');
+ AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attribute.php');
+ AnnotationRegistry::registerFile(__DIR__ . '/Annotation/Attributes.php');
+ }
+
+ $class = new \ReflectionClass($name);
+ $docComment = $class->getDocComment();
+
+ // Sets default values for annotation metadata
+ $metadata = array(
+ 'default_property' => null,
+ 'has_constructor' => (null !== $constructor = $class->getConstructor()) && $constructor->getNumberOfParameters() > 0,
+ 'properties' => array(),
+ 'property_types' => array(),
+ 'attribute_types' => array(),
+ 'targets_literal' => null,
+ 'targets' => Target::TARGET_ALL,
+ 'is_annotation' => false !== strpos($docComment, '@Annotation'),
+ );
+
+ // verify that the class is really meant to be an annotation
+ if ($metadata['is_annotation']) {
+ self::$metadataParser->setTarget(Target::TARGET_CLASS);
+
+ foreach (self::$metadataParser->parse($docComment, 'class @' . $name) as $annotation) {
+ if ($annotation instanceof Target) {
+ $metadata['targets'] = $annotation->targets;
+ $metadata['targets_literal'] = $annotation->literal;
+
+ continue;
+ }
+
+ if ($annotation instanceof Attributes) {
+ foreach ($annotation->value as $attribute) {
+ $this->collectAttributeTypeMetadata($metadata, $attribute);
+ }
+ }
+ }
+
+ // if not has a constructor will inject values into public properties
+ if (false === $metadata['has_constructor']) {
+ // collect all public properties
+ foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
+ $metadata['properties'][$property->name] = $property->name;
+
+ if (false === ($propertyComment = $property->getDocComment())) {
+ continue;
+ }
+
+ $attribute = new Attribute();
+
+ $attribute->required = (false !== strpos($propertyComment, '@Required'));
+ $attribute->name = $property->name;
+ $attribute->type = (false !== strpos($propertyComment, '@var') && preg_match('/@var\s+([^\s]+)/',$propertyComment, $matches))
+ ? $matches[1]
+ : 'mixed';
+
+ $this->collectAttributeTypeMetadata($metadata, $attribute);
+
+ // checks if the property has @Enum
+ if (false !== strpos($propertyComment, '@Enum')) {
+ $context = 'property ' . $class->name . "::\$" . $property->name;
+
+ self::$metadataParser->setTarget(Target::TARGET_PROPERTY);
+
+ foreach (self::$metadataParser->parse($propertyComment, $context) as $annotation) {
+ if ( ! $annotation instanceof Enum) {
+ continue;
+ }
+
+ $metadata['enum'][$property->name]['value'] = $annotation->value;
+ $metadata['enum'][$property->name]['literal'] = ( ! empty($annotation->literal))
+ ? $annotation->literal
+ : $annotation->value;
+ }
+ }
+ }
+
+ // choose the first property as default property
+ $metadata['default_property'] = reset($metadata['properties']);
+ }
+ }
+
+ self::$annotationMetadata[$name] = $metadata;
+ }
+
+ /**
+ * Collects parsing metadata for a given attribute.
+ *
+ * @param array $metadata
+ * @param Attribute $attribute
+ *
+ * @return void
+ */
+ private function collectAttributeTypeMetadata(&$metadata, Attribute $attribute)
+ {
+ // handle internal type declaration
+ $type = isset(self::$typeMap[$attribute->type])
+ ? self::$typeMap[$attribute->type]
+ : $attribute->type;
+
+ // handle the case if the property type is mixed
+ if ('mixed' === $type) {
+ return;
+ }
+
+ // Evaluate type
+ switch (true) {
+ // Checks if the property has array<type>
+ case (false !== $pos = strpos($type, '<')):
+ $arrayType = substr($type, $pos + 1, -1);
+ $type = 'array';
+
+ if (isset(self::$typeMap[$arrayType])) {
+ $arrayType = self::$typeMap[$arrayType];
+ }
+
+ $metadata['attribute_types'][$attribute->name]['array_type'] = $arrayType;
+ break;
+
+ // Checks if the property has type[]
+ case (false !== $pos = strrpos($type, '[')):
+ $arrayType = substr($type, 0, $pos);
+ $type = 'array';
+
+ if (isset(self::$typeMap[$arrayType])) {
+ $arrayType = self::$typeMap[$arrayType];
+ }
+
+ $metadata['attribute_types'][$attribute->name]['array_type'] = $arrayType;
+ break;
+ }
+
+ $metadata['attribute_types'][$attribute->name]['type'] = $type;
+ $metadata['attribute_types'][$attribute->name]['value'] = $attribute->type;
+ $metadata['attribute_types'][$attribute->name]['required'] = $attribute->required;
+ }
+
+ /**
+ * Annotations ::= Annotation {[ "*" ]* [Annotation]}*
+ *
+ * @return array
+ */
+ private function Annotations()
+ {
+ $annotations = array();
+
+ while (null !== $this->lexer->lookahead) {
+ if (DocLexer::T_AT !== $this->lexer->lookahead['type']) {
+ $this->lexer->moveNext();
+ continue;
+ }
+
+ // make sure the @ is preceded by non-catchable pattern
+ if (null !== $this->lexer->token && $this->lexer->lookahead['position'] === $this->lexer->token['position'] + strlen($this->lexer->token['value'])) {
+ $this->lexer->moveNext();
+ continue;
+ }
+
+ // make sure the @ is followed by either a namespace separator, or
+ // an identifier token
+ if ((null === $peek = $this->lexer->glimpse())
+ || (DocLexer::T_NAMESPACE_SEPARATOR !== $peek['type'] && !in_array($peek['type'], self::$classIdentifiers, true))
+ || $peek['position'] !== $this->lexer->lookahead['position'] + 1) {
+ $this->lexer->moveNext();
+ continue;
+ }
+
+ $this->isNestedAnnotation = false;
+ if (false !== $annot = $this->Annotation()) {
+ $annotations[] = $annot;
+ }
+ }
+
+ return $annotations;
+ }
+
+ /**
+ * Annotation ::= "@" AnnotationName MethodCall
+ * AnnotationName ::= QualifiedName | SimpleName
+ * QualifiedName ::= NameSpacePart "\" {NameSpacePart "\"}* SimpleName
+ * NameSpacePart ::= identifier | null | false | true
+ * SimpleName ::= identifier | null | false | true
+ *
+ * @return mixed False if it is not a valid annotation.
+ *
+ * @throws AnnotationException
+ */
+ private function Annotation()
+ {
+ $this->match(DocLexer::T_AT);
+
+ // check if we have an annotation
+ $name = $this->Identifier();
+
+ // only process names which are not fully qualified, yet
+ // fully qualified names must start with a \
+ $originalName = $name;
+
+ if ('\\' !== $name[0]) {
+ $pos = strpos($name, '\\');
+ $alias = (false === $pos)? $name : substr($name, 0, $pos);
+ $found = false;
+ $loweredAlias = strtolower($alias);
+
+ if ($this->namespaces) {
+ foreach ($this->namespaces as $namespace) {
+ if ($this->classExists($namespace.'\\'.$name)) {
+ $name = $namespace.'\\'.$name;
+ $found = true;
+ break;
+ }
+ }
+ } elseif (isset($this->imports[$loweredAlias])) {
+ $found = true;
+ $name = (false !== $pos)
+ ? $this->imports[$loweredAlias] . substr($name, $pos)
+ : $this->imports[$loweredAlias];
+ } elseif ( ! isset($this->ignoredAnnotationNames[$name])
+ && isset($this->imports['__NAMESPACE__'])
+ && $this->classExists($this->imports['__NAMESPACE__'] . '\\' . $name)
+ ) {
+ $name = $this->imports['__NAMESPACE__'].'\\'.$name;
+ $found = true;
+ } elseif (! isset($this->ignoredAnnotationNames[$name]) && $this->classExists($name)) {
+ $found = true;
+ }
+
+ if ( ! $found) {
+ if ($this->isIgnoredAnnotation($name)) {
+ return false;
+ }
+
+ throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s was never imported. Did you maybe forget to add a "use" statement for this annotation?', $name, $this->context));
+ }
+ }
+
+ $name = ltrim($name,'\\');
+
+ if ( ! $this->classExists($name)) {
+ throw AnnotationException::semanticalError(sprintf('The annotation "@%s" in %s does not exist, or could not be auto-loaded.', $name, $this->context));
+ }
+
+ // at this point, $name contains the fully qualified class name of the
+ // annotation, and it is also guaranteed that this class exists, and
+ // that it is loaded
+
+
+ // collects the metadata annotation only if there is not yet
+ if ( ! isset(self::$annotationMetadata[$name])) {
+ $this->collectAnnotationMetadata($name);
+ }
+
+ // verify that the class is really meant to be an annotation and not just any ordinary class
+ if (self::$annotationMetadata[$name]['is_annotation'] === false) {
+ if ($this->ignoreNotImportedAnnotations || isset($this->ignoredAnnotationNames[$originalName])) {
+ return false;
+ }
+
+ throw AnnotationException::semanticalError(sprintf('The class "%s" is not annotated with @Annotation. Are you sure this class can be used as annotation? If so, then you need to add @Annotation to the _class_ doc comment of "%s". If it is indeed no annotation, then you need to add @IgnoreAnnotation("%s") to the _class_ doc comment of %s.', $name, $name, $originalName, $this->context));
+ }
+
+ //if target is nested annotation
+ $target = $this->isNestedAnnotation ? Target::TARGET_ANNOTATION : $this->target;
+
+ // Next will be nested
+ $this->isNestedAnnotation = true;
+
+ //if annotation does not support current target
+ if (0 === (self::$annotationMetadata[$name]['targets'] & $target) && $target) {
+ throw AnnotationException::semanticalError(
+ sprintf('Annotation @%s is not allowed to be declared on %s. You may only use this annotation on these code elements: %s.',
+ $originalName, $this->context, self::$annotationMetadata[$name]['targets_literal'])
+ );
+ }
+
+ $values = $this->MethodCall();
+
+ if (isset(self::$annotationMetadata[$name]['enum'])) {
+ // checks all declared attributes
+ foreach (self::$annotationMetadata[$name]['enum'] as $property => $enum) {
+ // checks if the attribute is a valid enumerator
+ if (isset($values[$property]) && ! in_array($values[$property], $enum['value'])) {
+ throw AnnotationException::enumeratorError($property, $name, $this->context, $enum['literal'], $values[$property]);
+ }
+ }
+ }
+
+ // checks all declared attributes
+ foreach (self::$annotationMetadata[$name]['attribute_types'] as $property => $type) {
+ if ($property === self::$annotationMetadata[$name]['default_property']
+ && !isset($values[$property]) && isset($values['value'])) {
+ $property = 'value';
+ }
+
+ // handle a not given attribute or null value
+ if (!isset($values[$property])) {
+ if ($type['required']) {
+ throw AnnotationException::requiredError($property, $originalName, $this->context, 'a(n) '.$type['value']);
+ }
+
+ continue;
+ }
+
+ if ($type['type'] === 'array') {
+ // handle the case of a single value
+ if ( ! is_array($values[$property])) {
+ $values[$property] = array($values[$property]);
+ }
+
+ // checks if the attribute has array type declaration, such as "array<string>"
+ if (isset($type['array_type'])) {
+ foreach ($values[$property] as $item) {
+ if (gettype($item) !== $type['array_type'] && !$item instanceof $type['array_type']) {
+ throw AnnotationException::attributeTypeError($property, $originalName, $this->context, 'either a(n) '.$type['array_type'].', or an array of '.$type['array_type'].'s', $item);
+ }
+ }
+ }
+ } elseif (gettype($values[$property]) !== $type['type'] && !$values[$property] instanceof $type['type']) {
+ throw AnnotationException::attributeTypeError($property, $originalName, $this->context, 'a(n) '.$type['value'], $values[$property]);
+ }
+ }
+
+ // check if the annotation expects values via the constructor,
+ // or directly injected into public properties
+ if (self::$annotationMetadata[$name]['has_constructor'] === true) {
+ return new $name($values);
+ }
+
+ $instance = new $name();
+
+ foreach ($values as $property => $value) {
+ if (!isset(self::$annotationMetadata[$name]['properties'][$property])) {
+ if ('value' !== $property) {
+ throw AnnotationException::creationError(sprintf('The annotation @%s declared on %s does not have a property named "%s". Available properties: %s', $originalName, $this->context, $property, implode(', ', self::$annotationMetadata[$name]['properties'])));
+ }
+
+ // handle the case if the property has no annotations
+ if ( ! $property = self::$annotationMetadata[$name]['default_property']) {
+ throw AnnotationException::creationError(sprintf('The annotation @%s declared on %s does not accept any values, but got %s.', $originalName, $this->context, json_encode($values)));
+ }
+ }
+
+ $instance->{$property} = $value;
+ }
+
+ return $instance;
+ }
+
+ /**
+ * MethodCall ::= ["(" [Values] ")"]
+ *
+ * @return array
+ */
+ private function MethodCall()
+ {
+ $values = array();
+
+ if ( ! $this->lexer->isNextToken(DocLexer::T_OPEN_PARENTHESIS)) {
+ return $values;
+ }
+
+ $this->match(DocLexer::T_OPEN_PARENTHESIS);
+
+ if ( ! $this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) {
+ $values = $this->Values();
+ }
+
+ $this->match(DocLexer::T_CLOSE_PARENTHESIS);
+
+ return $values;
+ }
+
+ /**
+ * Values ::= Array | Value {"," Value}* [","]
+ *
+ * @return array
+ */
+ private function Values()
+ {
+ $values = array($this->Value());
+
+ while ($this->lexer->isNextToken(DocLexer::T_COMMA)) {
+ $this->match(DocLexer::T_COMMA);
+
+ if ($this->lexer->isNextToken(DocLexer::T_CLOSE_PARENTHESIS)) {
+ break;
+ }
+
+ $token = $this->lexer->lookahead;
+ $value = $this->Value();
+
+ if ( ! is_object($value) && ! is_array($value)) {
+ $this->syntaxError('Value', $token);
+ }
+
+ $values[] = $value;
+ }
+
+ foreach ($values as $k => $value) {
+ if (is_object($value) && $value instanceof \stdClass) {
+ $values[$value->name] = $value->value;
+ } else if ( ! isset($values['value'])){
+ $values['value'] = $value;
+ } else {
+ if ( ! is_array($values['value'])) {
+ $values['value'] = array($values['value']);
+ }
+
+ $values['value'][] = $value;
+ }
+
+ unset($values[$k]);
+ }
+
+ return $values;
+ }
+
+ /**
+ * Constant ::= integer | string | float | boolean
+ *
+ * @return mixed
+ *
+ * @throws AnnotationException
+ */
+ private function Constant()
+ {
+ $identifier = $this->Identifier();
+
+ if ( ! defined($identifier) && false !== strpos($identifier, '::') && '\\' !== $identifier[0]) {
+ list($className, $const) = explode('::', $identifier);
+
+ $pos = strpos($className, '\\');
+ $alias = (false === $pos) ? $className : substr($className, 0, $pos);
+ $found = false;
+ $loweredAlias = strtolower($alias);
+
+ switch (true) {
+ case !empty ($this->namespaces):
+ foreach ($this->namespaces as $ns) {
+ if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) {
+ $className = $ns.'\\'.$className;
+ $found = true;
+ break;
+ }
+ }
+ break;
+
+ case isset($this->imports[$loweredAlias]):
+ $found = true;
+ $className = (false !== $pos)
+ ? $this->imports[$loweredAlias] . substr($className, $pos)
+ : $this->imports[$loweredAlias];
+ break;
+
+ default:
+ if(isset($this->imports['__NAMESPACE__'])) {
+ $ns = $this->imports['__NAMESPACE__'];
+
+ if (class_exists($ns.'\\'.$className) || interface_exists($ns.'\\'.$className)) {
+ $className = $ns.'\\'.$className;
+ $found = true;
+ }
+ }
+ break;
+ }
+
+ if ($found) {
+ $identifier = $className . '::' . $const;
+ }
+ }
+
+ // checks if identifier ends with ::class, \strlen('::class') === 7
+ $classPos = stripos($identifier, '::class');
+ if ($classPos === strlen($identifier) - 7) {
+ return substr($identifier, 0, $classPos);
+ }
+
+ if (!defined($identifier)) {
+ throw AnnotationException::semanticalErrorConstants($identifier, $this->context);
+ }
+
+ return constant($identifier);
+ }
+
+ /**
+ * Identifier ::= string
+ *
+ * @return string
+ */
+ private function Identifier()
+ {
+ // check if we have an annotation
+ if ( ! $this->lexer->isNextTokenAny(self::$classIdentifiers)) {
+ $this->syntaxError('namespace separator or identifier');
+ }
+
+ $this->lexer->moveNext();
+
+ $className = $this->lexer->token['value'];
+
+ while ($this->lexer->lookahead['position'] === ($this->lexer->token['position'] + strlen($this->lexer->token['value']))
+ && $this->lexer->isNextToken(DocLexer::T_NAMESPACE_SEPARATOR)) {
+
+ $this->match(DocLexer::T_NAMESPACE_SEPARATOR);
+ $this->matchAny(self::$classIdentifiers);
+
+ $className .= '\\' . $this->lexer->token['value'];
+ }
+
+ return $className;
+ }
+
+ /**
+ * Value ::= PlainValue | FieldAssignment
+ *
+ * @return mixed
+ */
+ private function Value()
+ {
+ $peek = $this->lexer->glimpse();
+
+ if (DocLexer::T_EQUALS === $peek['type']) {
+ return $this->FieldAssignment();
+ }
+
+ return $this->PlainValue();
+ }
+
+ /**
+ * PlainValue ::= integer | string | float | boolean | Array | Annotation
+ *
+ * @return mixed
+ */
+ private function PlainValue()
+ {
+ if ($this->lexer->isNextToken(DocLexer::T_OPEN_CURLY_BRACES)) {
+ return $this->Arrayx();
+ }
+
+ if ($this->lexer->isNextToken(DocLexer::T_AT)) {
+ return $this->Annotation();
+ }
+
+ if ($this->lexer->isNextToken(DocLexer::T_IDENTIFIER)) {
+ return $this->Constant();
+ }
+
+ switch ($this->lexer->lookahead['type']) {
+ case DocLexer::T_STRING:
+ $this->match(DocLexer::T_STRING);
+ return $this->lexer->token['value'];
+
+ case DocLexer::T_INTEGER:
+ $this->match(DocLexer::T_INTEGER);
+ return (int)$this->lexer->token['value'];
+
+ case DocLexer::T_FLOAT:
+ $this->match(DocLexer::T_FLOAT);
+ return (float)$this->lexer->token['value'];
+
+ case DocLexer::T_TRUE:
+ $this->match(DocLexer::T_TRUE);
+ return true;
+
+ case DocLexer::T_FALSE:
+ $this->match(DocLexer::T_FALSE);
+ return false;
+
+ case DocLexer::T_NULL:
+ $this->match(DocLexer::T_NULL);
+ return null;
+
+ default:
+ $this->syntaxError('PlainValue');
+ }
+ }
+
+ /**
+ * FieldAssignment ::= FieldName "=" PlainValue
+ * FieldName ::= identifier
+ *
+ * @return \stdClass
+ */
+ private function FieldAssignment()
+ {
+ $this->match(DocLexer::T_IDENTIFIER);
+ $fieldName = $this->lexer->token['value'];
+
+ $this->match(DocLexer::T_EQUALS);
+
+ $item = new \stdClass();
+ $item->name = $fieldName;
+ $item->value = $this->PlainValue();
+
+ return $item;
+ }
+
+ /**
+ * Array ::= "{" ArrayEntry {"," ArrayEntry}* [","] "}"
+ *
+ * @return array
+ */
+ private function Arrayx()
+ {
+ $array = $values = array();
+
+ $this->match(DocLexer::T_OPEN_CURLY_BRACES);
+
+ // If the array is empty, stop parsing and return.
+ if ($this->lexer->isNextToken(DocLexer::T_CLOSE_CURLY_BRACES)) {
+ $this->match(DocLexer::T_CLOSE_CURLY_BRACES);
+
+ return $array;
+ }
+
+ $values[] = $this->ArrayEntry();
+
+ while ($this->lexer->isNextToken(DocLexer::T_COMMA)) {
+ $this->match(DocLexer::T_COMMA);
+
+ // optional trailing comma
+ if ($this->lexer->isNextToken(DocLexer::T_CLOSE_CURLY_BRACES)) {
+ break;
+ }
+
+ $values[] = $this->ArrayEntry();
+ }
+
+ $this->match(DocLexer::T_CLOSE_CURLY_BRACES);
+
+ foreach ($values as $value) {
+ list ($key, $val) = $value;
+
+ if ($key !== null) {
+ $array[$key] = $val;
+ } else {
+ $array[] = $val;
+ }
+ }
+
+ return $array;
+ }
+
+ /**
+ * ArrayEntry ::= Value | KeyValuePair
+ * KeyValuePair ::= Key ("=" | ":") PlainValue | Constant
+ * Key ::= string | integer | Constant
+ *
+ * @return array
+ */
+ private function ArrayEntry()
+ {
+ $peek = $this->lexer->glimpse();
+
+ if (DocLexer::T_EQUALS === $peek['type']
+ || DocLexer::T_COLON === $peek['type']) {
+
+ if ($this->lexer->isNextToken(DocLexer::T_IDENTIFIER)) {
+ $key = $this->Constant();
+ } else {
+ $this->matchAny(array(DocLexer::T_INTEGER, DocLexer::T_STRING));
+ $key = $this->lexer->token['value'];
+ }
+
+ $this->matchAny(array(DocLexer::T_EQUALS, DocLexer::T_COLON));
+
+ return array($key, $this->PlainValue());
+ }
+
+ return array(null, $this->Value());
+ }
+
+ /**
+ * Checks whether the given $name matches any ignored annotation name or namespace
+ *
+ * @param string $name
+ *
+ * @return bool
+ */
+ private function isIgnoredAnnotation($name)
+ {
+ if ($this->ignoreNotImportedAnnotations || isset($this->ignoredAnnotationNames[$name])) {
+ return true;
+ }
+
+ foreach (array_keys($this->ignoredAnnotationNamespaces) as $ignoredAnnotationNamespace) {
+ $ignoredAnnotationNamespace = rtrim($ignoredAnnotationNamespace, '\\') . '\\';
+
+ if (0 === stripos(rtrim($name, '\\') . '\\', $ignoredAnnotationNamespace)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+/**
+ * File cache reader for annotations.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Benjamin Eberlei <kontakt@beberlei.de>
+ *
+ * @deprecated the FileCacheReader is deprecated and will be removed
+ * in version 2.0.0 of doctrine/annotations. Please use the
+ * {@see \Doctrine\Common\Annotations\CachedReader} instead.
+ */
+class FileCacheReader implements Reader
+{
+ /**
+ * @var Reader
+ */
+ private $reader;
+
+ /**
+ * @var string
+ */
+ private $dir;
+
+ /**
+ * @var bool
+ */
+ private $debug;
+
+ /**
+ * @var array
+ */
+ private $loadedAnnotations = array();
+
+ /**
+ * @var array
+ */
+ private $classNameHashes = array();
+
+ /**
+ * @var int
+ */
+ private $umask;
+
+ /**
+ * Constructor.
+ *
+ * @param Reader $reader
+ * @param string $cacheDir
+ * @param boolean $debug
+ *
+ * @throws \InvalidArgumentException
+ */
+ public function __construct(Reader $reader, $cacheDir, $debug = false, $umask = 0002)
+ {
+ if ( ! is_int($umask)) {
+ throw new \InvalidArgumentException(sprintf(
+ 'The parameter umask must be an integer, was: %s',
+ gettype($umask)
+ ));
+ }
+
+ $this->reader = $reader;
+ $this->umask = $umask;
+
+ if (!is_dir($cacheDir) && !@mkdir($cacheDir, 0777 & (~$this->umask), true)) {
+ throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist and could not be created.', $cacheDir));
+ }
+
+ $this->dir = rtrim($cacheDir, '\\/');
+ $this->debug = $debug;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotations(\ReflectionClass $class)
+ {
+ if ( ! isset($this->classNameHashes[$class->name])) {
+ $this->classNameHashes[$class->name] = sha1($class->name);
+ }
+ $key = $this->classNameHashes[$class->name];
+
+ if (isset($this->loadedAnnotations[$key])) {
+ return $this->loadedAnnotations[$key];
+ }
+
+ $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
+ if (!is_file($path)) {
+ $annot = $this->reader->getClassAnnotations($class);
+ $this->saveCacheFile($path, $annot);
+ return $this->loadedAnnotations[$key] = $annot;
+ }
+
+ if ($this->debug
+ && (false !== $filename = $class->getFileName())
+ && filemtime($path) < filemtime($filename)) {
+ @unlink($path);
+
+ $annot = $this->reader->getClassAnnotations($class);
+ $this->saveCacheFile($path, $annot);
+ return $this->loadedAnnotations[$key] = $annot;
+ }
+
+ return $this->loadedAnnotations[$key] = include $path;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotations(\ReflectionProperty $property)
+ {
+ $class = $property->getDeclaringClass();
+ if ( ! isset($this->classNameHashes[$class->name])) {
+ $this->classNameHashes[$class->name] = sha1($class->name);
+ }
+ $key = $this->classNameHashes[$class->name].'$'.$property->getName();
+
+ if (isset($this->loadedAnnotations[$key])) {
+ return $this->loadedAnnotations[$key];
+ }
+
+ $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
+ if (!is_file($path)) {
+ $annot = $this->reader->getPropertyAnnotations($property);
+ $this->saveCacheFile($path, $annot);
+ return $this->loadedAnnotations[$key] = $annot;
+ }
+
+ if ($this->debug
+ && (false !== $filename = $class->getFilename())
+ && filemtime($path) < filemtime($filename)) {
+ @unlink($path);
+
+ $annot = $this->reader->getPropertyAnnotations($property);
+ $this->saveCacheFile($path, $annot);
+ return $this->loadedAnnotations[$key] = $annot;
+ }
+
+ return $this->loadedAnnotations[$key] = include $path;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotations(\ReflectionMethod $method)
+ {
+ $class = $method->getDeclaringClass();
+ if ( ! isset($this->classNameHashes[$class->name])) {
+ $this->classNameHashes[$class->name] = sha1($class->name);
+ }
+ $key = $this->classNameHashes[$class->name].'#'.$method->getName();
+
+ if (isset($this->loadedAnnotations[$key])) {
+ return $this->loadedAnnotations[$key];
+ }
+
+ $path = $this->dir.'/'.strtr($key, '\\', '-').'.cache.php';
+ if (!is_file($path)) {
+ $annot = $this->reader->getMethodAnnotations($method);
+ $this->saveCacheFile($path, $annot);
+ return $this->loadedAnnotations[$key] = $annot;
+ }
+
+ if ($this->debug
+ && (false !== $filename = $class->getFilename())
+ && filemtime($path) < filemtime($filename)) {
+ @unlink($path);
+
+ $annot = $this->reader->getMethodAnnotations($method);
+ $this->saveCacheFile($path, $annot);
+ return $this->loadedAnnotations[$key] = $annot;
+ }
+
+ return $this->loadedAnnotations[$key] = include $path;
+ }
+
+ /**
+ * Saves the cache file.
+ *
+ * @param string $path
+ * @param mixed $data
+ *
+ * @return void
+ */
+ private function saveCacheFile($path, $data)
+ {
+ if (!is_writable($this->dir)) {
+ throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.', $this->dir));
+ }
+
+ $tempfile = tempnam($this->dir, uniqid('', true));
+
+ if (false === $tempfile) {
+ throw new \RuntimeException(sprintf('Unable to create tempfile in directory: %s', $this->dir));
+ }
+
+ @chmod($tempfile, 0666 & (~$this->umask));
+
+ $written = file_put_contents($tempfile, '<?php return unserialize('.var_export(serialize($data), true).');');
+
+ if (false === $written) {
+ throw new \RuntimeException(sprintf('Unable to write cached file to: %s', $tempfile));
+ }
+
+ @chmod($tempfile, 0666 & (~$this->umask));
+
+ if (false === rename($tempfile, $path)) {
+ @unlink($tempfile);
+ throw new \RuntimeException(sprintf('Unable to rename %s to %s', $tempfile, $path));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotation(\ReflectionClass $class, $annotationName)
+ {
+ $annotations = $this->getClassAnnotations($class);
+
+ foreach ($annotations as $annotation) {
+ if ($annotation instanceof $annotationName) {
+ return $annotation;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotation(\ReflectionMethod $method, $annotationName)
+ {
+ $annotations = $this->getMethodAnnotations($method);
+
+ foreach ($annotations as $annotation) {
+ if ($annotation instanceof $annotationName) {
+ return $annotation;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName)
+ {
+ $annotations = $this->getPropertyAnnotations($property);
+
+ foreach ($annotations as $annotation) {
+ if ($annotation instanceof $annotationName) {
+ return $annotation;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Clears loaded annotations.
+ *
+ * @return void
+ */
+ public function clearLoadedAnnotations()
+ {
+ $this->loadedAnnotations = array();
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+/**
+ * Allows the reader to be used in-place of Doctrine's reader.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class IndexedReader implements Reader
+{
+ /**
+ * @var Reader
+ */
+ private $delegate;
+
+ /**
+ * Constructor.
+ *
+ * @param Reader $reader
+ */
+ public function __construct(Reader $reader)
+ {
+ $this->delegate = $reader;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotations(\ReflectionClass $class)
+ {
+ $annotations = array();
+ foreach ($this->delegate->getClassAnnotations($class) as $annot) {
+ $annotations[get_class($annot)] = $annot;
+ }
+
+ return $annotations;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotation(\ReflectionClass $class, $annotation)
+ {
+ return $this->delegate->getClassAnnotation($class, $annotation);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotations(\ReflectionMethod $method)
+ {
+ $annotations = array();
+ foreach ($this->delegate->getMethodAnnotations($method) as $annot) {
+ $annotations[get_class($annot)] = $annot;
+ }
+
+ return $annotations;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotation(\ReflectionMethod $method, $annotation)
+ {
+ return $this->delegate->getMethodAnnotation($method, $annotation);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotations(\ReflectionProperty $property)
+ {
+ $annotations = array();
+ foreach ($this->delegate->getPropertyAnnotations($property) as $annot) {
+ $annotations[get_class($annot)] = $annot;
+ }
+
+ return $annotations;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotation(\ReflectionProperty $property, $annotation)
+ {
+ return $this->delegate->getPropertyAnnotation($property, $annotation);
+ }
+
+ /**
+ * Proxies all methods to the delegate.
+ *
+ * @param string $method
+ * @param array $args
+ *
+ * @return mixed
+ */
+ public function __call($method, $args)
+ {
+ return call_user_func_array(array($this->delegate, $method), $args);
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+use SplFileObject;
+
+/**
+ * Parses a file for namespaces/use/class declarations.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ * @author Christian Kaps <christian.kaps@mohiva.com>
+ */
+final class PhpParser
+{
+ /**
+ * Parses a class.
+ *
+ * @param \ReflectionClass $class A <code>ReflectionClass</code> object.
+ *
+ * @return array A list with use statements in the form (Alias => FQN).
+ */
+ public function parseClass(\ReflectionClass $class)
+ {
+ if (method_exists($class, 'getUseStatements')) {
+ return $class->getUseStatements();
+ }
+
+ if (false === $filename = $class->getFileName()) {
+ return array();
+ }
+
+ $content = $this->getFileContent($filename, $class->getStartLine());
+
+ if (null === $content) {
+ return array();
+ }
+
+ $namespace = preg_quote($class->getNamespaceName());
+ $content = preg_replace('/^.*?(\bnamespace\s+' . $namespace . '\s*[;{].*)$/s', '\\1', $content);
+ $tokenizer = new TokenParser('<?php ' . $content);
+
+ $statements = $tokenizer->parseUseStatements($class->getNamespaceName());
+
+ return $statements;
+ }
+
+ /**
+ * Gets the content of the file right up to the given line number.
+ *
+ * @param string $filename The name of the file to load.
+ * @param integer $lineNumber The number of lines to read from file.
+ *
+ * @return string|null The content of the file or null if the file does not exist.
+ */
+ private function getFileContent($filename, $lineNumber)
+ {
+ if ( ! is_file($filename)) {
+ return null;
+ }
+
+ $content = '';
+ $lineCnt = 0;
+ $file = new SplFileObject($filename);
+ while (!$file->eof()) {
+ if ($lineCnt++ == $lineNumber) {
+ break;
+ }
+
+ $content .= $file->fgets();
+ }
+
+ return $content;
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+/**
+ * Interface for annotation readers.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface Reader
+{
+ /**
+ * Gets the annotations applied to a class.
+ *
+ * @param \ReflectionClass $class The ReflectionClass of the class from which
+ * the class annotations should be read.
+ *
+ * @return array An array of Annotations.
+ */
+ function getClassAnnotations(\ReflectionClass $class);
+
+ /**
+ * Gets a class annotation.
+ *
+ * @param \ReflectionClass $class The ReflectionClass of the class from which
+ * the class annotations should be read.
+ * @param string $annotationName The name of the annotation.
+ *
+ * @return object|null The Annotation or NULL, if the requested annotation does not exist.
+ */
+ function getClassAnnotation(\ReflectionClass $class, $annotationName);
+
+ /**
+ * Gets the annotations applied to a method.
+ *
+ * @param \ReflectionMethod $method The ReflectionMethod of the method from which
+ * the annotations should be read.
+ *
+ * @return array An array of Annotations.
+ */
+ function getMethodAnnotations(\ReflectionMethod $method);
+
+ /**
+ * Gets a method annotation.
+ *
+ * @param \ReflectionMethod $method The ReflectionMethod to read the annotations from.
+ * @param string $annotationName The name of the annotation.
+ *
+ * @return object|null The Annotation or NULL, if the requested annotation does not exist.
+ */
+ function getMethodAnnotation(\ReflectionMethod $method, $annotationName);
+
+ /**
+ * Gets the annotations applied to a property.
+ *
+ * @param \ReflectionProperty $property The ReflectionProperty of the property
+ * from which the annotations should be read.
+ *
+ * @return array An array of Annotations.
+ */
+ function getPropertyAnnotations(\ReflectionProperty $property);
+
+ /**
+ * Gets a property annotation.
+ *
+ * @param \ReflectionProperty $property The ReflectionProperty to read the annotations from.
+ * @param string $annotationName The name of the annotation.
+ *
+ * @return object|null The Annotation or NULL, if the requested annotation does not exist.
+ */
+ function getPropertyAnnotation(\ReflectionProperty $property, $annotationName);
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+/**
+ * Simple Annotation Reader.
+ *
+ * This annotation reader is intended to be used in projects where you have
+ * full-control over all annotations that are available.
+ *
+ * @since 2.2
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Fabio B. Silva <fabio.bat.silva@gmail.com>
+ */
+class SimpleAnnotationReader implements Reader
+{
+ /**
+ * @var DocParser
+ */
+ private $parser;
+
+ /**
+ * Constructor.
+ *
+ * Initializes a new SimpleAnnotationReader.
+ */
+ public function __construct()
+ {
+ $this->parser = new DocParser();
+ $this->parser->setIgnoreNotImportedAnnotations(true);
+ }
+
+ /**
+ * Adds a namespace in which we will look for annotations.
+ *
+ * @param string $namespace
+ *
+ * @return void
+ */
+ public function addNamespace($namespace)
+ {
+ $this->parser->addNamespace($namespace);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotations(\ReflectionClass $class)
+ {
+ return $this->parser->parse($class->getDocComment(), 'class '.$class->getName());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotations(\ReflectionMethod $method)
+ {
+ return $this->parser->parse($method->getDocComment(), 'method '.$method->getDeclaringClass()->name.'::'.$method->getName().'()');
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotations(\ReflectionProperty $property)
+ {
+ return $this->parser->parse($property->getDocComment(), 'property '.$property->getDeclaringClass()->name.'::$'.$property->getName());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getClassAnnotation(\ReflectionClass $class, $annotationName)
+ {
+ foreach ($this->getClassAnnotations($class) as $annot) {
+ if ($annot instanceof $annotationName) {
+ return $annot;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getMethodAnnotation(\ReflectionMethod $method, $annotationName)
+ {
+ foreach ($this->getMethodAnnotations($method) as $annot) {
+ if ($annot instanceof $annotationName) {
+ return $annot;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getPropertyAnnotation(\ReflectionProperty $property, $annotationName)
+ {
+ foreach ($this->getPropertyAnnotations($property) as $annot) {
+ if ($annot instanceof $annotationName) {
+ return $annot;
+ }
+ }
+
+ return null;
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Annotations;
+
+/**
+ * Parses a file for namespaces/use/class declarations.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ * @author Christian Kaps <christian.kaps@mohiva.com>
+ */
+class TokenParser
+{
+ /**
+ * The token list.
+ *
+ * @var array
+ */
+ private $tokens;
+
+ /**
+ * The number of tokens.
+ *
+ * @var int
+ */
+ private $numTokens;
+
+ /**
+ * The current array pointer.
+ *
+ * @var int
+ */
+ private $pointer = 0;
+
+ /**
+ * @param string $contents
+ */
+ public function __construct($contents)
+ {
+ $this->tokens = token_get_all($contents);
+
+ // The PHP parser sets internal compiler globals for certain things. Annoyingly, the last docblock comment it
+ // saw gets stored in doc_comment. When it comes to compile the next thing to be include()d this stored
+ // doc_comment becomes owned by the first thing the compiler sees in the file that it considers might have a
+ // docblock. If the first thing in the file is a class without a doc block this would cause calls to
+ // getDocBlock() on said class to return our long lost doc_comment. Argh.
+ // To workaround, cause the parser to parse an empty docblock. Sure getDocBlock() will return this, but at least
+ // it's harmless to us.
+ token_get_all("<?php\n/**\n *\n */");
+
+ $this->numTokens = count($this->tokens);
+ }
+
+ /**
+ * Gets the next non whitespace and non comment token.
+ *
+ * @param boolean $docCommentIsComment If TRUE then a doc comment is considered a comment and skipped.
+ * If FALSE then only whitespace and normal comments are skipped.
+ *
+ * @return array|null The token if exists, null otherwise.
+ */
+ public function next($docCommentIsComment = TRUE)
+ {
+ for ($i = $this->pointer; $i < $this->numTokens; $i++) {
+ $this->pointer++;
+ if ($this->tokens[$i][0] === T_WHITESPACE ||
+ $this->tokens[$i][0] === T_COMMENT ||
+ ($docCommentIsComment && $this->tokens[$i][0] === T_DOC_COMMENT)) {
+
+ continue;
+ }
+
+ return $this->tokens[$i];
+ }
+
+ return null;
+ }
+
+ /**
+ * Parses a single use statement.
+ *
+ * @return array A list with all found class names for a use statement.
+ */
+ public function parseUseStatement()
+ {
+
+ $groupRoot = '';
+ $class = '';
+ $alias = '';
+ $statements = array();
+ $explicitAlias = false;
+ while (($token = $this->next())) {
+ $isNameToken = $token[0] === T_STRING || $token[0] === T_NS_SEPARATOR;
+ if (!$explicitAlias && $isNameToken) {
+ $class .= $token[1];
+ $alias = $token[1];
+ } else if ($explicitAlias && $isNameToken) {
+ $alias .= $token[1];
+ } else if ($token[0] === T_AS) {
+ $explicitAlias = true;
+ $alias = '';
+ } else if ($token === ',') {
+ $statements[strtolower($alias)] = $groupRoot . $class;
+ $class = '';
+ $alias = '';
+ $explicitAlias = false;
+ } else if ($token === ';') {
+ $statements[strtolower($alias)] = $groupRoot . $class;
+ break;
+ } else if ($token === '{' ) {
+ $groupRoot = $class;
+ $class = '';
+ } else if ($token === '}' ) {
+ continue;
+ } else {
+ break;
+ }
+ }
+
+ return $statements;
+ }
+
+ /**
+ * Gets all use statements.
+ *
+ * @param string $namespaceName The namespace name of the reflected class.
+ *
+ * @return array A list with all found use statements.
+ */
+ public function parseUseStatements($namespaceName)
+ {
+ $statements = array();
+ while (($token = $this->next())) {
+ if ($token[0] === T_USE) {
+ $statements = array_merge($statements, $this->parseUseStatement());
+ continue;
+ }
+ if ($token[0] !== T_NAMESPACE || $this->parseNamespace() != $namespaceName) {
+ continue;
+ }
+
+ // Get fresh array for new namespace. This is to prevent the parser to collect the use statements
+ // for a previous namespace with the same name. This is the case if a namespace is defined twice
+ // or if a namespace with the same name is commented out.
+ $statements = array();
+ }
+
+ return $statements;
+ }
+
+ /**
+ * Gets the namespace.
+ *
+ * @return string The found namespace.
+ */
+ public function parseNamespace()
+ {
+ $name = '';
+ while (($token = $this->next()) && ($token[0] === T_STRING || $token[0] === T_NS_SEPARATOR)) {
+ $name .= $token[1];
+ }
+
+ return $name;
+ }
+
+ /**
+ * Gets the class name.
+ *
+ * @return string The found class name.
+ */
+ public function parseClass()
+ {
+ // Namespaces and class names are tokenized the same: T_STRINGs
+ // separated by T_NS_SEPARATOR so we can use one function to provide
+ // both.
+ return $this->parseNamespace();
+ }
+}
--- /dev/null
+parameters:
+ autoload_files:
+ - %currentWorkingDirectory%/tests/Doctrine/Tests/Common/Annotations/DocParserTest.php
+ excludes_analyse:
+ - %currentWorkingDirectory%/tests/*/Fixtures/*
+ polluteScopeWithLoopInitialAssignments: true
+ ignoreErrors:
+ - '#Class Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment not found#'
+ - '#Instantiated class Doctrine_Tests_Common_Annotations_Fixtures_ClassNoNamespaceNoComment not found#'
+ - '#Property Doctrine\\Tests\\Common\\Annotations\\DummyClassNonAnnotationProblem::\$foo has unknown class#'
+ - '#Class Doctrine\\Tests\\Common\\Annotations\\True not found#'
+ - '#Class Doctrine\\Tests\\Common\\Annotations\\False not found#'
+ - '#Class Doctrine\\Tests\\Common\\Annotations\\Null not found#'
+ - '#Call to an undefined method ReflectionClass::getUseStatements\(\)#'
--- /dev/null
+phpunit.xml
+composer.lock
+build
+vendor
+coverage.clover
--- /dev/null
+before_commands:
+ - "composer install --prefer-source"
+
+tools:
+ external_code_coverage:
+ timeout: 600
+ php_code_coverage:
+ enabled: true
+ test_command: ./vendor/bin/phpunit
+ php_code_sniffer:
+ enabled: true
+ config:
+ standard: PSR2
+ filter:
+ paths: ["src/*", "tests/*"]
+ php_cpd:
+ enabled: true
+ excluded_dirs: ["build/*", "tests", "vendor"]
+ php_cs_fixer:
+ enabled: true
+ config:
+ level: all
+ filter:
+ paths: ["src/*", "tests/*"]
+ php_loc:
+ enabled: true
+ excluded_dirs: ["build", "tests", "vendor"]
+ php_mess_detector:
+ enabled: true
+ config:
+ ruleset: phpmd.xml.dist
+ design_rules: { eval_expression: false }
+ filter:
+ paths: ["src/*"]
+ php_pdepend:
+ enabled: true
+ excluded_dirs: ["build", "tests", "vendor"]
+ php_analyzer:
+ enabled: true
+ filter:
+ paths: ["src/*", "tests/*"]
+ php_hhvm:
+ enabled: true
+ filter:
+ paths: ["src/*", "tests/*"]
+ sensiolabs_security_checker: true
--- /dev/null
+#!/bin/sh
+set -x
+if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ] || [ "$TRAVIS_PHP_VERSION" = 'hhvm-nightly' ] ; then
+ curl -sS https://getcomposer.org/installer > composer-installer.php
+ hhvm composer-installer.php
+ hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 composer.phar update --prefer-source
+elif [ "$TRAVIS_PHP_VERSION" = '5.3.3' ] ; then
+ composer self-update
+ composer update --prefer-source --no-dev
+ composer dump-autoload
+else
+ composer self-update
+ composer update --prefer-source
+fi
--- /dev/null
+language: php
+
+php:
+ - 5.3.3
+ - 5.3
+ - 5.4
+ - 5.5
+ - 5.6
+ - hhvm
+
+before_script:
+ - ./.travis.install.sh
+ - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then PHPUNIT_FLAGS="--coverage-clover coverage.clover"; else PHPUNIT_FLAGS=""; fi
+
+script:
+ - if [ $TRAVIS_PHP_VERSION = '5.3.3' ]; then phpunit; fi
+ - if [ $TRAVIS_PHP_VERSION != '5.3.3' ]; then ./vendor/bin/phpunit $PHPUNIT_FLAGS; fi
+ - if [ $TRAVIS_PHP_VERSION != '5.3.3' ]; then ./vendor/bin/phpcs --standard=PSR2 ./src/ ./tests/; fi
+ - if [[ $TRAVIS_PHP_VERSION != '5.3.3' && $TRAVIS_PHP_VERSION != '5.4.29' && $TRAVIS_PHP_VERSION != '5.5.13' ]]; then php -n ./vendor/bin/athletic -p ./tests/DoctrineTest/InstantiatorPerformance/ -f GroupedFormatter; fi
+
+after_script:
+ - if [ $TRAVIS_PHP_VERSION = '5.6' ]; then wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
--- /dev/null
+# Contributing
+
+ * Coding standard for the project is [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)
+ * The project will follow strict [object calisthenics](http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php)
+ * Any contribution must provide tests for additional introduced conditions
+ * Any un-confirmed issue needs a failing test case before being accepted
+ * Pull requests must be sent from a new hotfix/feature branch, not from `master`.
+
+## Installation
+
+To install the project and run the tests, you need to clone it first:
+
+```sh
+$ git clone git://github.com/doctrine/instantiator.git
+```
+
+You will then need to run a composer installation:
+
+```sh
+$ cd Instantiator
+$ curl -s https://getcomposer.org/installer | php
+$ php composer.phar update
+```
+
+## Testing
+
+The PHPUnit version to be used is the one installed as a dev- dependency via composer:
+
+```sh
+$ ./vendor/bin/phpunit
+```
+
+Accepted coverage for new contributions is 80%. Any contribution not satisfying this requirement
+won't be merged.
+
--- /dev/null
+Copyright (c) 2014 Doctrine Project
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
--- /dev/null
+# Instantiator
+
+This library provides a way of avoiding usage of constructors when instantiating PHP classes.
+
+[](https://travis-ci.org/doctrine/instantiator)
+[](https://scrutinizer-ci.com/g/doctrine/instantiator/?branch=master)
+[](https://scrutinizer-ci.com/g/doctrine/instantiator/?branch=master)
+[](https://www.versioneye.com/package/php--doctrine--instantiator)
+[](http://hhvm.h4cc.de/package/doctrine/instantiator)
+
+[](https://packagist.org/packages/doctrine/instantiator)
+[](https://packagist.org/packages/doctrine/instantiator)
+
+## Installation
+
+The suggested installation method is via [composer](https://getcomposer.org/):
+
+```sh
+php composer.phar require "doctrine/instantiator:~1.0.3"
+```
+
+## Usage
+
+The instantiator is able to create new instances of any class without using the constructor or any API of the class
+itself:
+
+```php
+$instantiator = new \Doctrine\Instantiator\Instantiator();
+
+$instance = $instantiator->instantiate('My\\ClassName\\Here');
+```
+
+## Contributing
+
+Please read the [CONTRIBUTING.md](CONTRIBUTING.md) contents if you wish to help out!
+
+## Credits
+
+This library was migrated from [ocramius/instantiator](https://github.com/Ocramius/Instantiator), which
+has been donated to the doctrine organization, and which is now deprecated in favour of this package.
--- /dev/null
+{
+ "name": "doctrine/instantiator",
+ "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
+ "type": "library",
+ "license": "MIT",
+ "homepage": "https://github.com/doctrine/instantiator",
+ "keywords": [
+ "instantiate",
+ "constructor"
+ ],
+ "authors": [
+ {
+ "name": "Marco Pivetta",
+ "email": "ocramius@gmail.com",
+ "homepage": "http://ocramius.github.com/"
+ }
+ ],
+ "require": {
+ "php": ">=5.3,<8.0-DEV"
+ },
+ "require-dev": {
+ "ext-phar": "*",
+ "ext-pdo": "*",
+ "phpunit/phpunit": "~4.0",
+ "squizlabs/php_codesniffer": "~2.0",
+ "athletic/athletic": "~0.1.8"
+ },
+ "autoload": {
+ "psr-4": {
+ "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/"
+ }
+ },
+ "autoload-dev": {
+ "psr-0": {
+ "DoctrineTest\\InstantiatorPerformance\\": "tests",
+ "DoctrineTest\\InstantiatorTest\\": "tests",
+ "DoctrineTest\\InstantiatorTestAsset\\": "tests"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<ruleset
+ name="Instantiator rules"
+ xmlns="http://pmd.sf.net/ruleset/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
+ xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
+>
+ <rule ref="rulesets/cleancode.xml">
+ <!-- static access is used for caching purposes -->
+ <exclude name="StaticAccess"/>
+ </rule>
+ <rule ref="rulesets/codesize.xml"/>
+ <rule ref="rulesets/controversial.xml"/>
+ <rule ref="rulesets/design.xml"/>
+ <rule ref="rulesets/naming.xml"/>
+ <rule ref="rulesets/unusedcode.xml"/>
+ <rule
+ name="NPathComplexity"
+ message="The {0} {1}() has an NPath complexity of {2}. The configured NPath complexity threshold is {3}."
+ class="PHP_PMD_Rule_Design_NpathComplexity"
+ >
+ <properties>
+ <property name="minimum" description="The npath reporting threshold" value="10"/>
+ </properties>
+ </rule>
+</ruleset>
--- /dev/null
+<?xml version="1.0"?>
+<phpunit
+ bootstrap="./vendor/autoload.php"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ verbose="true"
+ stopOnFailure="false"
+ processIsolation="false"
+ backupGlobals="false"
+ syntaxCheck="true"
+>
+ <testsuite name="Doctrine\Instantiator tests">
+ <directory>./tests/DoctrineTest/InstantiatorTest</directory>
+ </testsuite>
+ <filter>
+ <whitelist addUncoveredFilesFromWhitelist="true">
+ <directory suffix=".php">./src</directory>
+ </whitelist>
+ </filter>
+</phpunit>
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Instantiator\Exception;
+
+/**
+ * Base exception marker interface for the instantiator component
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+interface ExceptionInterface
+{
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Instantiator\Exception;
+
+use InvalidArgumentException as BaseInvalidArgumentException;
+use ReflectionClass;
+
+/**
+ * Exception for invalid arguments provided to the instantiator
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class InvalidArgumentException extends BaseInvalidArgumentException implements ExceptionInterface
+{
+ /**
+ * @param string $className
+ *
+ * @return self
+ */
+ public static function fromNonExistingClass($className)
+ {
+ if (interface_exists($className)) {
+ return new self(sprintf('The provided type "%s" is an interface, and can not be instantiated', $className));
+ }
+
+ if (PHP_VERSION_ID >= 50400 && trait_exists($className)) {
+ return new self(sprintf('The provided type "%s" is a trait, and can not be instantiated', $className));
+ }
+
+ return new self(sprintf('The provided class "%s" does not exist', $className));
+ }
+
+ /**
+ * @param ReflectionClass $reflectionClass
+ *
+ * @return self
+ */
+ public static function fromAbstractClass(ReflectionClass $reflectionClass)
+ {
+ return new self(sprintf(
+ 'The provided class "%s" is abstract, and can not be instantiated',
+ $reflectionClass->getName()
+ ));
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Instantiator\Exception;
+
+use Exception;
+use ReflectionClass;
+use UnexpectedValueException as BaseUnexpectedValueException;
+
+/**
+ * Exception for given parameters causing invalid/unexpected state on instantiation
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class UnexpectedValueException extends BaseUnexpectedValueException implements ExceptionInterface
+{
+ /**
+ * @param ReflectionClass $reflectionClass
+ * @param Exception $exception
+ *
+ * @return self
+ */
+ public static function fromSerializationTriggeredException(ReflectionClass $reflectionClass, Exception $exception)
+ {
+ return new self(
+ sprintf(
+ 'An exception was raised while trying to instantiate an instance of "%s" via un-serialization',
+ $reflectionClass->getName()
+ ),
+ 0,
+ $exception
+ );
+ }
+
+ /**
+ * @param ReflectionClass $reflectionClass
+ * @param string $errorString
+ * @param int $errorCode
+ * @param string $errorFile
+ * @param int $errorLine
+ *
+ * @return UnexpectedValueException
+ */
+ public static function fromUncleanUnSerialization(
+ ReflectionClass $reflectionClass,
+ $errorString,
+ $errorCode,
+ $errorFile,
+ $errorLine
+ ) {
+ return new self(
+ sprintf(
+ 'Could not produce an instance of "%s" via un-serialization, since an error was triggered '
+ . 'in file "%s" at line "%d"',
+ $reflectionClass->getName(),
+ $errorFile,
+ $errorLine
+ ),
+ 0,
+ new Exception($errorString, $errorCode)
+ );
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Instantiator;
+
+use Closure;
+use Doctrine\Instantiator\Exception\InvalidArgumentException;
+use Doctrine\Instantiator\Exception\UnexpectedValueException;
+use Exception;
+use ReflectionClass;
+
+/**
+ * {@inheritDoc}
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+final class Instantiator implements InstantiatorInterface
+{
+ /**
+ * Markers used internally by PHP to define whether {@see \unserialize} should invoke
+ * the method {@see \Serializable::unserialize()} when dealing with classes implementing
+ * the {@see \Serializable} interface.
+ */
+ const SERIALIZATION_FORMAT_USE_UNSERIALIZER = 'C';
+ const SERIALIZATION_FORMAT_AVOID_UNSERIALIZER = 'O';
+
+ /**
+ * @var \Closure[] of {@see \Closure} instances used to instantiate specific classes
+ */
+ private static $cachedInstantiators = array();
+
+ /**
+ * @var object[] of objects that can directly be cloned
+ */
+ private static $cachedCloneables = array();
+
+ /**
+ * {@inheritDoc}
+ */
+ public function instantiate($className)
+ {
+ if (isset(self::$cachedCloneables[$className])) {
+ return clone self::$cachedCloneables[$className];
+ }
+
+ if (isset(self::$cachedInstantiators[$className])) {
+ $factory = self::$cachedInstantiators[$className];
+
+ return $factory();
+ }
+
+ return $this->buildAndCacheFromFactory($className);
+ }
+
+ /**
+ * Builds the requested object and caches it in static properties for performance
+ *
+ * @param string $className
+ *
+ * @return object
+ */
+ private function buildAndCacheFromFactory($className)
+ {
+ $factory = self::$cachedInstantiators[$className] = $this->buildFactory($className);
+ $instance = $factory();
+
+ if ($this->isSafeToClone(new ReflectionClass($instance))) {
+ self::$cachedCloneables[$className] = clone $instance;
+ }
+
+ return $instance;
+ }
+
+ /**
+ * Builds a {@see \Closure} capable of instantiating the given $className without
+ * invoking its constructor.
+ *
+ * @param string $className
+ *
+ * @return Closure
+ */
+ private function buildFactory($className)
+ {
+ $reflectionClass = $this->getReflectionClass($className);
+
+ if ($this->isInstantiableViaReflection($reflectionClass)) {
+ return function () use ($reflectionClass) {
+ return $reflectionClass->newInstanceWithoutConstructor();
+ };
+ }
+
+ $serializedString = sprintf(
+ '%s:%d:"%s":0:{}',
+ $this->getSerializationFormat($reflectionClass),
+ strlen($className),
+ $className
+ );
+
+ $this->checkIfUnSerializationIsSupported($reflectionClass, $serializedString);
+
+ return function () use ($serializedString) {
+ return unserialize($serializedString);
+ };
+ }
+
+ /**
+ * @param string $className
+ *
+ * @return ReflectionClass
+ *
+ * @throws InvalidArgumentException
+ */
+ private function getReflectionClass($className)
+ {
+ if (! class_exists($className)) {
+ throw InvalidArgumentException::fromNonExistingClass($className);
+ }
+
+ $reflection = new ReflectionClass($className);
+
+ if ($reflection->isAbstract()) {
+ throw InvalidArgumentException::fromAbstractClass($reflection);
+ }
+
+ return $reflection;
+ }
+
+ /**
+ * @param ReflectionClass $reflectionClass
+ * @param string $serializedString
+ *
+ * @throws UnexpectedValueException
+ *
+ * @return void
+ */
+ private function checkIfUnSerializationIsSupported(ReflectionClass $reflectionClass, $serializedString)
+ {
+ set_error_handler(function ($code, $message, $file, $line) use ($reflectionClass, & $error) {
+ $error = UnexpectedValueException::fromUncleanUnSerialization(
+ $reflectionClass,
+ $message,
+ $code,
+ $file,
+ $line
+ );
+ });
+
+ $this->attemptInstantiationViaUnSerialization($reflectionClass, $serializedString);
+
+ restore_error_handler();
+
+ if ($error) {
+ throw $error;
+ }
+ }
+
+ /**
+ * @param ReflectionClass $reflectionClass
+ * @param string $serializedString
+ *
+ * @throws UnexpectedValueException
+ *
+ * @return void
+ */
+ private function attemptInstantiationViaUnSerialization(ReflectionClass $reflectionClass, $serializedString)
+ {
+ try {
+ unserialize($serializedString);
+ } catch (Exception $exception) {
+ restore_error_handler();
+
+ throw UnexpectedValueException::fromSerializationTriggeredException($reflectionClass, $exception);
+ }
+ }
+
+ /**
+ * @param ReflectionClass $reflectionClass
+ *
+ * @return bool
+ */
+ private function isInstantiableViaReflection(ReflectionClass $reflectionClass)
+ {
+ if (\PHP_VERSION_ID >= 50600) {
+ return ! ($this->hasInternalAncestors($reflectionClass) && $reflectionClass->isFinal());
+ }
+
+ return \PHP_VERSION_ID >= 50400 && ! $this->hasInternalAncestors($reflectionClass);
+ }
+
+ /**
+ * Verifies whether the given class is to be considered internal
+ *
+ * @param ReflectionClass $reflectionClass
+ *
+ * @return bool
+ */
+ private function hasInternalAncestors(ReflectionClass $reflectionClass)
+ {
+ do {
+ if ($reflectionClass->isInternal()) {
+ return true;
+ }
+ } while ($reflectionClass = $reflectionClass->getParentClass());
+
+ return false;
+ }
+
+ /**
+ * Verifies if the given PHP version implements the `Serializable` interface serialization
+ * with an incompatible serialization format. If that's the case, use serialization marker
+ * "C" instead of "O".
+ *
+ * @link http://news.php.net/php.internals/74654
+ *
+ * @param ReflectionClass $reflectionClass
+ *
+ * @return string the serialization format marker, either self::SERIALIZATION_FORMAT_USE_UNSERIALIZER
+ * or self::SERIALIZATION_FORMAT_AVOID_UNSERIALIZER
+ */
+ private function getSerializationFormat(ReflectionClass $reflectionClass)
+ {
+ if ($this->isPhpVersionWithBrokenSerializationFormat()
+ && $reflectionClass->implementsInterface('Serializable')
+ ) {
+ return self::SERIALIZATION_FORMAT_USE_UNSERIALIZER;
+ }
+
+ return self::SERIALIZATION_FORMAT_AVOID_UNSERIALIZER;
+ }
+
+ /**
+ * Checks whether the current PHP runtime uses an incompatible serialization format
+ *
+ * @return bool
+ */
+ private function isPhpVersionWithBrokenSerializationFormat()
+ {
+ return PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513;
+ }
+
+ /**
+ * Checks if a class is cloneable
+ *
+ * @param ReflectionClass $reflection
+ *
+ * @return bool
+ */
+ private function isSafeToClone(ReflectionClass $reflection)
+ {
+ if (method_exists($reflection, 'isCloneable') && ! $reflection->isCloneable()) {
+ return false;
+ }
+
+ // not cloneable if it implements `__clone`, as we want to avoid calling it
+ return ! $reflection->hasMethod('__clone');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Instantiator;
+
+/**
+ * Instantiator provides utility methods to build objects without invoking their constructors
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+interface InstantiatorInterface
+{
+ /**
+ * @param string $className
+ *
+ * @return object
+ *
+ * @throws \Doctrine\Instantiator\Exception\ExceptionInterface
+ */
+ public function instantiate($className);
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorPerformance;
+
+use Athletic\AthleticEvent;
+use Doctrine\Instantiator\Instantiator;
+
+/**
+ * Performance tests for {@see \Doctrine\Instantiator\Instantiator}
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class InstantiatorPerformanceEvent extends AthleticEvent
+{
+ /**
+ * @var \Doctrine\Instantiator\Instantiator
+ */
+ private $instantiator;
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function setUp()
+ {
+ $this->instantiator = new Instantiator();
+
+ $this->instantiator->instantiate(__CLASS__);
+ $this->instantiator->instantiate('ArrayObject');
+ $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset');
+ $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset');
+ $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset');
+ }
+
+ /**
+ * @iterations 20000
+ * @baseline
+ * @group instantiation
+ */
+ public function testInstantiateSelf()
+ {
+ $this->instantiator->instantiate(__CLASS__);
+ }
+
+ /**
+ * @iterations 20000
+ * @group instantiation
+ */
+ public function testInstantiateInternalClass()
+ {
+ $this->instantiator->instantiate('ArrayObject');
+ }
+
+ /**
+ * @iterations 20000
+ * @group instantiation
+ */
+ public function testInstantiateSimpleSerializableAssetClass()
+ {
+ $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset');
+ }
+
+ /**
+ * @iterations 20000
+ * @group instantiation
+ */
+ public function testInstantiateSerializableArrayObjectAsset()
+ {
+ $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset');
+ }
+
+ /**
+ * @iterations 20000
+ * @group instantiation
+ */
+ public function testInstantiateUnCloneableAsset()
+ {
+ $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTest\Exception;
+
+use Doctrine\Instantiator\Exception\InvalidArgumentException;
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * Tests for {@see \Doctrine\Instantiator\Exception\InvalidArgumentException}
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ *
+ * @covers \Doctrine\Instantiator\Exception\InvalidArgumentException
+ */
+class InvalidArgumentExceptionTest extends PHPUnit_Framework_TestCase
+{
+ public function testFromNonExistingTypeWithNonExistingClass()
+ {
+ $className = __CLASS__ . uniqid();
+ $exception = InvalidArgumentException::fromNonExistingClass($className);
+
+ $this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\InvalidArgumentException', $exception);
+ $this->assertSame('The provided class "' . $className . '" does not exist', $exception->getMessage());
+ }
+
+ public function testFromNonExistingTypeWithTrait()
+ {
+ if (PHP_VERSION_ID < 50400) {
+ $this->markTestSkipped('Need at least PHP 5.4.0, as this test requires traits support to run');
+ }
+
+ $exception = InvalidArgumentException::fromNonExistingClass(
+ 'DoctrineTest\\InstantiatorTestAsset\\SimpleTraitAsset'
+ );
+
+ $this->assertSame(
+ 'The provided type "DoctrineTest\\InstantiatorTestAsset\\SimpleTraitAsset" is a trait, '
+ . 'and can not be instantiated',
+ $exception->getMessage()
+ );
+ }
+
+ public function testFromNonExistingTypeWithInterface()
+ {
+ $exception = InvalidArgumentException::fromNonExistingClass('Doctrine\\Instantiator\\InstantiatorInterface');
+
+ $this->assertSame(
+ 'The provided type "Doctrine\\Instantiator\\InstantiatorInterface" is an interface, '
+ . 'and can not be instantiated',
+ $exception->getMessage()
+ );
+ }
+
+ public function testFromAbstractClass()
+ {
+ $reflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset');
+ $exception = InvalidArgumentException::fromAbstractClass($reflection);
+
+ $this->assertSame(
+ 'The provided class "DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset" is abstract, '
+ . 'and can not be instantiated',
+ $exception->getMessage()
+ );
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTest\Exception;
+
+use Doctrine\Instantiator\Exception\UnexpectedValueException;
+use Exception;
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * Tests for {@see \Doctrine\Instantiator\Exception\UnexpectedValueException}
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ *
+ * @covers \Doctrine\Instantiator\Exception\UnexpectedValueException
+ */
+class UnexpectedValueExceptionTest extends PHPUnit_Framework_TestCase
+{
+ public function testFromSerializationTriggeredException()
+ {
+ $reflectionClass = new ReflectionClass($this);
+ $previous = new Exception();
+ $exception = UnexpectedValueException::fromSerializationTriggeredException($reflectionClass, $previous);
+
+ $this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\UnexpectedValueException', $exception);
+ $this->assertSame($previous, $exception->getPrevious());
+ $this->assertSame(
+ 'An exception was raised while trying to instantiate an instance of "'
+ . __CLASS__ . '" via un-serialization',
+ $exception->getMessage()
+ );
+ }
+
+ public function testFromUncleanUnSerialization()
+ {
+ $reflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset');
+ $exception = UnexpectedValueException::fromUncleanUnSerialization($reflection, 'foo', 123, 'bar', 456);
+
+ $this->assertInstanceOf('Doctrine\\Instantiator\\Exception\\UnexpectedValueException', $exception);
+ $this->assertSame(
+ 'Could not produce an instance of "DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset" '
+ . 'via un-serialization, since an error was triggered in file "bar" at line "456"',
+ $exception->getMessage()
+ );
+
+ $previous = $exception->getPrevious();
+
+ $this->assertInstanceOf('Exception', $previous);
+ $this->assertSame('foo', $previous->getMessage());
+ $this->assertSame(123, $previous->getCode());
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTest;
+
+use Doctrine\Instantiator\Exception\UnexpectedValueException;
+use Doctrine\Instantiator\Instantiator;
+use PHPUnit_Framework_TestCase;
+use ReflectionClass;
+
+/**
+ * Tests for {@see \Doctrine\Instantiator\Instantiator}
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ *
+ * @covers \Doctrine\Instantiator\Instantiator
+ */
+class InstantiatorTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @var Instantiator
+ */
+ private $instantiator;
+
+ /**
+ * {@inheritDoc}
+ */
+ protected function setUp()
+ {
+ $this->instantiator = new Instantiator();
+ }
+
+ /**
+ * @param string $className
+ *
+ * @dataProvider getInstantiableClasses
+ */
+ public function testCanInstantiate($className)
+ {
+ $this->assertInstanceOf($className, $this->instantiator->instantiate($className));
+ }
+
+ /**
+ * @param string $className
+ *
+ * @dataProvider getInstantiableClasses
+ */
+ public function testInstantiatesSeparateInstances($className)
+ {
+ $instance1 = $this->instantiator->instantiate($className);
+ $instance2 = $this->instantiator->instantiate($className);
+
+ $this->assertEquals($instance1, $instance2);
+ $this->assertNotSame($instance1, $instance2);
+ }
+
+ public function testExceptionOnUnSerializationException()
+ {
+ if (defined('HHVM_VERSION')) {
+ $this->markTestSkipped(
+ 'As of facebook/hhvm#3432, HHVM has no PDORow, and therefore '
+ . ' no internal final classes that cannot be instantiated'
+ );
+ }
+
+ $className = 'DoctrineTest\\InstantiatorTestAsset\\UnserializeExceptionArrayObjectAsset';
+
+ if (\PHP_VERSION_ID >= 50600) {
+ $className = 'PDORow';
+ }
+
+ if (\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513) {
+ $className = 'DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset';
+ }
+
+ $this->setExpectedException('Doctrine\\Instantiator\\Exception\\UnexpectedValueException');
+
+ $this->instantiator->instantiate($className);
+ }
+
+ public function testNoticeOnUnSerializationException()
+ {
+ if (\PHP_VERSION_ID >= 50600) {
+ $this->markTestSkipped(
+ 'PHP 5.6 supports `ReflectionClass#newInstanceWithoutConstructor()` for some internal classes'
+ );
+ }
+
+ try {
+ $this->instantiator->instantiate('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset');
+
+ $this->fail('No exception was raised');
+ } catch (UnexpectedValueException $exception) {
+ $wakeUpNoticesReflection = new ReflectionClass('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset');
+ $previous = $exception->getPrevious();
+
+ $this->assertInstanceOf('Exception', $previous);
+
+ // in PHP 5.4.29 and PHP 5.5.13, this case is not a notice, but an exception being thrown
+ if (! (\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513)) {
+ $this->assertSame(
+ 'Could not produce an instance of "DoctrineTest\\InstantiatorTestAsset\WakeUpNoticesAsset" '
+ . 'via un-serialization, since an error was triggered in file "'
+ . $wakeUpNoticesReflection->getFileName() . '" at line "36"',
+ $exception->getMessage()
+ );
+
+ $this->assertSame('Something went bananas while un-serializing this instance', $previous->getMessage());
+ $this->assertSame(\E_USER_NOTICE, $previous->getCode());
+ }
+ }
+ }
+
+ /**
+ * @param string $invalidClassName
+ *
+ * @dataProvider getInvalidClassNames
+ */
+ public function testInstantiationFromNonExistingClass($invalidClassName)
+ {
+ $this->setExpectedException('Doctrine\\Instantiator\\Exception\\InvalidArgumentException');
+
+ $this->instantiator->instantiate($invalidClassName);
+ }
+
+ public function testInstancesAreNotCloned()
+ {
+ $className = 'TemporaryClass' . uniqid();
+
+ eval('namespace ' . __NAMESPACE__ . '; class ' . $className . '{}');
+
+ $instance = $this->instantiator->instantiate(__NAMESPACE__ . '\\' . $className);
+
+ $instance->foo = 'bar';
+
+ $instance2 = $this->instantiator->instantiate(__NAMESPACE__ . '\\' . $className);
+
+ $this->assertObjectNotHasAttribute('foo', $instance2);
+ }
+
+ /**
+ * Provides a list of instantiable classes (existing)
+ *
+ * @return string[][]
+ */
+ public function getInstantiableClasses()
+ {
+ $classes = array(
+ array('stdClass'),
+ array(__CLASS__),
+ array('Doctrine\\Instantiator\\Instantiator'),
+ array('Exception'),
+ array('PharException'),
+ array('DoctrineTest\\InstantiatorTestAsset\\SimpleSerializableAsset'),
+ array('DoctrineTest\\InstantiatorTestAsset\\ExceptionAsset'),
+ array('DoctrineTest\\InstantiatorTestAsset\\FinalExceptionAsset'),
+ array('DoctrineTest\\InstantiatorTestAsset\\PharExceptionAsset'),
+ array('DoctrineTest\\InstantiatorTestAsset\\UnCloneableAsset'),
+ array('DoctrineTest\\InstantiatorTestAsset\\XMLReaderAsset'),
+ );
+
+ if (\PHP_VERSION_ID === 50429 || \PHP_VERSION_ID === 50513) {
+ return $classes;
+ }
+
+ $classes = array_merge(
+ $classes,
+ array(
+ array('PharException'),
+ array('ArrayObject'),
+ array('DoctrineTest\\InstantiatorTestAsset\\ArrayObjectAsset'),
+ array('DoctrineTest\\InstantiatorTestAsset\\SerializableArrayObjectAsset'),
+ )
+ );
+
+ if (\PHP_VERSION_ID >= 50600) {
+ $classes[] = array('DoctrineTest\\InstantiatorTestAsset\\WakeUpNoticesAsset');
+ $classes[] = array('DoctrineTest\\InstantiatorTestAsset\\UnserializeExceptionArrayObjectAsset');
+ }
+
+ return $classes;
+ }
+
+ /**
+ * Provides a list of instantiable classes (existing)
+ *
+ * @return string[][]
+ */
+ public function getInvalidClassNames()
+ {
+ $classNames = array(
+ array(__CLASS__ . uniqid()),
+ array('Doctrine\\Instantiator\\InstantiatorInterface'),
+ array('DoctrineTest\\InstantiatorTestAsset\\AbstractClassAsset'),
+ );
+
+ if (\PHP_VERSION_ID >= 50400) {
+ $classNames[] = array('DoctrineTest\\InstantiatorTestAsset\\SimpleTraitAsset');
+ }
+
+ return $classNames;
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+/**
+ * A simple asset for an abstract class
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+abstract class AbstractClassAsset
+{
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use ArrayObject;
+use BadMethodCallException;
+
+/**
+ * Test asset that extends an internal PHP class
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class ArrayObjectAsset extends ArrayObject
+{
+ /**
+ * Constructor - should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function __construct()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use BadMethodCallException;
+use Exception;
+
+/**
+ * Test asset that extends an internal PHP base exception
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class ExceptionAsset extends Exception
+{
+ /**
+ * Constructor - should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function __construct()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use BadMethodCallException;
+use Exception;
+
+/**
+ * Test asset that extends an internal PHP base exception
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+final class FinalExceptionAsset extends Exception
+{
+ /**
+ * Constructor - should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function __construct()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use BadMethodCallException;
+use Phar;
+
+/**
+ * Test asset that extends an internal PHP class
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class PharAsset extends Phar
+{
+ /**
+ * Constructor - should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function __construct()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use BadMethodCallException;
+use PharException;
+
+/**
+ * Test asset that extends an internal PHP class
+ * This class should be serializable without problems
+ * and without getting the "Erroneous data format for unserializing"
+ * error
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class PharExceptionAsset extends PharException
+{
+ /**
+ * Constructor - should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function __construct()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use ArrayObject;
+use BadMethodCallException;
+use Serializable;
+
+/**
+ * Serializable test asset that also extends an internal class
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class SerializableArrayObjectAsset extends ArrayObject implements Serializable
+{
+ /**
+ * Constructor - should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function __construct()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function serialize()
+ {
+ return '';
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function unserialize($serialized)
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use BadMethodCallException;
+use Serializable;
+
+/**
+ * Base serializable test asset
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class SimpleSerializableAsset implements Serializable
+{
+ /**
+ * Constructor - should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function __construct()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function serialize()
+ {
+ return '';
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * Should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function unserialize($serialized)
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+/**
+ * A simple trait with no attached logic
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+trait SimpleTraitAsset
+{
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use BadMethodCallException;
+
+/**
+ * Base un-cloneable asset
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class UnCloneableAsset
+{
+ /**
+ * Constructor - should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function __construct()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+
+ /**
+ * Magic `__clone` - should not be invoked
+ *
+ * @throws BadMethodCallException
+ */
+ public function __clone()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use ArrayObject;
+use BadMethodCallException;
+
+/**
+ * A simple asset for an abstract class
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class UnserializeExceptionArrayObjectAsset extends ArrayObject
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function __wakeup()
+ {
+ throw new BadMethodCallException();
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use ArrayObject;
+
+/**
+ * A simple asset for an abstract class
+ *
+ * @author Marco Pivetta <ocramius@gmail.com>
+ */
+class WakeUpNoticesAsset extends ArrayObject
+{
+ /**
+ * Wakeup method called after un-serialization
+ */
+ public function __wakeup()
+ {
+ trigger_error('Something went bananas while un-serializing this instance');
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace DoctrineTest\InstantiatorTestAsset;
+
+use BadMethodCallException;
+use XMLReader;
+
+/**
+ * Test asset that extends an internal PHP class
+ *
+ * @author Dave Marshall <dave@atst.io>
+ */
+class XMLReaderAsset extends XMLReader
+{
+ /**
+ * Constructor - should not be called
+ *
+ * @throws BadMethodCallException
+ */
+ public function __construct()
+ {
+ throw new BadMethodCallException('Not supposed to be called!');
+ }
+}
--- /dev/null
+Copyright (c) 2006-2013 Doctrine Project
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
--- /dev/null
+# Doctrine Lexer
+
+Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
+
+This lexer is used in Doctrine Annotations and in Doctrine ORM (DQL).
--- /dev/null
+{
+ "name": "doctrine/lexer",
+ "type": "library",
+ "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.",
+ "keywords": ["lexer", "parser"],
+ "homepage": "http://www.doctrine-project.org",
+ "license": "MIT",
+ "authors": [
+ {"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
+ {"name": "Roman Borschel", "email": "roman@code-factory.org"},
+ {"name": "Johannes Schmitt", "email": "schmittjoh@gmail.com"}
+ ],
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "autoload": {
+ "psr-0": { "Doctrine\\Common\\Lexer\\": "lib/" }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0.x-dev"
+ }
+ }
+}
--- /dev/null
+<?php
+/*
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+namespace Doctrine\Common\Lexer;
+
+/**
+ * Base class for writing simple lexers, i.e. for creating small DSLs.
+ *
+ * @since 2.0
+ * @author Guilherme Blanco <guilhermeblanco@hotmail.com>
+ * @author Jonathan Wage <jonwage@gmail.com>
+ * @author Roman Borschel <roman@code-factory.org>
+ */
+abstract class AbstractLexer
+{
+ /**
+ * Lexer original input string.
+ *
+ * @var string
+ */
+ private $input;
+
+ /**
+ * Array of scanned tokens.
+ *
+ * Each token is an associative array containing three items:
+ * - 'value' : the string value of the token in the input string
+ * - 'type' : the type of the token (identifier, numeric, string, input
+ * parameter, none)
+ * - 'position' : the position of the token in the input string
+ *
+ * @var array
+ */
+ private $tokens = array();
+
+ /**
+ * Current lexer position in input string.
+ *
+ * @var integer
+ */
+ private $position = 0;
+
+ /**
+ * Current peek of current lexer position.
+ *
+ * @var integer
+ */
+ private $peek = 0;
+
+ /**
+ * The next token in the input.
+ *
+ * @var array
+ */
+ public $lookahead;
+
+ /**
+ * The last matched/seen token.
+ *
+ * @var array
+ */
+ public $token;
+
+ /**
+ * Sets the input data to be tokenized.
+ *
+ * The Lexer is immediately reset and the new input tokenized.
+ * Any unprocessed tokens from any previous input are lost.
+ *
+ * @param string $input The input to be tokenized.
+ *
+ * @return void
+ */
+ public function setInput($input)
+ {
+ $this->input = $input;
+ $this->tokens = array();
+
+ $this->reset();
+ $this->scan($input);
+ }
+
+ /**
+ * Resets the lexer.
+ *
+ * @return void
+ */
+ public function reset()
+ {
+ $this->lookahead = null;
+ $this->token = null;
+ $this->peek = 0;
+ $this->position = 0;
+ }
+
+ /**
+ * Resets the peek pointer to 0.
+ *
+ * @return void
+ */
+ public function resetPeek()
+ {
+ $this->peek = 0;
+ }
+
+ /**
+ * Resets the lexer position on the input to the given position.
+ *
+ * @param integer $position Position to place the lexical scanner.
+ *
+ * @return void
+ */
+ public function resetPosition($position = 0)
+ {
+ $this->position = $position;
+ }
+
+ /**
+ * Retrieve the original lexer's input until a given position.
+ *
+ * @param integer $position
+ *
+ * @return string
+ */
+ public function getInputUntilPosition($position)
+ {
+ return substr($this->input, 0, $position);
+ }
+
+ /**
+ * Checks whether a given token matches the current lookahead.
+ *
+ * @param integer|string $token
+ *
+ * @return boolean
+ */
+ public function isNextToken($token)
+ {
+ return null !== $this->lookahead && $this->lookahead['type'] === $token;
+ }
+
+ /**
+ * Checks whether any of the given tokens matches the current lookahead.
+ *
+ * @param array $tokens
+ *
+ * @return boolean
+ */
+ public function isNextTokenAny(array $tokens)
+ {
+ return null !== $this->lookahead && in_array($this->lookahead['type'], $tokens, true);
+ }
+
+ /**
+ * Moves to the next token in the input string.
+ *
+ * @return boolean
+ */
+ public function moveNext()
+ {
+ $this->peek = 0;
+ $this->token = $this->lookahead;
+ $this->lookahead = (isset($this->tokens[$this->position]))
+ ? $this->tokens[$this->position++] : null;
+
+ return $this->lookahead !== null;
+ }
+
+ /**
+ * Tells the lexer to skip input tokens until it sees a token with the given value.
+ *
+ * @param string $type The token type to skip until.
+ *
+ * @return void
+ */
+ public function skipUntil($type)
+ {
+ while ($this->lookahead !== null && $this->lookahead['type'] !== $type) {
+ $this->moveNext();
+ }
+ }
+
+ /**
+ * Checks if given value is identical to the given token.
+ *
+ * @param mixed $value
+ * @param integer $token
+ *
+ * @return boolean
+ */
+ public function isA($value, $token)
+ {
+ return $this->getType($value) === $token;
+ }
+
+ /**
+ * Moves the lookahead token forward.
+ *
+ * @return array|null The next token or NULL if there are no more tokens ahead.
+ */
+ public function peek()
+ {
+ if (isset($this->tokens[$this->position + $this->peek])) {
+ return $this->tokens[$this->position + $this->peek++];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Peeks at the next token, returns it and immediately resets the peek.
+ *
+ * @return array|null The next token or NULL if there are no more tokens ahead.
+ */
+ public function glimpse()
+ {
+ $peek = $this->peek();
+ $this->peek = 0;
+ return $peek;
+ }
+
+ /**
+ * Scans the input string for tokens.
+ *
+ * @param string $input A query string.
+ *
+ * @return void
+ */
+ protected function scan($input)
+ {
+ static $regex;
+
+ if ( ! isset($regex)) {
+ $regex = sprintf(
+ '/(%s)|%s/%s',
+ implode(')|(', $this->getCatchablePatterns()),
+ implode('|', $this->getNonCatchablePatterns()),
+ $this->getModifiers()
+ );
+ }
+
+ $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_OFFSET_CAPTURE;
+ $matches = preg_split($regex, $input, -1, $flags);
+
+ foreach ($matches as $match) {
+ // Must remain before 'value' assignment since it can change content
+ $type = $this->getType($match[0]);
+
+ $this->tokens[] = array(
+ 'value' => $match[0],
+ 'type' => $type,
+ 'position' => $match[1],
+ );
+ }
+ }
+
+ /**
+ * Gets the literal for a given token.
+ *
+ * @param integer $token
+ *
+ * @return string
+ */
+ public function getLiteral($token)
+ {
+ $className = get_class($this);
+ $reflClass = new \ReflectionClass($className);
+ $constants = $reflClass->getConstants();
+
+ foreach ($constants as $name => $value) {
+ if ($value === $token) {
+ return $className . '::' . $name;
+ }
+ }
+
+ return $token;
+ }
+
+ /**
+ * Regex modifiers
+ *
+ * @return string
+ */
+ protected function getModifiers()
+ {
+ return 'i';
+ }
+
+ /**
+ * Lexical catchable patterns.
+ *
+ * @return array
+ */
+ abstract protected function getCatchablePatterns();
+
+ /**
+ * Lexical non-catchable patterns.
+ *
+ * @return array
+ */
+ abstract protected function getNonCatchablePatterns();
+
+ /**
+ * Retrieve token type. Also processes the token value if necessary.
+ *
+ * @param string $value
+ *
+ * @return integer
+ */
+ abstract protected function getType(&$value);
+}
--- /dev/null
+/.buildpath
+/.project
+/.settings
+/.idea
+composer.lock
+vendor/
+
--- /dev/null
+tools:
+ external_code_coverage:
+ timeout: 600
+checks:
+ php:
+ code_rating: true
+ duplication: true
+filter:
+ paths:
+ - src/*
--- /dev/null
+language: php
+sudo: false
+cache:
+ directories:
+ - vendor
+ - $HOME/.composer/cache
+php:
+ - 5.5
+ - 5.6
+ - 7.0
+
+matrix:
+ include:
+ - php: 5.5
+ env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
+
+before_script:
+ - echo "xdebug.max_nesting_level=1000" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
+ - if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then PHPUNIT_FLAGS="--coverage-clover=coverage.clover"; else PHPUNIT_FLAGS=""; fi
+ - if [[ $TRAVIS_PHP_VERSION != '5.6' ]]; then phpenv config-rm xdebug.ini; fi
+ - composer self-update
+ - composer update $COMPOSER_FLAGS
+
+script: vendor/phpunit/phpunit/phpunit $PHPUNIT_FLAGS
+
+after_script:
+ - wget https://scrutinizer-ci.com/ocular.phar
+ - if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi
+
--- /dev/null
+The MIT License (MIT)
+
+Copyright (c) 2016 Asmir Mustafic
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
--- /dev/null
+# xsd2php-runtime
+
+[](https://travis-ci.org/goetas-webservices/xsd2php-runtime)
+[](https://scrutinizer-ci.com/g/goetas-webservices/xsd2php-runtime/?branch=master)
+[](https://scrutinizer-ci.com/g/goetas-webservices/xsd2php-runtime/?branch=master)
+
+
+Runtime libs for https://github.com/goetas-webservices/xsd2php
--- /dev/null
+{
+ "name": "goetas-webservices/xsd2php-runtime",
+ "description": "Convert XSD (XML Schema) definitions into PHP classes",
+ "type": "library",
+ "authors": [
+ {
+ "name": "Asmir Mustafic"
+ }
+ ],
+ "keywords": [
+ "converter",
+ "xml",
+ "xsd",
+ "php",
+ "jms",
+ "serializer"
+ ],
+ "license": "LGPL-3.0-or-later",
+ "require": {
+ "php": ">=5.5",
+ "jms/serializer": "^1.2",
+ "symfony/yaml": "^2.2|^3.0|^4.0"
+ },
+ "conflict": {
+ "jms/serializer": "1.4.1|1.6.1|1.6.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.8|^5.0"
+ },
+ "autoload": {
+ "psr-4": {
+ "GoetasWebservices\\Xsd\\XsdToPhpRuntime\\": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "GoetasWebservices\\Xsd\\XsdToPhpRuntime\\Tests\\": "tests/"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.2-dev"
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit backupGlobals="true"
+ backupStaticAttributes="false"
+ bootstrap="./vendor/autoload.php"
+ colors="false"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="false"
+ convertWarningsToExceptions="true"
+ forceCoversAnnotation="false"
+
+ processIsolation="false"
+ stopOnError="false"
+ stopOnFailure="false"
+ stopOnIncomplete="false"
+ stopOnSkipped="false"
+
+ verbose="false">
+
+ <testsuites>
+ <testsuite name="Goetas XSD to PHP Test Suite">
+ <directory>./tests</directory>
+ </testsuite>
+ </testsuites>
+
+<filter>
+ <whitelist>
+ <directory>src</directory>
+ </whitelist>
+ </filter>
+
+</phpunit>
+
+
--- /dev/null
+<?php
+namespace GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Handler\SubscribingHandlerInterface;
+use JMS\Serializer\XmlDeserializationVisitor;
+use JMS\Serializer\XmlSerializationVisitor;
+
+class BaseTypesHandler implements SubscribingHandlerInterface
+{
+
+ public static function getSubscribingMethods()
+ {
+ return array(
+ array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'format' => 'xml',
+ 'type' => 'GoetasWebservices\Xsd\XsdToPhp\Jms\SimpleListOf',
+ 'method' => 'simpleListOfToXml'
+ ),
+ array(
+ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
+ 'format' => 'xml',
+ 'type' => 'GoetasWebservices\Xsd\XsdToPhp\Jms\SimpleListOf',
+ 'method' => 'simpleListOfFromXML'
+ )
+ );
+ }
+
+ public function simpleListOfToXml(XmlSerializationVisitor $visitor, $object, array $type, Context $context)
+ {
+
+ $newType = array(
+ 'name' => $type["params"][0]["name"],
+ 'params' => array()
+ );
+
+ $ret = array();
+ foreach ($object as $v) {
+ $ret[] = $context->accept($v, $newType)->data;
+ }
+
+ return $visitor->getDocument()->createTextNode(implode(" ", $ret));
+ }
+
+ public function simpleListOfFromXml(XmlDeserializationVisitor $visitor, $node, array $type, Context $context)
+ {
+ $newType = array(
+ 'name' => $type["params"][0]["name"],
+ 'params' => array()
+ );
+ $ret = array();
+ foreach (explode(" ", (string)$node) as $v) {
+ $ret[] = $context->accept($v, $newType);
+ }
+ return $ret;
+ }
+}
+
--- /dev/null
+<?php
+namespace GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Handler\SubscribingHandlerInterface;
+use JMS\Serializer\XmlDeserializationVisitor;
+use JMS\Serializer\XmlSerializationVisitor;
+use RuntimeException;
+
+class XmlSchemaDateHandler implements SubscribingHandlerInterface
+{
+
+ protected $defaultTimezone;
+
+ public static function getSubscribingMethods()
+ {
+ return array(
+ array(
+ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
+ 'format' => 'xml',
+ 'type' => 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\Date',
+ 'method' => 'deserializeDate'
+ ),
+ array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'format' => 'xml',
+ 'type' => 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\Date',
+ 'method' => 'serializeDate'
+ ),
+ array(
+ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
+ 'format' => 'xml',
+ 'type' => 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime',
+ 'method' => 'deserializeDateTime'
+ ),
+ array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'format' => 'xml',
+ 'type' => 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\DateTime',
+ 'method' => 'serializeDateTime'
+ ),
+ array(
+ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
+ 'format' => 'xml',
+ 'type' => 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\Time',
+ 'method' => 'deserializeTime'
+ ),
+ array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'format' => 'xml',
+ 'type' => 'GoetasWebservices\Xsd\XsdToPhp\XMLSchema\Time',
+ 'method' => 'serializeTime'
+ ),
+ array(
+ 'type' => 'DateInterval',
+ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
+ 'format' => 'xml',
+ 'method' => 'deserializeDateIntervalXml',
+ ),
+ );
+ }
+
+ public function __construct($defaultTimezone = 'UTC')
+ {
+ $this->defaultTimezone = new \DateTimeZone($defaultTimezone);
+
+ }
+
+ public function deserializeDateIntervalXml(XmlDeserializationVisitor $visitor, $data, array $type){
+ $attributes = $data->attributes('xsi', true);
+ if (isset($attributes['nil'][0]) && (string) $attributes['nil'][0] === 'true') {
+ return null;
+ }
+ return new \DateInterval((string)$data);
+ }
+
+ public function serializeDate(XmlSerializationVisitor $visitor, \DateTime $date, array $type, Context $context)
+ {
+
+ $v = $date->format('Y-m-d');
+
+ return $visitor->visitSimpleString($v, $type, $context);
+ }
+
+ public function deserializeDate(XmlDeserializationVisitor $visitor, $data, array $type)
+ {
+ $attributes = $data->attributes('xsi', true);
+ if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') {
+ return null;
+ }
+ if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})(Z|([+-]\d{2}:\d{2}))?$/', $data)) {
+ throw new RuntimeException(sprintf('Invalid date "%s", expected valid XML Schema date string.', $data));
+ }
+
+ return $this->parseDateTime($data, $type);
+ }
+
+ public function serializeDateTime(XmlSerializationVisitor $visitor, \DateTime $date, array $type, Context $context)
+ {
+
+ $v = $date->format(\DateTime::W3C);
+
+ return $visitor->visitSimpleString($v, $type, $context);
+ }
+
+ public function deserializeDateTime(XmlDeserializationVisitor $visitor, $data, array $type)
+ {
+ $attributes = $data->attributes('xsi', true);
+ if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') {
+ return null;
+ }
+
+ return $this->parseDateTime($data, $type);
+
+ }
+
+ public function serializeTime(XmlSerializationVisitor $visitor, \DateTime $date, array $type, Context $context)
+ {
+ $v = $date->format('H:i:s');
+ if ($date->getTimezone()->getOffset($date) !== $this->defaultTimezone->getOffset($date)) {
+ $v .= $date->format('P');
+ }
+ return $visitor->visitSimpleString($v, $type, $context);
+ }
+
+ public function deserializeTime(XmlDeserializationVisitor $visitor, $data, array $type)
+ {
+ $attributes = $data->attributes('xsi', true);
+ if (isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true') {
+ return null;
+ }
+
+ $data = (string)$data;
+
+ return new \DateTime($data, $this->defaultTimezone);
+ }
+
+ private function parseDateTime($data, array $type)
+ {
+ $timezone = isset($type['params'][1]) ? new \DateTimeZone($type['params'][1]) : $this->defaultTimezone;
+ $datetime = new \DateTime((string)$data, $timezone);
+ if (false === $datetime) {
+ throw new RuntimeException(sprintf('Invalid datetime "%s", expected valid XML Schema dateTime string.', $data));
+ }
+
+ return $datetime;
+ }
+}
+
--- /dev/null
+<?php
+namespace GoetasWebservices\Xsd\XsdToPhpRuntime\Tests\Jms\Handler;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler\XmlSchemaDateHandler;
+use JMS\Serializer\Construction\UnserializeObjectConstructor;
+use JMS\Serializer\EventDispatcher\EventDispatcher;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Handler\HandlerRegistry;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
+use JMS\Serializer\XmlDeserializationVisitor;
+use Metadata\MetadataFactory;
+
+class XmlSchemaDateHandlerDeserializationTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var XmlSchemaDateHandler
+ */
+ protected $handler;
+ /**
+ * @var SerializationContext
+ */
+ protected $context;
+
+ /**
+ * @var XmlDeserializationVisitor
+ */
+ protected $visitor;
+
+ public function setUp()
+ {
+ $this->handler = new XmlSchemaDateHandler();
+ $this->visitor = new XmlDeserializationVisitor(new IdenticalPropertyNamingStrategy());
+
+ $dispatcher = new EventDispatcher();
+ $handlerRegistry= new HandlerRegistry();
+ $objectConstructor = new UnserializeObjectConstructor();
+ $metadataFactory = new MetadataFactory(new AnnotationDriver(new AnnotationReader()));
+
+ $navigator = new GraphNavigator($metadataFactory, $handlerRegistry, $objectConstructor, $dispatcher);
+
+ $this->visitor->setNavigator($navigator);
+ }
+
+ /**
+ * @dataProvider getDeserializeDate
+ * @param string $date
+ * @param \DateTime $expected
+ */
+ public function testDeserializeDate($date, \DateTime $expected)
+ {
+ $element = new \SimpleXMLElement("<Date>$date</Date>");
+ $deserialized = $this->handler->deserializeDate($this->visitor, $element, [], $this->context);
+ $this->assertEquals($expected, $deserialized);
+ }
+
+ public function getDeserializeDate()
+ {
+ return [
+ ['2015-01-01', new \DateTime('2015-01-01')],
+ ['2015-01-01Z', new \DateTime('2015-01-01', new \DateTimeZone("UTC"))],
+ ['2015-01-01+06:00', new \DateTime('2015-01-01', new \DateTimeZone("+06:00"))],
+ ['2015-01-01-20:00', new \DateTime('2015-01-01', new \DateTimeZone("-20:00"))],
+ ];
+ }
+
+ /**
+ * @expectedException \RuntimeException
+ */
+ public function testDeserializeInvalidDate()
+ {
+ $element = new \SimpleXMLElement("<Date>2015-01-01T</Date>");
+ $this->handler->deserializeDate($this->visitor, $element, [], $this->context);
+ }
+}
--- /dev/null
+<?php
+namespace GoetasWebservices\Xsd\XsdToPhpRuntime\Tests\Jms\Handler;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use GoetasWebservices\Xsd\XsdToPhpRuntime\Jms\Handler\XmlSchemaDateHandler;
+use JMS\Serializer\Construction\UnserializeObjectConstructor;
+use JMS\Serializer\EventDispatcher\EventDispatcher;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Handler\HandlerRegistry;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\XmlSerializationVisitor;
+use Metadata\MetadataFactory;
+
+class XmlSchemaDateHandlerSerializationTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var XmlSchemaDateHandler
+ */
+ protected $handler;
+ /**
+ * @var SerializationContext
+ */
+ protected $context;
+
+ /**
+ * @var XmlSerializationVisitor
+ */
+ protected $visitor;
+
+ public function setUp()
+ {
+ $this->handler = new XmlSchemaDateHandler();
+ $this->context = SerializationContext::create();
+ $this->visitor = new XmlSerializationVisitor(new IdenticalPropertyNamingStrategy());
+
+ $dispatcher = new EventDispatcher();
+ $handlerRegistry= new HandlerRegistry();
+ $objectConstructor = new UnserializeObjectConstructor();
+ $metadataFactory = new MetadataFactory(new AnnotationDriver(new AnnotationReader()));
+
+ $navigator = new GraphNavigator($metadataFactory, $handlerRegistry, $objectConstructor, $dispatcher);
+
+ $this->visitor->setNavigator($navigator);
+ }
+
+ /**
+ * @dataProvider getSerializeDateTime
+ * @param \DateTime $date
+ */
+ public function testSerializeDateTime(\DateTime $date, $expected)
+ {
+ $this->handler->serializeDateTime($this->visitor, $date, [], $this->context);
+ $this->assertEquals($expected, $this->visitor->getCurrentNode()->nodeValue);
+ }
+
+ public function getSerializeDateTime()
+ {
+ return [
+ [new \DateTime('2015-01-01 12:00+00:00'), '2015-01-01T12:00:00+00:00'],
+ [new \DateTime('2015-01-01 12:00:56+00:00'), '2015-01-01T12:00:56+00:00'],
+ [new \DateTime('2015-01-01 12:00:56+00:00'), '2015-01-01T12:00:56+00:00'],
+ [new \DateTime('2015-01-01 12:00:56+20:00'), '2015-01-01T12:00:56+20:00'],
+ [new \DateTime('2015-01-01 12:00:56', new \DateTimeZone("Europe/London")), '2015-01-01T12:00:56+00:00'],
+ [new \DateTime('2015-01-01 12:00:56+00:00', new \DateTimeZone("Europe/London")), '2015-01-01T12:00:56+00:00'],
+ [new \DateTime('2015-01-01 12:00:56', new \DateTimeZone("Europe/Rome")), '2015-01-01T12:00:56+01:00'],
+ ];
+ }
+
+ /**
+ * @dataProvider getSerializeDate
+ * @param \DateTime $date
+ * @param string $expected
+ */
+ public function testSerializeDate(\DateTime $date, $expected)
+ {
+ $this->handler->serializeDate($this->visitor, $date, [], $this->context);
+ $this->assertEquals($expected, $this->visitor->getCurrentNode()->nodeValue);
+ }
+
+ public function getSerializeDate()
+ {
+ return [
+ [new \DateTime('2015-01-01 12:00'), '2015-01-01'],
+ [new \DateTime('2015-01-01 12:00:56'), '2015-01-01'],
+ [new \DateTime('2015-01-01 12:00:56+00:00'), '2015-01-01'],
+ [new \DateTime('2015-01-01 12:00:56+20:00'), '2015-01-01'],
+ [new \DateTime('2015-01-01 12:00:56', new \DateTimeZone("Europe/London")), '2015-01-01'],
+ ];
+ }
+}
--- /dev/null
+vendor
\ No newline at end of file
--- /dev/null
+language: php
+
+php:
+ - 5.3
+ - 5.4
+ - 5.5
+ - 5.6
+ - hhvm
+
+matrix:
+ allow_failures:
+ - php: hhvm
+
+before_script:
+ - composer self-update
+ - composer install --dev --ignore-platform-reqs
+
+script: phpunit --coverage-clover clover
+
+after_success:
+ - wget https://scrutinizer-ci.com/ocular.phar
+ - php ocular.phar code-coverage:upload --format=php-clover clover
--- /dev/null
+CHANGELOG
+=========
+
+This changelog references all relevant changes:
+
+To get the diff between the two last versions, go to
+https://github.com/schmittjoh/metadata/compare/1.0.0...1.1.0
+
+* 1.5.0 (2013-11-06)
+ * adds ability to inject new drivers into the DriverChain after it has been constructed
+ * improves performance by removing some superfluous filesystem calls
+ * made MetadataFactory implementation non-final
+
+* 1.4.1 (2013-08-26)
+ * fixes a possible permission issue when using filesystem ACLs
+
+* 1.4.0 (2013-08-25)
+ * fixes a race condition when writing cache files
+
+* 1.3.0 (2013-01-22)
+ * added ability to retrieve all managed classes from the metadata factory
+
+* 1.2.0 (2012-08-21)
+ * added a Doctrine Cache Adapter
+ * better support for traits, and classes in the global namespace
+
+* 1.1.0 (2011-10-04)
+
+ * added support for metadata on interfaces
+ * added support for non annotation-based drivers
+ * added support for merging metadata
+
+This release is fully backwards compatible with the 1.0.0 release. Therefore,
+the 1.0.x branch has been discontinued.
+
+* 1.0.0 (2011-07-09)
--- /dev/null
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
--- /dev/null
+Metadata is a library for class/method/property metadata management in PHP
+==========================================================================
+
+Overview
+--------
+
+This library provides some commonly needed base classes for managing metadata
+for classes, methods and properties. The metadata can come from many different
+sources (annotations, YAML/XML/PHP configuration files).
+
+The metadata classes are used to abstract away that source and provide a common
+interface for all of them.
+
+Usage
+-----
+
+The library provides three classes that you can extend to add your application
+specific properties, and flags: ``ClassMetadata``, ``MethodMetadata``, and
+``PropertyMetadata``
+
+After you have added, your properties in sub-classes, you also need to add
+``DriverInterface`` implementations which know how to populate these classes
+from the different metadata sources.
+
+Finally, you can use the ``MetadataFactory`` to retrieve the metadata::
+
+ <?php
+
+ use Metadata\MetadataFactory;
+ use Metadata\Driver\DriverChain;
+
+ $driver = new DriverChain(array(
+ /** Annotation, YAML, XML, PHP, ... drivers */
+ ));
+ $factory = new MetadataFactory($driver);
+ $metadata = $factory->getMetadataForClass('MyNamespace\MyObject');
+
--- /dev/null
+{
+ "name": "jms/metadata",
+ "description": "Class/method/property metadata management in PHP",
+ "keywords": ["annotations","metadata","yaml","xml"],
+ "type": "library",
+ "license": "Apache-2.0",
+ "authors": [
+ {
+ "name": "Johannes M. Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev" : {
+ "doctrine/cache" : "~1.0",
+ "symfony/cache" : "~3.1"
+ },
+ "autoload": {
+ "psr-0": { "Metadata\\": "src/" }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.5.x-dev"
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false"
+ syntaxCheck="false"
+ bootstrap="tests/bootstrap.php"
+>
+ <testsuites>
+ <testsuite name="Metadata Test Suite">
+ <directory>./tests/Metadata/</directory>
+ </testsuite>
+ </testsuites>
+
+ <groups>
+ <exclude>
+ <group>performance</group>
+ </exclude>
+ </groups>
+</phpunit>
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata;
+
+/**
+ * Interface for advanced Metadata Factory implementations.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ * @author Jordan Stout <j@jrdn.org>
+ */
+interface AdvancedMetadataFactoryInterface extends MetadataFactoryInterface
+{
+ /**
+ * Gets all the possible classes.
+ *
+ * @throws \RuntimeException if driver does not an advanced driver.
+ * @return array
+ */
+ public function getAllClassNames();
+}
--- /dev/null
+<?php
+
+namespace Metadata\Cache;
+
+use Metadata\ClassMetadata;
+
+interface CacheInterface
+{
+ /**
+ * Loads a class metadata instance from the cache
+ *
+ * @param \ReflectionClass $class
+ *
+ * @return ClassMetadata
+ */
+ function loadClassMetadataFromCache(\ReflectionClass $class);
+
+ /**
+ * Puts a class metadata instance into the cache
+ *
+ * @param ClassMetadata $metadata
+ *
+ * @return void
+ */
+ function putClassMetadataInCache(ClassMetadata $metadata);
+
+ /**
+ * Evicts the class metadata for the given class from the cache.
+ *
+ * @param \ReflectionClass $class
+ *
+ * @return void
+ */
+ function evictClassMetadataFromCache(\ReflectionClass $class);
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata\Cache;
+
+use Doctrine\Common\Cache\Cache;
+use Metadata\ClassMetadata;
+
+/**
+ * @author Henrik Bjornskov <henrik@bjrnskov.dk>
+ */
+class DoctrineCacheAdapter implements CacheInterface
+{
+ /**
+ * @param string $prefix
+ */
+ private $prefix;
+
+ /**
+ * @var Cache $cache
+ */
+ private $cache;
+
+ /**
+ * @param string $prefix
+ * @param Cache $cache
+ */
+ public function __construct($prefix, Cache $cache)
+ {
+ $this->prefix = $prefix;
+ $this->cache = $cache;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function loadClassMetadataFromCache(\ReflectionClass $class)
+ {
+ $cache = $this->cache->fetch($this->prefix . $class->name);
+ return false === $cache ? null : $cache;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function putClassMetadataInCache(ClassMetadata $metadata)
+ {
+ $this->cache->save($this->prefix . $metadata->name, $metadata);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function evictClassMetadataFromCache(\ReflectionClass $class)
+ {
+ $this->cache->delete($this->prefix . $class->name);
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Cache;
+
+use Metadata\ClassMetadata;
+
+class FileCache implements CacheInterface
+{
+ private $dir;
+
+ public function __construct($dir)
+ {
+ if (!is_dir($dir)) {
+ throw new \InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir));
+ }
+ if (!is_writable($dir)) {
+ throw new \InvalidArgumentException(sprintf('The directory "%s" is not writable.', $dir));
+ }
+
+ $this->dir = rtrim($dir, '\\/');
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function loadClassMetadataFromCache(\ReflectionClass $class)
+ {
+ $path = $this->dir.'/'.strtr($class->name, '\\', '-').'.cache.php';
+ if (!file_exists($path)) {
+ return null;
+ }
+
+ return include $path;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function putClassMetadataInCache(ClassMetadata $metadata)
+ {
+ $path = $this->dir.'/'.strtr($metadata->name, '\\', '-').'.cache.php';
+
+ $tmpFile = tempnam($this->dir, 'metadata-cache');
+ file_put_contents($tmpFile, '<?php return unserialize('.var_export(serialize($metadata), true).');');
+
+ // Let's not break filesystems which do not support chmod.
+ @chmod($tmpFile, 0666 & ~umask());
+
+ $this->renameFile($tmpFile, $path);
+ }
+
+ /**
+ * Renames a file with fallback for windows
+ *
+ * @param string $source
+ * @param string $target
+ */
+ private function renameFile($source, $target) {
+ if (false === @rename($source, $target)) {
+ if (defined('PHP_WINDOWS_VERSION_BUILD')) {
+ if (false === copy($source, $target)) {
+ throw new \RuntimeException(sprintf('(WIN) Could not write new cache file to %s.', $target));
+ }
+ if (false === unlink($source)) {
+ throw new \RuntimeException(sprintf('(WIN) Could not delete temp cache file to %s.', $source));
+ }
+ } else {
+ throw new \RuntimeException(sprintf('Could not write new cache file to %s.', $target));
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function evictClassMetadataFromCache(\ReflectionClass $class)
+ {
+ $path = $this->dir.'/'.strtr($class->name, '\\', '-').'.cache.php';
+ if (file_exists($path)) {
+ unlink($path);
+ }
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Cache;
+
+use Metadata\ClassMetadata;
+use Psr\Cache\CacheItemPoolInterface;
+
+class PsrCacheAdapter implements CacheInterface
+{
+ private $prefix;
+ private $pool;
+ private $lastItem;
+
+ public function __construct($prefix, CacheItemPoolInterface $pool)
+ {
+ $this->prefix = $prefix;
+ $this->pool = $pool;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function loadClassMetadataFromCache(\ReflectionClass $class)
+ {
+ $this->lastItem = $this->pool->getItem(strtr($this->prefix . $class->name, '\\', '.'));
+
+ return $this->lastItem->get();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function putClassMetadataInCache(ClassMetadata $metadata)
+ {
+ $key = strtr($this->prefix . $metadata->name, '\\', '.');
+
+ if (null === $this->lastItem || $this->lastItem->getKey() !== $key) {
+ $this->lastItem = $this->pool->getItem($key);
+ }
+
+ $this->pool->save($this->lastItem->set($metadata));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function evictClassMetadataFromCache(\ReflectionClass $class)
+ {
+ $this->pool->deleteItem(strtr($this->prefix . $class->name, '\\', '.'));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata;
+
+/**
+ * Represents the metadata for the entire class hierarchy.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class ClassHierarchyMetadata
+{
+ public $classMetadata = array();
+
+ public function addClassMetadata(ClassMetadata $metadata)
+ {
+ $this->classMetadata[$metadata->name] = $metadata;
+ }
+
+ public function getRootClassMetadata()
+ {
+ return reset($this->classMetadata);
+ }
+
+ public function getOutsideClassMetadata()
+ {
+ return end($this->classMetadata);
+ }
+
+ public function isFresh($timestamp)
+ {
+ foreach ($this->classMetadata as $metadata) {
+ if (!$metadata->isFresh($timestamp)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata;
+
+/**
+ * Base class for class metadata.
+ *
+ * This class is intended to be extended to add your own application specific
+ * properties, and flags.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class ClassMetadata implements \Serializable
+{
+ public $name;
+ public $reflection;
+ public $methodMetadata = array();
+ public $propertyMetadata = array();
+ public $fileResources = array();
+ public $createdAt;
+
+ public function __construct($name)
+ {
+ $this->name = $name;
+
+ $this->reflection = new \ReflectionClass($name);
+ $this->createdAt = time();
+ }
+
+ public function addMethodMetadata(MethodMetadata $metadata)
+ {
+ $this->methodMetadata[$metadata->name] = $metadata;
+ }
+
+ public function addPropertyMetadata(PropertyMetadata $metadata)
+ {
+ $this->propertyMetadata[$metadata->name] = $metadata;
+ }
+
+ public function isFresh($timestamp = null)
+ {
+ if (null === $timestamp) {
+ $timestamp = $this->createdAt;
+ }
+
+ foreach ($this->fileResources as $filepath) {
+ if (!file_exists($filepath)) {
+ return false;
+ }
+
+ if ($timestamp < filemtime($filepath)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public function serialize()
+ {
+ return serialize(array(
+ $this->name,
+ $this->methodMetadata,
+ $this->propertyMetadata,
+ $this->fileResources,
+ $this->createdAt,
+ ));
+ }
+
+ public function unserialize($str)
+ {
+ list(
+ $this->name,
+ $this->methodMetadata,
+ $this->propertyMetadata,
+ $this->fileResources,
+ $this->createdAt
+ ) = unserialize($str);
+
+ $this->reflection = new \ReflectionClass($this->name);
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Driver;
+
+/**
+ * Base file driver implementation.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+abstract class AbstractFileDriver implements AdvancedDriverInterface
+{
+ /**
+ * @var FileLocatorInterface|FileLocator
+ */
+ private $locator;
+
+ public function __construct(FileLocatorInterface $locator)
+ {
+ $this->locator = $locator;
+ }
+
+ public function loadMetadataForClass(\ReflectionClass $class)
+ {
+ if (null === $path = $this->locator->findFileForClass($class, $this->getExtension())) {
+ return null;
+ }
+
+ return $this->loadMetadataFromFile($class, $path);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getAllClassNames()
+ {
+ if (!$this->locator instanceof AdvancedFileLocatorInterface) {
+ throw new \RuntimeException('Locator "%s" must be an instance of "AdvancedFileLocatorInterface".');
+ }
+
+ return $this->locator->findAllClasses($this->getExtension());
+ }
+
+ /**
+ * Parses the content of the file, and converts it to the desired metadata.
+ *
+ * @param \ReflectionClass $class
+ * @param string $file
+ *
+ * @return \Metadata\ClassMetadata|null
+ */
+ abstract protected function loadMetadataFromFile(\ReflectionClass $class, $file);
+
+ /**
+ * Returns the extension of the file.
+ *
+ * @return string
+ */
+ abstract protected function getExtension();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata\Driver;
+
+/**
+ * Forces advanced logic to drivers.
+ *
+ * @author Jordan Stout <j@jrdn.org>
+ */
+interface AdvancedDriverInterface extends DriverInterface
+{
+ /**
+ * Gets all the metadata class names known to this driver.
+ *
+ * @return array
+ */
+ public function getAllClassNames();
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata\Driver;
+
+/**
+ * Forces advanced logic on a file locator.
+ *
+ * @author Jordan Stout <j@jrdn.org>
+ */
+interface AdvancedFileLocatorInterface extends FileLocatorInterface
+{
+ /**
+ * Finds all possible metadata files.
+ *
+ * @param string $extension
+ *
+ * @return array
+ */
+ public function findAllClasses($extension);
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata\Driver;
+
+final class DriverChain implements AdvancedDriverInterface
+{
+ private $drivers;
+
+ public function __construct(array $drivers = array())
+ {
+ $this->drivers = $drivers;
+ }
+
+ public function addDriver(DriverInterface $driver)
+ {
+ $this->drivers[] = $driver;
+ }
+
+ public function loadMetadataForClass(\ReflectionClass $class)
+ {
+ foreach ($this->drivers as $driver) {
+ if (null !== $metadata = $driver->loadMetadataForClass($class)) {
+ return $metadata;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getAllClassNames()
+ {
+ $classes = array();
+ foreach ($this->drivers as $driver) {
+ if (!$driver instanceof AdvancedDriverInterface) {
+ throw new \RuntimeException(
+ sprintf(
+ 'Driver "%s" must be an instance of "AdvancedDriverInterface" to use '.
+ '"DriverChain::getAllClassNames()".',
+ get_class($driver)
+ )
+ );
+ }
+ $driverClasses = $driver->getAllClassNames();
+ if (!empty($driverClasses)) {
+ $classes = array_merge($classes, $driverClasses);
+ }
+ }
+
+ return $classes;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata\Driver;
+
+interface DriverInterface
+{
+ /**
+ * @param \ReflectionClass $class
+ *
+ * @return \Metadata\ClassMetadata
+ */
+ public function loadMetadataForClass(\ReflectionClass $class);
+}
--- /dev/null
+<?php
+
+namespace Metadata\Driver;
+
+class FileLocator implements AdvancedFileLocatorInterface
+{
+ private $dirs;
+
+ public function __construct(array $dirs)
+ {
+ $this->dirs = $dirs;
+ }
+
+ public function getDirs()
+ {
+ return $this->dirs;
+ }
+
+ /**
+ * @param \ReflectionClass $class
+ * @param string $extension
+ *
+ * @return string|null
+ */
+ public function findFileForClass(\ReflectionClass $class, $extension)
+ {
+ foreach ($this->dirs as $prefix => $dir) {
+ if ('' !== $prefix && 0 !== strpos($class->getNamespaceName(), $prefix)) {
+ continue;
+ }
+
+ $len = '' === $prefix ? 0 : strlen($prefix) + 1;
+ $path = $dir.'/'.str_replace('\\', '.', substr($class->name, $len)).'.'.$extension;
+ if (file_exists($path)) {
+ return $path;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function findAllClasses($extension)
+ {
+ $classes = array();
+ foreach ($this->dirs as $prefix => $dir) {
+ /** @var $iterator \RecursiveIteratorIterator|\SplFileInfo[] */
+ $iterator = new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($dir),
+ \RecursiveIteratorIterator::LEAVES_ONLY
+ );
+ $nsPrefix = $prefix !== '' ? $prefix.'\\' : '';
+ foreach ($iterator as $file) {
+ if (($fileName = $file->getBasename('.'.$extension)) == $file->getBasename()) {
+ continue;
+ }
+
+ $classes[] = $nsPrefix.str_replace('.', '\\', $fileName);
+ }
+ }
+
+ return $classes;
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Driver;
+
+interface FileLocatorInterface
+{
+ /**
+ * @param \ReflectionClass $class
+ * @param string $extension
+ *
+ * @return string|null
+ */
+ public function findFileForClass(\ReflectionClass $class, $extension);
+}
--- /dev/null
+<?php
+
+namespace Metadata\Driver;
+
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+class LazyLoadingDriver implements DriverInterface
+{
+ private $container;
+ private $realDriverId;
+
+ public function __construct(ContainerInterface $container, $realDriverId)
+ {
+ $this->container = $container;
+ $this->realDriverId = $realDriverId;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function loadMetadataForClass(\ReflectionClass $class)
+ {
+ return $this->container->get($this->realDriverId)->loadMetadataForClass($class);
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata;
+
+class MergeableClassMetadata extends ClassMetadata implements MergeableInterface
+{
+ public function merge(MergeableInterface $object)
+ {
+ if (!$object instanceof MergeableClassMetadata) {
+ throw new \InvalidArgumentException('$object must be an instance of MergeableClassMetadata.');
+ }
+
+ $this->name = $object->name;
+ $this->reflection = $object->reflection;
+ $this->methodMetadata = array_merge($this->methodMetadata, $object->methodMetadata);
+ $this->propertyMetadata = array_merge($this->propertyMetadata, $object->propertyMetadata);
+ $this->fileResources = array_merge($this->fileResources, $object->fileResources);
+
+ if ($object->createdAt < $this->createdAt) {
+ $this->createdAt = $object->createdAt;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata;
+
+interface MergeableInterface
+{
+ /**
+ * @param MergeableInterface $object
+ *
+ * @return void
+ */
+ public function merge(MergeableInterface $object);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata;
+
+use Metadata\Driver\AdvancedDriverInterface;
+use Metadata\Driver\DriverInterface;
+use Metadata\Cache\CacheInterface;
+
+class MetadataFactory implements AdvancedMetadataFactoryInterface
+{
+ private $driver;
+ private $cache;
+ private $loadedMetadata = array();
+ private $loadedClassMetadata = array();
+ private $hierarchyMetadataClass;
+ private $includeInterfaces = false;
+ private $debug;
+
+ /**
+ * @param DriverInterface $driver
+ * @param string $hierarchyMetadataClass
+ * @param boolean $debug
+ */
+ public function __construct(DriverInterface $driver, $hierarchyMetadataClass = 'Metadata\ClassHierarchyMetadata', $debug = false)
+ {
+ $this->driver = $driver;
+ $this->hierarchyMetadataClass = $hierarchyMetadataClass;
+ $this->debug = (Boolean) $debug;
+ }
+
+ /**
+ * @param boolean $include
+ */
+ public function setIncludeInterfaces($include)
+ {
+ $this->includeInterfaces = (Boolean) $include;
+ }
+
+ public function setCache(CacheInterface $cache)
+ {
+ $this->cache = $cache;
+ }
+
+ /**
+ * @param string $className
+ *
+ * @return ClassHierarchyMetadata|MergeableClassMetadata|null
+ */
+ public function getMetadataForClass($className)
+ {
+ if (isset($this->loadedMetadata[$className])) {
+ return $this->filterNullMetadata($this->loadedMetadata[$className]);
+ }
+
+ $metadata = null;
+ foreach ($this->getClassHierarchy($className) as $class) {
+ if (isset($this->loadedClassMetadata[$name = $class->getName()])) {
+ if (null !== $classMetadata = $this->filterNullMetadata($this->loadedClassMetadata[$name])) {
+ $this->addClassMetadata($metadata, $classMetadata);
+ }
+ continue;
+ }
+
+ // check the cache
+ if (null !== $this->cache) {
+ if (($classMetadata = $this->cache->loadClassMetadataFromCache($class)) instanceof NullMetadata) {
+ $this->loadedClassMetadata[$name] = $classMetadata;
+ continue;
+ }
+
+ if (null !== $classMetadata) {
+ if ( ! $classMetadata instanceof ClassMetadata) {
+ throw new \LogicException(sprintf('The cache must return instances of ClassMetadata, but got %s.', var_export($classMetadata, true)));
+ }
+
+ if ($this->debug && !$classMetadata->isFresh()) {
+ $this->cache->evictClassMetadataFromCache($classMetadata->reflection);
+ } else {
+ $this->loadedClassMetadata[$name] = $classMetadata;
+ $this->addClassMetadata($metadata, $classMetadata);
+ continue;
+ }
+ }
+ }
+
+ // load from source
+ if (null !== $classMetadata = $this->driver->loadMetadataForClass($class)) {
+ $this->loadedClassMetadata[$name] = $classMetadata;
+ $this->addClassMetadata($metadata, $classMetadata);
+
+ if (null !== $this->cache) {
+ $this->cache->putClassMetadataInCache($classMetadata);
+ }
+
+ continue;
+ }
+
+ if (null !== $this->cache && !$this->debug) {
+ $this->cache->putClassMetadataInCache(new NullMetadata($class->getName()));
+ }
+ }
+
+ if (null === $metadata) {
+ $metadata = new NullMetadata($className);
+ }
+
+ return $this->filterNullMetadata($this->loadedMetadata[$className] = $metadata);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getAllClassNames()
+ {
+ if (!$this->driver instanceof AdvancedDriverInterface) {
+ throw new \RuntimeException(
+ sprintf('Driver "%s" must be an instance of "AdvancedDriverInterface".', get_class($this->driver))
+ );
+ }
+
+ return $this->driver->getAllClassNames();
+ }
+
+ /**
+ * @param ClassMetadata|null $metadata
+ * @param ClassMetadata $toAdd
+ */
+ private function addClassMetadata(&$metadata, $toAdd)
+ {
+ if ($toAdd instanceof MergeableInterface) {
+ if (null === $metadata) {
+ $metadata = clone $toAdd;
+ } else {
+ $metadata->merge($toAdd);
+ }
+ } else {
+ if (null === $metadata) {
+ $metadata = new $this->hierarchyMetadataClass;
+ }
+
+ $metadata->addClassMetadata($toAdd);
+ }
+ }
+
+ /**
+ * @param string $class
+ */
+ private function getClassHierarchy($class)
+ {
+ $classes = array();
+ $refl = new \ReflectionClass($class);
+
+ do {
+ $classes[] = $refl;
+ $refl = $refl->getParentClass();
+ } while (false !== $refl);
+
+ $classes = array_reverse($classes, false);
+
+ if (!$this->includeInterfaces) {
+ return $classes;
+ }
+
+ $addedInterfaces = array();
+ $newHierarchy = array();
+
+ foreach ($classes as $class) {
+ foreach ($class->getInterfaces() as $interface) {
+ if (isset($addedInterfaces[$interface->getName()])) {
+ continue;
+ }
+ $addedInterfaces[$interface->getName()] = true;
+
+ $newHierarchy[] = $interface;
+ }
+
+ $newHierarchy[] = $class;
+ }
+
+ return $newHierarchy;
+ }
+
+ /**
+ * @param NullMetadata|null $metadata
+ *
+ * @return ClassMetadata|null
+ */
+ private function filterNullMetadata($metadata = null)
+ {
+ return !$metadata instanceof NullMetadata ? $metadata : null;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata;
+
+/**
+ * Interface for Metadata Factory implementations.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface MetadataFactoryInterface
+{
+ /**
+ * Returns the gathered metadata for the given class name.
+ *
+ * If the drivers return instances of MergeableClassMetadata, these will be
+ * merged prior to returning. Otherwise, all metadata for the inheritance
+ * hierarchy will be returned as ClassHierarchyMetadata unmerged.
+ *
+ * If no metadata is available, null is returned.
+ *
+ * @param string $className
+ *
+ * @return ClassHierarchyMetadata|MergeableClassMetadata|null
+ */
+ public function getMetadataForClass($className);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata;
+
+/**
+ * Base class for method metadata.
+ *
+ * This class is intended to be extended to add your application specific
+ * properties, and flags.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class MethodMetadata implements \Serializable
+{
+ public $class;
+ public $name;
+ public $reflection;
+
+ public function __construct($class, $name)
+ {
+ $this->class = $class;
+ $this->name = $name;
+
+ $this->reflection = new \ReflectionMethod($class, $name);
+ $this->reflection->setAccessible(true);
+ }
+
+ /**
+ * @param object $obj
+ * @param array $args
+ *
+ * @return mixed
+ */
+ public function invoke($obj, array $args = array())
+ {
+ return $this->reflection->invokeArgs($obj, $args);
+ }
+
+ public function serialize()
+ {
+ return serialize(array($this->class, $this->name));
+ }
+
+ public function unserialize($str)
+ {
+ list($this->class, $this->name) = unserialize($str);
+
+ $this->reflection = new \ReflectionMethod($this->class, $this->name);
+ $this->reflection->setAccessible(true);
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata;
+
+/**
+ * Represents the metadata for a class that has not metadata.
+ *
+ * @author Adrien Brault <adrien.brault@gmail.com>
+ */
+class NullMetadata extends ClassMetadata
+{
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata;
+
+/**
+ * Base class for property metadata.
+ *
+ * This class is intended to be extended to add your application specific
+ * properties, and flags.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class PropertyMetadata implements \Serializable
+{
+ public $class;
+ public $name;
+ public $reflection;
+
+ public function __construct($class, $name)
+ {
+ $this->class = $class;
+ $this->name = $name;
+
+ $this->reflection = new \ReflectionProperty($class, $name);
+ $this->reflection->setAccessible(true);
+ }
+
+ /**
+ * @param object $obj
+ *
+ * @return mixed
+ */
+ public function getValue($obj)
+ {
+ return $this->reflection->getValue($obj);
+ }
+
+ /**
+ * @param object $obj
+ * @param string $value
+ */
+ public function setValue($obj, $value)
+ {
+ $this->reflection->setValue($obj, $value);
+ }
+
+ public function serialize()
+ {
+ return serialize(array(
+ $this->class,
+ $this->name,
+ ));
+ }
+
+ public function unserialize($str)
+ {
+ list($this->class, $this->name) = unserialize($str);
+
+ $this->reflection = new \ReflectionProperty($this->class, $this->name);
+ $this->reflection->setAccessible(true);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Metadata;
+
+final class Version
+{
+ const VERSION = '1.4-DEV';
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Cache;
+
+use Metadata\ClassMetadata;
+use Metadata\Cache\DoctrineCacheAdapter;
+use Doctrine\Common\Cache\ArrayCache;
+
+/**
+ * @requires PHP 5.4
+ */
+class DoctrineCacheAdapterTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ if (!interface_exists('Doctrine\Common\Cache\Cache')) {
+ $this->markTestSkipped('Doctrine\Common is not installed.');
+ }
+ }
+
+ public function testLoadEvictPutClassMetadataFromInCache()
+ {
+ $cache = new DoctrineCacheAdapter('metadata-test', new ArrayCache());
+
+ $this->assertNull($cache->loadClassMetadataFromCache($refl = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject')));
+ $cache->putClassMetadataInCache($metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject'));
+
+ $this->assertEquals($metadata, $cache->loadClassMetadataFromCache($refl));
+
+ $cache->evictClassMetadataFromCache($refl);
+ $this->assertNull($cache->loadClassMetadataFromCache($refl));
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Cache;
+
+use Metadata\ClassMetadata;
+use Metadata\Cache\FileCache;
+
+class FileCacheTest extends \PHPUnit_Framework_TestCase
+{
+ public function testLoadEvictPutClassMetadataFromInCache()
+ {
+ $cache = new FileCache(sys_get_temp_dir());
+
+ $this->assertNull($cache->loadClassMetadataFromCache($refl = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject')));
+ $cache->putClassMetadataInCache($metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject'));
+
+ $this->assertEquals($metadata, $cache->loadClassMetadataFromCache($refl));
+
+ $cache->evictClassMetadataFromCache($refl);
+ $this->assertNull($cache->loadClassMetadataFromCache($refl));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Cache;
+
+use Metadata\ClassMetadata;
+use Metadata\Cache\PsrCacheAdapter;
+use Symfony\Component\Cache\Adapter\ArrayAdapter;
+
+/**
+ * @requires PHP 5.5
+ */
+class PsrCacheAdapterTest extends \PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ if (!class_exists('Symfony\Component\Cache\CacheItem')) {
+ $this->markTestSkipped('symfony/cache is not installed.');
+ }
+ }
+
+ public function testLoadEvictPutClassMetadataFromInCache()
+ {
+ $cache = new PsrCacheAdapter('metadata-test', new ArrayAdapter());
+
+ $this->assertNull($cache->loadClassMetadataFromCache($refl = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject')));
+ $cache->putClassMetadataInCache($metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject'));
+
+ $this->assertEquals($metadata, $cache->loadClassMetadataFromCache($refl));
+
+ $cache->evictClassMetadataFromCache($refl);
+ $this->assertNull($cache->loadClassMetadataFromCache($refl));
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests;
+
+use Metadata\ClassMetadata;
+
+class ClassMetadataTest extends \PHPUnit_Framework_TestCase
+{
+ public function testConstructor()
+ {
+ $metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject');
+
+ $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->name);
+ $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->reflection->name);
+ }
+
+ public function testSerializeUnserialize()
+ {
+ $metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject');
+
+ $this->assertEquals($metadata, unserialize(serialize($metadata)));
+ }
+
+ public function testIsFresh()
+ {
+ $ref = new \ReflectionClass('Metadata\Tests\Fixtures\TestObject');
+ touch($ref->getFilename());
+ sleep(2);
+
+ $metadata = new ClassMetadata($ref->name);
+ $metadata->fileResources[] = $ref->getFilename();
+ $this->assertTrue($metadata->isFresh());
+
+ sleep(2);
+ clearstatcache($ref->getFilename());
+ touch($ref->getFilename());
+ $this->assertFalse($metadata->isFresh());
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Driver;
+
+use Metadata\ClassMetadata;
+
+/**
+ * @author Jordan Stout <j@jrdn.org>
+ */
+class AbstractFileDriverTest extends \PHPUnit_Framework_TestCase
+{
+ private static $extension = 'jms_metadata.yml';
+
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
+ private $locator;
+
+ /** @var \PHPUnit_Framework_MockObject_MockObject */
+ private $driver;
+
+ public function setUp()
+ {
+ $this->locator = $this->getMock('Metadata\Driver\FileLocator', array(), array(), '', false);
+ $this->driver = $this->getMockBuilder('Metadata\Driver\AbstractFileDriver')
+ ->setConstructorArgs(array($this->locator))
+ ->getMockForAbstractClass();
+
+ $this->driver->expects($this->any())->method('getExtension')->will($this->returnValue(self::$extension));
+ }
+
+ public function testLoadMetadataForClass()
+ {
+ $class = new \ReflectionClass('\stdClass');
+ $this->locator
+ ->expects($this->once())
+ ->method('findFileForClass')
+ ->with($class, self::$extension)
+ ->will($this->returnValue('Some\Path'));
+
+ $this->driver
+ ->expects($this->once())
+ ->method('loadMetadataFromFile')
+ ->with($class, 'Some\Path')
+ ->will($this->returnValue($metadata = new ClassMetadata('\stdClass')));
+
+ $this->assertSame($metadata, $this->driver->loadMetadataForClass($class));
+ }
+
+ public function testLoadMetadataForClassWillReturnNull()
+ {
+ $class = new \ReflectionClass('\stdClass');
+ $this->locator
+ ->expects($this->once())
+ ->method('findFileForClass')
+ ->with($class, self::$extension)
+ ->will($this->returnValue(null));
+
+ $this->assertSame(null, $this->driver->loadMetadataForClass($class));
+ }
+
+ public function testGetAllClassNames()
+ {
+ $class = new \ReflectionClass('\stdClass');
+ $this->locator
+ ->expects($this->once())
+ ->method('findAllClasses')
+ ->with(self::$extension)
+ ->will($this->returnValue(array('\stdClass')));
+
+ $this->assertSame(array('\stdClass'), $this->driver->getAllClassNames($class));
+ }
+
+ public function testGetAllClassNamesThrowsRuntimeException()
+ {
+ $this->setExpectedException('RuntimeException');
+
+ $locator = $this->getMock('Metadata\Driver\FileLocatorInterface', array(), array(), '', false);
+ $driver = $this->getMockBuilder('Metadata\Driver\AbstractFileDriver')
+ ->setConstructorArgs(array($locator))
+ ->getMockForAbstractClass();
+ $class = new \ReflectionClass('\stdClass');
+ $locator->expects($this->never())->method('findAllClasses');
+
+ $driver->getAllClassNames($class);
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Driver;
+
+use Metadata\ClassMetadata;
+use Metadata\Driver\DriverChain;
+
+class DriverChainTest extends \PHPUnit_Framework_TestCase
+{
+ public function testLoadMetadataForClass()
+ {
+ $driver = $this->getMock('Metadata\\Driver\\DriverInterface');
+ $driver
+ ->expects($this->once())
+ ->method('loadMetadataForClass')
+ ->will($this->returnValue($metadata = new ClassMetadata('\stdClass')))
+ ;
+ $chain = new DriverChain(array($driver));
+
+ $this->assertSame($metadata, $chain->loadMetadataForClass(new \ReflectionClass('\stdClass')));
+ }
+
+ public function testGetAllClassNames()
+ {
+ $driver1 = $this->getMock('Metadata\\Driver\\AdvancedDriverInterface');
+ $driver1
+ ->expects($this->once())
+ ->method('getAllClassNames')
+ ->will($this->returnValue(array('Foo')));
+
+ $driver2 = $this->getMock('Metadata\\Driver\\AdvancedDriverInterface');
+ $driver2
+ ->expects($this->once())
+ ->method('getAllClassNames')
+ ->will($this->returnValue(array('Bar')));
+
+ $chain = new DriverChain(array($driver1, $driver2));
+
+ $this->assertSame(array('Foo', 'Bar'), $chain->getAllClassNames());
+ }
+
+ public function testLoadMetadataForClassReturnsNullWhenNoMetadataIsFound()
+ {
+ $driver = new DriverChain(array());
+ $this->assertNull($driver->loadMetadataForClass(new \ReflectionClass('\stdClass')));
+
+ $driver = $this->getMock('Metadata\\Driver\\DriverInterface');
+ $driver
+ ->expects($this->once())
+ ->method('loadMetadataForClass')
+ ->will($this->returnValue(null))
+ ;
+ $driverChain = new DriverChain(array($driver));
+ $this->assertNull($driver->loadMetadataForClass(new \ReflectionClass('\stdClass')));
+ }
+
+ public function testGetAllClassNamesThrowsException()
+ {
+ $this->setExpectedException('RuntimeException');
+ $driver = $this->getMock('Metadata\\Driver\\DriverInterface');
+ $driver->expects($this->never())->method('getAllClassNames');
+ $chain = new DriverChain(array($driver));
+ $chain->getAllClassNames();
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Driver;
+
+use Metadata\Driver\FileLocator;
+
+class FileLocatorTest extends \PHPUnit_Framework_TestCase
+{
+ public function testFindFileForClass()
+ {
+ $locator = new FileLocator(array(
+ 'Metadata\Tests\Driver\Fixture\A' => __DIR__.'/Fixture/A',
+ 'Metadata\Tests\Driver\Fixture\B' => __DIR__.'/Fixture/B',
+ 'Metadata\Tests\Driver\Fixture\C' => __DIR__.'/Fixture/C',
+ ));
+
+ $ref = new \ReflectionClass('Metadata\Tests\Driver\Fixture\A\A');
+ $this->assertEquals(realpath(__DIR__.'/Fixture/A/A.xml'), realpath($locator->findFileForClass($ref, 'xml')));
+
+ $ref = new \ReflectionClass('Metadata\Tests\Driver\Fixture\B\B');
+ $this->assertNull($locator->findFileForClass($ref, 'xml'));
+
+ $ref = new \ReflectionClass('Metadata\Tests\Driver\Fixture\C\SubDir\C');
+ $this->assertEquals(realpath(__DIR__.'/Fixture/C/SubDir.C.yml'), realpath($locator->findFileForClass($ref, 'yml')));
+ }
+
+ public function testTraits()
+ {
+ if (version_compare(PHP_VERSION, '5.4.0', '<')) {
+ $this->markTestSkipped('No traits available');
+ }
+
+ $locator = new FileLocator(array(
+ 'Metadata\Tests\Driver\Fixture\T' => __DIR__.'/Fixture/T',
+ ));
+
+ $ref = new \ReflectionClass('Metadata\Tests\Driver\Fixture\T\T');
+ $this->assertEquals(realpath(__DIR__.'/Fixture/T/T.xml'), realpath($locator->findFileForClass($ref, 'xml')));
+ }
+
+ public function testFindFileForGlobalNamespacedClass()
+ {
+ $locator = new FileLocator(array(
+ '' => __DIR__.'/Fixture/D',
+ ));
+
+ require_once __DIR__.'/Fixture/D/D.php';
+ $ref = new \ReflectionClass('D');
+ $this->assertEquals(realpath(__DIR__.'/Fixture/D/D.yml'), realpath($locator->findFileForClass($ref, 'yml')));
+ }
+
+ public function testFindAllFiles()
+ {
+ $locator = new FileLocator(array(
+ 'Metadata\Tests\Driver\Fixture\A' => __DIR__.'/Fixture/A',
+ 'Metadata\Tests\Driver\Fixture\B' => __DIR__.'/Fixture/B',
+ 'Metadata\Tests\Driver\Fixture\C' => __DIR__.'/Fixture/C',
+ 'Metadata\Tests\Driver\Fixture\D' => __DIR__.'/Fixture/D'
+ ));
+
+ $this->assertCount(1, $xmlFiles = $locator->findAllClasses('xml'));
+ $this->assertSame('Metadata\Tests\Driver\Fixture\A\A', $xmlFiles[0]);
+
+ $this->assertCount(3, $ymlFiles = $locator->findAllClasses('yml'));
+ $this->assertSame('Metadata\Tests\Driver\Fixture\B\B', $ymlFiles[0]);
+ $this->assertSame('Metadata\Tests\Driver\Fixture\C\SubDir\C', $ymlFiles[1]);
+ $this->assertSame('Metadata\Tests\Driver\Fixture\D\D', $ymlFiles[2]);
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Driver\Fixture\A;
+
+class A {}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Driver\Fixture\B;
+
+class B { }
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Driver\Fixture\C\SubDir;
+
+class C { }
\ No newline at end of file
--- /dev/null
+<?php
+
+class D { }
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Driver\Fixture\T;
+
+trait T {}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Fixtures\ComplexHierarchy;
+
+abstract class BaseClass implements InterfaceA
+{
+ private $foo;
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Fixtures\ComplexHierarchy;
+
+interface InterfaceA
+{
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Fixtures\ComplexHierarchy;
+
+interface InterfaceB
+{
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Fixtures\ComplexHierarchy;
+
+class SubClassA extends BaseClass implements InterfaceA, InterfaceB
+{
+ private $bar;
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Fixtures\ComplexHierarchy;
+
+class SubClassB extends BaseClass
+{
+ private $baz;
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Fixtures;
+
+class TestObject
+{
+ private $foo;
+
+ public function getFoo()
+ {
+ return $this->foo;
+ }
+
+ private function setFoo($foo)
+ {
+ $this->foo = $foo;
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests\Fixtures;
+
+class TestParent extends TestObject
+{
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata\Tests;
+
+use Metadata\MergeableClassMetadata;
+
+class MergeableClassMetadataTest extends \PHPUnit_Framework_TestCase
+{
+ public function testMerge()
+ {
+ $parentMetadata = new MergeableClassMetadata('Metadata\Tests\Fixtures\TestParent');
+ $parentMetadata->propertyMetadata['foo'] = 'bar';
+ $parentMetadata->propertyMetadata['baz'] = 'baz';
+ $parentMetadata->methodMetadata['foo'] = 'bar';
+ $parentMetadata->createdAt = 2;
+ $parentMetadata->fileResources[] = 'foo';
+
+ $childMetadata = new MergeableClassMetadata('Metadata\Tests\Fixtures\TestObject');
+ $childMetadata->propertyMetadata['foo'] = 'baz';
+ $childMetadata->methodMetadata['foo'] = 'baz';
+ $childMetadata->createdAt = 1;
+ $childMetadata->fileResources[] = 'bar';
+
+ $parentMetadata->merge($childMetadata);
+ $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $parentMetadata->name);
+ $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $parentMetadata->reflection->name);
+ $this->assertEquals(array('foo' => 'baz', 'baz' => 'baz',), $parentMetadata->propertyMetadata);
+ $this->assertEquals(array('foo' => 'baz',), $parentMetadata->methodMetadata);
+ $this->assertEquals(1, $parentMetadata->createdAt);
+ $this->assertEquals(array('foo', 'bar'), $parentMetadata->fileResources);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata\Tests;
+
+use Metadata\PropertyMetadata;
+use Metadata\MergeableClassMetadata;
+use Metadata\ClassMetadata;
+use Metadata\MetadataFactory;
+
+class MetadataFactoryTest extends \PHPUnit_Framework_TestCase
+{
+ public function testGetMetadataForClass()
+ {
+ $driver = $this->getMock('Metadata\Driver\DriverInterface');
+
+ $driver
+ ->expects($this->at(0))
+ ->method('loadMetadataForClass')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestObject')))
+ ->will($this->returnCallback(function($class) {
+ return new ClassMetadata($class->getName());
+ }))
+ ;
+ $driver
+ ->expects($this->at(1))
+ ->method('loadMetadataForClass')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestParent')))
+ ->will($this->returnCallback(function($class) {
+ return new ClassMetadata($class->getName());
+ }))
+ ;
+
+ $factory = new MetadataFactory($driver);
+ $metadata = $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestParent');
+
+ $this->assertInstanceOf('Metadata\ClassHierarchyMetadata', $metadata);
+ $this->assertEquals(2, count($metadata->classMetadata));
+ }
+
+ public function testGetMetadataForClassWhenMergeable()
+ {
+ $driver = $this->getMock('Metadata\Driver\DriverInterface');
+
+ $driver
+ ->expects($this->at(0))
+ ->method('loadMetadataForClass')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestObject')))
+ ->will($this->returnCallback(function($class) {
+ return new MergeableClassMetadata($class->getName());
+ }))
+ ;
+ $driver
+ ->expects($this->at(1))
+ ->method('loadMetadataForClass')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestParent')))
+ ->will($this->returnCallback(function($class) {
+ return new MergeableClassMetadata($class->getName());
+ }))
+ ;
+
+ $factory = new MetadataFactory($driver);
+ $metadata = $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestParent');
+
+ $this->assertInstanceOf('Metadata\MergeableClassMetadata', $metadata);
+ $this->assertEquals('Metadata\Tests\Fixtures\TestParent', $metadata->name);
+ }
+
+ public function testGetMetadataWithComplexHierarchy()
+ {
+ $driver = $this->getMock('Metadata\Driver\DriverInterface');
+
+ $driver
+ ->expects($this->any())
+ ->method('loadMetadataForClass')
+ ->will($this->returnCallback(function($class) {
+ $metadata = new MergeableClassMetadata($class->name);
+
+ switch ($class->name) {
+ case 'Metadata\Tests\Fixtures\ComplexHierarchy\BaseClass':
+ $metadata->propertyMetadata['foo'] = new PropertyMetadata($class->name, 'foo');
+ break;
+
+ case 'Metadata\Tests\Fixtures\ComplexHierarchy\SubClassA':
+ $metadata->propertyMetadata['bar'] = new PropertyMetadata($class->name, 'bar');
+ break;
+
+ case 'Metadata\Tests\Fixtures\ComplexHierarchy\SubClassB':
+ $metadata->propertyMetadata['baz'] = new PropertyMetadata($class->name, 'baz');
+ break;
+
+ default:
+ throw new \RuntimeException(sprintf('Unsupported class "%s".', $class->name));
+ }
+
+ return $metadata;
+ }))
+ ;
+
+ $factory = new MetadataFactory($driver);
+
+ $subClassA = $factory->getMetadataForClass('Metadata\Tests\Fixtures\ComplexHierarchy\SubClassA');
+ $this->assertInstanceOf('Metadata\MergeableClassMetadata', $subClassA);
+ $this->assertEquals(array('foo', 'bar'), array_keys($subClassA->propertyMetadata));
+
+ $subClassB = $factory->getMetadataForClass('Metadata\Tests\Fixtures\ComplexHierarchy\SubClassB');
+ $this->assertInstanceOf('Metadata\MergeableClassMetadata', $subClassB);
+ $this->assertEquals(array('foo', 'baz'), array_keys($subClassB->propertyMetadata));
+ }
+
+ public function testGetMetadataWithCache()
+ {
+ $driver = $this->getMock('Metadata\Driver\DriverInterface');
+ $driver
+ ->expects($this->once())
+ ->method('loadMetadataForClass')
+ ->will($this->returnValue($metadata = new ClassMetadata('Metadata\Tests\Fixtures\TestObject')))
+ ;
+
+ $factory = new MetadataFactory($driver);
+
+ $cache = $this->getMock('Metadata\Cache\CacheInterface');
+ $cache
+ ->expects($this->once())
+ ->method('loadClassMetadataFromCache')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestObject')))
+ ->will($this->returnValue(null))
+ ;
+ $cache
+ ->expects($this->once())
+ ->method('putClassMetadataInCache')
+ ->with($this->equalTo($metadata))
+ ;
+ $factory->setCache($cache);
+
+
+ $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject');
+ $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject');
+ $this->assertSame($metadata, reset($factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject')->classMetadata));
+ }
+
+ public function testGetMetadataReturnsNullIfNoMetadataIsFound()
+ {
+ $driver = $this->getMock('Metadata\Driver\DriverInterface');
+ $driver
+ ->expects($this->once())
+ ->method('loadMetadataForClass')
+ ->will($this->returnValue(null))
+ ;
+
+ $factory = new MetadataFactory($driver);
+
+ $this->assertNull($factory->getMetadataForClass('stdClass'));
+ }
+
+ public function testGetMetadataWithInterfaces()
+ {
+ $driver = $this->getMock('Metadata\Driver\DriverInterface');
+
+ $driver
+ ->expects($this->at(3))
+ ->method('loadMetadataForClass')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\ComplexHierarchy\SubClassA')))
+ ;
+ $driver
+ ->expects($this->at(2))
+ ->method('loadMetadataForClass')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\ComplexHierarchy\InterfaceB')))
+ ;
+ $driver
+ ->expects($this->at(1))
+ ->method('loadMetadataForClass')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\ComplexHierarchy\BaseClass')))
+ ;
+ $driver
+ ->expects($this->at(0))
+ ->method('loadMetadataForClass')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\ComplexHierarchy\InterfaceA')))
+ ;
+
+ $factory = new MetadataFactory($driver);
+ $factory->setIncludeInterfaces(true);
+
+ $factory->getMetadataForClass('Metadata\Tests\Fixtures\ComplexHierarchy\SubClassA');
+ }
+
+ public function testGetAllClassNames()
+ {
+ $driver = $this->getMock('Metadata\Driver\AdvancedDriverInterface');
+ $driver
+ ->expects($this->once())
+ ->method('getAllClassNames')
+ ->will($this->returnValue(array()));
+
+ $factory = new MetadataFactory($driver);
+ $this->assertSame(array(), $factory->getAllClassNames());
+ }
+
+ public function testGetAllClassNamesThrowsException()
+ {
+ $this->setExpectedException('RuntimeException');
+ $factory = new MetadataFactory($this->getMock('Metadata\Driver\DriverInterface'));
+ $factory->getAllClassNames();
+ }
+
+ public function testNotFoundMetadataIsCached()
+ {
+ $driver = $this->getMock('Metadata\Driver\DriverInterface');
+ $driver
+ ->expects($this->once()) // This is the important part of this test
+ ->method('loadMetadataForClass')
+ ->will($this->returnValue(null))
+ ;
+
+ $cachedMetadata = null;
+ $cache = $this->getMock('Metadata\Cache\CacheInterface');
+ $cache
+ ->expects($this->any())
+ ->method('loadClassMetadataFromCache')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestObject')))
+ ->will($this->returnCallback(function () use (&$cachedMetadata) {
+ return $cachedMetadata;
+ }))
+ ;
+ $cache
+ ->expects($this->once())
+ ->method('putClassMetadataInCache')
+ ->will($this->returnCallback(function ($metadata) use (&$cachedMetadata) {
+ $cachedMetadata = $metadata;
+ }))
+ ;
+
+ $factory = new MetadataFactory($driver);
+ $factory->setCache($cache);
+ $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject');
+ $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject');
+ $this->assertNull($factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject'));
+
+ // We use another factory with the same cache, to simulate another request and skip the in memory
+ $factory = new MetadataFactory($driver);
+ $factory->setCache($cache);
+ $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject');
+ $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject');
+ $this->assertNull($factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject'));
+ }
+
+ public function testNotFoundMetadataIsNotCachedInDebug()
+ {
+ $driver = $this->getMock('Metadata\Driver\DriverInterface');
+ $driver
+ ->expects($this->exactly(2))
+ ->method('loadMetadataForClass')
+ ->will($this->returnValue(null))
+ ;
+
+ $cachedMetadata = null;
+ $cache = $this->getMock('Metadata\Cache\CacheInterface');
+ $cache
+ ->expects($this->any())
+ ->method('loadClassMetadataFromCache')
+ ->with($this->equalTo(new \ReflectionClass('Metadata\Tests\Fixtures\TestObject')))
+ ->will($this->returnValue(null))
+ ;
+ $cache
+ ->expects($this->never())
+ ->method('putClassMetadataInCache')
+ ;
+
+ $factory = new MetadataFactory($driver, 'Metadata\ClassHierarchyMetadata', true);
+ $factory->setCache($cache);
+ $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject');
+ $this->assertNull($factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject'));
+
+ // We use another factory with the same cache, to simulate another request and skip the in memory
+ $factory = new MetadataFactory($driver, 'Metadata\ClassHierarchyMetadata', true);
+ $factory->setCache($cache);
+ $factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject');
+ $this->assertNull($factory->getMetadataForClass('Metadata\Tests\Fixtures\TestObject'));
+ }
+}
--- /dev/null
+<?php
+
+namespace Metadata\Tests;
+
+use Metadata\Tests\Fixtures\TestObject;
+use Metadata\MethodMetadata;
+
+class MethodMetadataTest extends \PHPUnit_Framework_TestCase
+{
+ public function testConstructor()
+ {
+ $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
+ $expectedReflector = new \ReflectionMethod('Metadata\Tests\Fixtures\TestObject', 'setFoo');
+ $expectedReflector->setAccessible(true);
+
+ $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->class);
+ $this->assertEquals('setFoo', $metadata->name);
+ $this->assertEquals($expectedReflector, $metadata->reflection);
+ }
+
+ public function testSerializeUnserialize()
+ {
+ $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
+
+ $this->assertEquals($metadata, unserialize(serialize($metadata)));
+ }
+
+ public function testInvoke()
+ {
+ $obj = new TestObject();
+ $metadata = new MethodMetadata('Metadata\Tests\Fixtures\TestObject', 'setFoo');
+
+ $this->assertNull($obj->getFoo());
+ $metadata->invoke($obj, array('foo'));
+ $this->assertEquals('foo', $obj->getFoo());
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace Metadata\Tests;
+
+use Metadata\Tests\Fixtures\TestObject;
+use Metadata\PropertyMetadata;
+
+class PropertyMetadataTest extends \PHPUnit_Framework_TestCase
+{
+ public function testConstructor()
+ {
+ $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo');
+ $expectedReflector = new \ReflectionProperty('Metadata\Tests\Fixtures\TestObject', 'foo');
+ $expectedReflector->setAccessible(true);
+
+ $this->assertEquals('Metadata\Tests\Fixtures\TestObject', $metadata->class);
+ $this->assertEquals('foo', $metadata->name);
+ $this->assertEquals($expectedReflector, $metadata->reflection);
+ }
+
+ public function testSerializeUnserialize()
+ {
+ $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo');
+
+ $this->assertEquals($metadata, unserialize(serialize($metadata)));
+ }
+
+ public function testSetGetValue()
+ {
+ $obj = new TestObject();
+ $metadata = new PropertyMetadata('Metadata\Tests\Fixtures\TestObject', 'foo');
+
+ $this->assertNull($metadata->getValue($obj));
+ $metadata->setValue($obj, 'foo');
+ $this->assertEquals('foo', $metadata->getValue($obj));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Metadata library.
+ *
+ * (C) 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ */
+
+spl_autoload_register(function($class) {
+ if (0 === strpos($class, 'Metadata\Tests\\')) {
+ $path = __DIR__.'/../tests/'.strtr($class, '\\', '/').'.php';
+ if (file_exists($path) && is_readable($path)) {
+ require_once $path;
+
+ return true;
+ }
+ } elseif (0 === strpos($class, 'Metadata\\')) {
+ $path = __DIR__.'/../src/'.($class = strtr($class, '\\', '/')).'.php';
+ if (file_exists($path) && is_readable($path)) {
+ require_once $path;
+
+ return true;
+ }
+ } elseif (0 === strpos($class, 'Symfony\\')) {
+ $path = __DIR__.'/../../symfony/src/'.strtr($class, '\\', '/').'.php';
+
+ if (file_exists($path) && is_readable($path)) {
+ require_once $path;
+
+ return true;
+ }
+ }
+});
+
+@include __DIR__ . '/../vendor/autoload.php';
--- /dev/null
+vendor/
+phpunit.xml
+
--- /dev/null
+filter:
+ paths: [src/*, tests/*]
+ excluded_paths: ["tests/*/Fixture/*"]
+
+default_config:
+ psr0_compliance: true
+ checkstyle: true
+ composer_config_check:
+ publish_checks: true
+ level: warning
+ reflection_fixes: true
+ use_statement_fixes: true
+
+path_configs:
+ tests:
+ paths: [tests/*]
+ psr0_compliance: false
+ checkstyle: false
+ phpunit_checks: true
--- /dev/null
+language: php
+
+php:
+ - 5.3
+ - 5.4
+
+before_script:
+ - curl -s http://getcomposer.org/installer | php
+ - php composer.phar install --dev
+
+script: phpunit --coverage-clover clover
+
+after_success:
+ - curl -sL https://bit.ly/artifact-uploader | php
+
--- /dev/null
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
--- /dev/null
+Parser Library
+==============
+
+Learn more about it in its [documentation](http://jmsyst.com/libs/parser-lib).
--- /dev/null
+{
+ "name": "jms/parser-lib",
+ "description": "A library for easily creating recursive-descent parsers.",
+ "license": "Apache2",
+ "require": {
+ "phpoption/phpoption": ">=0.9,<2.0-dev"
+ },
+ "autoload": {
+ "psr-0": {
+ "JMS\\": "src/"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.0-dev"
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.\r
+\r
+BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.\r
+\r
+1. Definitions\r
+\r
+ "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.\r
+ "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License.\r
+ "Distribute" means to make available to the public the original and copies of the Work through sale or other transfer of ownership.\r
+ "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.\r
+ "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.\r
+ "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.\r
+ "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.\r
+ "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.\r
+ "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.\r
+\r
+2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.\r
+\r
+3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:\r
+\r
+ to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; and,\r
+ to Distribute and Publicly Perform the Work including as incorporated in Collections.\r
+\r
+The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats, but otherwise you have no rights to make Adaptations. Subject to 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights set forth in Section 4(d).\r
+\r
+4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:\r
+\r
+ You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested.\r
+ You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works.\r
+ If You Distribute, or Publicly Perform the Work or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work. The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Collection, at a minimum such credit will appear, if a credit for all contributing authors of Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.\r
+\r
+ For the avoidance of doubt:\r
+ Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;\r
+ Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and,\r
+ Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b).\r
+ Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation.\r
+\r
+5. Representations, Warranties and Disclaimer\r
+\r
+UNLESS OTHERWISE MUTUALLY AGREED BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.\r
+\r
+6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
+\r
+7. Termination\r
+\r
+ This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.\r
+ Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.\r
+\r
+8. Miscellaneous\r
+\r
+ Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.\r
+ If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.\r
+ No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.\r
+ This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.\r
+ The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.\r
--- /dev/null
+Parser Library
+==============
+
+This library allows you to easily implement recursive-descent parsers.
+
+Installation
+------------
+You can install this library through composer:
+
+.. code-block :: bash
+
+ composer require jms/parser-lib
+
+or add it to your ``composer.json`` file directly.
+
+Example
+-------
+Let's assume that you would like to write a parser for a calculator. For simplicity
+sake, we will assume that the parser would already return the result of the
+calculation. Inputs could look like this ``1 + 1`` and we would expect ``2`` as
+a result.
+
+The first step, is to create a lexer which breaks the input string up into
+individual tokens which can then be consumed by the parser. This library provides
+a convenient class for simple problems which we will use::
+
+ $lexer = new \JMS\Parser\SimpleLexer(
+ '/
+ # Numbers
+ ([0-9]+)
+
+ # Do not surround with () because whitespace is not meaningful for
+ # our purposes.
+ |\s+
+
+ # Operators; we support only + and -
+ |(+)|(-)
+ /x', // The x modifier tells PCRE to ignore whitespace in the regex above.
+
+ // This maps token types to a human readable name.
+ array(0 => 'T_UNKNOWN', 1 => 'T_INT', 2 => 'T_PLUS', 3 => 'T_MINUS'),
+
+ // This function tells the lexer which type a token has. The first element is
+ // an integer from the map above, the second element the normalized value.
+ function($value) {
+ if ('+' === $value) {
+ return array(2, '+');
+ }
+ if ('-' === $value) {
+ return array(3, '-');
+ }
+ if (is_numeric($value)) {
+ return array(1, (integer) $value);
+ }
+
+ return array(0, $value);
+ }
+ );
+
+Now the second step, is to create the parser which can consume the tokens once
+the lexer has split them::
+
+ class MyParser extends \JMS\Parser\AbstractParser
+ {
+ const T_UNKNOWN = 0;
+ const T_INT = 1;
+ const T_PLUS = 2;
+ const T_MINUS = 3;
+
+ public function parseInternal()
+ {
+ $result = $this->match(self::T_INT);
+
+ while ($this->lexer->isNextAny(array(self::T_PLUS, self::T_MINUS))) {
+ if ($this->lexer->isNext(self::T_PLUS)) {
+ $this->lexer->moveNext();
+ $result += $this->match(self::T_INT);
+ } else if ($this->lexer->isNext(self::T_MINUS)) {
+ $this->lexer->moveNext();
+ $result -= $this->match(self::T_INT);
+ } else {
+ throw new \LogicException('Previous ifs were exhaustive.');
+ }
+ }
+
+ return $result;
+ }
+ }
+
+ $parser = new MyParser($lexer);
+ $parser->parse('1 + 1'); // int(2)
+ $parser->parse('5 + 10 - 4'); // int(11)
+
+That's it. Now you can perform basic operations already. If you like you can now
+also replace the hard-coded integers in the lexer with the class constants of the
+parser.
+
+License
+-------
+
+The code is released under the business-friendly `Apache2 license`_.
+
+Documentation is subject to the `Attribution-NonCommercial-NoDerivs 3.0 Unported
+license`_.
+
+.. _Apache2 license: http://www.apache.org/licenses/LICENSE-2.0.html
+.. _Attribution-NonCommercial-NoDerivs 3.0 Unported license: http://creativecommons.org/licenses/by-nc-nd/3.0/
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false"
+ syntaxCheck="false"
+ bootstrap="tests/bootstrap.php"
+>
+ <testsuites>
+ <testsuite name="Parser-Lib Test Suite">
+ <directory>./tests/JMS/</directory>
+ </testsuite>
+ </testsuites>
+
+ <groups>
+ <exclude>
+ <group>performance</group>
+ </exclude>
+ </groups>
+</phpunit>
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Parser;
+
+/**
+ * Abstract Lexer.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+abstract class AbstractLexer
+{
+ public $token;
+ public $next;
+
+ private $i;
+ private $peek;
+ private $tokens;
+
+ /**
+ * Returns the name of the given token.
+ *
+ * @param integer $type
+ *
+ * @return string
+ */
+ public function getName($type)
+ {
+ $ref = new \ReflectionClass($this);
+ foreach ($ref->getConstants() as $name => $value) {
+ if ($value === $type) {
+ return $name;
+ }
+ }
+
+ throw new \InvalidArgumentException(sprintf('There is no token with value %s.', json_encode($type)));
+ }
+
+ public function setInput($str)
+ {
+ $tokens = preg_split($this->getRegex(), $str, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
+
+ $this->tokens = array();
+ foreach ($tokens as $token) {
+ list($token[2], $token[0]) = $this->determineTypeAndValue($token[0]);
+ $this->tokens[] = $token;
+ }
+
+ $this->reset();
+ }
+
+ public function reset()
+ {
+ $this->i = -1;
+ $this->peek = 0;
+ $this->token = $this->next = null;
+ $this->moveNext();
+ }
+
+ /**
+ * Moves the pointer one token forward.
+ *
+ * @return boolean if we have not yet reached the end of the input
+ */
+ public function moveNext()
+ {
+ $this->peek = 0;
+ $this->token = $this->next;
+ $this->next = isset($this->tokens[++$this->i]) ? $this->tokens[$this->i] : null;
+
+ return null !== $this->next;
+ }
+
+ /**
+ * Skips the token stream until a token of the given type.
+ *
+ * @param integer $type
+ *
+ * @return boolean true if a token of the passed type was found, false otherwise.
+ */
+ public function skipUntil($type)
+ {
+ while ( ! $this->isNext($type) && $this->moveNext());
+
+ if ( ! $this->isNext($type)) {
+ throw new \RuntimeException(sprintf('Could not find the token %s.', $this->getName($type)));
+ }
+ }
+
+ /**
+ * @param integer $type
+ *
+ * @return boolean
+ */
+ public function isNext($type)
+ {
+ return null !== $this->next && $type === $this->next[2];
+ }
+
+ /**
+ * @param array<integer> $types
+ *
+ * @return boolean
+ */
+ public function isNextAny(array $types)
+ {
+ if (null === $this->next) {
+ return false;
+ }
+
+ foreach ($types as $type) {
+ if ($type === $this->next[2]) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return \PhpOption\Option<[string,integer,integer]>
+ */
+ public function peek()
+ {
+ if ( ! isset($this->tokens[$this->i + (++$this->peek)])) {
+ return \PhpOption\None::create();
+ }
+
+ return new \PhpOption\Some($this->tokens[$this->i + $this->peek]);
+ }
+
+ /**
+ * @return string
+ */
+ abstract protected function getRegex();
+
+ /**
+ * Determines the type of the given value.
+ *
+ * This method may also modify the passed value for example to cast them to
+ * a different PHP type where necessary.
+ *
+ * @param string $value
+ *
+ * @return array a tupel of type and normalized value
+ */
+ abstract protected function determineTypeAndValue($value);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Parser;
+
+/**
+ * Base Parser which provides some useful parsing methods intended for sub-classing.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+abstract class AbstractParser
+{
+ protected $lexer;
+ protected $context;
+
+ public function __construct(AbstractLexer $lexer)
+ {
+ $this->lexer = $lexer;
+ }
+
+ /**
+ * Parses the given input.
+ *
+ * @param string $str
+ * @param string $context parsing context (allows to produce better error messages)
+ *
+ * @return mixed
+ */
+ public function parse($str, $context = null)
+ {
+ $this->lexer->setInput($str);
+ $this->context = $context;
+
+ $rs = $this->parseInternal();
+
+ if (null !== $this->lexer->next) {
+ $this->syntaxError('end of input');
+ }
+
+ return $rs;
+ }
+
+ /**
+ * @return mixed
+ */
+ abstract protected function parseInternal();
+
+ /**
+ * Matches a token, and returns its value.
+ *
+ * @param integer $type
+ *
+ * @return mixed the value of the matched token
+ */
+ protected function match($type)
+ {
+ if ( ! $this->lexer->isNext($type)) {
+ $this->syntaxError($this->lexer->getName($type));
+ }
+
+ $this->lexer->moveNext();
+
+ return $this->lexer->token[0];
+ }
+
+ /**
+ * Matches any of the passed tokens, and returns the matched token's value.
+ *
+ * @param array<integer> $types
+ *
+ * @return mixed
+ */
+ protected function matchAny(array $types)
+ {
+ if ( ! $this->lexer->isNextAny($types)) {
+ $this->syntaxError('any of '.implode(' or ', array_map(array($this->lexer, 'getName'), $types)));
+ }
+
+ $this->lexer->moveNext();
+
+ return $this->lexer->token[0];
+ }
+
+ /**
+ * Raises a syntax error exception.
+ *
+ * @param string $expectedDesc A human understandable explanation what was expected
+ * @param array $actualToken The token that was found. If not given, next token will be assumed.
+ */
+ protected function syntaxError($expectedDesc, $actualToken = null)
+ {
+ if (null === $actualToken) {
+ $actualToken = $this->lexer->next;
+ }
+ if (null === $actualToken) {
+ $actualDesc = 'end of input';
+ } else if ($actualToken[1] === 0) {
+ $actualDesc = sprintf('"%s" of type %s at beginning of input', $actualToken[0], $this->lexer->getName($actualToken[2]));
+ } else {
+ $actualDesc = sprintf('"%s" of type %s at position %d (0-based)', $actualToken[0], $this->lexer->getName($actualToken[2]), $actualToken[1]);
+ }
+
+ $ex = new SyntaxErrorException(sprintf('Expected %s, but got %s%s.', $expectedDesc, $actualDesc, $this->context ? ' '.$this->context : ''));
+ if (null !== $actualToken) {
+ $ex->setActualToken($actualToken);
+ }
+ if (null !== $this->context) {
+ $ex->setContext($this->context);
+ }
+
+ throw $ex;
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Parser;
+
+/**
+ * The simple lexer is a fully usable lexer that does not require sub-classing.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class SimpleLexer extends AbstractLexer
+{
+ private $regex;
+ private $callable;
+ private $tokenNames;
+
+ public function __construct($regex, array $tokenNames, $typeCallable)
+ {
+ $this->regex = $regex;
+ $this->callable = $typeCallable;
+ $this->tokenNames = $tokenNames;
+ }
+
+ public function getName($type)
+ {
+ if ( ! isset($this->tokenNames[$type])) {
+ throw new \InvalidArgumentException(sprintf('There is no token with type %s.', json_encode($type)));
+ }
+
+ return $this->tokenNames[$type];
+ }
+
+ protected function getRegex()
+ {
+ return $this->regex;
+ }
+
+ protected function determineTypeAndValue($value)
+ {
+ return call_user_func($this->callable, $value);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Parser;
+
+class SyntaxErrorException extends \RuntimeException
+{
+ private $actualToken;
+ private $context;
+
+ public function setActualToken(array $actualToken)
+ {
+ $this->actualToken = $actualToken;
+ }
+
+ public function setContext($context)
+ {
+ $this->context = $context;
+ }
+
+ public function getActualToken()
+ {
+ return $this->actualToken;
+ }
+
+ public function getContext()
+ {
+ return $this->context;
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Parser;
+
+class AbstractLexerTest extends \PHPUnit_Framework_TestCase
+{
+ const T_UNKNOWN = 0;
+ const T_STRING = 1;
+ const T_INTEGER = 2;
+
+ const T_COMMA = 100;
+
+ private $lexer;
+
+ public function testTokenization()
+ {
+ $this->lexer->setInput('"foo" 1234');
+
+ $this->assertNull($this->lexer->token);
+ $this->assertNotNull($this->lexer->next);
+
+ $this->assertAttributeEquals(array(
+ array('foo', 0, self::T_STRING),
+ array(1234, 7, self::T_INTEGER),
+ ), 'tokens', $this->lexer);
+ }
+
+ public function testMoveNext()
+ {
+ $this->lexer->setInput('1 2 3');
+ $this->assertNull($this->lexer->token);
+
+ $this->assertTrue($this->lexer->moveNext());
+ $this->assertValue(1, $this->lexer->token);
+
+ $this->assertTrue($this->lexer->moveNext());
+ $this->assertValue(2, $this->lexer->token);
+
+ $this->assertFalse($this->lexer->moveNext());
+ $this->assertValue(3, $this->lexer->token);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testSkipUntilWithNonExistent()
+ {
+ $this->lexer->setInput('1 2 3');
+ $this->lexer->skipUntil(self::T_STRING);
+ }
+
+ public function testSkipUntil()
+ {
+ $this->lexer->setInput('1 "foo"');
+ $this->assertNull($this->lexer->skipUntil(self::T_STRING));
+ $this->assertValue(1, $this->lexer->token);
+ $this->assertValue('foo', $this->lexer->next);
+ }
+
+ public function testIsNext()
+ {
+ $this->lexer->setInput('1');
+ $this->assertTrue($this->lexer->isNext(self::T_INTEGER));
+ $this->assertFalse($this->lexer->isNext(self::T_COMMA));
+ }
+
+ public function testIsNextAny()
+ {
+ $this->lexer->setInput('1');
+ $this->assertTrue($this->lexer->isNextAny(array(self::T_COMMA, self::T_INTEGER)));
+ $this->assertFalse($this->lexer->isNextAny(array(self::T_COMMA, self::T_STRING)));
+ }
+
+ public function testPeek()
+ {
+ $this->lexer->setInput('1 2 3');
+
+ $this->assertValue(1, $this->lexer->next);
+ $this->assertValue(2, $this->lexer->peek()->get());
+
+ $this->assertValue(1, $this->lexer->next);
+ $this->assertValue(3, $this->lexer->peek()->get());
+
+ $this->assertValue(1, $this->lexer->next);
+ $this->assertTrue($this->lexer->moveNext());
+ $this->assertValue(2, $this->lexer->next);
+ $this->assertValue(3, $this->lexer->peek()->get());
+ $this->assertValue(2, $this->lexer->next);
+ }
+
+ private function assertValue($expected, $actualToken)
+ {
+ $this->assertNotNull($actualToken);
+ $this->assertSame($expected, $actualToken[0]);
+ }
+
+ protected function setUp()
+ {
+ $this->lexer = $this->getMockForAbstractClass('JMS\Parser\AbstractLexer');
+ $this->lexer->expects($this->any())
+ ->method('getRegex')
+ ->will($this->returnValue('/("(?:[^"]*|(?<=\\)"))*")|([0-9]+)|\s+|(.)/i'));
+ $this->lexer->expects($this->any())
+ ->method('determineTypeAndValue')
+ ->will($this->returnCallback(function($value) {
+ if (',' === $value) {
+ return array(AbstractLexerTest::T_COMMA, $value);
+ }
+
+ if ('"' === $value[0]) {
+ return array(AbstractLexerTest::T_STRING, substr($value, 1, -1));
+ }
+
+ if (preg_match('/^[0-9]+$/', $value)) {
+ return array(AbstractLexerTest::T_INTEGER, (integer) $value);
+ }
+
+ return array(AbstractLexerTest::T_UNKNOWN, $value);
+ }));
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Parser\Tests;
+
+class AbstractParserTest extends \PHPUnit_Framework_TestCase
+{
+ const T_UNKNOWN = 0;
+ const T_INT = 1;
+ const T_PLUS = 100;
+ const T_MINUS = 101;
+
+ private $parser;
+ private $lexer;
+
+ public function testParse()
+ {
+ $this->assertSame(2, $this->parser->parse('1 + 1'));
+ $this->assertSame(5, $this->parser->parse('1 + 1 + 4 - 1'));
+ }
+
+ /**
+ * @expectedException JMS\Parser\SyntaxErrorException
+ * @expectedExceptionMessage Expected T_INT, but got end of input.
+ */
+ public function testUnexpectedEnd()
+ {
+ $this->parser->parse('1 + ');
+ }
+
+ protected function setUp()
+ {
+ $this->lexer = $lexer = new \JMS\Parser\SimpleLexer(
+ '/([0-9]+)|\s+|(.)/',
+ array(0 => 'T_UNKNOWN', 1 => 'T_INT', 100 => 'T_PLUS', 101 => 'T_MINUS'),
+ function($value) {
+ if ('+' === $value) {
+ return array(AbstractParserTest::T_PLUS, $value);
+ }
+ if ('-' === $value) {
+ return array(AbstractParserTest::T_MINUS, $value);
+ }
+
+ // We would loose information on doubles here, but for this test it
+ // does not matter anyway.
+ if (is_numeric($value)) {
+ return array(AbstractParserTest::T_INT, (integer) $value);
+ }
+
+ return AbstractParserTest::T_UNKNOWN;
+ }
+ );
+
+ $this->parser = $parser = $this->getMockBuilder('JMS\Parser\AbstractParser')
+ ->setConstructorArgs(array($this->lexer))
+ ->getMockForAbstractClass();
+
+ $match = function($type) use ($parser) {
+ $ref = new \ReflectionMethod($parser, 'match');
+ $ref->setAccessible(true);
+
+ return $ref->invoke($parser, $type);
+ };
+
+ $this->parser->expects($this->any())
+ ->method('parseInternal')
+ ->will($this->returnCallback(function() use ($lexer, $match) {
+ // Result :== Number ( ("+"|"-") Number )*
+
+ $result = $match(AbstractParserTest::T_INT);
+ while ($lexer->isNextAny(array(AbstractParserTest::T_PLUS, AbstractParserTest::T_MINUS))) {
+ if ($lexer->isNext(AbstractParserTest::T_PLUS)) {
+ $lexer->moveNext();
+
+ $result += $match(AbstractParserTest::T_INT);
+ } else if ($lexer->isNext(AbstractParserTest::T_MINUS)) {
+ $lexer->moveNext();
+
+ $result -= $match(AbstractParserTest::T_INT);
+ } else {
+ throw new \LogicException('Previous ifs were exhaustive.');
+ }
+ }
+
+ return $result;
+ }));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+if ( ! is_file($autoloadFile = __DIR__.'/../vendor/autoload.php')) {
+ echo 'Could not find "vendor/autoload.php". Did you forget to run "composer install --dev"?'.PHP_EOL;
+ exit(1);
+}
+
+require_once $autoloadFile;
\ No newline at end of file
--- /dev/null
+# Contributor Code of Conduct
+
+As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we
+pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation,
+submitting pull requests or patches, and other activities.
+
+We are committed to making participation in this project a harassment-free experience for everyone, regardless of level
+of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size,
+race, ethnicity, age, religion, or nationality.
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery
+* Personal attacks
+* Trolling or insulting/derogatory comments
+* Public or private harassment
+* Publishing other's private information, such as physical or electronic addresses, without explicit permission
+* Other unethical or unprofessional conduct
+* Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
+ issues, and other contributions that are not aligned to this Code of Conduct. By adopting this Code of Conduct,
+ project maintainers commit themselves to fairly and consistently applying these principles to every aspect of
+ managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently
+ removed from the project team.
+
+This code of conduct applies both within project spaces and in public spaces when an individual is representing the
+project or its community.
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting
+one or more of the project maintainers.
+
+This Code of Conduct is adapted from the Contributor Covenant, version 1.2.0, available from
+http://contributor-covenant.org/version/1/2/0/
--- /dev/null
+# CONTRIBUTING
+
+First of all, **thank you** for contributing, **you are awesome**!
+
+Before we can merge your Pull-Request here are some guidelines that you need to follow.
+These guidelines exist not to annoy you, but to keep the code base clean, unified and future proof.
+
+Thank you for contributing!
+
+## Pull Request Description
+
+While creating your Pull Request on GitHub, you must write a description
+which gives the context and/or explains why you are creating it.
+
+## Dependencies
+
+We're using [`composer/composer`](https://github.com/composer/composer) to manage dependencies
+
+## Coding Standard
+
+We are using the latest [PSR](http://www.php-fig.org/psr/) recommendations.
+
+## Unit-Tests
+
+We're using [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) to run tests.
+
+You can run the unit-tests by calling `vendor/bin/phpunit` from the root of the project.
+
+If you are changing code, you must update or add tests for your changes.
+
+
+## Travis
+
+We automatically run your pull request through [Travis CI](http://www.travis-ci.org).
+If you break the tests, we cannot merge your code,
+so please make sure that your code is working before opening up a Pull-Request.
+
+## Documentation
+
+If you are adding a new feature, you must update the documentation.
+
+## Issues and Bugs
+
+To create a new issue, you can use the GitHub issue tracking system.
+
+Please avoid creating issues for support requests,
+please read carefully the project documentation,
+try more appropriate channels as forums, questions and answers platforms...
+
+Issues considered as "support request" will be closed,
+the discussion can continue on a closed issue, maintainers will do their best to help.
+
+## Getting merged
+
+Please allow us time to review your pull requests.
+We will give our best to review everything as fast as possible,
+but cannot always live up to our own expectations.
+
+Please, write [commit messages that make
+sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
+and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing)
+before submitting your Pull Request.
+
+One may ask you to [squash your
+commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)
+too. This is used to "clean" your Pull Request before merging it (we don't want
+commits such as "fix tests", "fix 2", "fix 3", etc.).
+
+Pull requests without tests most probably will not be merged.
+Documentation PRs obviously do not require tests.
+
--- /dev/null
+| Q | A
+| ---------------- | -----
+| Bug report? | yes/no
+| Feature request? | yes/no
+| BC Break report? | yes/no
+| RFC? | yes/no
+
+<!--
+- Please fill in this template according to your issue.
+- For support request or how-tos, please have a look to the documentation
+- Otherwise, replace this comment by the description of your issue.
+-->
+
+
+## Steps required to reproduce the problem
+
+1.
+2.
+3.
+
+## Expected Result
+
+*
+
+## Actual Result
+
+*
--- /dev/null
+| Q | A
+| ------------- | ---
+| Bug fix? | yes/no
+| New feature? | yes/no
+| Doc updated | yes/no
+| BC breaks? | yes/no <!-- don't forget updating UPGRADING.md file -->
+| Deprecations? | yes/no <!-- don't forget updating UPGRADING.md file -->
+| Tests pass? | yes/no
+| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
+| License | Apache-2.0
+
--- /dev/null
+vendor/
+phpunit.xml
+composer.lock
+.idea/
--- /dev/null
+tools:
+ external_code_coverage:
+ timeout: 600
\ No newline at end of file
--- /dev/null
+language: php
+
+sudo: false
+
+git:
+ depth: 1
+
+cache:
+ directories:
+ - $HOME/.composer/cache
+
+matrix:
+ include:
+ - php: 5.5
+ - php: 5.6
+ - php: 7.0
+ - php: 7.1
+ - php: 7.2
+ - php: 5.5
+ env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
+ fast_finish: true
+
+before_script:
+ - if [[ $TRAVIS_PHP_VERSION = '7.0' ]]; then PHPUNIT_FLAGS="--coverage-clover clover"; else PHPUNIT_FLAGS=""; fi
+ - if [[ $TRAVIS_PHP_VERSION != '7.0' ]]; then phpenv config-rm xdebug.ini; fi
+ - composer self-update
+ - composer update $COMPOSER_FLAGS
+
+script:
+ - vendor/bin/phpunit $PHPUNIT_FLAGS
+ - php tests/benchmark.php json 10
+ - php tests/benchmark.php yml 10
+ - php tests/benchmark.php xml 10
+
+after_success:
+ - if [[ $TRAVIS_PHP_VERSION = '7.0' ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
+ - if [[ $TRAVIS_PHP_VERSION = '7.0' ]]; then php ocular.phar code-coverage:upload --format=php-clover clover; fi
+
--- /dev/null
+# Change Log
+
+## [1.11.0](https://github.com/schmittjoh/serializer/tree/1.11.0) (2018-02-04)
+
+**Implemented enhancements:**
+
+- Deserialize xmlKeyValuePairs [\#868](https://github.com/schmittjoh/serializer/pull/868) ([goetas](https://github.com/goetas))
+- Add AdvancedNamingStrategyInterface [\#859](https://github.com/schmittjoh/serializer/pull/859) ([LeaklessGfy](https://github.com/LeaklessGfy))
+
+**Fixed bugs:**
+
+- Exception thrown for non-existant accessor to an excluded property [\#862](https://github.com/schmittjoh/serializer/issues/862)
+- Support non-namespaced lists in namespaced XML [\#851](https://github.com/schmittjoh/serializer/pull/851) ([bertterheide](https://github.com/bertterheide))
+
+**Closed issues:**
+
+- Context Group not working [\#865](https://github.com/schmittjoh/serializer/issues/865)
+- Not all virtual properties are serialized [\#864](https://github.com/schmittjoh/serializer/issues/864)
+- DeserializedName [\#857](https://github.com/schmittjoh/serializer/issues/857)
+- Annotation does not exist, or could not be auto-loaded. [\#855](https://github.com/schmittjoh/serializer/issues/855)
+- \[Question\] Serialization of primitive types [\#853](https://github.com/schmittjoh/serializer/issues/853)
+- Empty list when deserializing namespaced XML with children that are not namespaced [\#850](https://github.com/schmittjoh/serializer/issues/850)
+- XmlList\(skipWhenEmpty=true\) or @SkipWhenEmpty\(\) does not work [\#847](https://github.com/schmittjoh/serializer/issues/847)
+- DateHandler Timezone ignored on deserialization [\#457](https://github.com/schmittjoh/serializer/issues/457)
+
+**Merged pull requests:**
+
+- Drop HHVM support [\#869](https://github.com/schmittjoh/serializer/pull/869) ([goetas](https://github.com/goetas))
+- Allow excluded private properties to not have a getter acc… [\#863](https://github.com/schmittjoh/serializer/pull/863) ([0mars](https://github.com/0mars))
+- Solve php 7.2 deprecations [\#860](https://github.com/schmittjoh/serializer/pull/860) ([goetas](https://github.com/goetas))
+- Fixed issue where timezone is lost when creating DateTime from unix timestamp [\#835](https://github.com/schmittjoh/serializer/pull/835) ([goetas](https://github.com/goetas))
+
+## [1.10.0](https://github.com/schmittjoh/serializer/tree/1.10.0) (2017-11-30)
+**Implemented enhancements:**
+
+- support PSR-11 compatible DI containers [\#844](https://github.com/schmittjoh/serializer/pull/844) ([xabbuh](https://github.com/xabbuh))
+- Deserialize xmlKeyValuePairs [\#840](https://github.com/schmittjoh/serializer/pull/840) ([fdyckhoff](https://github.com/fdyckhoff))
+
+**Closed issues:**
+
+- Serialize using jsonSerialize\(\) if object implements JsonSerializable [\#846](https://github.com/schmittjoh/serializer/issues/846)
+- ExclusionStrategy backward compatibility break [\#843](https://github.com/schmittjoh/serializer/issues/843)
+- @MaxDepth jms/serializer-bundle 2.2 [\#842](https://github.com/schmittjoh/serializer/issues/842)
+
+## [1.9.2](https://github.com/schmittjoh/serializer/tree/1.9.2) (2017-11-22)
+**Fixed bugs:**
+
+- Missing ClassMetadata deserialization data [\#841](https://github.com/schmittjoh/serializer/pull/841) ([TristanMogwai](https://github.com/TristanMogwai))
+
+**Closed issues:**
+
+- DateTime format documentation [\#836](https://github.com/schmittjoh/serializer/issues/836)
+- Deserialization not working with camelCase [\#831](https://github.com/schmittjoh/serializer/issues/831)
+
+**Merged pull requests:**
+
+- Fix documentation syntax errors on available types [\#839](https://github.com/schmittjoh/serializer/pull/839) ([andy-morgan](https://github.com/andy-morgan))
+- Improve documentation about default DateTime format [\#838](https://github.com/schmittjoh/serializer/pull/838) ([enumag](https://github.com/enumag))
+
+## [1.9.1](https://github.com/schmittjoh/serializer/tree/1.9.1) (2017-10-27)
+**Fixed bugs:**
+
+- Dynamic exclusion strategy, Variable "object" is not valid [\#826](https://github.com/schmittjoh/serializer/issues/826)
+
+**Closed issues:**
+
+- Allow DateTime or Null [\#779](https://github.com/schmittjoh/serializer/issues/779)
+
+**Merged pull requests:**
+
+- Alow to use "object" var in expressions when deserializing [\#827](https://github.com/schmittjoh/serializer/pull/827) ([goetas](https://github.com/goetas))
+
+## [1.9.0](https://github.com/schmittjoh/serializer/tree/1.9.0) (2017-09-28)
+**Implemented enhancements:**
+
+- Doctrine LazyCriteriaCollection not supported [\#814](https://github.com/schmittjoh/serializer/issues/814)
+- Do not require the translator [\#824](https://github.com/schmittjoh/serializer/pull/824) ([goetas](https://github.com/goetas))
+- Added mapping for guid type [\#802](https://github.com/schmittjoh/serializer/pull/802) ([develth](https://github.com/develth))
+- Added translation domain to FormErrorHandler [\#783](https://github.com/schmittjoh/serializer/pull/783) ([prosalov](https://github.com/prosalov))
+
+**Fixed bugs:**
+
+- Node no longer exists - Deserialize Error [\#817](https://github.com/schmittjoh/serializer/issues/817)
+- Serializer fails if there is no AnnotationDriver in the DriverChain instance [\#815](https://github.com/schmittjoh/serializer/issues/815)
+- Evaluate XML xsi:nil="1" to null [\#799](https://github.com/schmittjoh/serializer/pull/799) ([Bouwdie](https://github.com/Bouwdie))
+
+**Closed issues:**
+
+- Empty array removed from XML serialization [\#816](https://github.com/schmittjoh/serializer/issues/816)
+- XML Discriminator tags don't work in YAML metadata [\#811](https://github.com/schmittjoh/serializer/issues/811)
+- Launching phpunit does not execute any test [\#809](https://github.com/schmittjoh/serializer/issues/809)
+- Add "bool" Annotation/Type [\#807](https://github.com/schmittjoh/serializer/issues/807)
+- Add support for overriding default annotation driver configuration [\#804](https://github.com/schmittjoh/serializer/issues/804)
+- Add description to PropertyMetadata? [\#800](https://github.com/schmittjoh/serializer/issues/800)
+
+**Merged pull requests:**
+
+- Workaround to avoid triggering simplexml warning [\#825](https://github.com/schmittjoh/serializer/pull/825) ([goetas](https://github.com/goetas))
+- Added null metadata driver [\#822](https://github.com/schmittjoh/serializer/pull/822) ([goetas](https://github.com/goetas))
+- Run Travis tests against modern PHP [\#819](https://github.com/schmittjoh/serializer/pull/819) ([Majkl578](https://github.com/Majkl578))
+- Added bool type alias [\#818](https://github.com/schmittjoh/serializer/pull/818) ([Majkl578](https://github.com/Majkl578))
+
+## [1.8.1](https://github.com/schmittjoh/serializer/tree/1.8.1) (2017-07-13)
+**Closed issues:**
+
+- Version 1.8 is breaking backwards compatibility [\#796](https://github.com/schmittjoh/serializer/issues/796)
+
+**Merged pull requests:**
+
+- Revert back to PSR-0 [\#797](https://github.com/schmittjoh/serializer/pull/797) ([goetas](https://github.com/goetas))
+
+## [1.8.0](https://github.com/schmittjoh/serializer/tree/1.8.0) (2017-07-12)
+**Implemented enhancements:**
+
+- Detect XML xsi:nil="true" to null when deserializing [\#790](https://github.com/schmittjoh/serializer/pull/790) ([goetas](https://github.com/goetas))
+- Added support for a third deserialize parameter for the DateTime type [\#788](https://github.com/schmittjoh/serializer/pull/788) ([bobvandevijver](https://github.com/bobvandevijver))
+- Added trim to xml metadata reader for groups parameter, and added support for groups element [\#781](https://github.com/schmittjoh/serializer/pull/781) ([mrosiu](https://github.com/mrosiu))
+- Add propertyMetdata to dynamic expression variables [\#778](https://github.com/schmittjoh/serializer/pull/778) ([goetas](https://github.com/goetas))
+- Fix xml deserialization when xsi:nil="true" is set [\#771](https://github.com/schmittjoh/serializer/pull/771) ([Bouwdie](https://github.com/Bouwdie))
+
+**Fixed bugs:**
+
+- do not disappear type params in DoctrineProxySubscriber [\#793](https://github.com/schmittjoh/serializer/pull/793) ([kriswallsmith](https://github.com/kriswallsmith))
+- \#784 fix with inline array of type array\<K, V\> [\#785](https://github.com/schmittjoh/serializer/pull/785) ([aviortm](https://github.com/aviortm))
+
+**Closed issues:**
+
+- inline array with type array\<K, V\> not serialized [\#784](https://github.com/schmittjoh/serializer/issues/784)
+- \[2.0\] \[Feature-request\] Provide InitializedObjectConstructor as default [\#775](https://github.com/schmittjoh/serializer/issues/775)
+- Allow access to PropertyMetadata in Dynamic Exclusion strategies [\#772](https://github.com/schmittjoh/serializer/issues/772)
+- Overriding groups at runtime does not work, or? [\#767](https://github.com/schmittjoh/serializer/issues/767)
+- DateTime format and control characters [\#94](https://github.com/schmittjoh/serializer/issues/94)
+
+**Merged pull requests:**
+
+- Missing features of the compiler pass [\#789](https://github.com/schmittjoh/serializer/pull/789) ([mikemix](https://github.com/mikemix))
+- Updated documentation related to PR \#778 [\#780](https://github.com/schmittjoh/serializer/pull/780) ([bblue](https://github.com/bblue))
+- \[RFC\] Move to PSR 4 [\#770](https://github.com/schmittjoh/serializer/pull/770) ([goetas](https://github.com/goetas))
+- Re-formatted code for better PSR compliance [\#769](https://github.com/schmittjoh/serializer/pull/769) ([goetas](https://github.com/goetas))
+- Proposing some guidelines for contributing [\#763](https://github.com/schmittjoh/serializer/pull/763) ([goetas](https://github.com/goetas))
+
+## [1.7.1](https://github.com/schmittjoh/serializer/tree/1.7.1) (2017-05-15)
+**Fixed bugs:**
+
+- Custom type handlers does not work with doctrine proxies anymore [\#765](https://github.com/schmittjoh/serializer/issues/765)
+- Doctrine listener should not change the type on proxies with virtual type [\#768](https://github.com/schmittjoh/serializer/pull/768) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- Missing bool type in graphNavigator.php in method accept\(\) [\#764](https://github.com/schmittjoh/serializer/issues/764)
+- The sub-class "Proxy-Class" is not listed in the discriminator of the base class "DiscriminatorClass" [\#459](https://github.com/schmittjoh/serializer/issues/459)
+- Configure whether serializing empty array. [\#124](https://github.com/schmittjoh/serializer/issues/124)
+
+## [1.7.0](https://github.com/schmittjoh/serializer/tree/1.7.0) (2017-05-10)
+**Implemented enhancements:**
+
+- Skip doctrine proxy initializations when exclusion strategy will exclude it [\#760](https://github.com/schmittjoh/serializer/pull/760) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- Error deserializing a map of \(nullable\) objects [\#762](https://github.com/schmittjoh/serializer/issues/762)
+- Add data using setData produces hashes instead of arrays [\#761](https://github.com/schmittjoh/serializer/issues/761)
+
+## [1.7.0-RC2](https://github.com/schmittjoh/serializer/tree/1.7.0-RC2) (2017-05-05)
+**Implemented enhancements:**
+
+- Make sure input is always a string [\#755](https://github.com/schmittjoh/serializer/pull/755) ([goetas](https://github.com/goetas))
+- Allow namespaced XML element discriminator [\#753](https://github.com/schmittjoh/serializer/pull/753) ([goetas](https://github.com/goetas))
+
+**Fixed bugs:**
+
+- Allow to skip "empty serialization result" when serializing [\#757](https://github.com/schmittjoh/serializer/pull/757) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- Is it possible to use @XmlNamespace & @XmlRoot in a class at same time ? [\#759](https://github.com/schmittjoh/serializer/issues/759)
+- Serializes FOS:User datas with ExclusionPolicy\("all"\) [\#599](https://github.com/schmittjoh/serializer/issues/599)
+
+**Merged pull requests:**
+
+- Add a quick reference for how to enable expression evaluator [\#758](https://github.com/schmittjoh/serializer/pull/758) ([chasen](https://github.com/chasen))
+- Allow for setExpressionEvaluator usage to be chainable [\#756](https://github.com/schmittjoh/serializer/pull/756) ([chasen](https://github.com/chasen))
+- Fix typo in annotation docs [\#754](https://github.com/schmittjoh/serializer/pull/754) ([JustBlackBird](https://github.com/JustBlackBird))
+
+## [1.7.0-RC1](https://github.com/schmittjoh/serializer/tree/1.7.0-RC1) (2017-04-25)
+**Implemented enhancements:**
+
+- Allow to configure the doctrine object constructor [\#751](https://github.com/schmittjoh/serializer/pull/751) ([goetas](https://github.com/goetas))
+- Trigger doctrine events on doctrine proxies [\#750](https://github.com/schmittjoh/serializer/pull/750) ([goetas](https://github.com/goetas))
+- Added stdClass serialization handler [\#749](https://github.com/schmittjoh/serializer/pull/749) ([goetas](https://github.com/goetas))
+- Allow to typehint for the type \(array/hash\) of the root item to be serialized [\#728](https://github.com/schmittjoh/serializer/pull/728) ([goetas](https://github.com/goetas))
+
+**Fixed bugs:**
+
+- Array gets serialized as object, not as array, depending on order. [\#709](https://github.com/schmittjoh/serializer/issues/709)
+- Doctrine Proxies and serializer.pre\_serialize [\#666](https://github.com/schmittjoh/serializer/issues/666)
+- Fix stdClass inconsistencies when serializing to JSON [\#730](https://github.com/schmittjoh/serializer/pull/730) ([goetas](https://github.com/goetas))
+- Allow to typehint for the type \\(array/hash\\) of the root item to be serialized [\#728](https://github.com/schmittjoh/serializer/pull/728) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- Array serialized as JSON object [\#706](https://github.com/schmittjoh/serializer/issues/706)
+- From old issue \#290 [\#670](https://github.com/schmittjoh/serializer/issues/670)
+- Form validation error response - field names not converted from camel case to underscore [\#587](https://github.com/schmittjoh/serializer/issues/587)
+- Ability to getGroups on Context [\#554](https://github.com/schmittjoh/serializer/issues/554)
+- SerializedName misleading usage and constructor issue [\#548](https://github.com/schmittjoh/serializer/issues/548)
+- Discriminator should support xmlAttribute [\#547](https://github.com/schmittjoh/serializer/issues/547)
+- Public method accessor is required for excluded/not exposed properties [\#519](https://github.com/schmittjoh/serializer/issues/519)
+- Entity changed via preserialize and wrongly persisted [\#509](https://github.com/schmittjoh/serializer/issues/509)
+- XML deserialization properties null when using default namespace [\#504](https://github.com/schmittjoh/serializer/issues/504)
+- AccessorOrder is ignored [\#501](https://github.com/schmittjoh/serializer/issues/501)
+- Deserialization of sub entites with non existing id [\#492](https://github.com/schmittjoh/serializer/issues/492)
+- \[Question\] Handler/Converter for specific field [\#476](https://github.com/schmittjoh/serializer/issues/476)
+- getClassName regex may incorrectly retrieve a false class name from comments above the class. [\#460](https://github.com/schmittjoh/serializer/issues/460)
+- Multiple types for property? [\#445](https://github.com/schmittjoh/serializer/issues/445)
+- Allow non-qualified XML serialization when XML namespaces are part of the metadata [\#413](https://github.com/schmittjoh/serializer/issues/413)
+- Discriminator field name [\#412](https://github.com/schmittjoh/serializer/issues/412)
+- Serializing to and deserializing from DateTime is inconsistent [\#394](https://github.com/schmittjoh/serializer/issues/394)
+- ManyToOne and OneToMany Serialization Groups [\#387](https://github.com/schmittjoh/serializer/issues/387)
+- Static SubscribingHandlerInterface::getSubscribingMethod [\#380](https://github.com/schmittjoh/serializer/issues/380)
+- User defined ordering function [\#379](https://github.com/schmittjoh/serializer/issues/379)
+- serialized\_name for discriminator [\#372](https://github.com/schmittjoh/serializer/issues/372)
+- Serializing object with empty array [\#350](https://github.com/schmittjoh/serializer/issues/350)
+- VirtualProperty\(s\) are ignored with AccessorOrder [\#349](https://github.com/schmittjoh/serializer/issues/349)
+- When setting a group of serialization, the inheritance doesn't work anymore [\#328](https://github.com/schmittjoh/serializer/issues/328)
+- Serialization of empty object [\#323](https://github.com/schmittjoh/serializer/issues/323)
+- "Can't pop from an empty datastructure" error when multiple serializer calls [\#319](https://github.com/schmittjoh/serializer/issues/319)
+- virtual\_properties cannot be excluded with groups [\#291](https://github.com/schmittjoh/serializer/issues/291)
+- Integer serialized as String using VirtualProperty [\#289](https://github.com/schmittjoh/serializer/issues/289)
+- SimpleObjectProxy is not implement abstract methods of Proxy class [\#287](https://github.com/schmittjoh/serializer/issues/287)
+- Serializing array that have one of the element or member of an element an empty object [\#277](https://github.com/schmittjoh/serializer/issues/277)
+- Serialization with groups return json object instead array [\#267](https://github.com/schmittjoh/serializer/issues/267)
+- The purpose of "Force JSON output to "{}" instead of "\[\]" if it contains either no properties or all properties are null" [\#248](https://github.com/schmittjoh/serializer/issues/248)
+- Json array serialisation [\#242](https://github.com/schmittjoh/serializer/issues/242)
+- Ignoring "Assert" in output doc if excluded [\#241](https://github.com/schmittjoh/serializer/issues/241)
+- Alphabetical accessor order doesn't respect SerializedName overrides [\#240](https://github.com/schmittjoh/serializer/issues/240)
+- Request Annotation for Array Data [\#234](https://github.com/schmittjoh/serializer/issues/234)
+- Allow @var instead of @Type when deserializing [\#233](https://github.com/schmittjoh/serializer/issues/233)
+- Strange issue with groups exclusion strategy [\#230](https://github.com/schmittjoh/serializer/issues/230)
+- Warning when deserializing removed entity [\#216](https://github.com/schmittjoh/serializer/issues/216)
+- Where in the JMS code does the navigator call VisitProperty method for visitor [\#207](https://github.com/schmittjoh/serializer/issues/207)
+- Property of the type array is not in alphabetic order after serialization [\#196](https://github.com/schmittjoh/serializer/issues/196)
+- Magic and inconsistencies in array serialization [\#191](https://github.com/schmittjoh/serializer/issues/191)
+- PreSerialization Event not handled if the value is not object [\#162](https://github.com/schmittjoh/serializer/issues/162)
+- Hierarchical object serialization does not appear to inherit metadata from ancestors for metadata defined in XML [\#151](https://github.com/schmittjoh/serializer/issues/151)
+- When using MaxDepth, Serialization of an array entitiy is not working [\#132](https://github.com/schmittjoh/serializer/issues/132)
+- Switch to change default naming strategy [\#128](https://github.com/schmittjoh/serializer/issues/128)
+- Throw exceptions on invalid input [\#112](https://github.com/schmittjoh/serializer/issues/112)
+- Recursion detected error when serialization groups are in use [\#96](https://github.com/schmittjoh/serializer/issues/96)
+- Allow serialization groups to be accessible within event subscriber callbacks. [\#84](https://github.com/schmittjoh/serializer/issues/84)
+- Allow Constructed Object to be Passed to Deserialize [\#79](https://github.com/schmittjoh/serializer/issues/79)
+- JSON recursion when first object in root list is empty [\#61](https://github.com/schmittjoh/serializer/issues/61)
+- Can't serialize an array with an empty object [\#59](https://github.com/schmittjoh/serializer/issues/59)
+
+**Merged pull requests:**
+
+- Added runtime twig extension support \(significant performance improvements\) [\#747](https://github.com/schmittjoh/serializer/pull/747) ([goetas](https://github.com/goetas))
+
+## [1.6.2](https://github.com/schmittjoh/serializer/tree/1.6.2) (2017-04-17)
+**Fixed bugs:**
+
+- @VirtualProperty "exp" does not play nice with @ExclusionPolicy\("ALL"\) [\#746](https://github.com/schmittjoh/serializer/issues/746)
+
+## [1.6.1](https://github.com/schmittjoh/serializer/tree/1.6.1) (2017-04-12)
+**Fixed bugs:**
+
+- Do not output the XML node when the object will be emtpy [\#744](https://github.com/schmittjoh/serializer/pull/744) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- XmlList not working since version 1.5.0 with xmlns attributes [\#742](https://github.com/schmittjoh/serializer/issues/742)
+- DoctrineObjectConstructor: how to use it without Symfony, in a PHP project [\#741](https://github.com/schmittjoh/serializer/issues/741)
+- Outdated docs site [\#733](https://github.com/schmittjoh/serializer/issues/733)
+- Allow data access to Property naming strategy [\#717](https://github.com/schmittjoh/serializer/issues/717)
+- Can't hint interface using @Type to trigger custom handler [\#631](https://github.com/schmittjoh/serializer/issues/631)
+- JSON/YAML encoding changes [\#617](https://github.com/schmittjoh/serializer/issues/617)
+- Why do we need this check inside SerializedName constructor, if there is name? [\#558](https://github.com/schmittjoh/serializer/issues/558)
+- Is it possible to deserialize Collection from Json [\#534](https://github.com/schmittjoh/serializer/issues/534)
+- PhpCollection 0.4 [\#531](https://github.com/schmittjoh/serializer/issues/531)
+- Possible mismatch of xml-attribute-map and $pMetadata-\>xmlAttribute in XmlDriver.php [\#422](https://github.com/schmittjoh/serializer/issues/422)
+- Access level propose for Handler/DateHandler.php [\#386](https://github.com/schmittjoh/serializer/issues/386)
+- Type DateTime and Timestamp \(U format\) [\#343](https://github.com/schmittjoh/serializer/issues/343)
+
+**Merged pull requests:**
+
+- Update PHPDocs [\#736](https://github.com/schmittjoh/serializer/pull/736) ([gnat42](https://github.com/gnat42))
+
+## [1.6.0](https://github.com/schmittjoh/serializer/tree/1.6.0) (2017-03-24)
+**Implemented enhancements:**
+
+- Add DateTimeImmutable support to DateHandler [\#543](https://github.com/schmittjoh/serializer/issues/543)
+
+**Fixed bugs:**
+
+- Virtual property having type overriden by doctrine metadata [\#276](https://github.com/schmittjoh/serializer/issues/276)
+
+**Closed issues:**
+
+- Serialize a subclass [\#735](https://github.com/schmittjoh/serializer/issues/735)
+- How to handle Doctrine not found entity ? [\#731](https://github.com/schmittjoh/serializer/issues/731)
+- Regression with 1.5.0 =\> Undefined offset 15 [\#715](https://github.com/schmittjoh/serializer/issues/715)
+- detect serialisation without groups set [\#546](https://github.com/schmittjoh/serializer/issues/546)
+- Introducing the NormalizerInterface [\#537](https://github.com/schmittjoh/serializer/issues/537)
+- How to set JSON serialization options? [\#535](https://github.com/schmittjoh/serializer/issues/535)
+- @MaxDepth doesn't seem to be working [\#522](https://github.com/schmittjoh/serializer/issues/522)
+- max\_depth in YML config is ignored [\#498](https://github.com/schmittjoh/serializer/issues/498)
+- Dynamic property type annotation [\#436](https://github.com/schmittjoh/serializer/issues/436)
+- How to deserialize JSON if property might have a list of subobjects? [\#355](https://github.com/schmittjoh/serializer/issues/355)
+- Object to array normalization [\#354](https://github.com/schmittjoh/serializer/issues/354)
+- Serialize Doctrine object without references [\#353](https://github.com/schmittjoh/serializer/issues/353)
+- Post\_serialize doesn't serialize relation! [\#236](https://github.com/schmittjoh/serializer/issues/236)
+- parsing string to date [\#217](https://github.com/schmittjoh/serializer/issues/217)
+- Discriminator is not exposed when using a group exclusion strategy [\#157](https://github.com/schmittjoh/serializer/issues/157)
+
+## [1.6.0-RC1](https://github.com/schmittjoh/serializer/tree/1.6.0-RC1) (2017-03-14)
+**Implemented enhancements:**
+
+- Add symfony expression in exclusions/expositions [\#406](https://github.com/schmittjoh/serializer/issues/406)
+- check that cache directory was not created before throwing exception [\#729](https://github.com/schmittjoh/serializer/pull/729) ([mente](https://github.com/mente))
+- \#720 - Adding support for DateInterval deserialization [\#721](https://github.com/schmittjoh/serializer/pull/721) ([c0ntax](https://github.com/c0ntax))
+- Expression language based virtual properties [\#708](https://github.com/schmittjoh/serializer/pull/708) ([goetas](https://github.com/goetas))
+- Xml namespaces improvements [\#644](https://github.com/schmittjoh/serializer/pull/644) ([goetas](https://github.com/goetas))
+
+**Fixed bugs:**
+
+- Serialize correctly empty intervals according to ISO-8601 [\#722](https://github.com/schmittjoh/serializer/pull/722) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- Is it possible to achieve something like - shouldSerializeEmpty [\#725](https://github.com/schmittjoh/serializer/issues/725)
+- How to handle DateTime serialization with fromArray method ? [\#723](https://github.com/schmittjoh/serializer/issues/723)
+- DateInterval supported for serialization but not deserialization [\#720](https://github.com/schmittjoh/serializer/issues/720)
+- Deserialization of collection when wraped by aditional xml tags [\#719](https://github.com/schmittjoh/serializer/issues/719)
+- SerializedName based on a property value [\#716](https://github.com/schmittjoh/serializer/issues/716)
+- Blank XML breaks XmlDeserializationVisitor error handling [\#701](https://github.com/schmittjoh/serializer/issues/701)
+- Problem with FOSUserBundle ROLE serialization [\#690](https://github.com/schmittjoh/serializer/issues/690)
+- Doctrine cache dependency when using setCacheDir [\#676](https://github.com/schmittjoh/serializer/issues/676)
+- OneToOne entities are not deserialized if passing a nested one-to-one property [\#652](https://github.com/schmittjoh/serializer/issues/652)
+- \[RFC\] Serialization refacotring [\#609](https://github.com/schmittjoh/serializer/issues/609)
+- Object handler callback returns array, but serialized object = null [\#594](https://github.com/schmittjoh/serializer/issues/594)
+- Cannot add @Discriminator field into specific @Group [\#557](https://github.com/schmittjoh/serializer/issues/557)
+- Object check on SerializationContext::isVisiting\(\) [\#502](https://github.com/schmittjoh/serializer/issues/502)
+- Define cdata and namespace for @XmlList elements [\#480](https://github.com/schmittjoh/serializer/issues/480)
+- Serializer working with parent class [\#376](https://github.com/schmittjoh/serializer/issues/376)
+- Add support for array format [\#374](https://github.com/schmittjoh/serializer/issues/374)
+- Obtain VirtualProperty value using a service [\#359](https://github.com/schmittjoh/serializer/issues/359)
+- make deserialisation of non existing id's configurable [\#333](https://github.com/schmittjoh/serializer/issues/333)
+- HHVM compatibility issue with undefined property JMS\Serializer\Metadata\ClassMetadata::$inline [\#312](https://github.com/schmittjoh/serializer/issues/312)
+- resources serialization [\#275](https://github.com/schmittjoh/serializer/issues/275)
+- I'm receiving "Class ArrayCollection does not exist" when serializing \(temporarily solved with a workaround\) [\#274](https://github.com/schmittjoh/serializer/issues/274)
+- Can't use handlers on strings \(and other simple types\) [\#194](https://github.com/schmittjoh/serializer/issues/194)
+- composer.json update for doctrine [\#178](https://github.com/schmittjoh/serializer/issues/178)
+- Use expression for virtual properties [\#171](https://github.com/schmittjoh/serializer/issues/171)
+- Handle classes that implement collections \(e.g. ArrayObject\) and properties [\#137](https://github.com/schmittjoh/serializer/issues/137)
+- Check CDATA is needed [\#136](https://github.com/schmittjoh/serializer/issues/136)
+- property path support [\#22](https://github.com/schmittjoh/serializer/issues/22)
+
+**Merged pull requests:**
+
+- Include reference to cache [\#727](https://github.com/schmittjoh/serializer/pull/727) ([hyperized](https://github.com/hyperized))
+
+## [1.5.0](https://github.com/schmittjoh/serializer/tree/1.5.0) (2017-02-14)
+**Closed issues:**
+
+- Serialized DateTime instances are not valid ISO-8601 [\#713](https://github.com/schmittjoh/serializer/issues/713)
+- Impossible to use discriminator field. Why we need StaticPropertyMetadata ? [\#705](https://github.com/schmittjoh/serializer/issues/705)
+- Deserializing XMLList with Namespaces not \(always\) working as intended [\#695](https://github.com/schmittjoh/serializer/issues/695)
+
+## [1.5.0-RC1](https://github.com/schmittjoh/serializer/tree/1.5.0-RC1) (2017-01-19)
+**Implemented enhancements:**
+
+- added support for xml-attributes as discriminators [\#692](https://github.com/schmittjoh/serializer/pull/692) ([twtinteractive](https://github.com/twtinteractive))
+- Added clearing previous libxml errors [\#688](https://github.com/schmittjoh/serializer/pull/688) ([zerkms](https://github.com/zerkms))
+- Prevent doctrine proxy loading for virtual types [\#684](https://github.com/schmittjoh/serializer/pull/684) ([goetas](https://github.com/goetas))
+- Implemented dynamic exclusion using symfony expression language [\#673](https://github.com/schmittjoh/serializer/pull/673) ([goetas](https://github.com/goetas))
+
+**Fixed bugs:**
+
+- Deserializing XMLList with Namespaces not \(always\) working as intended [\#697](https://github.com/schmittjoh/serializer/pull/697) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- Groups logic [\#693](https://github.com/schmittjoh/serializer/issues/693)
+- BC from 1.1.\* to ^1.2 [\#643](https://github.com/schmittjoh/serializer/issues/643)
+- DoctrineProxySubscriber forces loading of the proxy even if custom handler exist [\#575](https://github.com/schmittjoh/serializer/issues/575)
+- ConditionalExpose/Exclude annotation [\#540](https://github.com/schmittjoh/serializer/issues/540)
+- Deprecated usage of ValidatorInterface [\#438](https://github.com/schmittjoh/serializer/issues/438)
+- Missing addData in XmlSerializerVisitor makes it impossible to add data in serializer.post\_serialize event [\#235](https://github.com/schmittjoh/serializer/issues/235)
+- Support JSON PATCH for updating object graph [\#231](https://github.com/schmittjoh/serializer/issues/231)
+- Dynamic expose, aka 'fields' query param [\#195](https://github.com/schmittjoh/serializer/issues/195)
+
+**Merged pull requests:**
+
+- Added doc reference for disabling discriminator [\#699](https://github.com/schmittjoh/serializer/pull/699) ([dragosprotung](https://github.com/dragosprotung))
+- Use GroupsExclusionStrategy::DEFAULT\_GROUP instead default group. [\#694](https://github.com/schmittjoh/serializer/pull/694) ([Aliance](https://github.com/Aliance))
+- A possible fix for the \#688 [\#689](https://github.com/schmittjoh/serializer/pull/689) ([zerkms](https://github.com/zerkms))
+- Improved Symfony 3.x compatibility [\#682](https://github.com/schmittjoh/serializer/pull/682) ([goetas](https://github.com/goetas))
+
+## [1.4.2](https://github.com/schmittjoh/serializer/tree/1.4.2) (2016-11-13)
+**Fixed bugs:**
+
+- Warning: JMS\Serializer\XmlDeserializationVisitor::visitArray\(\): Node no longer exists [\#674](https://github.com/schmittjoh/serializer/issues/674)
+- Fixed xml arrays with namespaced entry triggers error [\#675](https://github.com/schmittjoh/serializer/pull/675) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- Max depth produces array of nulls [\#671](https://github.com/schmittjoh/serializer/issues/671)
+
+## [1.4.1](https://github.com/schmittjoh/serializer/tree/1.4.1) (2016-11-02)
+**Fixed bugs:**
+
+- Groups context might be not initialized [\#669](https://github.com/schmittjoh/serializer/pull/669) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- Warning: Invalid argument supplied for foreach\(\) on getCurrentPath method [\#668](https://github.com/schmittjoh/serializer/issues/668)
+
+## [1.4.0](https://github.com/schmittjoh/serializer/tree/1.4.0) (2016-10-31)
+**Implemented enhancements:**
+
+- Document the implied 'Default' property group when no group is specified [\#661](https://github.com/schmittjoh/serializer/pull/661) ([akoebbe](https://github.com/akoebbe))
+- Allow discriminator map in the middle of the hierarchy when deserializing [\#659](https://github.com/schmittjoh/serializer/pull/659) ([goetas](https://github.com/goetas))
+- Handle both int and integer [\#657](https://github.com/schmittjoh/serializer/pull/657) ([Aliance](https://github.com/Aliance))
+
+**Fixed bugs:**
+
+- Deserialization fails when discriminator base class extends another class [\#182](https://github.com/schmittjoh/serializer/issues/182)
+- Xml setters ignored when deserializing [\#665](https://github.com/schmittjoh/serializer/pull/665) ([goetas](https://github.com/goetas))
+
+**Closed issues:**
+
+- Move `FormErrorHandler` to the bundle [\#664](https://github.com/schmittjoh/serializer/issues/664)
+- Not compatible with Symfony 3's Controller::json\(\) [\#663](https://github.com/schmittjoh/serializer/issues/663)
+- Class name not reflecting in serialized json [\#662](https://github.com/schmittjoh/serializer/issues/662)
+- YML virtual\_properties no group exlcusion [\#656](https://github.com/schmittjoh/serializer/issues/656)
+- \[RFC\] Introduce normalizer\denormalizer interface [\#646](https://github.com/schmittjoh/serializer/issues/646)
+- Plain arrays are serialized \(normalized\) as "objects", ignoring serializeNull [\#641](https://github.com/schmittjoh/serializer/issues/641)
+- serializer doesn't serialize traits [\#638](https://github.com/schmittjoh/serializer/issues/638)
+- Add metadata informations [\#637](https://github.com/schmittjoh/serializer/issues/637)
+- Unexpected results when serializing arrays containing null value elements [\#593](https://github.com/schmittjoh/serializer/issues/593)
+- Allow to set default serialization context when building serializer [\#528](https://github.com/schmittjoh/serializer/issues/528)
+- Enable Sourcegraph [\#455](https://github.com/schmittjoh/serializer/issues/455)
+- Use different accessor for each group [\#420](https://github.com/schmittjoh/serializer/issues/420)
+- GenericSerializationVisitor and shouldSerializeNull [\#360](https://github.com/schmittjoh/serializer/issues/360)
+- Specify group along with MaxDepth [\#150](https://github.com/schmittjoh/serializer/issues/150)
+- Allow Post Serialize Event to overwrite existing data [\#129](https://github.com/schmittjoh/serializer/issues/129)
+- Warning: array\_key\_exists\(\) expects parameter 2 to be array, string given [\#70](https://github.com/schmittjoh/serializer/issues/70)
+
+**Merged pull requests:**
+
+- Nullable array inconsistency [\#660](https://github.com/schmittjoh/serializer/pull/660) ([goetas](https://github.com/goetas))
+- Fixed PHP 7.0.11 BC break \(or bugfix\) [\#658](https://github.com/schmittjoh/serializer/pull/658) ([goetas](https://github.com/goetas))
+- Renamed replaceData to setData [\#653](https://github.com/schmittjoh/serializer/pull/653) ([goetas](https://github.com/goetas))
+- add required sqlite extension for developing [\#649](https://github.com/schmittjoh/serializer/pull/649) ([scasei](https://github.com/scasei))
+- Run serialization benchmarks in the build process [\#647](https://github.com/schmittjoh/serializer/pull/647) ([goetas](https://github.com/goetas))
+- Alcalyn feature default serializer context [\#645](https://github.com/schmittjoh/serializer/pull/645) ([goetas](https://github.com/goetas))
+- Add format output option [\#640](https://github.com/schmittjoh/serializer/pull/640) ([AyrtonRicardo](https://github.com/AyrtonRicardo))
+- Remove deprecated FileCacheReader for doctrine annotations [\#634](https://github.com/schmittjoh/serializer/pull/634) ([goetas](https://github.com/goetas))
+- Added tests to ensure SerializeNull policy [\#633](https://github.com/schmittjoh/serializer/pull/633) ([goetas](https://github.com/goetas))
+- Fix inheritance of discriminators on Doctrine entities [\#382](https://github.com/schmittjoh/serializer/pull/382) ([xoob](https://github.com/xoob))
+- Allow Post Serialize Event to overwrite existing data [\#273](https://github.com/schmittjoh/serializer/pull/273) ([jockri](https://github.com/jockri))
+
+## [1.3.1](https://github.com/schmittjoh/serializer/tree/1.3.1) (2016-08-23)
+**Closed issues:**
+
+- \[Idea\] Inline name [\#629](https://github.com/schmittjoh/serializer/issues/629)
+- indexBy property doesn't work since 1.2.0 [\#618](https://github.com/schmittjoh/serializer/issues/618)
+- Composer deps issue [\#494](https://github.com/schmittjoh/serializer/issues/494)
+- PHP 7 compatability issue [\#478](https://github.com/schmittjoh/serializer/issues/478)
+- Add new tag \(upgrade packagist\) [\#461](https://github.com/schmittjoh/serializer/issues/461)
+- Custom Type Handler for String Values [\#384](https://github.com/schmittjoh/serializer/issues/384)
+- serializer ignores properties added by traits [\#313](https://github.com/schmittjoh/serializer/issues/313)
+- Skip an element during Xml deserialization process [\#229](https://github.com/schmittjoh/serializer/issues/229)
+- Using serializer for JSON serialising [\#223](https://github.com/schmittjoh/serializer/issues/223)
+- No way to serialize binary data with a custom type [\#202](https://github.com/schmittjoh/serializer/issues/202)
+- Automatic mapping of properties [\#200](https://github.com/schmittjoh/serializer/issues/200)
+- Maybe the serializer should also allow the legal literals {1, 0} for booleans [\#198](https://github.com/schmittjoh/serializer/issues/198)
+- Customize how Booleans are serialized [\#180](https://github.com/schmittjoh/serializer/issues/180)
+- Problem with deserialize related entity [\#123](https://github.com/schmittjoh/serializer/issues/123)
+- serialized\_name does not work in yaml [\#118](https://github.com/schmittjoh/serializer/issues/118)
+
+**Merged pull requests:**
+
+- Revert "Default `$serializeNull` to false" [\#630](https://github.com/schmittjoh/serializer/pull/630) ([goetas](https://github.com/goetas))
+
+## [1.3.0](https://github.com/schmittjoh/serializer/tree/1.3.0) (2016-08-17)
+**Closed issues:**
+
+- problems with xml namespaces after update [\#621](https://github.com/schmittjoh/serializer/issues/621)
+- Trying to decorate a member to ArrayCollection but gets an error when deserilizing because composer didn't download the class from doctrine. [\#596](https://github.com/schmittjoh/serializer/issues/596)
+- Missing doctrine/common requirement ? [\#517](https://github.com/schmittjoh/serializer/issues/517)
+- PHP Fatal error: Using $this when not in object context in JMS/Serializer/Serializer.php on line 99 [\#441](https://github.com/schmittjoh/serializer/issues/441)
+- custom collection handler [\#415](https://github.com/schmittjoh/serializer/issues/415)
+- Exclude annotation not preventing attempt to find public methods when using AccessType [\#367](https://github.com/schmittjoh/serializer/issues/367)
+- serializer.pre\_serialize event only thrown on objects/classes [\#337](https://github.com/schmittjoh/serializer/issues/337)
+- Installing through composer gets "Segmentation fault" [\#308](https://github.com/schmittjoh/serializer/issues/308)
+- Erroneous data format for unserializing... [\#283](https://github.com/schmittjoh/serializer/issues/283)
+- DoctrineObjectConstructor should skip empty identifier field [\#193](https://github.com/schmittjoh/serializer/issues/193)
+
+**Merged pull requests:**
+
+- Added public `hasData` function to check if a data key already have been added. [\#625](https://github.com/schmittjoh/serializer/pull/625) ([goetas](https://github.com/goetas))
+- $context is not used [\#622](https://github.com/schmittjoh/serializer/pull/622) ([olvlvl](https://github.com/olvlvl))
+- Fix Doctrine PHPCR ODM 2.0 compatibility [\#605](https://github.com/schmittjoh/serializer/pull/605) ([wouterj](https://github.com/wouterj))
+- Introducing NormalizerInterface [\#592](https://github.com/schmittjoh/serializer/pull/592) ([alcalyn](https://github.com/alcalyn))
+- Fixed type-hinting [\#586](https://github.com/schmittjoh/serializer/pull/586) ([jgendera](https://github.com/jgendera))
+- Fix multiple handler callbacks in YamlDriver [\#515](https://github.com/schmittjoh/serializer/pull/515) ([mpajunen](https://github.com/mpajunen))
+- Fixed minor typos [\#364](https://github.com/schmittjoh/serializer/pull/364) ([sdaoudi](https://github.com/sdaoudi))
+- Default `$serializeNull` to false [\#317](https://github.com/schmittjoh/serializer/pull/317) ([steveYeah](https://github.com/steveYeah))
+- Missing attribute 'xml-value' in XML Reference [\#269](https://github.com/schmittjoh/serializer/pull/269) ([holtkamp](https://github.com/holtkamp))
+- Removed unnecessary use statement [\#262](https://github.com/schmittjoh/serializer/pull/262) ([dunglas](https://github.com/dunglas))
+
+## [1.2.0](https://github.com/schmittjoh/serializer/tree/1.2.0) (2016-08-03)
+**Implemented enhancements:**
+
+- Issue543 - Adding DateTimeImmutable support [\#635](https://github.com/schmittjoh/serializer/pull/635) ([toby-griffiths](https://github.com/toby-griffiths))
+
+**Fixed bugs:**
+
+- Fix xml-attribute-map for the xml driver [\#595](https://github.com/schmittjoh/serializer/pull/595) ([romantomchak](https://github.com/romantomchak))
+- Fix warning array\_key\_exists in deserialization. [\#398](https://github.com/schmittjoh/serializer/pull/398) ([leonnleite](https://github.com/leonnleite))
+- \#367 Exclude annotation not preventing attempt to find public methods when using AccessType [\#397](https://github.com/schmittjoh/serializer/pull/397) ([Strate](https://github.com/Strate))
+
+**Closed issues:**
+
+- XML serialisation performance vs. SimpleXML? [\#606](https://github.com/schmittjoh/serializer/issues/606)
+- Undefined Offset 21 - PropertyMetadata \(master\) [\#581](https://github.com/schmittjoh/serializer/issues/581)
+- Invalid null serialization in arrays [\#571](https://github.com/schmittjoh/serializer/issues/571)
+- List Polymorphic with XML Deserialization [\#568](https://github.com/schmittjoh/serializer/issues/568)
+- Serialize null values as empty string [\#566](https://github.com/schmittjoh/serializer/issues/566)
+- Type mismatch should throw an exception instead of coercing when deserializing JSON [\#561](https://github.com/schmittjoh/serializer/issues/561)
+- Serialize to array [\#518](https://github.com/schmittjoh/serializer/issues/518)
+- AnnotationDriver Exception on Missing Setter/Getter even on @Exclude'd Properties [\#516](https://github.com/schmittjoh/serializer/issues/516)
+- Arrays are serialized as objects like {"0":... } when data contains empty objects [\#488](https://github.com/schmittjoh/serializer/issues/488)
+- Tag new release [\#465](https://github.com/schmittjoh/serializer/issues/465)
+- Forcing no scientific notation for larg number, type double [\#405](https://github.com/schmittjoh/serializer/issues/405)
+- PHP \< 5.3.9 BC break [\#383](https://github.com/schmittjoh/serializer/issues/383)
+- Ignoring a tag when deserializing [\#352](https://github.com/schmittjoh/serializer/issues/352)
+
+**Merged pull requests:**
+
+- Allow to not skip empty not inline array root node [\#611](https://github.com/schmittjoh/serializer/pull/611) ([goetas](https://github.com/goetas))
+- Allow to use custom serializer with primitive type [\#610](https://github.com/schmittjoh/serializer/pull/610) ([goetas](https://github.com/goetas))
+- Composer is not able to resolve a dependency [\#608](https://github.com/schmittjoh/serializer/pull/608) ([goetas](https://github.com/goetas))
+- Test on Travis always high and low deps [\#584](https://github.com/schmittjoh/serializer/pull/584) ([goetas](https://github.com/goetas))
+- Update Symfony validator and allow PHPUnit 7 [\#583](https://github.com/schmittjoh/serializer/pull/583) ([goetas](https://github.com/goetas))
+- Fix serialize bug [\#582](https://github.com/schmittjoh/serializer/pull/582) ([goetas](https://github.com/goetas))
+- HHVM compatibility [\#580](https://github.com/schmittjoh/serializer/pull/580) ([goetas](https://github.com/goetas))
+- Discriminator Groups [\#579](https://github.com/schmittjoh/serializer/pull/579) ([maennchen](https://github.com/maennchen))
+- Fixed test suite on master [\#578](https://github.com/schmittjoh/serializer/pull/578) ([goetas](https://github.com/goetas))
+- Fix for a broken test: a missing \(incorrectly positioned\) argument [\#577](https://github.com/schmittjoh/serializer/pull/577) ([zerkms](https://github.com/zerkms))
+- Add extra test for handling child elements [\#569](https://github.com/schmittjoh/serializer/pull/569) ([tarjei](https://github.com/tarjei))
+- Fix bug \#343 return integer when the column is datetime [\#562](https://github.com/schmittjoh/serializer/pull/562) ([Bukashk0zzz](https://github.com/Bukashk0zzz))
+- \[doc\] fix AccessorOrder documentation [\#553](https://github.com/schmittjoh/serializer/pull/553) ([aledeg](https://github.com/aledeg))
+- Generic way to solve setValue on a property which respects its setter [\#550](https://github.com/schmittjoh/serializer/pull/550) ([maennchen](https://github.com/maennchen))
+- Added travis-ci label [\#399](https://github.com/schmittjoh/serializer/pull/399) ([spolischook](https://github.com/spolischook))
+- Generate namespaced element on XmlList entries [\#301](https://github.com/schmittjoh/serializer/pull/301) ([goetas](https://github.com/goetas))
+
+## [1.1.0](https://github.com/schmittjoh/serializer/tree/1.1.0) (2015-10-27)
+**Closed issues:**
+
+- Possible to set xsi:schemalocation? [\#505](https://github.com/schmittjoh/serializer/issues/505)
+- Travis needs a renewed token to be able to set the status [\#495](https://github.com/schmittjoh/serializer/issues/495)
+- Serialize a many-to-many relation [\#474](https://github.com/schmittjoh/serializer/issues/474)
+- The document type "..." is not allowed [\#427](https://github.com/schmittjoh/serializer/issues/427)
+- Yml serializer don't serialize empty arrays [\#183](https://github.com/schmittjoh/serializer/issues/183)
+
+**Merged pull requests:**
+
+- Manage empty array for serializer [\#510](https://github.com/schmittjoh/serializer/pull/510) ([Soullivaneuh](https://github.com/Soullivaneuh))
+- Fix the method name for the serialization context factory [\#490](https://github.com/schmittjoh/serializer/pull/490) ([stof](https://github.com/stof))
+- Switch the Twig integration to use non-deprecated APIs [\#482](https://github.com/schmittjoh/serializer/pull/482) ([stof](https://github.com/stof))
+- Add PHP 7 on Travis [\#477](https://github.com/schmittjoh/serializer/pull/477) ([Soullivaneuh](https://github.com/Soullivaneuh))
+- Change Proxy class used to Doctrine\Common\Persistence\Proxy [\#351](https://github.com/schmittjoh/serializer/pull/351) ([bburnichon](https://github.com/bburnichon))
+- Added PHP 5.6 [\#297](https://github.com/schmittjoh/serializer/pull/297) ([Nyholm](https://github.com/Nyholm))
+
+## [1.0.0](https://github.com/schmittjoh/serializer/tree/1.0.0) (2015-06-16)
+**Closed issues:**
+
+- Unrecognized 4 parts namespace [\#449](https://github.com/schmittjoh/serializer/issues/449)
+- Groups is ignored [\#440](https://github.com/schmittjoh/serializer/issues/440)
+- Property FelDev\CoreBundle\Entity\Persona::$apellido does not exist [\#432](https://github.com/schmittjoh/serializer/issues/432)
+- Erroneous data format for unserializing [\#430](https://github.com/schmittjoh/serializer/issues/430)
+- Deserialize JSON into existing Doctrine entities and empty strings are ignored [\#417](https://github.com/schmittjoh/serializer/issues/417)
+- Failing to deserealize JSON string [\#402](https://github.com/schmittjoh/serializer/issues/402)
+- Empty results serializing virtual\_properties [\#400](https://github.com/schmittjoh/serializer/issues/400)
+- API stable 1.0.0 release in sight? [\#395](https://github.com/schmittjoh/serializer/issues/395)
+- Is this project maintained still? [\#361](https://github.com/schmittjoh/serializer/issues/361)
+- PreSerialize [\#339](https://github.com/schmittjoh/serializer/issues/339)
+- Change default `access\_type` globally [\#336](https://github.com/schmittjoh/serializer/issues/336)
+- Deserialization of XmlList does not support namespaces [\#332](https://github.com/schmittjoh/serializer/issues/332)
+- Recursion groups, serializing properties in entities [\#329](https://github.com/schmittjoh/serializer/issues/329)
+- The testsuite is broken [\#326](https://github.com/schmittjoh/serializer/issues/326)
+- Namespaces and serialize/deserialize process [\#303](https://github.com/schmittjoh/serializer/issues/303)
+- Exclusion of parent properties failing [\#282](https://github.com/schmittjoh/serializer/issues/282)
+- How to deserialize correctly an array of arbitrary values ? [\#280](https://github.com/schmittjoh/serializer/issues/280)
+- Try to identify getter/setter from an excluded property [\#278](https://github.com/schmittjoh/serializer/issues/278)
+- Bug Entity constructor not called [\#270](https://github.com/schmittjoh/serializer/issues/270)
+- Make it possible to escape special characters on serialization [\#265](https://github.com/schmittjoh/serializer/issues/265)
+- doctrine annotations without namespace [\#264](https://github.com/schmittjoh/serializer/issues/264)
+- php-collection constraint [\#257](https://github.com/schmittjoh/serializer/issues/257)
+- \[Metadata\] PHP warning only when unittesting [\#255](https://github.com/schmittjoh/serializer/issues/255)
+- Discriminator [\#220](https://github.com/schmittjoh/serializer/issues/220)
+
+**Merged pull requests:**
+
+- fix json output \(from \[\] to {} if empty\) of form error [\#462](https://github.com/schmittjoh/serializer/pull/462) ([jhkchan](https://github.com/jhkchan))
+- Add toArray and fromArray methods to the serializer [\#435](https://github.com/schmittjoh/serializer/pull/435) ([tystr](https://github.com/tystr))
+- Erroneous data format for unserializing \#430 [\#431](https://github.com/schmittjoh/serializer/pull/431) ([tmilos](https://github.com/tmilos))
+- Scrutinizer Auto-Fixes [\#381](https://github.com/schmittjoh/serializer/pull/381) ([scrutinizer-auto-fixer](https://github.com/scrutinizer-auto-fixer))
+- Fixing tests for bugfixed PHP versions [\#375](https://github.com/schmittjoh/serializer/pull/375) ([urakozz](https://github.com/urakozz))
+- Making test running against phpunit 4.\* [\#369](https://github.com/schmittjoh/serializer/pull/369) ([joelwurtz](https://github.com/joelwurtz))
+- Fixes a typo in the annotations.rst [\#363](https://github.com/schmittjoh/serializer/pull/363) ([Potherca](https://github.com/Potherca))
+- \[doc\] Default group informations [\#345](https://github.com/schmittjoh/serializer/pull/345) ([emilien-puget](https://github.com/emilien-puget))
+- bump branch alias to 0.17 as 0.16 is already released [\#305](https://github.com/schmittjoh/serializer/pull/305) ([lsmith77](https://github.com/lsmith77))
+- Unserialization of XML booleans [\#302](https://github.com/schmittjoh/serializer/pull/302) ([goetas](https://github.com/goetas))
+- Added xml\_root\_namespace on YAML reference [\#299](https://github.com/schmittjoh/serializer/pull/299) ([goetas](https://github.com/goetas))
+- Fixed yml mapping file name [\#256](https://github.com/schmittjoh/serializer/pull/256) ([spolischook](https://github.com/spolischook))
+- Serialization of nested polymorphic objects [\#238](https://github.com/schmittjoh/serializer/pull/238) ([DavidMikeSimon](https://github.com/DavidMikeSimon))
+
+## [0.16.0](https://github.com/schmittjoh/serializer/tree/0.16.0) (2014-03-18)
+**Closed issues:**
+
+- best way to add root to json? [\#250](https://github.com/schmittjoh/serializer/issues/250)
+- Use Doctrine metadata [\#247](https://github.com/schmittjoh/serializer/issues/247)
+- Integration Points - run-time exclusion checking [\#239](https://github.com/schmittjoh/serializer/issues/239)
+- Using DoctrineTypeDriver to use Doctrine Anotations [\#232](https://github.com/schmittjoh/serializer/issues/232)
+
+**Merged pull requests:**
+
+- Changed some constraint to allow latest versions [\#251](https://github.com/schmittjoh/serializer/pull/251) ([stof](https://github.com/stof))
+- XML root element namespace support [\#246](https://github.com/schmittjoh/serializer/pull/246) ([andreasferber](https://github.com/andreasferber))
+- Added test for leading backslash in front of class name to TypeParserTest [\#245](https://github.com/schmittjoh/serializer/pull/245) ([deralex](https://github.com/deralex))
+- Allow to fetch data from has\*\(\) with public\_method [\#243](https://github.com/schmittjoh/serializer/pull/243) ([jaymecd](https://github.com/jaymecd))
+- Improve yaml documentacion Fix \#100 [\#221](https://github.com/schmittjoh/serializer/pull/221) ([BraisGabin](https://github.com/BraisGabin))
+
+## [0.15.0](https://github.com/schmittjoh/serializer/tree/0.15.0) (2014-02-10)
+**Closed issues:**
+
+- Add trait support [\#228](https://github.com/schmittjoh/serializer/issues/228)
+- "array" type: Not working for arrays of DateTime objects [\#199](https://github.com/schmittjoh/serializer/issues/199)
+- Discriminator field filtered by exclusion strategy [\#189](https://github.com/schmittjoh/serializer/issues/189)
+- DateTime within an array \(format get ignored\) [\#140](https://github.com/schmittjoh/serializer/issues/140)
+- EntityNotFoundException using softDeletable [\#101](https://github.com/schmittjoh/serializer/issues/101)
+- Virtual property documentation xml & yaml [\#100](https://github.com/schmittjoh/serializer/issues/100)
+
+**Merged pull requests:**
+
+- Read only class [\#227](https://github.com/schmittjoh/serializer/pull/227) ([goetas](https://github.com/goetas))
+- @Alex88's Serialize only form child of type Form \#117 [\#224](https://github.com/schmittjoh/serializer/pull/224) ([minayaserrano](https://github.com/minayaserrano))
+- @XmlElement notation consistency [\#219](https://github.com/schmittjoh/serializer/pull/219) ([ajgarlag](https://github.com/ajgarlag))
+- add $this-\>maxDepth to serialize / unserialize [\#218](https://github.com/schmittjoh/serializer/pull/218) ([rothfahl](https://github.com/rothfahl))
+- xml reference updated with virtual-property example [\#215](https://github.com/schmittjoh/serializer/pull/215) ([ribeiropaulor](https://github.com/ribeiropaulor))
+- Add XmlNamespace annotation documentation [\#213](https://github.com/schmittjoh/serializer/pull/213) ([jeserkin](https://github.com/jeserkin))
+- Scrutinizer Auto-Fixes [\#210](https://github.com/schmittjoh/serializer/pull/210) ([scrutinizer-auto-fixer](https://github.com/scrutinizer-auto-fixer))
+- Scrutinizer Auto-Fixes [\#206](https://github.com/schmittjoh/serializer/pull/206) ([scrutinizer-auto-fixer](https://github.com/scrutinizer-auto-fixer))
+- Add xmlAttributeMap to serialized values [\#204](https://github.com/schmittjoh/serializer/pull/204) ([colinfrei](https://github.com/colinfrei))
+- fix issue \#199: "array" type ignoring DateTime format [\#201](https://github.com/schmittjoh/serializer/pull/201) ([lukey78](https://github.com/lukey78))
+- Potential fix for "recursion detected" issue [\#104](https://github.com/schmittjoh/serializer/pull/104) ([tyler-sommer](https://github.com/tyler-sommer))
+
+## [0.14.0](https://github.com/schmittjoh/serializer/tree/0.14.0) (2013-12-04)
+**Implemented enhancements:**
+
+- Can now override groups on specific paths of the graph [\#170](https://github.com/schmittjoh/serializer/pull/170) ([adrienbrault](https://github.com/adrienbrault))
+
+**Closed issues:**
+
+- @HandlerCallback not inherited [\#181](https://github.com/schmittjoh/serializer/issues/181)
+- Conditional serialization [\#173](https://github.com/schmittjoh/serializer/issues/173)
+- Deserialize XML partially [\#167](https://github.com/schmittjoh/serializer/issues/167)
+- getter is not called when serializing Discriminator parent entity [\#156](https://github.com/schmittjoh/serializer/issues/156)
+- Deserialize DateTime from js Date.toJSON format fail [\#145](https://github.com/schmittjoh/serializer/issues/145)
+- Yaml driver for the parameter xml\_attribute\_map is broken [\#141](https://github.com/schmittjoh/serializer/issues/141)
+- XmlKeyValueStore annotation does not seem to deserialize properly [\#139](https://github.com/schmittjoh/serializer/issues/139)
+- Boolean conversion gone wrong [\#134](https://github.com/schmittjoh/serializer/issues/134)
+- Serialize to/from array? [\#133](https://github.com/schmittjoh/serializer/issues/133)
+- @XmlRoot annotation no longer working [\#131](https://github.com/schmittjoh/serializer/issues/131)
+- Skip an element based on a condition in a XmlList [\#121](https://github.com/schmittjoh/serializer/issues/121)
+
+**Merged pull requests:**
+
+- No CData [\#187](https://github.com/schmittjoh/serializer/pull/187) ([mvrhov](https://github.com/mvrhov))
+- composer is preinstalled on travis [\#185](https://github.com/schmittjoh/serializer/pull/185) ([lsmith77](https://github.com/lsmith77))
+- \[WIP\] added support for PHPCR [\#184](https://github.com/schmittjoh/serializer/pull/184) ([lsmith77](https://github.com/lsmith77))
+- Metadata filename convention added to yml/xml references [\#172](https://github.com/schmittjoh/serializer/pull/172) ([rodrigodiez](https://github.com/rodrigodiez))
+- Fix inline bug with empty child [\#165](https://github.com/schmittjoh/serializer/pull/165) ([adrienbrault](https://github.com/adrienbrault))
+- Add virtual properties yaml example [\#163](https://github.com/schmittjoh/serializer/pull/163) ([adrienbrault](https://github.com/adrienbrault))
+- Allow deserialization to constructed objects [\#160](https://github.com/schmittjoh/serializer/pull/160) ([eugene-dounar](https://github.com/eugene-dounar))
+- Fix DoctrineDriverTest random failures [\#155](https://github.com/schmittjoh/serializer/pull/155) ([eugene-dounar](https://github.com/eugene-dounar))
+- Fix XML null DateTime deserialization [\#154](https://github.com/schmittjoh/serializer/pull/154) ([eugene-dounar](https://github.com/eugene-dounar))
+- Update doctrine/orm dev dependency [\#153](https://github.com/schmittjoh/serializer/pull/153) ([eugene-dounar](https://github.com/eugene-dounar))
+- composer install --dev fails [\#152](https://github.com/schmittjoh/serializer/pull/152) ([eugene-dounar](https://github.com/eugene-dounar))
+- Update annotations.rst [\#146](https://github.com/schmittjoh/serializer/pull/146) ([chrisjohnson00](https://github.com/chrisjohnson00))
+- Add Doctrine\ODM\PHPCR\ChildrenCollection to ArrayCollectionHandler [\#143](https://github.com/schmittjoh/serializer/pull/143) ([hacfi](https://github.com/hacfi))
+- xml\_attribute\_map fix for the yaml driver [\#142](https://github.com/schmittjoh/serializer/pull/142) ([mvanmeerbeck](https://github.com/mvanmeerbeck))
+- Support PropelCollection serialization [\#81](https://github.com/schmittjoh/serializer/pull/81) ([zebraf1](https://github.com/zebraf1))
+- Adds XML namespaces support [\#58](https://github.com/schmittjoh/serializer/pull/58) ([ajgarlag](https://github.com/ajgarlag))
+
+## [0.13.0](https://github.com/schmittjoh/serializer/tree/0.13.0) (2013-07-29)
+**Closed issues:**
+
+- Documentation on Exclusion Strategies has an error [\#122](https://github.com/schmittjoh/serializer/issues/122)
+- How access to the current serializing group in a subscriber ? [\#99](https://github.com/schmittjoh/serializer/issues/99)
+- DoctrineProxySubscriber not found [\#93](https://github.com/schmittjoh/serializer/issues/93)
+- Namespaces at root level [\#86](https://github.com/schmittjoh/serializer/issues/86)
+- Issues when requesting JSON or XML using Doctrine MongoDB ODM [\#85](https://github.com/schmittjoh/serializer/issues/85)
+- addGlobalIgnoredName not working [\#78](https://github.com/schmittjoh/serializer/issues/78)
+- serialize\_null configuration [\#77](https://github.com/schmittjoh/serializer/issues/77)
+- Add json prefix to prevent script tag csrf attack [\#76](https://github.com/schmittjoh/serializer/issues/76)
+- Add support for replacing serialization object inside events [\#74](https://github.com/schmittjoh/serializer/issues/74)
+- Next stable version? [\#64](https://github.com/schmittjoh/serializer/issues/64)
+- Deserialize with object refs [\#62](https://github.com/schmittjoh/serializer/issues/62)
+
+**Merged pull requests:**
+
+- fix wrong quote in used in docs [\#130](https://github.com/schmittjoh/serializer/pull/130) ([jaapio](https://github.com/jaapio))
+- Document the handler $context argument [\#116](https://github.com/schmittjoh/serializer/pull/116) ([adrienbrault](https://github.com/adrienbrault))
+- Document the SubscribingHandlerInterface a bit [\#115](https://github.com/schmittjoh/serializer/pull/115) ([adrienbrault](https://github.com/adrienbrault))
+- Add getter for the xml serialization visitor defaultRootName property [\#114](https://github.com/schmittjoh/serializer/pull/114) ([adrienbrault](https://github.com/adrienbrault))
+- Add Serializer::getMetadataFactory [\#113](https://github.com/schmittjoh/serializer/pull/113) ([adrienbrault](https://github.com/adrienbrault))
+- Accessor order [\#108](https://github.com/schmittjoh/serializer/pull/108) ([jaapio](https://github.com/jaapio))
+- Added xmlns:xsi namespace and fixed tests [\#107](https://github.com/schmittjoh/serializer/pull/107) ([josser](https://github.com/josser))
+- \[Doc\] Fixed typo in event\_system [\#106](https://github.com/schmittjoh/serializer/pull/106) ([lyrixx](https://github.com/lyrixx))
+- Fix discriminator map search in ClassMetadata [\#97](https://github.com/schmittjoh/serializer/pull/97) ([xanido](https://github.com/xanido))
+- Use the AnnotationReader interface in the SerializerBuilder, instead of the implemented AnnotationReader itself [\#82](https://github.com/schmittjoh/serializer/pull/82) ([HarmenM](https://github.com/HarmenM))
+- Remove useless YamlSerializationVisitor::prepare method [\#75](https://github.com/schmittjoh/serializer/pull/75) ([adrienbrault](https://github.com/adrienbrault))
+- Add the PRE\_DESERIALIZE event to the Events class [\#73](https://github.com/schmittjoh/serializer/pull/73) ([adrienbrault](https://github.com/adrienbrault))
+- Improve serialization example [\#71](https://github.com/schmittjoh/serializer/pull/71) ([tvlooy](https://github.com/tvlooy))
+- Max depth strategy [\#4](https://github.com/schmittjoh/serializer/pull/4) ([adrienbrault](https://github.com/adrienbrault))
+
+## [0.12.0](https://github.com/schmittjoh/serializer/tree/0.12.0) (2013-03-28)
+**Closed issues:**
+
+- Serialization profile/definition builder [\#68](https://github.com/schmittjoh/serializer/issues/68)
+- I want to configure the default exclution policy [\#65](https://github.com/schmittjoh/serializer/issues/65)
+- Mulit type property mapping [\#56](https://github.com/schmittjoh/serializer/issues/56)
+- AccessType\("public\_method"\): Setters ignored when deserializing to non-standard XML properties [\#53](https://github.com/schmittjoh/serializer/issues/53)
+- Adding @Accessor with custom getter causes LogicException if Doctrine ManyToOneEntity [\#52](https://github.com/schmittjoh/serializer/issues/52)
+- Handler callback's does not get passed context [\#49](https://github.com/schmittjoh/serializer/issues/49)
+- PostSerialize callback causes data loss [\#46](https://github.com/schmittjoh/serializer/issues/46)
+- Empty Objects get serialized as "array\(\)" [\#43](https://github.com/schmittjoh/serializer/issues/43)
+- Exclusion Policies aren't properly applied when "serializeNull" is "true" [\#42](https://github.com/schmittjoh/serializer/issues/42)
+- Accessor annotation ignored [\#40](https://github.com/schmittjoh/serializer/issues/40)
+- Support for multiple exclusion strategies [\#39](https://github.com/schmittjoh/serializer/issues/39)
+- srholt123@yahoo.com [\#35](https://github.com/schmittjoh/serializer/issues/35)
+- Could you tag a stable version? [\#34](https://github.com/schmittjoh/serializer/issues/34)
+- Default conversion of camelCase to underscores is counterintuitive [\#33](https://github.com/schmittjoh/serializer/issues/33)
+- Define the xml root when deserializing [\#18](https://github.com/schmittjoh/serializer/issues/18)
+
+**Merged pull requests:**
+
+- \[Annotation\] Added the ability to set the type when using @VirtualProperty [\#69](https://github.com/schmittjoh/serializer/pull/69) ([pylebecq](https://github.com/pylebecq))
+- Added documentation for the @VirtualProperty annotation [\#67](https://github.com/schmittjoh/serializer/pull/67) ([pylebecq](https://github.com/pylebecq))
+- Metadata stack tests [\#57](https://github.com/schmittjoh/serializer/pull/57) ([adrienbrault](https://github.com/adrienbrault))
+- Adding context to twig extension [\#55](https://github.com/schmittjoh/serializer/pull/55) ([smurfy](https://github.com/smurfy))
+- Allow deserialization of polymorphic classes by class without specifying the type [\#48](https://github.com/schmittjoh/serializer/pull/48) ([gordalina](https://github.com/gordalina))
+- Moves all state to dedicated context class [\#47](https://github.com/schmittjoh/serializer/pull/47) ([schmittjoh](https://github.com/schmittjoh))
+- Add PropertyNamingStrategy [\#37](https://github.com/schmittjoh/serializer/pull/37) ([passkey1510](https://github.com/passkey1510))
+- The NavigatorContext now holds a metadata stack [\#28](https://github.com/schmittjoh/serializer/pull/28) ([adrienbrault](https://github.com/adrienbrault))
+
+## [0.11.0](https://github.com/schmittjoh/serializer/tree/0.11.0) (2013-01-29)
+**Closed issues:**
+
+- Hooking into metadata directly... [\#17](https://github.com/schmittjoh/serializer/issues/17)
+- Serializing null values [\#14](https://github.com/schmittjoh/serializer/issues/14)
+- Strange caching-error [\#13](https://github.com/schmittjoh/serializer/issues/13)
+- handling of plain array [\#10](https://github.com/schmittjoh/serializer/issues/10)
+- Unsupported format doesn't throw exception anymore [\#8](https://github.com/schmittjoh/serializer/issues/8)
+
+**Merged pull requests:**
+
+- Fix typo [\#32](https://github.com/schmittjoh/serializer/pull/32) ([inanimatt](https://github.com/inanimatt))
+- Fixed the serialization of pluralized form errors [\#31](https://github.com/schmittjoh/serializer/pull/31) ([stof](https://github.com/stof))
+- Extract json specific logic from GenericSerializationVisitor [\#29](https://github.com/schmittjoh/serializer/pull/29) ([adrienbrault](https://github.com/adrienbrault))
+- \[Serializer\] Misc cleanup [\#27](https://github.com/schmittjoh/serializer/pull/27) ([vicb](https://github.com/vicb))
+- \[Builder\] Add ability to include if metadata [\#25](https://github.com/schmittjoh/serializer/pull/25) ([vicb](https://github.com/vicb))
+- Fix DateTimeZone issue when using the DateTime type [\#23](https://github.com/schmittjoh/serializer/pull/23) ([colinmorelli](https://github.com/colinmorelli))
+- Wrong exception message for parsing datetime [\#21](https://github.com/schmittjoh/serializer/pull/21) ([nickelc](https://github.com/nickelc))
+- Fixed typo in doc/reference/annotations.rst [\#16](https://github.com/schmittjoh/serializer/pull/16) ([iambrosi](https://github.com/iambrosi))
+- Typecast when serializing primitive types [\#15](https://github.com/schmittjoh/serializer/pull/15) ([baldurrensch](https://github.com/baldurrensch))
+- add check and helpful exception message on inconsistent type situation [\#12](https://github.com/schmittjoh/serializer/pull/12) ([dbu](https://github.com/dbu))
+- Dispatch pre-serialization event before handling data to have ability change type in listener [\#7](https://github.com/schmittjoh/serializer/pull/7) ([megazoll](https://github.com/megazoll))
+- Fix tests running in different environments [\#6](https://github.com/schmittjoh/serializer/pull/6) ([megazoll](https://github.com/megazoll))
+- Add DateInterval serialization to DateHandler formerly DateTimeHandler [\#5](https://github.com/schmittjoh/serializer/pull/5) ([rpg600](https://github.com/rpg600))
+- WIP Navigator context [\#3](https://github.com/schmittjoh/serializer/pull/3) ([adrienbrault](https://github.com/adrienbrault))
+- Update src/JMS/Serializer/Construction/DoctrineObjectConstructor.php [\#2](https://github.com/schmittjoh/serializer/pull/2) ([robocoder](https://github.com/robocoder))
+- Filter out non-identifiers from $data before calling find\(\) [\#1](https://github.com/schmittjoh/serializer/pull/1) ([robocoder](https://github.com/robocoder))
+
+
+
+\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
--- /dev/null
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
--- /dev/null
+# Generating changelog
+
+Use: https://github.com/skywinder/Github-Changelog-Generator
+
+```bash
+github_changelog_generator --pull-requests --no-compare-link -t GITHUB-TOKEN
+```
--- /dev/null
+Serializer [](https://scrutinizer-ci.com/g/schmittjoh/serializer/) [](https://travis-ci.org/schmittjoh/serializer)
+==========
+
+Learn more about it in its [documentation](http://jmsyst.com/libs/serializer).
--- /dev/null
+From 0.13 to ???
+================
+
+- If you have implemented your own ObjectConstructor, you need to add the DeserializationContext as an additional
+ parameter for the ``construct`` method.
+
+
+From 0.11 to 0.12
+=================
+
+- GraphNavigator::detachObject has been removed, you can directly use Context::stopVisiting instead.
+- VisitorInterface::getNavigator was deprecated, instead use Context::accept
+- Serializer::setGroups, Serializer::setExclusionStrategy and Serializer::setVersion were removed, these settings must
+ now be passed as part of a new Context object.
+
+ Before:
+
+ $serializer->setVersion(1);
+ $serializer->serialize($data, 'json');
+
+ After:
+
+ $serializer->serialize($data, 'json', SerializationContext::create()->setVersion(1));
+
+- All visit??? methods of the VisitorInterface, now require a third argument, the Context; the context is for example
+ passed as an additional argument to handlers, exclusion strategies, and also available in event listeners.
--- /dev/null
+{
+ "name": "jms/serializer",
+ "type": "library",
+ "description": "Library for (de-)serializing data of any complexity; supports XML, JSON, and YAML.",
+ "keywords": ["serialization", "deserialization", "json", "jaxb", "xml"],
+ "homepage": "http://jmsyst.com/libs/serializer",
+ "license": "Apache-2.0",
+ "authors": [
+ {
+ "name": "Johannes M. Schmitt",
+ "email": "schmittjoh@gmail.com"
+ },
+ {
+ "name": "Asmir Mustafic",
+ "email": "goetas@gmail.com"
+ }
+ ],
+ "require": {
+ "php": "^5.5|^7.0",
+ "jms/metadata": "~1.1",
+ "jms/parser-lib": "1.*",
+ "phpoption/phpoption": "^1.1",
+ "phpcollection/phpcollection": "~0.1",
+ "doctrine/annotations": "^1.0",
+ "doctrine/instantiator": "^1.0.3"
+ },
+ "conflict": {
+ "twig/twig": "<1.12"
+ },
+ "suggest": {
+ "symfony/yaml": "Required if you'd like to serialize data to YAML format.",
+ "doctrine/collections": "Required if you like to use doctrine collection types as ArrayCollection.",
+ "doctrine/cache": "Required if you like to use cache functionality."
+ },
+ "require-dev": {
+ "ext-pdo_sqlite": "*",
+ "twig/twig": "~1.12|~2.0",
+ "doctrine/orm": "~2.1",
+ "jackalope/jackalope-doctrine-dbal": "^1.1.5",
+ "doctrine/phpcr-odm": "^1.3|^2.0",
+ "propel/propel1": "~1.7",
+ "psr/container": "^1.0",
+ "symfony/dependency-injection": "^2.7|^3.3|^4.0",
+ "symfony/yaml": "^2.1|^3.0",
+ "symfony/translation": "^2.1|^3.0",
+ "symfony/validator": "^2.2|^3.0",
+ "symfony/form": "~2.1|^3.0",
+ "symfony/filesystem": "^2.1",
+ "symfony/expression-language": "^2.6|^3.0",
+ "phpunit/phpunit": "^4.8|^5.0"
+ },
+ "autoload": {
+ "psr-0": {
+ "JMS\\Serializer": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "JMS\\Serializer\\Tests\\": "tests/"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.11-dev"
+ }
+ }
+}
--- /dev/null
+THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.\r
+\r
+BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.\r
+\r
+1. Definitions\r
+\r
+ "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.\r
+ "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License.\r
+ "Distribute" means to make available to the public the original and copies of the Work through sale or other transfer of ownership.\r
+ "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.\r
+ "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.\r
+ "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.\r
+ "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.\r
+ "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.\r
+ "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.\r
+\r
+2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.\r
+\r
+3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:\r
+\r
+ to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; and,\r
+ to Distribute and Publicly Perform the Work including as incorporated in Collections.\r
+\r
+The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats, but otherwise you have no rights to make Adaptations. Subject to 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights set forth in Section 4(d).\r
+\r
+4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:\r
+\r
+ You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested.\r
+ You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works.\r
+ If You Distribute, or Publicly Perform the Work or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work. The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Collection, at a minimum such credit will appear, if a credit for all contributing authors of Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.\r
+\r
+ For the avoidance of doubt:\r
+ Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;\r
+ Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and,\r
+ Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b).\r
+ Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation.\r
+\r
+5. Representations, Warranties and Disclaimer\r
+\r
+UNLESS OTHERWISE MUTUALLY AGREED BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.\r
+\r
+6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
+\r
+7. Termination\r
+\r
+ This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.\r
+ Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.\r
+\r
+8. Miscellaneous\r
+\r
+ Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.\r
+ If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.\r
+ No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.\r
+ This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.\r
+ The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.\r
--- /dev/null
+Configuration
+=============
+
+.. note ::
+
+ If you are using Symfony2, this section is mostly irrelevant for you as the entire integration is provided by
+ JMSSerializerBundle; please see `its documentation <http://jmsyst.com/bundles/JMSSerializerBundle>`_. If you are
+ using another framework, there also might be a module, or other special integration. Please check packagist, or
+ whatever registry usually holds such information for your framework.
+
+Constructing a Serializer
+-------------------------
+
+This library provides a special builder object which makes constructing serializer instances a breeze in any PHP
+project. In its shortest version, it's just a single line of code::
+
+ $serializer = JMS\Serializer\SerializerBuilder::create()->build();
+
+This serializer is fully functional, but you might want to tweak it a bit for example to configure a cache directory.
+
+Configuring a Cache Directory
+-----------------------------
+The serializer collects several metadata about your objects from various sources such as YML, XML, or annotations. In
+order to make this process as efficient as possible, it is encourage to let the serializer cache that information. For
+that, you can configure a cache directory::
+
+ $builder = new JMS\Serializer\SerializerBuilder();
+
+ $serializer =
+ JMS\Serializer\SerializerBuilder::create()
+ ->setCacheDir($someWritableDir)
+ ->setDebug($trueOrFalse)
+ ->build();
+
+As you can see, we also added a call to the ``setDebug`` method. In debug mode, the serializer will perform a bit more
+filesystem checks to see whether the data that it has cached is still valid. These checks are useful during development
+so that you do not need to manually clear cache folders, however in production they are just unnecessary overhead. The
+debug setting allows you to make the behavior environment specific.
+
+Adding Custom Handlers
+----------------------
+If you have created custom handlers, you can add them to the serializer easily::
+
+ $serializer =
+ JMS\Serializer\SerializerBuilder::create()
+ ->addDefaultHandlers()
+ ->configureHandlers(function(JMS\Serializer\Handler\HandlerRegistry $registry) {
+ $registry->registerHandler('serialization', 'MyObject', 'json',
+ function($visitor, MyObject $obj, array $type) {
+ return $obj->getName();
+ }
+ );
+ })
+ ->build();
+
+For more complex handlers, it is advisable to extract them to dedicated classes,
+see :doc:`handlers documentation <handlers>`.
+
+Configuring Metadata Locations
+------------------------------
+This library supports several metadata sources. By default, it uses Doctrine annotations, but you may also store
+metadata in XML, or YML files. For the latter, it is necessary to configure a metadata directory where those files
+are located::
+
+ $serializer =
+ JMS\Serializer\SerializerBuilder::create()
+ ->addMetadataDir($someDir)
+ ->build();
+
+The serializer would expect the metadata files to be named like the fully qualified class names where all ``\`` are
+replaced with ``.``. So, if you class would be named ``Vendor\Package\Foo``, the metadata file would need to be located
+at ``$someDir/Vendor.Package.Foo.(xml|yml)``. For more information, see the :doc:`reference <reference>`.
+
+Setting a default SerializationContext factory
+--------------------------------------------
+To avoid to pass an instance of SerializationContext
+every time you call method ``serialize()`` (or ``toArray()``),
+you can set a ``SerializationContextFactory`` to the Serializer.
+
+Example using the SerializerBuilder::
+
+ use JMS\Serializer\SerializationContext;
+
+ $serializer = JMS\Serializer\SerializerBuilder::create()
+ ->setSerializationContextFactory(function () {
+ return SerializationContext::create()
+ ->setSerializeNull(true)
+ ;
+ })
+ ->build()
+ ;
+
+Then, calling ``$serializer->serialize($data, 'json');`` will generate
+a serialization context from your callable and use it.
+
+.. note ::
+
+ You can also set a default DeserializationContextFactory with
+ ``->setDeserializationContextFactory(function () { /* ... */ })``
+ to be used with methods ``deserialize()`` and ``fromArray()``.
--- /dev/null
+Cookbook\r
+========\r
+\r
+.. toctree ::\r
+ :glob:\r
+\r
+ cookbook/*
\ No newline at end of file
--- /dev/null
+Serailizing arrays and hashes
+=============================
+
+Introduction
+------------
+Serializing arrays and hashes (a concept that in PHP has not explicit boundaries)
+can be challenging. The serializer offers via ``@Type`` annotation different options
+to configure its behavior, but if we try to serialize directly an array
+(not as a property of an object), we need to use context information to determine the
+array "type"
+
+Examples
+--------
+
+In case of a JSON serialization:
+
+.. code-block :: php
+
+ <?php
+
+ // default (let the PHP's json_encode function decide)
+ $serializer->serialize([1, 2]); // [1, 2]
+ $serializer->serialize(['a', 'b']); // ['a', 'b']
+ $serializer->serialize(['c' => 'd']); // {"c" => "d"}
+
+ // same as default (let the PHP's json_encode function decide)
+ $serializer->serialize([1, 2], SerializationContext::create()->setInitialType('array')); // [1, 2]
+ $serializer->serialize([1 => 2], SerializationContext::create()->setInitialType('array')); // {"1": 2}
+ $serializer->serialize(['a', 'b'], SerializationContext::create()->setInitialType('array')); // ['a', 'b']
+ $serializer->serialize(['c' => 'd'], SerializationContext::create()->setInitialType('array')); // {"c" => "d"}
+
+ // typehint as strict array, keys will be always discarded
+ $serializer->serialize([], SerializationContext::create()->setInitialType('array<integer>')); // []
+ $serializer->serialize([1, 2], SerializationContext::create()->setInitialType('array<integer>')); // [1, 2]
+ $serializer->serialize(['a', 'b'], SerializationContext::create()->setInitialType('array<integer>')); // ['a', 'b']
+ $serializer->serialize(['c' => 'd'], SerializationContext::create()->setInitialType('array<string>')); // ["d"]
+
+ // typehint as hash, keys will be always considered
+ $serializer->serialize([], SerializationContext::create()->setInitialType('array<integer,integer>')); // {}
+ $serializer->serialize([1, 2], SerializationContext::create()->setInitialType('array<integer,integer>')); // {"0" : 1, "1" : 2}
+ $serializer->serialize(['a', 'b'], SerializationContext::create()->setInitialType('array<integer,integer>')); // {"0" : "a", "1" : "b"}
+ $serializer->serialize(['c' => 'd'], SerializationContext::create()->setInitialType('array<string,string>')); // {"d" : "d"}
+
+
+.. note ::
+
+ This applies only for the JSON and YAML serialization.
--- /dev/null
+Exclusion Strategies\r
+====================\r
+\r
+Introduction\r
+------------\r
+The serializer supports different exclusion strategies. Each strategy allows\r
+you to define which properties of your objects should be serialized.\r
+\r
+General Exclusion Strategies\r
+----------------------------\r
+If you would like to always expose, or exclude certain properties. Then, you can\r
+do this with the annotations ``@ExclusionPolicy``, ``@Exclude``, and ``@Expose``.\r
+\r
+The default exclusion policy is to exclude nothing. That is, all properties of the\r
+object will be serialized. If you only want to expose a few of the properties,\r
+then it is easier to change the exclusion policy, and only mark these few properties:\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\ExclusionPolicy;\r
+ use JMS\Serializer\Annotation\Expose;\r
+\r
+ /**\r
+ * The following annotations tells the serializer to skip all properties which\r
+ * have not marked with @Expose.\r
+ *\r
+ * @ExclusionPolicy("all")\r
+ */\r
+ class MyObject\r
+ {\r
+ private $foo;\r
+ private $bar;\r
+\r
+ /**\r
+ * @Expose\r
+ */\r
+ private $name;\r
+ }\r
+\r
+.. note ::\r
+\r
+ A property that is excluded by ``@Exclude`` cannot be exposed anymore by any\r
+ of the following strategies, but is always hidden.\r
+\r
+Versioning Objects\r
+------------------\r
+JMSSerializerBundle comes by default with a very neat feature which allows\r
+you to add versioning support to your objects, e.g. if you want to\r
+expose them via an API that is consumed by a third-party:\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ class VersionedObject\r
+ {\r
+ /**\r
+ * @Until("1.0.x")\r
+ */\r
+ private $name;\r
+\r
+ /**\r
+ * @Since("1.1")\r
+ * @SerializedName("name")\r
+ */\r
+ private $name2;\r
+ }\r
+\r
+.. note ::\r
+\r
+ ``@Until``, and ``@Since`` both accept a standardized PHP version number.\r
+\r
+If you have annotated your objects like above, you can serializing different\r
+versions like this::\r
+\r
+ use JMS\Serializer\SerializationContext;\r
+\r
+ $serializer->serialize(new VersionObject(), 'json', SerializationContext::create()->setVersion(1));\r
+\r
+\r
+Creating Different Views of Your Objects\r
+----------------------------------------\r
+Another default exclusion strategy is to create different views of your objects.\r
+Let's say you would like to serialize your object in a different view depending\r
+whether it is displayed in a list view or in a details view.\r
+\r
+You can achieve that by using the ``@Groups`` annotation on your properties. Any\r
+property without an explicit ``@Groups`` annotation will be included in a\r
+``Default`` group, which can be used when specifying groups in the serialization\r
+context.\r
+\r
+.. code-block :: php\r
+\r
+ use JMS\Serializer\Annotation\Groups;\r
+\r
+ class BlogPost\r
+ {\r
+ /** @Groups({"list", "details"}) */\r
+ private $id;\r
+\r
+ /** @Groups({"list", "details"}) */\r
+ private $title;\r
+\r
+ /** @Groups({"list"}) */\r
+ private $nbComments;\r
+\r
+ /** @Groups({"details"}) */\r
+ private $comments;\r
+\r
+ private $createdAt;\r
+ }\r
+\r
+You can then tell the serializer which groups to serialize in your controller::\r
+\r
+ use JMS\Serializer\SerializationContext;\r
+\r
+ $serializer->serialize(new BlogPost(), 'json', SerializationContext::create()->setGroups(array('list')));\r
+\r
+ //will output $id, $title and $nbComments.\r
+\r
+ $serializer->serialize(new BlogPost(), 'json', SerializationContext::create()->setGroups(array('Default', 'list')));\r
+\r
+ //will output $id, $title, $nbComments and $createdAt.\r
+\r
+Overriding Groups of Deeper Branches of the Graph\r
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+In some cases you want to control more precisely what is serialized because you may have the same class at different\r
+depths of the object graph.\r
+\r
+For example if you have a User that has a manager and friends::\r
+\r
+ use JMS\Serializer\Annotation\Groups;\r
+\r
+ class User\r
+ {\r
+ private $name;\r
+\r
+ /** @Groups({"manager_group"}) */\r
+ private $manager;\r
+\r
+ /** @Groups({"friends_group"}) */\r
+ private $friends;\r
+\r
+ public function __construct($name, User $manager = null, array $friends = null)\r
+ {\r
+ $this->name = $name;\r
+ $this->manager = $manager;\r
+ $this->friends = $friends;\r
+ }\r
+ }\r
+\r
+And the following object graph::\r
+\r
+ $john = new User(\r
+ 'John',\r
+ new User(\r
+ 'John Manager',\r
+ new User('The boss'),\r
+ array(\r
+ new User('John Manager friend 1'),\r
+ )\r
+ ),\r
+ array(\r
+ new User(\r
+ 'John friend 1',\r
+ new User('John friend 1 manager')\r
+ ),\r
+ new User(\r
+ 'John friend 2',\r
+ new User('John friend 2 manager')\r
+ ),\r
+ )\r
+ );\r
+\r
+You can override groups on specific paths::\r
+\r
+ use JMS\Serializer\SerializationContext;\r
+\r
+ $context = SerializationContext::create()->setGroups(array(\r
+ 'Default', // Serialize John's name\r
+ 'manager_group', // Serialize John's manager\r
+ 'friends_group', // Serialize John's friends\r
+\r
+ 'manager' => array( // Override the groups for the manager of John\r
+ 'Default', // Serialize John manager's name\r
+ 'friends_group', // Serialize John manager's friends. If you do not override the groups for the friends, it will default to Default.\r
+ ),\r
+\r
+ 'friends' => array( // Override the groups for the friends of John\r
+ 'manager_group' // Serialize John friends' managers.\r
+\r
+ 'manager' => array( // Override the groups for the John friends' manager\r
+ 'Default', // This would be the default if you did not override the groups of the manager property.\r
+ ),\r
+ ),\r
+ ));\r
+ $serializer->serialize($john, 'json', $context);\r
+\r
+This would result in the following json::\r
+\r
+ {\r
+ "name": "John",\r
+ "manager": {\r
+ "name": "John Manager",\r
+ "friends": [\r
+ {\r
+ "name": "John Manager friend 1"\r
+ }\r
+ ]\r
+ },\r
+ "friends": [\r
+ {\r
+ "manager": {\r
+ "name": "John friend 1 manager"\r
+ },\r
+ },\r
+ {\r
+ "manager": {\r
+ "name": "John friend 2 manager"\r
+ },\r
+ },\r
+ ]\r
+ }\r
+\r
+Limiting serialization depth of some properties\r
+-----------------------------------------------\r
+You can limit the depth of what will be serialized in a property with the\r
+``@MaxDepth`` annotation.\r
+This exclusion strategy is a bit different from the others, because it will\r
+affect the serialized content of others classes than the one you apply the\r
+annotation to.\r
+\r
+.. code-block :: php\r
+\r
+ use JMS\Serializer\Annotation\MaxDepth;\r
+\r
+ class User\r
+ {\r
+ private $username;\r
+\r
+ /** @MaxDepth(1) */\r
+ private $friends;\r
+\r
+ /** @MaxDepth(2) */\r
+ private $posts;\r
+ }\r
+\r
+ class Post\r
+ {\r
+ private $title;\r
+\r
+ private $author;\r
+ }\r
+\r
+In this example, serializing a user, because the max depth of the ``$friends``\r
+property is 1, the user friends would be serialized, but not their friends;\r
+and because the the max depth of the ``$posts`` property is 2, the posts would\r
+be serialized, and their author would also be serialized.\r
+\r
+You need to tell the serializer to take into account MaxDepth checks::\r
+\r
+ use JMS\Serializer\SerializationContext;\r
+\r
+ $serializer->serialize($data, 'json', SerializationContext::create()->enableMaxDepthChecks());\r
+\r
+\r
+Dynamic exclusion strategy\r
+--------------------------\r
+\r
+If the previous exclusion strategies are not enough, is possible to use the ``ExpressionLanguageExclusionStrategy``\r
+that uses the `symfony expression language`_ to\r
+allow a more sophisticated exclusion strategies using ``@Exclude(if="expression")`` and ``@Expose(if="expression")`` methods.\r
+\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ class MyObject\r
+ {\r
+ /**\r
+ * @Exclude(if="true")\r
+ */\r
+ private $name;\r
+\r
+ /**\r
+ * @Expose(if="true")\r
+ */\r
+ private $name2;\r
+ }\r
+\r
+.. note ::\r
+\r
+ ``true`` is just a generic expression, you can use any expression allowed by the Symfony Expression Language\r
+\r
+To enable this feature you have to set the Expression Evaluator when initializing the serializer. \r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+ use JMS\Serializer\Expression\ExpressionEvaluator;\r
+ use JMS\Serializer\Expression\SerializerBuilder;\r
+ use Symfony\Component\ExpressionLanguage\ExpressionLanguage;\r
+ \r
+ $serializer = SerializerBuilder::create()\r
+ ->setExpressionEvaluator(new ExpressionEvaluator(new ExpressionLanguage()))\r
+ ->build();\r
+\r
+.. _symfony expression language: https://github.com/symfony/expression-language\r
+\r
+By default the serializer exposes three variables (`object`, `context` and `property_metadata` for use in an expression. This enables you to create custom exclusion strategies similar to i.e. the [GroupExclusionStrategy](https://github.com/schmittjoh/serializer/blob/master/src/Exclusion/GroupsExclusionStrategy.php). In the below example, `someMethod` would receive all three variables.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ class MyObject\r
+ {\r
+ /**\r
+ * @Exclude(if="someMethod(object, context, property_metadata)")\r
+ */\r
+ private $name;\r
+\r
+ /**\r
+ * @Exclude(if="someMethod(object, context, property_metadata)")\r
+ */\r
+ private $name2;\r
+ }\r
--- /dev/null
+stdClass
+========
+
+The serializer offers support for serializing ``stdClass`` objects, however the use of
+``stdClass`` objects is discouraged.
+
+The current implementation serializes all the properties of a ``stdClass`` object in
+the order they appear.
+
+There are may know limitations wen dealing with ``stdClass`` objects,
+more in detail, is not possible to:
+
+- change serialization order of properties
+- apply per-property exclusion policies
+- specify any extra serialization information for properties that are part of the ``stdClass`` object, as serialization name, type, xml structure and so on
+- deserialize data into ``stdClass`` objects
--- /dev/null
+Event System
+============
+
+The serializer dispatches different events during the serialization, and
+deserialization process which you can use to hook in and alter the default
+behavior.
+
+Register an Event Listener, or Subscriber
+-----------------------------------------
+The difference between listeners, and subscribers is that listener do not know to which events they listen
+while subscribers contain that information. Thus, subscribers are easier to share, and re-use. Listeners
+on the other hand, can be simple callables and do not require a dedicated class.
+
+.. code-block :: php
+
+ class MyEventSubscriber implements JMS\Serializer\EventDispatcher\EventSubscriberInterface
+ {
+ public static function getSubscribedEvents()
+ {
+ return array(
+ array(
+ 'event' => 'serializer.pre_serialize',
+ 'method' => 'onPreSerialize',
+ 'class' => 'AppBundle\\Entity\\SpecificClass', // if no class, subscribe to every serialization
+ 'format' => 'json', // optional format
+ 'priority' => 0, // optional priority
+ ),
+ );
+ }
+
+ public function onPreSerialize(JMS\Serializer\EventDispatcher\PreSerializeEvent $event)
+ {
+ // do something
+ }
+ }
+
+ $builder
+ ->configureListeners(function(JMS\Serializer\EventDispatcher\EventDispatcher $dispatcher) {
+ $dispatcher->addListener('serializer.pre_serialize',
+ function(JMS\Serializer\EventDispatcher\PreSerializeEvent $event) {
+ // do something
+ }
+ );
+
+ $dispatcher->addSubscriber(new MyEventSubscriber());
+ })
+ ;
+
+Events
+------
+
+serializer.pre_serialize
+~~~~~~~~~~~~~~~~~~~~~~~~
+This is dispatched before a type is visited. You have access to the visitor,
+data, and type. Listeners may modify the type that is being used for
+serialization.
+
+**Event Object**: ``JMS\Serializer\EventDispatcher\PreSerializeEvent``
+
+serializer.post_serialize
+~~~~~~~~~~~~~~~~~~~~~~~~~
+This is dispatched right before a type is left. You can for example use this
+to add additional data for an object that you normally do not save inside
+objects such as links.
+
+**Event Object**: ``JMS\Serializer\EventDispatcher\ObjectEvent``
+
+serializer.pre_deserialize
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. versionadded : 0.12
+ Event was added
+
+This is dispatched before an object is deserialized. You can use this to
+modify submitted data, or modify the type that is being used for deserialization.
+
+**Event Object**: ``JMS\Serializer\EventDispatcher\PreDeserializeEvent``
+
+serializer.post_deserialize
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+This is dispatched after a type is processed. You can use it to normalize
+submitted data if you require external services for example, or also to
+perform validation of the submitted data.
+
+**Event Object**: ``JMS\Serializer\EventDispatcher\ObjectEvent``
--- /dev/null
+Handlers\r
+========\r
+\r
+Introduction\r
+------------\r
+Handlers allow you to change the serialization, or deserialization process\r
+for a single type/format combination.\r
+\r
+Handlers are simple callback which receive three arguments: the visitor,\r
+the data, and the type.\r
+\r
+Simple Callables\r
+----------------\r
+You can register simple callables on the builder object::\r
+\r
+ $builder\r
+ ->configureHandlers(function(JMS\Serializer\Handler\HandlerRegistry $registry) {\r
+ $registry->registerHandler('serialization', 'MyObject', 'json',\r
+ function($visitor, MyObject $obj, array $type) {\r
+ return $obj->getName();\r
+ }\r
+ );\r
+ })\r
+ ;\r
+\r
+Subscribing Handlers\r
+--------------------\r
+Subscribing handlers contain the configuration themselves which makes them easier to share with other users,\r
+and easier to set-up in general::\r
+\r
+ use JMS\Serializer\Handler\SubscribingHandlerInterface;\r
+ use JMS\Serializer\GraphNavigator;\r
+ use JMS\Serializer\JsonSerializationVisitor;\r
+ use JMS\Serializer\Context;\r
+\r
+ class MyHandler implements SubscribingHandlerInterface\r
+ {\r
+ public static function getSubscribingMethods()\r
+ {\r
+ return array(\r
+ array(\r
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,\r
+ 'format' => 'json',\r
+ 'type' => 'DateTime',\r
+ 'method' => 'serializeDateTimeToJson',\r
+ ),\r
+ );\r
+ }\r
+\r
+ public function serializeDateTimeToJson(JsonSerializationVisitor $visitor, \DateTime $date, array $type, Context $context)\r
+ {\r
+ return $date->format($type['params'][0]);\r
+ }\r
+ }\r
+\r
+Also, this type of handler is registered via the builder object::\r
+\r
+ $builder\r
+ ->configureHandlers(function(JMS\Serializer\Handler\HandlerRegistry $registry) {\r
+ $registry->registerSubscribingHandler(new MyHandler());\r
+ })\r
+ ;\r
+\r
--- /dev/null
+Serializer
+==========
+
+Introduction
+------------
+This library allows you to (de-)serialize data of any complexity. Currently, it supports XML, JSON, and YAML.
+
+It also provides you with a rich tool-set to adapt the output to your specific needs.
+
+Built-in features include:
+
+- (De-)serialize data of any complexity; circular references are handled gracefully.
+- Supports many built-in PHP types (such as dates)
+- Integrates with Doctrine ORM, et. al.
+- Supports versioning, e.g. for APIs
+- Configurable via PHP, XML, YAML, or Doctrine Annotations
+
+Installation
+------------
+This library can be easily installed via composer
+
+.. code-block :: bash
+
+ composer require jms/serializer
+
+or just add it to your ``composer.json`` file directly.
+
+Usage
+-----
+For standalone projects usage of the provided builder is encouraged::
+
+ $serializer = JMS\Serializer\SerializerBuilder::create()->build();
+ $jsonContent = $serializer->serialize($data, 'json');
+ echo $jsonContent; // or return it in a Response
+
+Documentation
+-------------
+
+.. toctree ::
+ :hidden:
+
+ configuration
+ usage
+ event_system
+ handlers
+ reference
+ cookbook
+
+- :doc:`Configuration <configuration>`
+- :doc:`Usage <usage>`
+- :doc:`Events <event_system>`
+- :doc:`Handlers <handlers>`
+
+- Recipes
+ * :doc:`/cookbook/exclusion_strategies`
+
+- Reference
+ * :doc:`Annotations </reference/annotations>`
+ * :doc:`XML Reference </reference/xml_reference>`
+ * :doc:`YML Reference </reference/yml_reference>`
+
+License
+-------
+
+The code is released under the business-friendly `Apache2 license`_.
+
+Documentation is subject to the `Attribution-NonCommercial-NoDerivs 3.0 Unported
+license`_.
+
+.. _Apache2 license: http://www.apache.org/licenses/LICENSE-2.0.html
+.. _Attribution-NonCommercial-NoDerivs 3.0 Unported license: http://creativecommons.org/licenses/by-nc-nd/3.0/
+
--- /dev/null
+Reference\r
+=========\r
+\r
+.. toctree ::\r
+ :glob:\r
+ :maxdepth: 1\r
+\r
+ reference/*
\ No newline at end of file
--- /dev/null
+Annotations\r
+-----------\r
+\r
+@ExclusionPolicy\r
+~~~~~~~~~~~~~~~~\r
+This annotation can be defined on a class to indicate the exclusion strategy\r
+that should be used for the class.\r
+\r
++----------+----------------------------------------------------------------+\r
+| Policy | Description |\r
++==========+================================================================+\r
+| all | all properties are excluded by default; only properties marked |\r
+| | with @Expose will be serialized/unserialized |\r
++----------+----------------------------------------------------------------+\r
+| none | no properties are excluded by default; all properties except |\r
+| | those marked with @Exclude will be serialized/unserialized |\r
++----------+----------------------------------------------------------------+\r
+\r
+@Exclude\r
+~~~~~~~~\r
+This annotation can be defined on a property to indicate that the property should\r
+not be serialized/unserialized. Works only in combination with NoneExclusionPolicy.\r
+\r
+If the ``ExpressionLanguageExclusionStrategy`` exclusion strategy is enabled, will\r
+be possible to use ``@Exclude(if="expression")`` to exclude dynamically a property.\r
+\r
+@Expose\r
+~~~~~~~\r
+This annotation can be defined on a property to indicate that the property should\r
+be serialized/unserialized. Works only in combination with AllExclusionPolicy.\r
+\r
+If the ``ExpressionLanguageExclusionStrategy`` exclusion strategy is enabled, will\r
+be possible to use ``@Expose(if="expression")`` to expose dynamically a property.\r
+\r
+@SkipWhenEmpty\r
+~~~~~~~~~~~~~~\r
+This annotation can be defined on a property to indicate that the property should\r
+not be serialized if the result will be "empty".\r
+\r
+Works option works only when serializing.\r
+\r
+@SerializedName\r
+~~~~~~~~~~~~~~~\r
+This annotation can be defined on a property to define the serialized name for a\r
+property. If this is not defined, the property will be translated from camel-case\r
+to a lower-cased underscored name, e.g. camelCase -> camel_case.\r
+\r
+@Since\r
+~~~~~~\r
+This annotation can be defined on a property to specify starting from which\r
+version this property is available. If an earlier version is serialized, then\r
+this property is excluded automatically. The version must be in a format that is\r
+understood by PHP's ``version_compare`` function.\r
+\r
+@Until\r
+~~~~~~\r
+This annotation can be defined on a property to specify until which version this\r
+property was available. If a later version is serialized, then this property is\r
+excluded automatically. The version must be in a format that is understood by\r
+PHP's ``version_compare`` function.\r
+\r
+@Groups\r
+~~~~~~~\r
+This annotation can be defined on a property to specify if the property\r
+should be serialized when only serializing specific groups (see\r
+:doc:`../cookbook/exclusion_strategies`).\r
+\r
+@MaxDepth\r
+~~~~~~~~~\r
+This annotation can be defined on a property to limit the depth to which the\r
+content will be serialized. It is very useful when a property will contain a\r
+large object graph.\r
+\r
+@AccessType\r
+~~~~~~~~~~~\r
+This annotation can be defined on a property, or a class to specify in which way\r
+the properties should be accessed. By default, the serializer will retrieve, or\r
+set the value via reflection, but you may change this to use a public method instead:\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+ use JMS\Serializer\Annotation\AccessType;\r
+\r
+ /** @AccessType("public_method") */\r
+ class User\r
+ {\r
+ private $name;\r
+\r
+ public function getName()\r
+ {\r
+ return $this->name;\r
+ }\r
+\r
+ public function setName($name)\r
+ {\r
+ $this->name = trim($name);\r
+ }\r
+ }\r
+\r
+@Accessor\r
+~~~~~~~~~\r
+This annotation can be defined on a property to specify which public method should\r
+be called to retrieve, or set the value of the given property:\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+ use JMS\Serializer\Annotation\Accessor;\r
+\r
+ class User\r
+ {\r
+ private $id;\r
+\r
+ /** @Accessor(getter="getTrimmedName",setter="setName") */\r
+ private $name;\r
+\r
+ // ...\r
+ public function getTrimmedName()\r
+ {\r
+ return trim($this->name);\r
+ }\r
+\r
+ public function setName($name)\r
+ {\r
+ $this->name = $name;\r
+ }\r
+ }\r
+ \r
+.. note ::\r
+\r
+ If you need only to serialize your data, you can avoid providing a setter by\r
+ setting the property as read-only using the ``@ReadOnly`` annotation.\r
+\r
+@AccessorOrder\r
+~~~~~~~~~~~~~~\r
+This annotation can be defined on a class to control the order of properties. By\r
+default the order is undefined, but you may change it to either "alphabetical", or\r
+"custom".\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+ use JMS\Serializer\Annotation\AccessorOrder;\r
+\r
+ /**\r
+ * @AccessorOrder("alphabetical")\r
+ *\r
+ * Resulting Property Order: id, name\r
+ */\r
+ class User\r
+ {\r
+ private $id;\r
+ private $name;\r
+ }\r
+\r
+ /**\r
+ * @AccessorOrder("custom", custom = {"name", "id"})\r
+ *\r
+ * Resulting Property Order: name, id\r
+ */\r
+ class User\r
+ {\r
+ private $id;\r
+ private $name;\r
+ }\r
+\r
+ /**\r
+ * @AccessorOrder("custom", custom = {"name", "someMethod" ,"id"})\r
+ *\r
+ * Resulting Property Order: name, mood, id\r
+ */\r
+ class User\r
+ {\r
+ private $id;\r
+ private $name;\r
+\r
+ /**\r
+ * @Serializer\VirtualProperty\r
+ * @Serializer\SerializedName("mood")\r
+ *\r
+ * @return string\r
+ */\r
+ public function getSomeMethod()\r
+ {\r
+ return 'happy';\r
+ }\r
+ }\r
+\r
+@VirtualProperty\r
+~~~~~~~~~~~~~~~~\r
+This annotation can be defined on a method to indicate that the data returned by\r
+the method should appear like a property of the object.\r
+\r
+A virtual property can be defined for a method of an object to serialize and can be\r
+also defined at class level exposing data using the Symfony Expression Language.\r
+\r
+.. code-block :: php\r
+\r
+ /**\r
+ * @Serializer\VirtualProperty(\r
+ * "firstName",\r
+ * exp="object.getFirstName()",\r
+ * options={@Serializer\SerializedName("my_first_name")}\r
+ * )\r
+ */\r
+ class Author\r
+ {\r
+ /**\r
+ * @Serializer\Expose()\r
+ */\r
+ private $id;\r
+\r
+ /**\r
+ * @Serializer\Exclude()\r
+ */\r
+ private $firstName;\r
+\r
+ /**\r
+ * @Serializer\Exclude()\r
+ */\r
+ private $lastName;\r
+\r
+ /**\r
+ * @Serializer\VirtualProperty()\r
+ */\r
+ public function getLastName()\r
+ {\r
+ return $this->lastName;\r
+ }\r
+\r
+ public function getFirstName()\r
+ {\r
+ return $this->firstName;\r
+ }\r
+ }\r
+\r
+In this example:\r
+\r
+- ``id`` is exposed using the object reflection.\r
+- ``lastName`` is exposed using the ``getLastName`` getter method.\r
+- ``firstName`` is exposed using the ``object.getFirstName()`` expression (``exp`` can contain any valid symfony expression).\r
+\r
+\r
+.. note ::\r
+\r
+ This only works for serialization and is completely ignored during deserialization.\r
+\r
+@Inline\r
+~~~~~~~\r
+This annotation can be defined on a property to indicate that the data of the property\r
+should be inlined.\r
+\r
+**Note**: This only works for serialization, the serializer will not be able to deserialize\r
+objects with this annotation. Also, AccessorOrder will be using the name of the property\r
+to determine the order.\r
+\r
+@ReadOnly\r
+~~~~~~~~~\r
+This annotation can be defined on a property to indicate that the data of the property\r
+is read only and cannot be set during deserialization.\r
+\r
+A property can be marked as non read only with ``@ReadOnly(false)`` annotation (useful when a class is marked as read only).\r
+\r
+@PreSerialize\r
+~~~~~~~~~~~~~\r
+This annotation can be defined on a method which is supposed to be called before\r
+the serialization of the object starts.\r
+\r
+@PostSerialize\r
+~~~~~~~~~~~~~~\r
+This annotation can be defined on a method which is then called directly after the\r
+object has been serialized.\r
+\r
+@PostDeserialize\r
+~~~~~~~~~~~~~~~~\r
+This annotation can be defined on a method which is supposed to be called after\r
+the object has been deserialized.\r
+\r
+@HandlerCallback\r
+~~~~~~~~~~~~~~~~\r
+This annotation can be defined on a method if serialization/deserialization is handled\r
+by the object itself.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ class Article\r
+ {\r
+ /**\r
+ * @HandlerCallback("xml", direction = "serialization")\r
+ */\r
+ public function serializeToXml(XmlSerializationVisitor $visitor)\r
+ {\r
+ // custom logic here\r
+ }\r
+ }\r
+\r
+@Discriminator\r
+~~~~~~~~~~~~~~\r
+\r
+.. versionadded : 0.12\r
+ @Discriminator was added\r
+\r
+This annotation allows serialization/deserialization of relations which are polymorphic, but\r
+where a common base class exists. The ``@Discriminator`` annotation has to be applied\r
+to the least super type::\r
+\r
+ /**\r
+ * @Discriminator(field = "type", disabled = false, map = {"car": "Car", "moped": "Moped"}, groups={"foo", "bar"})\r
+ */\r
+ abstract class Vehicle { }\r
+ class Car extends Vehicle { }\r
+ class Moped extends Vehicle { }\r
+\r
+\r
+.. note ::\r
+\r
+ `groups` is optional and is used as exclusion policy.\r
+\r
+@Type\r
+~~~~~\r
+This annotation can be defined on a property to specify the type of that property.\r
+For deserialization, this annotation must be defined.\r
+The ``@Type`` annotation can have parameters and parameters can be used by serialization/deserialization\r
+handlers to enhance the serialization or deserialization result; for example, you may want to\r
+force a certain format to be used for serializing DateTime types and specifying at the same time a different format\r
+used when deserializing them.\r
+\r
+Available Types:\r
+\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| Type | Description |\r
++==========================================================+==================================================+\r
+| boolean or bool | Primitive boolean |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| integer or int | Primitive integer |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| double or float | Primitive double |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| string | Primitive string |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| array | An array with arbitrary keys, and values. |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| array<T> | A list of type T (T can be any available type). |\r
+| | Examples: |\r
+| | array<string>, array<MyNamespace\MyObject>, etc. |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| array<K, V> | A map of keys of type K to values of type V. |\r
+| | Examples: array<string, string>, |\r
+| | array<string, MyNamespace\MyObject>, etc. |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| DateTime | PHP's DateTime object (default format*/timezone) |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| DateTime<'format'> | PHP's DateTime object (custom format/default |\r
+| | timezone) |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| DateTime<'format', 'zone'> | PHP's DateTime object (custom format/timezone) |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| DateTime<'format', 'zone', 'deserializeFormat'> | PHP's DateTime object (custom format/timezone, |\r
+| | deserialize format). If you do not want to |\r
+| | specify a specific timezone, use an empty |\r
+| | string (''). |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| DateTimeImmutable | PHP's DateTimeImmutable object (default format*/ |\r
+| | timezone) |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| DateTimeImmutable<'format'> | PHP's DateTimeImmutable object (custom format/ |\r
+| | default timezone) |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| DateTimeImmutable<'format', 'zone'> | PHP's DateTimeImmutable object (custom format/ |\r
+| | timezone) |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| DateTimeImmutable<'format', 'zone', 'deserializeFormat'> | PHP's DateTimeImmutable object (custom format/ |\r
+| | timezone/deserialize format). If you do not want |\r
+| | to specify a specific timezone, use an empty |\r
+| | string (''). |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| DateInterval | PHP's DateInterval object using ISO 8601 format |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| T | Where T is a fully qualified class name. |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| ArrayCollection<T> | Similar to array<T>, but will be deserialized |\r
+| | into Doctrine's ArrayCollection class. |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+| ArrayCollection<K, V> | Similar to array<K, V>, but will be deserialized |\r
+| | into Doctrine's ArrayCollection class. |\r
++----------------------------------------------------------+--------------------------------------------------+\r
+\r
+(*) If the standalone jms/serializer is used then default format is `\DateTime::ISO8601` (which is not compatible with ISO-8601 despite the name). For jms/serializer-bundle the default format is `\DateTime::ATOM` (the real ISO-8601 format) but it can be changed in [configuration](https://jmsyst.com/bundles/JMSSerializerBundle/master/configuration#configuration-block-2-0).\r
+\r
+Examples:\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ namespace MyNamespace;\r
+\r
+ use JMS\Serializer\Annotation\Type;\r
+\r
+ class BlogPost\r
+ {\r
+ /**\r
+ * @Type("ArrayCollection<MyNamespace\Comment>")\r
+ */\r
+ private $comments;\r
+\r
+ /**\r
+ * @Type("string")\r
+ */\r
+ private $title;\r
+\r
+ /**\r
+ * @Type("MyNamespace\Author")\r
+ */\r
+ private $author;\r
+\r
+ /**\r
+ * @Type("DateTime")\r
+ */\r
+ private $startAt;\r
+\r
+ /**\r
+ * @Type("DateTime<'Y-m-d'>")\r
+ */\r
+ private $endAt;\r
+\r
+ /**\r
+ * @Type("DateTimeImmutable")\r
+ */\r
+ private $createdAt;\r
+\r
+ /**\r
+ * @Type("DateTimeImmutable<'Y-m-d'>")\r
+ */\r
+ private $updatedAt;\r
+\r
+ /**\r
+ * @Type("boolean")\r
+ */\r
+ private $published;\r
+\r
+ /**\r
+ * @Type("array<string, string>")\r
+ */\r
+ private $keyValueStore;\r
+ }\r
+\r
+@XmlRoot\r
+~~~~~~~~\r
+This allows you to specify the name of the top-level element.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\XmlRoot;\r
+\r
+ /** @XmlRoot("user") */\r
+ class User\r
+ {\r
+ private $name = 'Johannes';\r
+ }\r
+\r
+Resulting XML:\r
+\r
+.. code-block :: xml\r
+\r
+ <user>\r
+ <name><![CDATA[Johannes]]></name>\r
+ </user>\r
+\r
+.. note ::\r
+\r
+ @XmlRoot only applies to the root element, but is for example not taken into\r
+ account for collections. You can define the entry name for collections using\r
+ @XmlList, or @XmlMap.\r
+\r
+@XmlAttribute\r
+~~~~~~~~~~~~~\r
+This allows you to mark properties which should be set as attributes,\r
+and not as child elements.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\XmlAttribute;\r
+\r
+ class User\r
+ {\r
+ /** @XmlAttribute */\r
+ private $id = 1;\r
+ private $name = 'Johannes';\r
+ }\r
+\r
+Resulting XML:\r
+\r
+.. code-block :: xml\r
+\r
+ <result id="1">\r
+ <name><![CDATA[Johannes]]></name>\r
+ </result>\r
+\r
+\r
+@XmlDiscriminator\r
+~~~~~~~~~~~~~~~~~\r
+This annotation allows to modify the behaviour of @Discriminator regarding handling of XML.\r
+\r
+\r
+Available Options:\r
+\r
++-------------------------------------+--------------------------------------------------+\r
+| Type | Description |\r
++=====================================+==================================================+\r
+| attribute | use an attribute instead of a child node |\r
++-------------------------------------+--------------------------------------------------+\r
+| cdata | render child node content with or without cdata |\r
++-------------------------------------+--------------------------------------------------+\r
+| namespace | render child node using the specified namespace |\r
++-------------------------------------+--------------------------------------------------+\r
+\r
+Example for "attribute":\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\Discriminator;\r
+ use JMS\Serializer\Annotation\XmlDiscriminator;\r
+\r
+ /**\r
+ * @Discriminator(field = "type", map = {"car": "Car", "moped": "Moped"}, groups={"foo", "bar"})\r
+ * @XmlDiscriminator(attribute=true)\r
+ */\r
+ abstract class Vehicle { }\r
+ class Car extends Vehicle { }\r
+\r
+Resulting XML:\r
+\r
+.. code-block :: xml\r
+\r
+ <vehicle type="car" />\r
+\r
+\r
+Example for "cdata":\r
+\r
+.. code-block :: php\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\Discriminator;\r
+ use JMS\Serializer\Annotation\XmlDiscriminator;\r
+\r
+\r
+\r
+ /**\r
+ * @Discriminator(field = "type", map = {"car": "Car", "moped": "Moped"}, groups={"foo", "bar"})\r
+ * @XmlDiscriminator(attribute=true)\r
+ */\r
+ abstract class Vehicle { }\r
+ class Car extends Vehicle { }\r
+\r
+Resulting XML:\r
+\r
+.. code-block :: xml\r
+\r
+ <vehicle><type>car</type></vehicle>\r
+\r
+\r
+@XmlValue\r
+~~~~~~~~~\r
+This allows you to mark properties which should be set as the value of the\r
+current element. Note that this has the limitation that any additional\r
+properties of that object must have the @XmlAttribute annotation.\r
+XMlValue also has property cdata. Which has the same meaning as the one in\r
+XMLElement.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\XmlAttribute;\r
+ use JMS\Serializer\Annotation\XmlValue;\r
+ use JMS\Serializer\Annotation\XmlRoot;\r
+\r
+ /** @XmlRoot("price") */\r
+ class Price\r
+ {\r
+ /** @XmlAttribute */\r
+ private $currency = 'EUR';\r
+\r
+ /** @XmlValue */\r
+ private $amount = 1.23;\r
+ }\r
+\r
+Resulting XML:\r
+\r
+.. code-block :: xml\r
+\r
+ <price currency="EUR">1.23</price>\r
+\r
+@XmlList\r
+~~~~~~~~\r
+This allows you to define several properties of how arrays should be\r
+serialized. This is very similar to @XmlMap, and should be used if the\r
+keys of the array are not important.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\XmlList;\r
+ use JMS\Serializer\Annotation\XmlRoot;\r
+\r
+ /** @XmlRoot("post") */\r
+ class Post\r
+ {\r
+ /**\r
+ * @XmlList(inline = true, entry = "comment")\r
+ */\r
+ private $comments = array(\r
+ new Comment('Foo'),\r
+ new Comment('Bar'),\r
+ );\r
+ }\r
+\r
+ class Comment\r
+ {\r
+ private $text;\r
+\r
+ public function __construct($text)\r
+ {\r
+ $this->text = $text;\r
+ }\r
+ }\r
+\r
+Resulting XML:\r
+\r
+.. code-block :: xml\r
+\r
+ <post>\r
+ <comment>\r
+ <text><![CDATA[Foo]]></text>\r
+ </comment>\r
+ <comment>\r
+ <text><![CDATA[Bar]]></text>\r
+ </comment>\r
+ </post>\r
+\r
+You can also specify the entry tag namespace using the ``namespace`` attribute (``@XmlList(inline = true, entry = "comment", namespace="http://www.example.com/ns")``).\r
+\r
+@XmlMap\r
+~~~~~~~\r
+Similar to @XmlList, but the keys of the array are meaningful.\r
+\r
+@XmlKeyValuePairs\r
+~~~~~~~~~~~~~~~~~\r
+This allows you to use the keys of an array as xml tags.\r
+\r
+.. note ::\r
+\r
+ When a key is an invalid xml tag name (e.g. 1_foo) the tag name *entry* will be used instead of the key.\r
+\r
+@XmlAttributeMap\r
+~~~~~~~~~~~~~~~~\r
+\r
+This is similar to the @XmlKeyValuePairs, but instead of creating child elements, it creates attributes.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\XmlAttribute;\r
+\r
+ class Input\r
+ {\r
+ /** @XmlAttributeMap */\r
+ private $id = array(\r
+ 'name' => 'firstname',\r
+ 'value' => 'Adrien',\r
+ );\r
+ }\r
+\r
+Resulting XML:\r
+\r
+.. code-block :: xml\r
+\r
+ <result name="firstname" value="Adrien"/>\r
+\r
+@XmlElement\r
+~~~~~~~~~~~\r
+This annotation can be defined on a property to add additional xml serialization/deserialization properties.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\XmlElement;\r
+\r
+ /**\r
+ * @XmlNamespace(uri="http://www.w3.org/2005/Atom", prefix="atom")\r
+ */\r
+ class User\r
+ {\r
+ /**\r
+ * @XmlElement(cdata=false, namespace="http://www.w3.org/2005/Atom")\r
+ */\r
+ private $id = 'my_id';\r
+ }\r
+\r
+Resulting XML:\r
+\r
+.. code-block :: xml\r
+\r
+ <atom:id>my_id</atom:id>\r
+\r
+@XmlNamespace\r
+~~~~~~~~~~~~~\r
+This annotation allows you to specify Xml namespace/s and prefix used.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ use JMS\Serializer\Annotation\XmlNamespace;\r
+\r
+ /**\r
+ * @XmlNamespace(uri="http://example.com/namespace")\r
+ * @XmlNamespace(uri="http://www.w3.org/2005/Atom", prefix="atom")\r
+ */\r
+ class BlogPost\r
+ {\r
+ /**\r
+ * @Type("JMS\Serializer\Tests\Fixtures\Author")\r
+ * @Groups({"post"})\r
+ * @XmlElement(namespace="http://www.w3.org/2005/Atom")\r
+ */\r
+ private $author;\r
+ }\r
+\r
+ class Author\r
+ {\r
+ /**\r
+ * @Type("string")\r
+ * @SerializedName("full_name")\r
+ */\r
+ private $name;\r
+ }\r
+\r
+Resulting XML:\r
+\r
+.. code-block :: xml\r
+\r
+ <?xml version="1.0" encoding="UTF-8"?>\r
+ <blog-post xmlns="http://example.com/namespace" xmlns:atom="http://www.w3.org/2005/Atom">\r
+ <atom:author>\r
+ <full_name><![CDATA[Foo Bar]]></full_name>\r
+ </atom:author>\r
+ </blog>\r
--- /dev/null
+XML Reference\r
+-------------\r
+::\r
+\r
+ <!-- MyBundle\Resources\config\serializer\Fully.Qualified.ClassName.xml -->\r
+ <?xml version="1.0" encoding="UTF-8" ?>\r
+ <serializer>\r
+ <class name="Fully\Qualified\ClassName" exclusion-policy="ALL" xml-root-name="foo-bar" exclude="true"\r
+ accessor-order="custom" custom-accessor-order="propertyName1,propertyName2,...,propertyNameN"\r
+ access-type="public_method" discriminator-field-name="type" discriminator-disabled="false" read-only="false">\r
+ <xml-namespace prefix="atom" uri="http://www.w3.org/2005/Atom"/>\r
+ <xml-discriminator attribute="true" cdata="false" namespace=""/>\r
+ <discriminator-class value="some-value">ClassName</discriminator-class>\r
+ <discriminator-groups>\r
+ <group>foo</group>\r
+ </discriminator-groups>\r
+ <property name="some-property"\r
+ exclude="true"\r
+ expose="true"\r
+ exclude-if="expr"\r
+ expose-if="expr"\r
+ skip-when-empty="false"\r
+ type="string"\r
+ serialized-name="foo"\r
+ since-version="1.0"\r
+ until-version="1.1"\r
+ xml-attribute="true"\r
+ xml-value="true"\r
+ access-type="public_method"\r
+ accessor-getter="getSomeProperty"\r
+ accessor-setter="setSomeProperty"\r
+ inline="true"\r
+ read-only="true"\r
+ groups="foo,bar"\r
+ xml-key-value-pairs="true"\r
+ xml-attribute-map="true"\r
+ max-depth="2"\r
+ >\r
+ <!-- You can also specify the type as element which is necessary if\r
+ your type contains "<" or ">" characters. -->\r
+ <type><![CDATA[]]></type>\r
+ <xml-list inline="true" entry-name="foobar" namespace="http://www.w3.org/2005/Atom" skip-when-empty="true" />\r
+ <xml-map inline="true" key-attribute-name="foo" entry-name="bar" namespace="http://www.w3.org/2005/Atom" />\r
+ <xml-element cdata="false" namespace="http://www.w3.org/2005/Atom"/>\r
+ <groups>\r
+ <value>foo</value>\r
+ <value>bar</value>\r
+ </groups>\r
+ </property>\r
+ <callback-method name="foo" type="pre-serialize" />\r
+ <callback-method name="bar" type="post-serialize" />\r
+ <callback-method name="baz" type="post-deserialize" />\r
+ <callback-method name="serializeToXml" type="handler" direction="serialization" format="xml" />\r
+ <callback-method name="deserializeFromJson" type="handler" direction="deserialization" format="xml" />\r
+\r
+ <virtual-property method="public_method"\r
+ name="some-property"\r
+ exclude="true"\r
+ expose="true"\r
+ skip-when-empty="false"\r
+ type="string"\r
+ serialized-name="foo"\r
+ since-version="1.0"\r
+ until-version="1.1"\r
+ xml-attribute="true"\r
+ access-type="public_method"\r
+ accessor-getter="getSomeProperty"\r
+ accessor-setter="setSomeProperty"\r
+ inline="true"\r
+ read-only="true"\r
+ groups="foo,bar"\r
+ xml-key-value-pairs="true"\r
+ xml-attribute-map="true"\r
+ max-depth="2"\r
+ >\r
+ <virtual-property expression="object.getName()"\r
+ name="some-property"\r
+ exclude="true"\r
+ expose="true"\r
+ type="string"\r
+ serialized-name="foo"\r
+ since-version="1.0"\r
+ until-version="1.1"\r
+ xml-attribute="true"\r
+ access-type="public_method"\r
+ accessor-getter="getSomeProperty"\r
+ accessor-setter="setSomeProperty"\r
+ inline="true"\r
+ read-only="true"\r
+ groups="foo,bar"\r
+ xml-key-value-pairs="true"\r
+ xml-attribute-map="true"\r
+ max-depth="2"\r
+ >\r
+ <!-- You can also specify the type as element which is necessary if\r
+ your type contains "<" or ">" characters. -->\r
+ <type><![CDATA[]]></type>\r
+ <groups>\r
+ <value>foo</value>\r
+ <value>bar</value>\r
+ </groups>\r
+ <xml-list inline="true" entry-name="foobar" namespace="http://www.w3.org/2005/Atom" skip-when-empty="true" />\r
+ <xml-map inline="true" key-attribute-name="foo" entry-name="bar" namespace="http://www.w3.org/2005/Atom" />\r
+ </virtual-property>\r
+ \r
+ </class>\r
+ </serializer>\r
--- /dev/null
+YAML Reference
+--------------
+::
+
+ # Vendor\MyBundle\Resources\config\serializer\Model.ClassName.yml
+ Vendor\MyBundle\Model\ClassName:
+ exclusion_policy: ALL
+ xml_root_name: foobar
+ xml_root_namespace: http://your.default.namespace
+ exclude: true
+ read_only: false
+ access_type: public_method # defaults to property
+ accessor_order: custom
+ custom_accessor_order: [propertyName1, propertyName2, ..., propertyNameN]
+ discriminator:
+ field_name: type
+ disabled: false
+ map:
+ some-value: ClassName
+ groups: [foo, bar]
+ xml_attribute: true
+ xml_element:
+ cdata: false
+ namespace: http://www.w3.org/2005/Atom
+ virtual_properties:
+ getSomeProperty:
+ serialized_name: foo
+ type: integer
+ expression_prop:
+ exp: object.getName()
+ serialized_name: foo
+ type: integer
+ xml_namespaces:
+ "": http://your.default.namespace
+ atom: http://www.w3.org/2005/Atom
+ properties:
+ some-property:
+ exclude: true
+ expose: true
+ exclude_if: expr
+ expose_if: expr
+ skip_when_empty: false
+ access_type: public_method # defaults to property
+ accessor: # access_type must be set to public_method
+ getter: getSomeOtherProperty
+ setter: setSomeOtherProperty
+ type: string
+ serialized_name: foo
+ since_version: 1.0
+ until_version: 1.1
+ groups: [foo, bar]
+ xml_attribute: true
+ xml_value: true
+ inline: true
+ read_only: true
+ xml_key_value_pairs: true
+ xml_list:
+ inline: true
+ entry_name: foo
+ namespace: http://www.w3.org/2005/Atom
+ xml_map:
+ inline: true
+ key_attribute_name: foo
+ entry_name: bar
+ namespace: http://www.w3.org/2005/Atom
+ xml_attribute_map: true
+ xml_element:
+ cdata: false
+ namespace: http://www.w3.org/2005/Atom
+ max_depth: 2
+
+ handler_callbacks:
+ serialization:
+ xml: serializeToXml
+ json: serializeToJson
+ deserialization:
+ xml: deserializeFromXml
+
+ callback_methods:
+ pre_serialize: [foo, bar]
+ post_serialize: [foo, bar]
+ post_deserialize: [foo, bar]
--- /dev/null
+Usage\r
+=====\r
+\r
+Serializing Objects\r
+-------------------\r
+Most common usage is probably to serialize objects. This can be achieved\r
+very easily:\r
+\r
+.. configuration-block ::\r
+\r
+ .. code-block :: php\r
+\r
+ <?php\r
+\r
+ $serializer = JMS\Serializer\SerializerBuilder::create()->build();\r
+ $serializer->serialize($object, 'json');\r
+ $serializer->serialize($object, 'xml');\r
+ $serializer->serialize($object, 'yml');\r
+\r
+ .. code-block :: jinja\r
+\r
+ {{ object | serialize }} {# uses JSON #}\r
+ {{ object | serialize('json') }}\r
+ {{ object | serialize('xml') }}\r
+ {{ object | serialize('yml') }}\r
+\r
+Deserializing Objects\r
+---------------------\r
+You can also deserialize objects from their XML, or JSON representation. For\r
+example, when accepting data via an API.\r
+\r
+.. code-block :: php\r
+\r
+ <?php\r
+\r
+ $serializer = JMS\Serializer\SerializerBuilder::create()->build();\r
+ $object = $serializer->deserialize($jsonData, 'MyNamespace\MyObject', 'json');\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit
+ backupGlobals = "false"
+ backupStaticAttributes = "false"
+ colors = "true"
+ convertErrorsToExceptions = "true"
+ convertNoticesToExceptions = "true"
+ convertWarningsToExceptions = "true"
+ processIsolation = "false"
+ stopOnFailure = "false"
+ syntaxCheck = "false"
+ bootstrap = "tests/bootstrap.php"
+>
+ <testsuites>
+ <testsuite name="JMS Serializer Test Suite">
+ <directory>./tests</directory>
+ </testsuite>
+ </testsuites>
+
+ <groups>
+ <exclude>
+ <group>performance</group>
+ </exclude>
+ </groups>
+ <filter>
+ <whitelist>
+ <directory>src</directory>
+ </whitelist>
+ </filter>
+</phpunit>
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Accessor\AccessorStrategyInterface;
+use JMS\Serializer\Accessor\DefaultAccessorStrategy;
+
+abstract class AbstractVisitor implements VisitorInterface
+{
+ protected $namingStrategy;
+
+ /**
+ * @var AccessorStrategyInterface
+ */
+ protected $accessor;
+
+ public function __construct($namingStrategy, AccessorStrategyInterface $accessorStrategy = null)
+ {
+ $this->namingStrategy = $namingStrategy;
+ $this->accessor = $accessorStrategy ?: new DefaultAccessorStrategy();
+ }
+
+ public function getNamingStrategy()
+ {
+ return $this->namingStrategy;
+ }
+
+ public function prepare($data)
+ {
+ return $data;
+ }
+
+ /**
+ * @param array $typeArray
+ */
+ protected function getElementType($typeArray)
+ {
+ if (false === isset($typeArray['params'][0])) {
+ return null;
+ }
+
+ if (isset($typeArray['params'][1]) && is_array($typeArray['params'][1])) {
+ return $typeArray['params'][1];
+ } else {
+ return $typeArray['params'][0];
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Accessor;
+
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+interface AccessorStrategyInterface
+{
+ /**
+ * @param object $object
+ * @param PropertyMetadata $metadata
+ * @return mixed
+ */
+ public function getValue($object, PropertyMetadata $metadata);
+
+ /**
+ * @param object $object
+ * @param mixed $value
+ * @param PropertyMetadata $metadata
+ * @return void
+ */
+ public function setValue($object, $value, PropertyMetadata $metadata);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Accessor;
+
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+class DefaultAccessorStrategy implements AccessorStrategyInterface
+{
+
+ public function getValue($object, PropertyMetadata $metadata)
+ {
+ return $metadata->getValue($object);
+ }
+
+ public function setValue($object, $value, PropertyMetadata $metadata)
+ {
+ $metadata->setValue($object, $value);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Accessor;
+
+use JMS\Serializer\Expression\ExpressionEvaluatorInterface;
+use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+class ExpressionAccessorStrategy implements AccessorStrategyInterface
+{
+ /**
+ * @var AccessorStrategyInterface
+ */
+ private $fallback;
+ /**
+ * @var ExpressionEvaluatorInterface
+ */
+ private $evaluator;
+
+ public function __construct(ExpressionEvaluatorInterface $evaluator, AccessorStrategyInterface $fallback)
+ {
+ $this->fallback = $fallback;
+ $this->evaluator = $evaluator;
+ }
+
+ public function getValue($object, PropertyMetadata $metadata)
+ {
+ if ($metadata instanceof ExpressionPropertyMetadata) {
+ return $this->evaluator->evaluate($metadata->expression, array('object' => $object));
+ }
+ return $this->fallback->getValue($object, $metadata);
+ }
+
+ public function setValue($object, $value, PropertyMetadata $metadata)
+ {
+ $this->fallback->setValue($object, $value, $metadata);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"CLASS", "PROPERTY"})
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class AccessType
+{
+ /**
+ * @Required
+ * @var string
+ */
+ public $type;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target("PROPERTY")
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class Accessor
+{
+ /**
+ * @var string
+ */
+ public $getter;
+
+ /**
+ * @var string
+ */
+ public $setter;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * Controls the order of properties in a class.
+ *
+ * @Annotation
+ * @Target("CLASS")
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class AccessorOrder
+{
+ /**
+ * @Required
+ * @var string
+ */
+ public $order;
+
+ /**
+ * @var array<string>
+ */
+ public $custom = array();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target("CLASS")
+ */
+class Discriminator
+{
+ /** @var array<string> */
+ public $map;
+
+ /** @var string */
+ public $field = 'type';
+
+ /** @var boolean */
+ public $disabled = false;
+
+ /** @var string[] */
+ public $groups = array();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY", "CLASS", "METHOD", "ANNOTATION"})
+ */
+final class Exclude
+{
+ public $if;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+use JMS\Serializer\Exception\RuntimeException;
+
+/**
+ * @Annotation
+ * @Target("CLASS")
+ */
+final class ExclusionPolicy
+{
+ const NONE = 'NONE';
+ const ALL = 'ALL';
+
+ public $policy;
+
+ public function __construct(array $values)
+ {
+ if (!is_string($values['value'])) {
+ throw new RuntimeException('"value" must be a string.');
+ }
+
+ $this->policy = strtoupper($values['value']);
+
+ if (self::NONE !== $this->policy && self::ALL !== $this->policy) {
+ throw new RuntimeException('Exclusion policy must either be "ALL", or "NONE".');
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY", "METHOD","ANNOTATION"})
+ */
+final class Expose
+{
+ public $if;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY","METHOD","ANNOTATION"})
+ */
+final class Groups
+{
+ /** @var array<string> @Required */
+ public $groups;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target("METHOD")
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class HandlerCallback
+{
+ /**
+ * @Required
+ * @var string
+ */
+ public $format;
+
+ /**
+ * @Required
+ * @var string
+ */
+ public $direction;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY","METHOD","ANNOTATION"})
+ */
+final class Inline
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY","METHOD","ANNOTATION"})
+ */
+final class MaxDepth
+{
+ /**
+ * @Required
+ * @var integer
+ */
+ public $depth;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * This annotation can be defined on methods which are called after the
+ * deserialization of the object is complete.
+ *
+ * These methods do not necessarily have to be public.
+ *
+ * @Annotation
+ * @Target("METHOD")
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class PostDeserialize
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target("METHOD")
+ */
+final class PostSerialize
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * This annotation can be declared on methods which should be called
+ * before the Serialization process.
+ *
+ * These methods do not need to be public, and should do any clean-up, or
+ * preparation of the object that is necessary.
+ *
+ * @Annotation
+ * @Target("METHOD")
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class PreSerialize
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"CLASS","PROPERTY"})
+ */
+final class ReadOnly
+{
+ /**
+ * @var boolean
+ */
+ public $readOnly = true;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+use JMS\Serializer\Exception\RuntimeException;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY","METHOD", "ANNOTATION"})
+ */
+final class SerializedName
+{
+ public $name;
+
+ public function __construct(array $values)
+ {
+ if (!isset($values['value']) || !is_string($values['value'])) {
+ throw new RuntimeException(sprintf('"value" must be a string.'));
+ }
+
+ $this->name = $values['value'];
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY", "METHOD"})
+ */
+final class Since extends Version
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY","METHOD","ANNOTATION"})
+ */
+final class SkipWhenEmpty
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY", "METHOD","ANNOTATION"})
+ */
+final class Type
+{
+ /**
+ * @Required
+ * @var string
+ */
+ public $name;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY", "METHOD"})
+ */
+final class Until extends Version
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+abstract class Version
+{
+ /**
+ * @Required
+ * @var string
+ */
+ public $version;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"METHOD", "CLASS"})
+ *
+ * @author Alexander Klimenkov <alx.devel@gmail.com>
+ */
+final class VirtualProperty
+{
+ public $exp;
+ public $name;
+ public $options = array();
+
+ public function __construct(array $data)
+ {
+ if (isset($data['value'])) {
+ $data['name'] = $data['value'];
+ unset($data['value']);
+ }
+
+ foreach ($data as $key => $value) {
+ if (!property_exists(__CLASS__, $key)) {
+ throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, __CLASS__));
+ }
+ $this->{$key} = $value;
+ }
+ }
+}
+
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY", "METHOD","ANNOTATION"})
+ */
+final class XmlAttribute
+{
+ /**
+ * @var string
+ */
+ public $namespace;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY", "METHOD"})
+ */
+final class XmlAttributeMap
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+abstract class XmlCollection
+{
+ /**
+ * @var string
+ */
+ public $entry = 'entry';
+
+ /**
+ * @var boolean
+ */
+ public $inline = false;
+
+ /**
+ * @var string
+ */
+ public $namespace;
+
+ /**
+ * @var boolean
+ */
+ public $skipWhenEmpty = true;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Björn Bösel <bjoern.boesel@twt.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+
+/**
+ * @Annotation
+ * @Target("CLASS")
+ */
+class XmlDiscriminator
+{
+ /**
+ * @var boolean
+ */
+ public $attribute = false;
+
+ /**
+ * @var boolean
+ */
+ public $cdata = true;
+
+ /**
+ * @var string
+ */
+ public $namespace;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY", "METHOD","ANNOTATION"})
+ */
+final class XmlElement
+{
+ /**
+ * @var boolean
+ */
+ public $cdata = true;
+
+ /**
+ * @var string
+ */
+ public $namespace;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY","METHOD","ANNOTATION"})
+ */
+final class XmlKeyValuePairs
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY","METHOD","ANNOTATION"})
+ */
+final class XmlList extends XmlCollection
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY","METHOD","ANNOTATION"})
+ */
+final class XmlMap extends XmlCollection
+{
+ /**
+ * @var string
+ */
+ public $keyAttribute = '_key';
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target("CLASS")
+ */
+final class XmlNamespace
+{
+ /**
+ * @Required
+ * @var string
+ */
+ public $uri;
+
+ /**
+ * @var string
+ */
+ public $prefix = '';
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target("CLASS")
+ */
+final class XmlRoot
+{
+ /**
+ * @Required
+ * @var string
+ */
+ public $name;
+
+ /**
+ * @var string
+ */
+ public $namespace;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Annotation;
+
+/**
+ * @Annotation
+ * @Target({"PROPERTY","METHOD","ANNOTATION"})
+ */
+final class XmlValue
+{
+ /**
+ * @var boolean
+ */
+ public $cdata = true;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+/**
+ * Interface for array transformation.
+ *
+ * @author Daniel Bojdo <daniel@bojdo.eu>
+ */
+interface ArrayTransformerInterface
+{
+ /**
+ * Converts objects to an array structure.
+ *
+ * This is useful when the data needs to be passed on to other methods which expect array data.
+ *
+ * @param mixed $data anything that converts to an array, typically an object or an array of objects
+ * @param SerializationContext|null $context
+ *
+ * @return array
+ */
+ public function toArray($data, SerializationContext $context = null);
+
+ /**
+ * Restores objects from an array structure.
+ *
+ * @param array $data
+ * @param string $type
+ * @param DeserializationContext|null $context
+ *
+ * @return mixed this returns whatever the passed type is, typically an object or an array of objects
+ */
+ public function fromArray(array $data, $type, DeserializationContext $context = null);
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Builder;
+
+use Doctrine\Common\Annotations\Reader;
+use Metadata\Driver\DriverInterface;
+
+class CallbackDriverFactory implements DriverFactoryInterface
+{
+ private $callback;
+
+ /**
+ * @param callable $callable
+ */
+ public function __construct($callable)
+ {
+ $this->callback = $callable;
+ }
+
+ public function createDriver(array $metadataDirs, Reader $reader)
+ {
+ $driver = call_user_func($this->callback, $metadataDirs, $reader);
+ if (!$driver instanceof DriverInterface) {
+ throw new \LogicException('The callback must return an instance of DriverInterface.');
+ }
+
+ return $driver;
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Builder;
+
+use Doctrine\Common\Annotations\Reader;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+use JMS\Serializer\Metadata\Driver\XmlDriver;
+use JMS\Serializer\Metadata\Driver\YamlDriver;
+use Metadata\Driver\DriverChain;
+use Metadata\Driver\FileLocator;
+
+class DefaultDriverFactory implements DriverFactoryInterface
+{
+ public function createDriver(array $metadataDirs, Reader $annotationReader)
+ {
+ if (!empty($metadataDirs)) {
+ $fileLocator = new FileLocator($metadataDirs);
+
+ return new DriverChain(array(
+ new YamlDriver($fileLocator),
+ new XmlDriver($fileLocator),
+ new AnnotationDriver($annotationReader),
+ ));
+ }
+
+ return new AnnotationDriver($annotationReader);
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Builder;
+
+use Doctrine\Common\Annotations\Reader;
+use Metadata\Driver\DriverInterface;
+
+interface DriverFactoryInterface
+{
+ /**
+ * @param array $metadataDirs
+ * @param Reader $annotationReader
+ *
+ * @return DriverInterface
+ */
+ public function createDriver(array $metadataDirs, Reader $annotationReader);
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Construction;
+
+use Doctrine\Common\Persistence\ManagerRegistry;
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\Exception\InvalidArgumentException;
+use JMS\Serializer\Exception\ObjectConstructionException;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\VisitorInterface;
+
+/**
+ * Doctrine object constructor for new (or existing) objects during deserialization.
+ */
+class DoctrineObjectConstructor implements ObjectConstructorInterface
+{
+ const ON_MISSING_NULL = 'null';
+ const ON_MISSING_EXCEPTION = 'exception';
+ const ON_MISSING_FALLBACK = 'fallback';
+ /**
+ * @var string
+ */
+ private $fallbackStrategy;
+
+ private $managerRegistry;
+ private $fallbackConstructor;
+
+ /**
+ * Constructor.
+ *
+ * @param ManagerRegistry $managerRegistry Manager registry
+ * @param ObjectConstructorInterface $fallbackConstructor Fallback object constructor
+ * @param string $fallbackStrategy
+ */
+ public function __construct(ManagerRegistry $managerRegistry, ObjectConstructorInterface $fallbackConstructor, $fallbackStrategy = self::ON_MISSING_NULL)
+ {
+ $this->managerRegistry = $managerRegistry;
+ $this->fallbackConstructor = $fallbackConstructor;
+ $this->fallbackStrategy = $fallbackStrategy;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function construct(VisitorInterface $visitor, ClassMetadata $metadata, $data, array $type, DeserializationContext $context)
+ {
+ // Locate possible ObjectManager
+ $objectManager = $this->managerRegistry->getManagerForClass($metadata->name);
+
+ if (!$objectManager) {
+ // No ObjectManager found, proceed with normal deserialization
+ return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
+ }
+
+ // Locate possible ClassMetadata
+ $classMetadataFactory = $objectManager->getMetadataFactory();
+
+ if ($classMetadataFactory->isTransient($metadata->name)) {
+ // No ClassMetadata found, proceed with normal deserialization
+ return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
+ }
+
+ // Managed entity, check for proxy load
+ if (!is_array($data)) {
+ // Single identifier, load proxy
+ return $objectManager->getReference($metadata->name, $data);
+ }
+
+ // Fallback to default constructor if missing identifier(s)
+ $classMetadata = $objectManager->getClassMetadata($metadata->name);
+ $identifierList = array();
+
+ foreach ($classMetadata->getIdentifierFieldNames() as $name) {
+ if (!array_key_exists($name, $data)) {
+ return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
+ }
+
+ $identifierList[$name] = $data[$name];
+ }
+
+ // Entity update, load it from database
+ $object = $objectManager->find($metadata->name, $identifierList);
+
+ if (null === $object) {
+ switch ($this->fallbackStrategy) {
+ case self::ON_MISSING_NULL:
+ return null;
+ case self::ON_MISSING_EXCEPTION:
+ throw new ObjectConstructionException(sprintf("Entity %s can not be found", $metadata->name));
+ case self::ON_MISSING_FALLBACK:
+ return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
+ default:
+ throw new InvalidArgumentException("The provided fallback strategy for the object constructor is not valid");
+ }
+ }
+
+ $objectManager->initializeObject($object);
+
+ return $object;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Construction;
+
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\VisitorInterface;
+
+/**
+ * Implementations of this interface construct new objects during deserialization.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface ObjectConstructorInterface
+{
+ /**
+ * Constructs a new object.
+ *
+ * Implementations could for example create a new object calling "new", use
+ * "unserialize" techniques, reflection, or other means.
+ *
+ * @param VisitorInterface $visitor
+ * @param ClassMetadata $metadata
+ * @param mixed $data
+ * @param array $type ["name" => string, "params" => array]
+ * @param DeserializationContext $context
+ *
+ * @return object
+ */
+ public function construct(VisitorInterface $visitor, ClassMetadata $metadata, $data, array $type, DeserializationContext $context);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Construction;
+
+use Doctrine\Instantiator\Instantiator;
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\VisitorInterface;
+
+class UnserializeObjectConstructor implements ObjectConstructorInterface
+{
+ /** @var Instantiator */
+ private $instantiator;
+
+ public function construct(VisitorInterface $visitor, ClassMetadata $metadata, $data, array $type, DeserializationContext $context)
+ {
+ return $this->getInstantiator()->instantiate($metadata->name);
+ }
+
+ /**
+ * @return Instantiator
+ */
+ private function getInstantiator()
+ {
+ if (null == $this->instantiator) {
+ $this->instantiator = new Instantiator();
+ }
+
+ return $this->instantiator;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\Exclusion\DepthExclusionStrategy;
+use JMS\Serializer\Exclusion\DisjunctExclusionStrategy;
+use JMS\Serializer\Exclusion\ExclusionStrategyInterface;
+use JMS\Serializer\Exclusion\GroupsExclusionStrategy;
+use JMS\Serializer\Exclusion\VersionExclusionStrategy;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use Metadata\MetadataFactory;
+use Metadata\MetadataFactoryInterface;
+use PhpCollection\Map;
+
+abstract class Context
+{
+ /**
+ * @var \PhpCollection\Map
+ */
+ public $attributes;
+
+ private $format;
+
+ /** @var VisitorInterface */
+ private $visitor;
+
+ /** @var GraphNavigator */
+ private $navigator;
+
+ /** @var MetadataFactory */
+ private $metadataFactory;
+
+ /** @var ExclusionStrategyInterface */
+ private $exclusionStrategy;
+
+ /** @var boolean|null */
+ private $serializeNull;
+
+ private $initialized = false;
+
+ /** @var \SplStack */
+ private $metadataStack;
+
+ public function __construct()
+ {
+ $this->attributes = new Map();
+ }
+
+ /**
+ * @param string $format
+ */
+ public function initialize($format, VisitorInterface $visitor, GraphNavigator $navigator, MetadataFactoryInterface $factory)
+ {
+ if ($this->initialized) {
+ throw new \LogicException('This context was already initialized, and cannot be re-used.');
+ }
+
+ $this->initialized = true;
+ $this->format = $format;
+ $this->visitor = $visitor;
+ $this->navigator = $navigator;
+ $this->metadataFactory = $factory;
+ $this->metadataStack = new \SplStack();
+ }
+
+ public function accept($data, array $type = null)
+ {
+ return $this->navigator->accept($data, $type, $this);
+ }
+
+ public function getMetadataFactory()
+ {
+ return $this->metadataFactory;
+ }
+
+ public function getVisitor()
+ {
+ return $this->visitor;
+ }
+
+ public function getNavigator()
+ {
+ return $this->navigator;
+ }
+
+ public function getExclusionStrategy()
+ {
+ return $this->exclusionStrategy;
+ }
+
+ public function setAttribute($key, $value)
+ {
+ $this->assertMutable();
+ $this->attributes->set($key, $value);
+
+ return $this;
+ }
+
+ private function assertMutable()
+ {
+ if (!$this->initialized) {
+ return;
+ }
+
+ throw new \LogicException('This context was already initialized and is immutable; you cannot modify it anymore.');
+ }
+
+ public function addExclusionStrategy(ExclusionStrategyInterface $strategy)
+ {
+ $this->assertMutable();
+
+ if (null === $this->exclusionStrategy) {
+ $this->exclusionStrategy = $strategy;
+
+ return $this;
+ }
+
+ if ($this->exclusionStrategy instanceof DisjunctExclusionStrategy) {
+ $this->exclusionStrategy->addStrategy($strategy);
+
+ return $this;
+ }
+
+ $this->exclusionStrategy = new DisjunctExclusionStrategy(array(
+ $this->exclusionStrategy,
+ $strategy,
+ ));
+
+ return $this;
+ }
+
+ /**
+ * @param integer $version
+ */
+ public function setVersion($version)
+ {
+ if (null === $version) {
+ throw new \LogicException('The version must not be null.');
+ }
+
+ $this->attributes->set('version', $version);
+ $this->addExclusionStrategy(new VersionExclusionStrategy($version));
+
+ return $this;
+ }
+
+ /**
+ * @param array|string $groups
+ */
+ public function setGroups($groups)
+ {
+ if (empty($groups)) {
+ throw new \LogicException('The groups must not be empty.');
+ }
+
+ $this->attributes->set('groups', (array)$groups);
+ $this->addExclusionStrategy(new GroupsExclusionStrategy((array)$groups));
+
+ return $this;
+ }
+
+ public function enableMaxDepthChecks()
+ {
+ $this->addExclusionStrategy(new DepthExclusionStrategy());
+
+ return $this;
+ }
+
+ /**
+ * Set if NULLs should be serialized (TRUE) ot not (FALSE)
+ *
+ * @param bool $bool
+ * @return $this
+ */
+ public function setSerializeNull($bool)
+ {
+ $this->serializeNull = (boolean)$bool;
+
+ return $this;
+ }
+
+ /**
+ * Returns TRUE when NULLs should be serialized
+ * Returns FALSE when NULLs should not be serialized
+ * Returns NULL when NULLs should not be serialized,
+ * but the user has not explicitly decided to use this policy
+ *
+ * @return bool|null
+ */
+ public function shouldSerializeNull()
+ {
+ return $this->serializeNull;
+ }
+
+ /**
+ * @return string
+ */
+ public function getFormat()
+ {
+ return $this->format;
+ }
+
+ public function pushClassMetadata(ClassMetadata $metadata)
+ {
+ $this->metadataStack->push($metadata);
+ }
+
+ public function pushPropertyMetadata(PropertyMetadata $metadata)
+ {
+ $this->metadataStack->push($metadata);
+ }
+
+ public function popPropertyMetadata()
+ {
+ $metadata = $this->metadataStack->pop();
+
+ if (!$metadata instanceof PropertyMetadata) {
+ throw new RuntimeException('Context metadataStack not working well');
+ }
+ }
+
+ public function popClassMetadata()
+ {
+ $metadata = $this->metadataStack->pop();
+
+ if (!$metadata instanceof ClassMetadata) {
+ throw new RuntimeException('Context metadataStack not working well');
+ }
+ }
+
+ public function getMetadataStack()
+ {
+ return $this->metadataStack;
+ }
+
+ /**
+ * @return array
+ */
+ public function getCurrentPath()
+ {
+ if (!$this->metadataStack) {
+ return array();
+ }
+
+ $paths = array();
+ foreach ($this->metadataStack as $metadata) {
+ if ($metadata instanceof PropertyMetadata) {
+ array_unshift($paths, $metadata->name);
+ }
+ }
+
+ return $paths;
+ }
+
+
+ abstract public function getDepth();
+
+ /**
+ * @return integer
+ */
+ abstract public function getDirection();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\ContextFactory;
+
+/**
+ * Context Factory using a callable.
+ */
+abstract class CallableContextFactory
+{
+ /**
+ * @var callable
+ */
+ private $callable;
+
+ /**
+ * @param callable $callable
+ */
+ public function __construct(callable $callable)
+ {
+ $this->callable = $callable;
+ }
+
+ /**
+ * @return mixed
+ */
+ protected function createContext()
+ {
+ $callable = $this->callable;
+
+ return $callable();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\ContextFactory;
+
+/**
+ * Deserialization Context Factory using a callable.
+ */
+class CallableDeserializationContextFactory extends CallableContextFactory implements
+ DeserializationContextFactoryInterface
+{
+ /**
+ * {@InheritDoc}
+ */
+ public function createDeserializationContext()
+ {
+ return $this->createContext();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\ContextFactory;
+
+/**
+ * Serialization Context Factory using a callable.
+ */
+class CallableSerializationContextFactory extends CallableContextFactory implements
+ SerializationContextFactoryInterface
+{
+ /**
+ * {@InheritDoc}
+ */
+ public function createSerializationContext()
+ {
+ return $this->createContext();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\ContextFactory;
+
+use JMS\Serializer\DeserializationContext;
+
+/**
+ * Default Deserialization Context Factory.
+ */
+class DefaultDeserializationContextFactory implements DeserializationContextFactoryInterface
+{
+ /**
+ * {@InheritDoc}
+ */
+ public function createDeserializationContext()
+ {
+ return new DeserializationContext();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\ContextFactory;
+
+use JMS\Serializer\SerializationContext;
+
+/**
+ * Default Serialization Context Factory.
+ */
+class DefaultSerializationContextFactory implements SerializationContextFactoryInterface
+{
+ /**
+ * {@InheritDoc}
+ */
+ public function createSerializationContext()
+ {
+ return new SerializationContext();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\ContextFactory;
+
+use JMS\Serializer\DeserializationContext;
+
+/**
+ * Deserialization Context Factory Interface.
+ */
+interface DeserializationContextFactoryInterface
+{
+ /**
+ * @return DeserializationContext
+ */
+ public function createDeserializationContext();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\ContextFactory;
+
+use JMS\Serializer\SerializationContext;
+
+/**
+ * Serialization Context Factory Interface.
+ */
+interface SerializationContextFactoryInterface
+{
+ /**
+ * @return SerializationContext
+ */
+ public function createSerializationContext();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+class DeserializationContext extends Context
+{
+ private $depth = 0;
+
+ public static function create()
+ {
+ return new self();
+ }
+
+ public function getDirection()
+ {
+ return GraphNavigator::DIRECTION_DESERIALIZATION;
+ }
+
+ public function getDepth()
+ {
+ return $this->depth;
+ }
+
+ public function increaseDepth()
+ {
+ $this->depth += 1;
+ }
+
+ public function decreaseDepth()
+ {
+ if ($this->depth <= 0) {
+ throw new \LogicException('Depth cannot be smaller than zero.');
+ }
+
+ $this->depth -= 1;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher;
+
+use JMS\Serializer\Context;
+
+class Event
+{
+ /**
+ * @var bool Whether no further event listeners should be triggered
+ */
+ private $propagationStopped = false;
+
+ protected $type;
+ private $context;
+
+ public function __construct(Context $context, array $type)
+ {
+ $this->context = $context;
+ $this->type = $type;
+ }
+
+ public function getVisitor()
+ {
+ return $this->context->getVisitor();
+ }
+
+ public function getContext()
+ {
+ return $this->context;
+ }
+
+ public function getType()
+ {
+ return $this->type;
+ }
+
+ /**
+ * Returns whether further event listeners should be triggered.
+ *
+ * @see Event::stopPropagation()
+ *
+ * @return bool Whether propagation was already stopped for this event
+ */
+ public function isPropagationStopped()
+ {
+ return $this->propagationStopped;
+ }
+
+ /**
+ * Stops the propagation of the event to further event listeners.
+ *
+ * If multiple event listeners are connected to the same event, no
+ * further event listener will be triggered once any trigger calls
+ * stopPropagation().
+ */
+ public function stopPropagation()
+ {
+ $this->propagationStopped = true;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher;
+
+use JMS\Serializer\Exception\InvalidArgumentException;
+
+/**
+ * Light-weight event dispatcher.
+ *
+ * This implementation focuses primarily on performance, and dispatching
+ * events for certain classes. It is not a general purpose event dispatcher.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class EventDispatcher implements EventDispatcherInterface
+{
+ private $listeners = array();
+ private $classListeners = array();
+
+ public static function getDefaultMethodName($eventName)
+ {
+ return 'on' . str_replace(array('_', '.'), '', $eventName);
+ }
+
+ /**
+ * Sets the listeners.
+ *
+ * @param array $listeners
+ */
+ public function setListeners(array $listeners)
+ {
+ $this->listeners = $listeners;
+ $this->classListeners = array();
+ }
+
+ public function addListener($eventName, $callable, $class = null, $format = null)
+ {
+ $this->listeners[$eventName][] = array($callable, null === $class ? null : strtolower($class), $format);
+ unset($this->classListeners[$eventName]);
+ }
+
+ public function addSubscriber(EventSubscriberInterface $subscriber)
+ {
+ foreach ($subscriber->getSubscribedEvents() as $eventData) {
+ if (!isset($eventData['event'])) {
+ throw new InvalidArgumentException(sprintf('Each event must have a "event" key.'));
+ }
+
+ $method = isset($eventData['method']) ? $eventData['method'] : self::getDefaultMethodName($eventData['event']);
+ $class = isset($eventData['class']) ? strtolower($eventData['class']) : null;
+ $format = isset($eventData['format']) ? $eventData['format'] : null;
+ $this->listeners[$eventData['event']][] = array(array($subscriber, $method), $class, $format);
+ unset($this->classListeners[$eventData['event']]);
+ }
+ }
+
+ public function hasListeners($eventName, $class, $format)
+ {
+ if (!isset($this->listeners[$eventName])) {
+ return false;
+ }
+
+ $loweredClass = strtolower($class);
+ if (!isset($this->classListeners[$eventName][$loweredClass][$format])) {
+ $this->classListeners[$eventName][$loweredClass][$format] = $this->initializeListeners($eventName, $loweredClass, $format);
+ }
+
+ return !!$this->classListeners[$eventName][$loweredClass][$format];
+ }
+
+ public function dispatch($eventName, $class, $format, Event $event)
+ {
+ if (!isset($this->listeners[$eventName])) {
+ return;
+ }
+
+ $loweredClass = strtolower($class);
+ if (!isset($this->classListeners[$eventName][$loweredClass][$format])) {
+ $this->classListeners[$eventName][$loweredClass][$format] = $this->initializeListeners($eventName, $loweredClass, $format);
+ }
+
+ foreach ($this->classListeners[$eventName][$loweredClass][$format] as $listener) {
+
+ if ($event->isPropagationStopped()) {
+ break;
+ }
+
+ call_user_func($listener, $event, $eventName, $loweredClass, $format, $this);
+ }
+ }
+
+ /**
+ * @param string $eventName
+ * @param string $loweredClass
+ * @param string $format
+ *
+ * @return array An array of listeners
+ */
+ protected function initializeListeners($eventName, $loweredClass, $format)
+ {
+ $listeners = array();
+ foreach ($this->listeners[$eventName] as $listener) {
+ if (null !== $listener[1] && $loweredClass !== $listener[1]) {
+ continue;
+ }
+ if (null !== $listener[2] && $format !== $listener[2]) {
+ continue;
+ }
+
+ $listeners[] = $listener[0];
+ }
+
+ return $listeners;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher;
+
+interface EventDispatcherInterface
+{
+ /**
+ * Returns whether there are listeners.
+ *
+ * @param string $eventName
+ * @param string $class
+ * @param string $format
+ *
+ * @return boolean
+ */
+ public function hasListeners($eventName, $class, $format);
+
+ /**
+ * Dispatches an event.
+ *
+ * The listeners/subscribers are called in the same order in which they
+ * were added to the dispatcher.
+ *
+ * @param string $eventName
+ * @param string $class
+ * @param string $format
+ * @param Event $event
+ * @return void
+ */
+ public function dispatch($eventName, $class, $format, Event $event);
+
+ /**
+ * Adds a listener.
+ *
+ * @param string $eventName
+ * @param callable $callable
+ * @param string|null $class
+ * @param string|null $format
+ * @return void
+ */
+ public function addListener($eventName, $callable, $class = null, $format = null);
+
+ /**
+ * Adds a subscribers.
+ *
+ * @param EventSubscriberInterface $subscriber
+ * @return void
+ */
+ public function addSubscriber(EventSubscriberInterface $subscriber);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher;
+
+interface EventSubscriberInterface
+{
+ /**
+ * Returns the events to which this class has subscribed.
+ *
+ * Return format:
+ * array(
+ * array('event' => 'the-event-name', 'method' => 'onEventName', 'class' => 'some-class', 'format' => 'json'),
+ * array(...),
+ * )
+ *
+ * The class may be omitted if the class wants to subscribe to events of all classes.
+ * Same goes for the format key.
+ *
+ * @return array
+ */
+ public static function getSubscribedEvents();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher;
+
+abstract class Events
+{
+ const PRE_SERIALIZE = 'serializer.pre_serialize';
+ const POST_SERIALIZE = 'serializer.post_serialize';
+ const PRE_DESERIALIZE = 'serializer.pre_deserialize';
+ const POST_DESERIALIZE = 'serializer.post_deserialize';
+
+ final private function __construct()
+ {
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher;
+
+use Psr\Container\ContainerInterface as PsrContainerInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+class LazyEventDispatcher extends EventDispatcher
+{
+ private $container;
+
+ public function __construct($container)
+ {
+ if (!$container instanceof PsrContainerInterface && !$container instanceof ContainerInterface) {
+ throw new \InvalidArgumentException(sprintf('The container must be an instance of %s or %s (%s given).', PsrContainerInterface::class, ContainerInterface::class, is_object($container) ? get_class($container) : gettype($container)));
+ }
+
+ $this->container = $container;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function initializeListeners($eventName, $loweredClass, $format)
+ {
+ $listeners = parent::initializeListeners($eventName, $loweredClass, $format);
+
+ foreach ($listeners as &$listener) {
+ if (!is_array($listener) || !is_string($listener[0])) {
+ continue;
+ }
+
+ if (!$this->container->has($listener[0])) {
+ continue;
+ }
+
+ $listener[0] = $this->container->get($listener[0]);
+ }
+
+ return $listeners;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher;
+
+use JMS\Serializer\Context;
+
+class ObjectEvent extends Event
+{
+ private $object;
+
+ public function __construct(Context $context, $object, array $type)
+ {
+ parent::__construct($context, $type);
+
+ $this->object = $object;
+ }
+
+ public function getObject()
+ {
+ return $this->object;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher;
+
+use JMS\Serializer\DeserializationContext;
+
+class PreDeserializeEvent extends Event
+{
+ private $data;
+
+ public function __construct(DeserializationContext $context, $data, array $type)
+ {
+ parent::__construct($context, $type);
+
+ $this->data = $data;
+ }
+
+ public function setType($name, array $params = array())
+ {
+ $this->type = array('name' => $name, 'params' => $params);
+ }
+
+ public function getData()
+ {
+ return $this->data;
+ }
+
+ public function setData($data)
+ {
+ $this->data = $data;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher;
+
+class PreSerializeEvent extends ObjectEvent
+{
+ /**
+ * @param string $typeName
+ * @param array $params
+ */
+ public function setType($typeName, array $params = array())
+ {
+ $this->type = array('name' => $typeName, 'params' => $params);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher\Subscriber;
+
+use Doctrine\Common\Persistence\Proxy;
+use Doctrine\ODM\MongoDB\PersistentCollection as MongoDBPersistentCollection;
+use Doctrine\ODM\PHPCR\PersistentCollection as PHPCRPersistentCollection;
+use Doctrine\ORM\PersistentCollection;
+use Doctrine\ORM\Proxy\Proxy as ORMProxy;
+use JMS\Serializer\EventDispatcher\EventDispatcherInterface;
+use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
+use JMS\Serializer\EventDispatcher\PreSerializeEvent;
+
+class DoctrineProxySubscriber implements EventSubscriberInterface
+{
+ /**
+ * @var bool
+ */
+ private $skipVirtualTypeInit = false;
+
+ /**
+ * @var bool
+ */
+ private $initializeExcluded = true;
+
+ public function __construct($skipVirtualTypeInit = false, $initializeExcluded = true)
+ {
+ $this->skipVirtualTypeInit = (bool)$skipVirtualTypeInit;
+ $this->initializeExcluded = (bool)$initializeExcluded;
+ }
+
+ public function onPreSerialize(PreSerializeEvent $event)
+ {
+ $object = $event->getObject();
+ $type = $event->getType();
+
+ // If the set type name is not an actual class, but a faked type for which a custom handler exists, we do not
+ // modify it with this subscriber. Also, we forgo autoloading here as an instance of this type is already created,
+ // so it must be loaded if its a real class.
+ $virtualType = !class_exists($type['name'], false);
+
+ if ($object instanceof PersistentCollection
+ || $object instanceof MongoDBPersistentCollection
+ || $object instanceof PHPCRPersistentCollection
+ ) {
+ if (!$virtualType) {
+ $event->setType('ArrayCollection');
+ }
+
+ return;
+ }
+
+ if (($this->skipVirtualTypeInit && $virtualType) ||
+ (!$object instanceof Proxy && !$object instanceof ORMProxy)
+ ) {
+ return;
+ }
+
+ // do not initialize the proxy if is going to be excluded by-class by some exclusion strategy
+ if ($this->initializeExcluded === false && !$virtualType) {
+ $context = $event->getContext();
+ $exclusionStrategy = $context->getExclusionStrategy();
+ if ($exclusionStrategy !== null && $exclusionStrategy->shouldSkipClass($context->getMetadataFactory()->getMetadataForClass(get_parent_class($object)), $context)) {
+ return;
+ }
+ }
+
+ $object->__load();
+
+ if (!$virtualType) {
+ $event->setType(get_parent_class($object), $type['params']);
+ }
+ }
+
+ public function onPreSerializeTypedProxy(PreSerializeEvent $event, $eventName, $class, $format, EventDispatcherInterface $dispatcher)
+ {
+ $type = $event->getType();
+ // is a virtual type? then there is no need to change the event name
+ if (!class_exists($type['name'], false)) {
+ return;
+ }
+
+ $object = $event->getObject();
+ if ($object instanceof Proxy) {
+ $parentClassName = get_parent_class($object);
+
+ // check if this is already a re-dispatch
+ if (strtolower($class) !== strtolower($parentClassName)) {
+ $event->stopPropagation();
+ $newEvent = new PreSerializeEvent($event->getContext(), $object, array('name' => $parentClassName, 'params' => $type['params']));
+ $dispatcher->dispatch($eventName, $parentClassName, $format, $newEvent);
+
+ // update the type in case some listener changed it
+ $newType = $newEvent->getType();
+ $event->setType($newType['name'], $newType['params']);
+ }
+ }
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return array(
+ array('event' => 'serializer.pre_serialize', 'method' => 'onPreSerializeTypedProxy'),
+ array('event' => 'serializer.pre_serialize', 'method' => 'onPreSerialize'),
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher\Subscriber;
+
+use JMS\Serializer\EventDispatcher\Event;
+use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
+use JMS\Serializer\Exception\ValidationFailedException;
+use Symfony\Component\Validator\ValidatorInterface;
+
+class SymfonyValidatorSubscriber implements EventSubscriberInterface
+{
+ private $validator;
+
+ public function __construct(ValidatorInterface $validator)
+ {
+ $this->validator = $validator;
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return array(
+ array('event' => 'serializer.post_deserialize', 'method' => 'onPostDeserialize'),
+ );
+ }
+
+ public function onPostDeserialize(Event $event)
+ {
+ $context = $event->getContext();
+
+ if ($context->getDepth() > 0) {
+ return;
+ }
+
+ $validator = $this->validator;
+ $context->attributes->get('validation_groups')->map(
+ function (array $groups) use ($event, $validator) {
+ $list = $validator->validate($event->getObject(), $groups);
+
+ if ($list->count() > 0) {
+ throw new ValidationFailedException($list);
+ }
+ }
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Asmir Mustafic <goetas@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\EventDispatcher\Subscriber;
+
+use JMS\Serializer\EventDispatcher\Event;
+use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
+use JMS\Serializer\Exception\ValidationFailedException;
+use PhpOption\None;
+use Symfony\Component\Validator\Validator\ValidatorInterface;
+
+class SymfonyValidatorValidatorSubscriber implements EventSubscriberInterface
+{
+ /**
+ * @var ValidatorInterface
+ */
+ private $validator;
+
+ public function __construct(ValidatorInterface $validator)
+ {
+ $this->validator = $validator;
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return array(
+ array('event' => 'serializer.post_deserialize', 'method' => 'onPostDeserialize'),
+ );
+ }
+
+ public function onPostDeserialize(Event $event)
+ {
+ $context = $event->getContext();
+
+ if ($context->getDepth() > 0) {
+ return;
+ }
+
+ $validator = $this->validator;
+ $groups = $context->attributes->get('validation_groups') instanceof None
+ ? null
+ : $context->attributes->get('validation_groups')->get();
+
+ if (!$groups) {
+ return;
+ }
+
+ $constraints = $context->attributes->get('validation_constraints') instanceof None
+ ? null
+ : $context->attributes->get('validation_constraints')->get();
+
+ $list = $validator->validate($event->getObject(), $constraints, $groups);
+
+ if ($list->count() > 0) {
+ throw new ValidationFailedException($list);
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exception;
+
+/**
+ * Base exception for the Serializer.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface Exception
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exception;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+class ExpressionLanguageRequiredException extends LogicException
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exception;
+
+/**
+ * InvalidArgumentException for the Serializer.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class InvalidArgumentException extends \InvalidArgumentException implements Exception
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exception;
+
+/**
+ * LogicException for the Serializer.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class LogicException extends \LogicException implements Exception
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exception;
+
+/**
+ * InvalidArgumentException for the Serializer.
+ *
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+class ObjectConstructionException extends RuntimeException implements Exception
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exception;
+
+/**
+ * RuntimeException for the Serializer.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class RuntimeException extends \RuntimeException implements Exception
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exception;
+
+class UnsupportedFormatException extends InvalidArgumentException
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exception;
+
+use Symfony\Component\Validator\ConstraintViolationListInterface;
+
+class ValidationFailedException extends RuntimeException
+{
+ /**
+ * @var ConstraintViolationListInterface
+ */
+ private $list;
+
+ public function __construct(ConstraintViolationListInterface $list)
+ {
+ parent::__construct(sprintf('Validation failed with %d error(s).', count($list)));
+
+ $this->list = $list;
+ }
+
+ /**
+ * @return ConstraintViolationListInterface
+ */
+ public function getConstraintViolationList()
+ {
+ return $this->list;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exception;
+
+class XmlErrorException extends RuntimeException
+{
+ private $xmlError;
+
+ public function __construct(\LibXMLError $error)
+ {
+ switch ($error->level) {
+ case LIBXML_ERR_WARNING:
+ $level = 'WARNING';
+ break;
+
+ case LIBXML_ERR_FATAL:
+ $level = 'FATAL';
+ break;
+
+ case LIBXML_ERR_ERROR:
+ $level = 'ERROR';
+ break;
+
+ default:
+ $level = 'UNKNOWN';
+ }
+
+ parent::__construct(sprintf('[%s] %s in %s (line: %d, column: %d)', $level, $error->message, $error->file, $error->line, $error->column));
+
+ $this->xmlError = $error;
+ }
+
+ public function getXmlError()
+ {
+ return $this->xmlError;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exclusion;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * @author Adrien Brault <adrien.brault@gmail.com>
+ */
+class DepthExclusionStrategy implements ExclusionStrategyInterface
+{
+ /**
+ * {@inheritDoc}
+ */
+ public function shouldSkipClass(ClassMetadata $metadata, Context $context)
+ {
+ return $this->isTooDeep($context);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function shouldSkipProperty(PropertyMetadata $property, Context $context)
+ {
+ return $this->isTooDeep($context);
+ }
+
+ private function isTooDeep(Context $context)
+ {
+ $depth = $context->getDepth();
+ $metadataStack = $context->getMetadataStack();
+
+ $nthProperty = 0;
+ // iterate from the first added items to the lasts
+ for ($i = $metadataStack->count() - 1; $i > 0; $i--) {
+ $metadata = $metadataStack[$i];
+ if ($metadata instanceof PropertyMetadata) {
+ $nthProperty++;
+ $relativeDepth = $depth - $nthProperty;
+
+ if (null !== $metadata->maxDepth && $relativeDepth > $metadata->maxDepth) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exclusion;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use PhpCollection\Sequence;
+use PhpCollection\SequenceInterface;
+
+/**
+ * Disjunct Exclusion Strategy.
+ *
+ * This strategy is short-circuiting and will skip a class, or property as soon as one of the delegates skips it.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class DisjunctExclusionStrategy implements ExclusionStrategyInterface
+{
+ /** @var \PhpCollection\SequenceInterface */
+ private $delegates;
+
+ /**
+ * @param ExclusionStrategyInterface[]|SequenceInterface $delegates
+ */
+ public function __construct($delegates)
+ {
+ if (!$delegates instanceof SequenceInterface) {
+ $delegates = new Sequence($delegates);
+ }
+
+ $this->delegates = $delegates;
+ }
+
+ public function addStrategy(ExclusionStrategyInterface $strategy)
+ {
+ $this->delegates->add($strategy);
+ }
+
+ /**
+ * Whether the class should be skipped.
+ *
+ * @param ClassMetadata $metadata
+ *
+ * @return boolean
+ */
+ public function shouldSkipClass(ClassMetadata $metadata, Context $context)
+ {
+ foreach ($this->delegates as $delegate) {
+ /** @var $delegate ExclusionStrategyInterface */
+ if ($delegate->shouldSkipClass($metadata, $context)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Whether the property should be skipped.
+ *
+ * @param PropertyMetadata $property
+ *
+ * @return boolean
+ */
+ public function shouldSkipProperty(PropertyMetadata $property, Context $context)
+ {
+ foreach ($this->delegates as $delegate) {
+ /** @var $delegate ExclusionStrategyInterface */
+ if ($delegate->shouldSkipProperty($property, $context)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exclusion;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * Interface for exclusion strategies.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface ExclusionStrategyInterface
+{
+ /**
+ * Whether the class should be skipped.
+ *
+ * @param ClassMetadata $metadata
+ *
+ * @return boolean
+ */
+ public function shouldSkipClass(ClassMetadata $metadata, Context $context);
+
+ /**
+ * Whether the property should be skipped.
+ *
+ * @param PropertyMetadata $property
+ *
+ * @return boolean
+ */
+ public function shouldSkipProperty(PropertyMetadata $property, Context $context);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exclusion;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\Expression\ExpressionEvaluatorInterface;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\SerializationContext;
+
+/**
+ * Exposes an exclusion strategy based on the Symfony's expression language.
+ * This is not a standard exclusion strategy and can not be used in user applications.
+ *
+ * @internal
+ *
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+class ExpressionLanguageExclusionStrategy
+{
+ /**
+ * @var ExpressionEvaluatorInterface
+ */
+ private $expressionEvaluator;
+
+ public function __construct(ExpressionEvaluatorInterface $expressionEvaluator)
+ {
+ $this->expressionEvaluator = $expressionEvaluator;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function shouldSkipProperty(PropertyMetadata $property, Context $navigatorContext)
+ {
+ if (null === $property->excludeIf) {
+ return false;
+ }
+
+ $variables = [
+ 'context' => $navigatorContext,
+ 'property_metadata' => $property,
+ ];
+ if ($navigatorContext instanceof SerializationContext) {
+ $variables['object'] = $navigatorContext->getObject();
+ } else {
+ $variables['object'] = null;
+ }
+
+ return $this->expressionEvaluator->evaluate($property->excludeIf, $variables);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exclusion;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+class GroupsExclusionStrategy implements ExclusionStrategyInterface
+{
+ const DEFAULT_GROUP = 'Default';
+
+ private $groups = array();
+
+ public function __construct(array $groups)
+ {
+ if (empty($groups)) {
+ $groups = array(self::DEFAULT_GROUP);
+ }
+
+ $this->groups = $groups;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function shouldSkipClass(ClassMetadata $metadata, Context $navigatorContext)
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function shouldSkipProperty(PropertyMetadata $property, Context $navigatorContext)
+ {
+ $groups = $this->getGroupsFor($navigatorContext);
+
+ if (!$property->groups) {
+ return !in_array(self::DEFAULT_GROUP, $groups);
+ }
+
+ return $this->shouldSkipUsingGroups($property, $groups);
+ }
+
+ private function shouldSkipUsingGroups(PropertyMetadata $property, $groups)
+ {
+ foreach ($property->groups as $group) {
+ if (in_array($group, $groups)) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private function getGroupsFor(Context $navigatorContext)
+ {
+ $paths = $navigatorContext->getCurrentPath();
+
+ $groups = $this->groups;
+ foreach ($paths as $index => $path) {
+ if (!array_key_exists($path, $groups)) {
+ if ($index > 0) {
+ $groups = array(self::DEFAULT_GROUP);
+ }
+
+ break;
+ }
+
+ $groups = $groups[$path];
+ }
+
+ return $groups;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Exclusion;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+class VersionExclusionStrategy implements ExclusionStrategyInterface
+{
+ private $version;
+
+ public function __construct($version)
+ {
+ $this->version = $version;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function shouldSkipClass(ClassMetadata $metadata, Context $navigatorContext)
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function shouldSkipProperty(PropertyMetadata $property, Context $navigatorContext)
+ {
+ if ((null !== $version = $property->sinceVersion) && version_compare($this->version, $version, '<')) {
+ return true;
+ }
+
+ if ((null !== $version = $property->untilVersion) && version_compare($this->version, $version, '>')) {
+ return true;
+ }
+
+ return false;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Expression;
+
+use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+class ExpressionEvaluator implements ExpressionEvaluatorInterface
+{
+
+ /**
+ * @var ExpressionLanguage
+ */
+ private $expressionLanguage;
+
+ /**
+ * @var array
+ */
+ private $context = array();
+
+ /**
+ * @var array
+ */
+ private $cache = array();
+
+ public function __construct(ExpressionLanguage $expressionLanguage, array $context = array(), array $cache = array())
+ {
+ $this->expressionLanguage = $expressionLanguage;
+ $this->context = $context;
+ $this->cache = $cache;
+ }
+
+ /**
+ * @param string $name
+ * @param mixed $value
+ */
+ public function setContextVariable($name, $value)
+ {
+ $this->context[$name] = $value;
+ }
+
+ /**
+ * @param string $expression
+ * @param array $data
+ * @return mixed
+ */
+ public function evaluate($expression, array $data = array())
+ {
+ if (!is_string($expression)) {
+ return $expression;
+ }
+
+ $context = $data + $this->context;
+
+ if (!array_key_exists($expression, $this->cache)) {
+ $this->cache[$expression] = $this->expressionLanguage->parse($expression, array_keys($context));
+ }
+
+ return $this->expressionLanguage->evaluate($this->cache[$expression], $context);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Expression;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+interface ExpressionEvaluatorInterface
+{
+ /**
+ * @param string $expression
+ * @param array $data
+ * @return mixed
+ */
+ public function evaluate($expression, array $data = array());
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Naming\AdvancedNamingStrategyInterface;
+use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
+
+/**
+ * Generic Deserialization Visitor.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+abstract class GenericDeserializationVisitor extends AbstractVisitor
+{
+ private $navigator;
+ private $result;
+ private $objectStack;
+ private $currentObject;
+
+ public function setNavigator(GraphNavigator $navigator)
+ {
+ $this->navigator = $navigator;
+ $this->result = null;
+ $this->objectStack = new \SplStack;
+ }
+
+ public function getNavigator()
+ {
+ return $this->navigator;
+ }
+
+ public function prepare($data)
+ {
+ return $this->decode($data);
+ }
+
+ public function visitNull($data, array $type, Context $context)
+ {
+ return null;
+ }
+
+ public function visitString($data, array $type, Context $context)
+ {
+ $data = (string)$data;
+
+ if (null === $this->result) {
+ $this->result = $data;
+ }
+
+ return $data;
+ }
+
+ public function visitBoolean($data, array $type, Context $context)
+ {
+ $data = (Boolean)$data;
+
+ if (null === $this->result) {
+ $this->result = $data;
+ }
+
+ return $data;
+ }
+
+ public function visitInteger($data, array $type, Context $context)
+ {
+ $data = (integer)$data;
+
+ if (null === $this->result) {
+ $this->result = $data;
+ }
+
+ return $data;
+ }
+
+ public function visitDouble($data, array $type, Context $context)
+ {
+ $data = (double)$data;
+
+ if (null === $this->result) {
+ $this->result = $data;
+ }
+
+ return $data;
+ }
+
+ public function visitArray($data, array $type, Context $context)
+ {
+ if (!is_array($data)) {
+ throw new RuntimeException(sprintf('Expected array, but got %s: %s', gettype($data), json_encode($data)));
+ }
+
+ // If no further parameters were given, keys/values are just passed as is.
+ if (!$type['params']) {
+ if (null === $this->result) {
+ $this->result = $data;
+ }
+
+ return $data;
+ }
+
+ switch (count($type['params'])) {
+ case 1: // Array is a list.
+ $listType = $type['params'][0];
+
+ $result = array();
+ if (null === $this->result) {
+ $this->result = &$result;
+ }
+
+ foreach ($data as $v) {
+ $result[] = $this->navigator->accept($v, $listType, $context);
+ }
+
+ return $result;
+
+ case 2: // Array is a map.
+ list($keyType, $entryType) = $type['params'];
+
+ $result = array();
+ if (null === $this->result) {
+ $this->result = &$result;
+ }
+
+ foreach ($data as $k => $v) {
+ $result[$this->navigator->accept($k, $keyType, $context)] = $this->navigator->accept($v, $entryType, $context);
+ }
+
+ return $result;
+
+ default:
+ throw new RuntimeException(sprintf('Array type cannot have more than 2 parameters, but got %s.', json_encode($type['params'])));
+ }
+ }
+
+ public function startVisitingObject(ClassMetadata $metadata, $object, array $type, Context $context)
+ {
+ $this->setCurrentObject($object);
+
+ if (null === $this->result) {
+ $this->result = $this->currentObject;
+ }
+ }
+
+ public function visitProperty(PropertyMetadata $metadata, $data, Context $context)
+ {
+ if ($this->namingStrategy instanceof AdvancedNamingStrategyInterface) {
+ $name = $this->namingStrategy->getPropertyName($metadata, $context);
+ } else {
+ $name = $this->namingStrategy->translateName($metadata);
+ }
+
+ if (null === $data) {
+ return;
+ }
+
+ if (!is_array($data)) {
+ throw new RuntimeException(sprintf('Invalid data "%s"(%s), expected "%s".', $data, $metadata->type['name'], $metadata->reflection->class));
+ }
+
+ if (!array_key_exists($name, $data)) {
+ return;
+ }
+
+ if (!$metadata->type) {
+ throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name));
+ }
+
+ $v = $data[$name] !== null ? $this->navigator->accept($data[$name], $metadata->type, $context) : null;
+
+ $this->accessor->setValue($this->currentObject, $v, $metadata);
+
+ }
+
+ public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ $obj = $this->currentObject;
+ $this->revertCurrentObject();
+
+ return $obj;
+ }
+
+ public function getResult()
+ {
+ return $this->result;
+ }
+
+ public function setCurrentObject($object)
+ {
+ $this->objectStack->push($this->currentObject);
+ $this->currentObject = $object;
+ }
+
+ public function getCurrentObject()
+ {
+ return $this->currentObject;
+ }
+
+ public function revertCurrentObject()
+ {
+ return $this->currentObject = $this->objectStack->pop();
+ }
+
+ abstract protected function decode($str);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Exception\InvalidArgumentException;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Naming\AdvancedNamingStrategyInterface;
+
+/**
+ * @deprecated
+ */
+abstract class GenericSerializationVisitor extends AbstractVisitor
+{
+ private $navigator;
+ private $root;
+ private $dataStack;
+ private $data;
+
+ public function setNavigator(GraphNavigator $navigator)
+ {
+ $this->navigator = $navigator;
+ $this->root = null;
+ $this->dataStack = new \SplStack;
+ }
+
+ /**
+ * @return GraphNavigator
+ */
+ public function getNavigator()
+ {
+ return $this->navigator;
+ }
+
+ public function visitNull($data, array $type, Context $context)
+ {
+ return null;
+ }
+
+ public function visitString($data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = $data;
+ }
+
+ return (string)$data;
+ }
+
+ public function visitBoolean($data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = $data;
+ }
+
+ return (boolean)$data;
+ }
+
+ public function visitInteger($data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = $data;
+ }
+
+ return (int)$data;
+ }
+
+ public function visitDouble($data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = $data;
+ }
+
+ return (float)$data;
+ }
+
+ /**
+ * @param array $data
+ * @param array $type
+ */
+ public function visitArray($data, array $type, Context $context)
+ {
+ $this->dataStack->push($data);
+
+ $isHash = isset($type['params'][1]);
+
+ if (null === $this->root) {
+ $this->root = $isHash ? new \ArrayObject() : array();
+ $rs = &$this->root;
+ } else {
+ $rs = $isHash ? new \ArrayObject() : array();
+ }
+
+ $isList = isset($type['params'][0]) && !isset($type['params'][1]);
+
+ foreach ($data as $k => $v) {
+ $v = $this->navigator->accept($v, $this->getElementType($type), $context);
+
+ if (null === $v && $context->shouldSerializeNull() !== true) {
+ continue;
+ }
+
+ if ($isList) {
+ $rs[] = $v;
+ } else {
+ $rs[$k] = $v;
+ }
+ }
+
+ $this->dataStack->pop();
+
+ return $rs;
+ }
+
+ public function startVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = new \stdClass;
+ }
+
+ $this->dataStack->push($this->data);
+ $this->data = array();
+ }
+
+ public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ $rs = $this->data;
+ $this->data = $this->dataStack->pop();
+
+ if ($this->root instanceof \stdClass && 0 === $this->dataStack->count()) {
+ $this->root = $rs;
+ }
+
+ return $rs;
+ }
+
+ public function visitProperty(PropertyMetadata $metadata, $data, Context $context)
+ {
+ $v = $this->accessor->getValue($data, $metadata);
+
+ $v = $this->navigator->accept($v, $metadata->type, $context);
+ if (null === $v && $context->shouldSerializeNull() !== true) {
+ return;
+ }
+
+ if ($this->namingStrategy instanceof AdvancedNamingStrategyInterface) {
+ $k = $this->namingStrategy->getPropertyName($metadata, $context);
+ } else {
+ $k = $this->namingStrategy->translateName($metadata);
+ }
+
+ if ($metadata->inline) {
+ if (is_array($v)) {
+ $this->data = array_merge($this->data, $v);
+ }
+ } else {
+ $this->data[$k] = $v;
+ }
+ }
+
+ /**
+ * Allows you to add additional data to the current object/root element.
+ * @deprecated use setData instead
+ * @param string $key
+ * @param integer|float|boolean|string|array|null $value This value must either be a regular scalar, or an array.
+ * It must not contain any objects anymore.
+ */
+ public function addData($key, $value)
+ {
+ if (isset($this->data[$key])) {
+ throw new InvalidArgumentException(sprintf('There is already data for "%s".', $key));
+ }
+
+ $this->data[$key] = $value;
+ }
+
+ /**
+ * Checks if some data key exists.
+ *
+ * @param string $key
+ * @return boolean
+ */
+ public function hasData($key)
+ {
+ return isset($this->data[$key]);
+ }
+
+ /**
+ * Allows you to replace existing data on the current object/root element.
+ *
+ * @param string $key
+ * @param integer|float|boolean|string|array|null $value This value must either be a regular scalar, or an array.
+ * It must not contain any objects anymore.
+ */
+ public function setData($key, $value)
+ {
+ $this->data[$key] = $value;
+ }
+
+ public function getRoot()
+ {
+ return $this->root;
+ }
+
+ /**
+ * @param array|\ArrayObject $data the passed data must be understood by whatever encoding function is applied later.
+ */
+ public function setRoot($data)
+ {
+ $this->root = $data;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Construction\ObjectConstructorInterface;
+use JMS\Serializer\EventDispatcher\EventDispatcherInterface;
+use JMS\Serializer\EventDispatcher\ObjectEvent;
+use JMS\Serializer\EventDispatcher\PreDeserializeEvent;
+use JMS\Serializer\EventDispatcher\PreSerializeEvent;
+use JMS\Serializer\Exception\ExpressionLanguageRequiredException;
+use JMS\Serializer\Exception\InvalidArgumentException;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\Exclusion\ExpressionLanguageExclusionStrategy;
+use JMS\Serializer\Expression\ExpressionEvaluatorInterface;
+use JMS\Serializer\Handler\HandlerRegistryInterface;
+use JMS\Serializer\Metadata\ClassMetadata;
+use Metadata\MetadataFactoryInterface;
+
+/**
+ * Handles traversal along the object graph.
+ *
+ * This class handles traversal along the graph, and calls different methods
+ * on visitors, or custom handlers to process its nodes.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class GraphNavigator
+{
+ const DIRECTION_SERIALIZATION = 1;
+ const DIRECTION_DESERIALIZATION = 2;
+
+ /**
+ * @var ExpressionLanguageExclusionStrategy
+ */
+ private $expressionExclusionStrategy;
+
+ private $dispatcher;
+ private $metadataFactory;
+ private $handlerRegistry;
+ private $objectConstructor;
+
+ /**
+ * Parses a direction string to one of the direction constants.
+ *
+ * @param string $dirStr
+ *
+ * @return integer
+ */
+ public static function parseDirection($dirStr)
+ {
+ switch (strtolower($dirStr)) {
+ case 'serialization':
+ return self::DIRECTION_SERIALIZATION;
+
+ case 'deserialization':
+ return self::DIRECTION_DESERIALIZATION;
+
+ default:
+ throw new InvalidArgumentException(sprintf('The direction "%s" does not exist.', $dirStr));
+ }
+ }
+
+ public function __construct(
+ MetadataFactoryInterface $metadataFactory,
+ HandlerRegistryInterface $handlerRegistry,
+ ObjectConstructorInterface $objectConstructor,
+ EventDispatcherInterface $dispatcher = null,
+ ExpressionEvaluatorInterface $expressionEvaluator = null
+ )
+ {
+ $this->dispatcher = $dispatcher;
+ $this->metadataFactory = $metadataFactory;
+ $this->handlerRegistry = $handlerRegistry;
+ $this->objectConstructor = $objectConstructor;
+ if ($expressionEvaluator) {
+ $this->expressionExclusionStrategy = new ExpressionLanguageExclusionStrategy($expressionEvaluator);
+ }
+ }
+
+ /**
+ * Called for each node of the graph that is being traversed.
+ *
+ * @param mixed $data the data depends on the direction, and type of visitor
+ * @param null|array $type array has the format ["name" => string, "params" => array]
+ * @param Context $context
+ * @return mixed the return value depends on the direction, and type of visitor
+ */
+ public function accept($data, array $type = null, Context $context)
+ {
+ $visitor = $context->getVisitor();
+
+ // If the type was not given, we infer the most specific type from the
+ // input data in serialization mode.
+ if (null === $type) {
+ if ($context instanceof DeserializationContext) {
+ throw new RuntimeException('The type must be given for all properties when deserializing.');
+ }
+
+ $typeName = gettype($data);
+ if ('object' === $typeName) {
+ $typeName = get_class($data);
+ }
+
+ $type = array('name' => $typeName, 'params' => array());
+ }
+ // If the data is null, we have to force the type to null regardless of the input in order to
+ // guarantee correct handling of null values, and not have any internal auto-casting behavior.
+ else if ($context instanceof SerializationContext && null === $data) {
+ $type = array('name' => 'NULL', 'params' => array());
+ }
+ // Sometimes data can convey null but is not of a null type.
+ // Visitors can have the power to add this custom null evaluation
+ if ($visitor instanceof NullAwareVisitorInterface && $visitor->isNull($data) === true) {
+ $type = array('name' => 'NULL', 'params' => array());
+ }
+
+ switch ($type['name']) {
+ case 'NULL':
+ return $visitor->visitNull($data, $type, $context);
+
+ case 'string':
+ return $visitor->visitString($data, $type, $context);
+
+ case 'int':
+ case 'integer':
+ return $visitor->visitInteger($data, $type, $context);
+
+ case 'bool':
+ case 'boolean':
+ return $visitor->visitBoolean($data, $type, $context);
+
+ case 'double':
+ case 'float':
+ return $visitor->visitDouble($data, $type, $context);
+
+ case 'array':
+ return $visitor->visitArray($data, $type, $context);
+
+ case 'resource':
+ $msg = 'Resources are not supported in serialized data.';
+ if ($context instanceof SerializationContext && null !== $path = $context->getPath()) {
+ $msg .= ' Path: ' . $path;
+ }
+
+ throw new RuntimeException($msg);
+
+ default:
+ // TODO: The rest of this method needs some refactoring.
+ if ($context instanceof SerializationContext) {
+ if (null !== $data) {
+ if ($context->isVisiting($data)) {
+ return null;
+ }
+ $context->startVisiting($data);
+ }
+
+ // If we're serializing a polymorphic type, then we'll be interested in the
+ // metadata for the actual type of the object, not the base class.
+ if (class_exists($type['name'], false) || interface_exists($type['name'], false)) {
+ if (is_subclass_of($data, $type['name'], false)) {
+ $type = array('name' => get_class($data), 'params' => array());
+ }
+ }
+ } elseif ($context instanceof DeserializationContext) {
+ $context->increaseDepth();
+ }
+
+ // Trigger pre-serialization callbacks, and listeners if they exist.
+ // Dispatch pre-serialization event before handling data to have ability change type in listener
+ if ($context instanceof SerializationContext) {
+ if (null !== $this->dispatcher && $this->dispatcher->hasListeners('serializer.pre_serialize', $type['name'], $context->getFormat())) {
+ $this->dispatcher->dispatch('serializer.pre_serialize', $type['name'], $context->getFormat(), $event = new PreSerializeEvent($context, $data, $type));
+ $type = $event->getType();
+ }
+ } elseif ($context instanceof DeserializationContext) {
+ if (null !== $this->dispatcher && $this->dispatcher->hasListeners('serializer.pre_deserialize', $type['name'], $context->getFormat())) {
+ $this->dispatcher->dispatch('serializer.pre_deserialize', $type['name'], $context->getFormat(), $event = new PreDeserializeEvent($context, $data, $type));
+ $type = $event->getType();
+ $data = $event->getData();
+ }
+ }
+
+ // First, try whether a custom handler exists for the given type. This is done
+ // before loading metadata because the type name might not be a class, but
+ // could also simply be an artifical type.
+ if (null !== $handler = $this->handlerRegistry->getHandler($context->getDirection(), $type['name'], $context->getFormat())) {
+ $rs = call_user_func($handler, $visitor, $data, $type, $context);
+ $this->leaveScope($context, $data);
+
+ return $rs;
+ }
+
+ $exclusionStrategy = $context->getExclusionStrategy();
+
+ /** @var $metadata ClassMetadata */
+ $metadata = $this->metadataFactory->getMetadataForClass($type['name']);
+
+ if ($metadata->usingExpression && !$this->expressionExclusionStrategy) {
+ throw new ExpressionLanguageRequiredException("To use conditional exclude/expose in {$metadata->name} you must configure the expression language.");
+ }
+
+ if ($context instanceof DeserializationContext && !empty($metadata->discriminatorMap) && $type['name'] === $metadata->discriminatorBaseClass) {
+ $metadata = $this->resolveMetadata($data, $metadata);
+ }
+
+ if (null !== $exclusionStrategy && $exclusionStrategy->shouldSkipClass($metadata, $context)) {
+ $this->leaveScope($context, $data);
+
+ return null;
+ }
+
+ $context->pushClassMetadata($metadata);
+
+ if ($context instanceof SerializationContext) {
+ foreach ($metadata->preSerializeMethods as $method) {
+ $method->invoke($data);
+ }
+ }
+
+ $object = $data;
+ if ($context instanceof DeserializationContext) {
+ $object = $this->objectConstructor->construct($visitor, $metadata, $data, $type, $context);
+ }
+
+ if (isset($metadata->handlerCallbacks[$context->getDirection()][$context->getFormat()])) {
+ $rs = $object->{$metadata->handlerCallbacks[$context->getDirection()][$context->getFormat()]}(
+ $visitor,
+ $context instanceof SerializationContext ? null : $data,
+ $context
+ );
+ $this->afterVisitingObject($metadata, $object, $type, $context);
+
+ return $context instanceof SerializationContext ? $rs : $object;
+ }
+
+ $visitor->startVisitingObject($metadata, $object, $type, $context);
+ foreach ($metadata->propertyMetadata as $propertyMetadata) {
+ if (null !== $exclusionStrategy && $exclusionStrategy->shouldSkipProperty($propertyMetadata, $context)) {
+ continue;
+ }
+
+ if (null !== $this->expressionExclusionStrategy && $this->expressionExclusionStrategy->shouldSkipProperty($propertyMetadata, $context)) {
+ continue;
+ }
+
+ if ($context instanceof DeserializationContext && $propertyMetadata->readOnly) {
+ continue;
+ }
+
+ $context->pushPropertyMetadata($propertyMetadata);
+ $visitor->visitProperty($propertyMetadata, $data, $context);
+ $context->popPropertyMetadata();
+ }
+
+ if ($context instanceof SerializationContext) {
+ $this->afterVisitingObject($metadata, $data, $type, $context);
+
+ return $visitor->endVisitingObject($metadata, $data, $type, $context);
+ }
+
+ $rs = $visitor->endVisitingObject($metadata, $data, $type, $context);
+ $this->afterVisitingObject($metadata, $rs, $type, $context);
+
+ return $rs;
+ }
+ }
+
+ private function resolveMetadata($data, ClassMetadata $metadata)
+ {
+ switch (true) {
+ case is_array($data) && isset($data[$metadata->discriminatorFieldName]):
+ $typeValue = (string)$data[$metadata->discriminatorFieldName];
+ break;
+
+ // Check XML attribute for discriminatorFieldName
+ case is_object($data) && $metadata->xmlDiscriminatorAttribute && isset($data[$metadata->discriminatorFieldName]):
+ $typeValue = (string)$data[$metadata->discriminatorFieldName];
+ break;
+
+ // Check XML element with namespace for discriminatorFieldName
+ case is_object($data) && !$metadata->xmlDiscriminatorAttribute && null !== $metadata->xmlDiscriminatorNamespace && isset($data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName}):
+ $typeValue = (string)$data->children($metadata->xmlDiscriminatorNamespace)->{$metadata->discriminatorFieldName};
+ break;
+
+ // Check XML element for discriminatorFieldName
+ case is_object($data) && isset($data->{$metadata->discriminatorFieldName}):
+ $typeValue = (string)$data->{$metadata->discriminatorFieldName};
+ break;
+
+ default:
+ throw new \LogicException(sprintf(
+ 'The discriminator field name "%s" for base-class "%s" was not found in input data.',
+ $metadata->discriminatorFieldName,
+ $metadata->name
+ ));
+ }
+
+ if (!isset($metadata->discriminatorMap[$typeValue])) {
+ throw new \LogicException(sprintf(
+ 'The type value "%s" does not exist in the discriminator map of class "%s". Available types: %s',
+ $typeValue,
+ $metadata->name,
+ implode(', ', array_keys($metadata->discriminatorMap))
+ ));
+ }
+
+ return $this->metadataFactory->getMetadataForClass($metadata->discriminatorMap[$typeValue]);
+ }
+
+ private function leaveScope(Context $context, $data)
+ {
+ if ($context instanceof SerializationContext) {
+ $context->stopVisiting($data);
+ } elseif ($context instanceof DeserializationContext) {
+ $context->decreaseDepth();
+ }
+ }
+
+ private function afterVisitingObject(ClassMetadata $metadata, $object, array $type, Context $context)
+ {
+ $this->leaveScope($context, $object);
+ $context->popClassMetadata();
+
+ if ($context instanceof SerializationContext) {
+ foreach ($metadata->postSerializeMethods as $method) {
+ $method->invoke($object);
+ }
+
+ if (null !== $this->dispatcher && $this->dispatcher->hasListeners('serializer.post_serialize', $metadata->name, $context->getFormat())) {
+ $this->dispatcher->dispatch('serializer.post_serialize', $metadata->name, $context->getFormat(), new ObjectEvent($context, $object, $type));
+ }
+
+ return;
+ }
+
+ foreach ($metadata->postDeserializeMethods as $method) {
+ $method->invoke($object);
+ }
+
+ if (null !== $this->dispatcher && $this->dispatcher->hasListeners('serializer.post_deserialize', $metadata->name, $context->getFormat())) {
+ $this->dispatcher->dispatch('serializer.post_deserialize', $metadata->name, $context->getFormat(), new ObjectEvent($context, $object, $type));
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\Common\Collections\Collection;
+use JMS\Serializer\Context;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\VisitorInterface;
+
+class ArrayCollectionHandler implements SubscribingHandlerInterface
+{
+ /**
+ * @var bool
+ */
+ private $initializeExcluded = true;
+
+ public function __construct($initializeExcluded = true)
+ {
+ $this->initializeExcluded = $initializeExcluded;
+ }
+
+ public static function getSubscribingMethods()
+ {
+ $methods = array();
+ $formats = array('json', 'xml', 'yml');
+ $collectionTypes = array(
+ 'ArrayCollection',
+ 'Doctrine\Common\Collections\ArrayCollection',
+ 'Doctrine\ORM\PersistentCollection',
+ 'Doctrine\ODM\MongoDB\PersistentCollection',
+ 'Doctrine\ODM\PHPCR\PersistentCollection',
+ );
+
+ foreach ($collectionTypes as $type) {
+ foreach ($formats as $format) {
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'type' => $type,
+ 'format' => $format,
+ 'method' => 'serializeCollection',
+ );
+
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
+ 'type' => $type,
+ 'format' => $format,
+ 'method' => 'deserializeCollection',
+ );
+ }
+ }
+
+ return $methods;
+ }
+
+ public function serializeCollection(VisitorInterface $visitor, Collection $collection, array $type, Context $context)
+ {
+ // We change the base type, and pass through possible parameters.
+ $type['name'] = 'array';
+
+ if ($this->initializeExcluded === false) {
+ $exclusionStrategy = $context->getExclusionStrategy();
+ if ($exclusionStrategy !== null && $exclusionStrategy->shouldSkipClass($context->getMetadataFactory()->getMetadataForClass(get_class($collection)), $context)) {
+ return $visitor->visitArray([], $type, $context);
+ }
+ }
+
+ return $visitor->visitArray($collection->toArray(), $type, $context);
+ }
+
+ public function deserializeCollection(VisitorInterface $visitor, $data, array $type, Context $context)
+ {
+ // See above.
+ $type['name'] = 'array';
+
+ return new ArrayCollection($visitor->visitArray($data, $type, $context));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\JsonSerializationVisitor;
+use JMS\Serializer\XmlSerializationVisitor;
+use JMS\Serializer\YamlSerializationVisitor;
+use Symfony\Component\Validator\ConstraintViolation;
+use Symfony\Component\Validator\ConstraintViolationList;
+
+class ConstraintViolationHandler implements SubscribingHandlerInterface
+{
+ public static function getSubscribingMethods()
+ {
+ $methods = array();
+ $formats = array('xml', 'json', 'yml');
+ $types = array('Symfony\Component\Validator\ConstraintViolationList' => 'serializeList', 'Symfony\Component\Validator\ConstraintViolation' => 'serializeViolation');
+
+ foreach ($types as $type => $method) {
+ foreach ($formats as $format) {
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'type' => $type,
+ 'format' => $format,
+ 'method' => $method . 'To' . $format,
+ );
+ }
+ }
+
+ return $methods;
+ }
+
+ public function serializeListToXml(XmlSerializationVisitor $visitor, ConstraintViolationList $list, array $type)
+ {
+ if (null === $visitor->document) {
+ $visitor->document = $visitor->createDocument();
+ }
+
+ foreach ($list as $violation) {
+ $this->serializeViolationToXml($visitor, $violation);
+ }
+ }
+
+ public function serializeListToJson(JsonSerializationVisitor $visitor, ConstraintViolationList $list, array $type, Context $context)
+ {
+ return $visitor->visitArray(iterator_to_array($list), $type, $context);
+ }
+
+ public function serializeListToYml(YamlSerializationVisitor $visitor, ConstraintViolationList $list, array $type, Context $context)
+ {
+ return $visitor->visitArray(iterator_to_array($list), $type, $context);
+ }
+
+ public function serializeViolationToXml(XmlSerializationVisitor $visitor, ConstraintViolation $violation, array $type = null)
+ {
+ if (null === $visitor->document) {
+ $visitor->document = $visitor->createDocument(null, null, false);
+ $visitor->document->appendChild($violationNode = $visitor->document->createElement('violation'));
+ $visitor->setCurrentNode($violationNode);
+ } else {
+ $visitor->getCurrentNode()->appendChild(
+ $violationNode = $visitor->document->createElement('violation')
+ );
+ }
+
+ $violationNode->setAttribute('property_path', $violation->getPropertyPath());
+ $violationNode->appendChild($messageNode = $visitor->document->createElement('message'));
+
+ $messageNode->appendChild($visitor->document->createCDATASection($violation->getMessage()));
+ }
+
+ public function serializeViolationToJson(JsonSerializationVisitor $visitor, ConstraintViolation $violation, array $type = null)
+ {
+ $data = array(
+ 'property_path' => $violation->getPropertyPath(),
+ 'message' => $violation->getMessage()
+ );
+
+ if (null === $visitor->getRoot()) {
+ $visitor->setRoot($data);
+ }
+
+ return $data;
+ }
+
+ public function serializeViolationToYml(YamlSerializationVisitor $visitor, ConstraintViolation $violation, array $type = null)
+ {
+ return array(
+ 'property_path' => $violation->getPropertyPath(),
+ 'message' => $violation->getMessage(),
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\JsonDeserializationVisitor;
+use JMS\Serializer\VisitorInterface;
+use JMS\Serializer\XmlDeserializationVisitor;
+use JMS\Serializer\XmlSerializationVisitor;
+
+class DateHandler implements SubscribingHandlerInterface
+{
+ private $defaultFormat;
+ private $defaultTimezone;
+ private $xmlCData;
+
+ public static function getSubscribingMethods()
+ {
+ $methods = array();
+ $deserializationTypes = array('DateTime', 'DateTimeImmutable', 'DateInterval');
+ $serialisationTypes = array('DateTime', 'DateTimeImmutable', 'DateInterval');
+
+ foreach (array('json', 'xml', 'yml') as $format) {
+
+ foreach ($deserializationTypes as $type) {
+ $methods[] = [
+ 'type' => $type,
+ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
+ 'format' => $format,
+ ];
+ }
+
+ foreach ($serialisationTypes as $type) {
+ $methods[] = array(
+ 'type' => $type,
+ 'format' => $format,
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'method' => 'serialize' . $type,
+ );
+ }
+ }
+
+ return $methods;
+ }
+
+ public function __construct($defaultFormat = \DateTime::ISO8601, $defaultTimezone = 'UTC', $xmlCData = true)
+ {
+ $this->defaultFormat = $defaultFormat;
+ $this->defaultTimezone = new \DateTimeZone($defaultTimezone);
+ $this->xmlCData = $xmlCData;
+ }
+
+ private function serializeDateTimeInterface(
+ VisitorInterface $visitor,
+ \DateTimeInterface $date,
+ array $type,
+ Context $context
+ )
+ {
+ if ($visitor instanceof XmlSerializationVisitor && false === $this->xmlCData) {
+ return $visitor->visitSimpleString($date->format($this->getFormat($type)), $type, $context);
+ }
+
+ $format = $this->getFormat($type);
+ if ('U' === $format) {
+ return $visitor->visitInteger($date->format($format), $type, $context);
+ }
+
+ return $visitor->visitString($date->format($this->getFormat($type)), $type, $context);
+ }
+
+ public function serializeDateTime(VisitorInterface $visitor, \DateTime $date, array $type, Context $context)
+ {
+ return $this->serializeDateTimeInterface($visitor, $date, $type, $context);
+ }
+
+ public function serializeDateTimeImmutable(
+ VisitorInterface $visitor,
+ \DateTimeImmutable $date,
+ array $type,
+ Context $context
+ )
+ {
+ return $this->serializeDateTimeInterface($visitor, $date, $type, $context);
+ }
+
+ public function serializeDateInterval(VisitorInterface $visitor, \DateInterval $date, array $type, Context $context)
+ {
+ $iso8601DateIntervalString = $this->format($date);
+
+ if ($visitor instanceof XmlSerializationVisitor && false === $this->xmlCData) {
+ return $visitor->visitSimpleString($iso8601DateIntervalString, $type, $context);
+ }
+
+ return $visitor->visitString($iso8601DateIntervalString, $type, $context);
+ }
+
+ private function isDataXmlNull($data)
+ {
+ $attributes = $data->attributes('xsi', true);
+ return isset($attributes['nil'][0]) && (string)$attributes['nil'][0] === 'true';
+ }
+
+ public function deserializeDateTimeFromXml(XmlDeserializationVisitor $visitor, $data, array $type)
+ {
+ if ($this->isDataXmlNull($data)) {
+ return null;
+ }
+
+ return $this->parseDateTime($data, $type);
+ }
+
+ public function deserializeDateTimeImmutableFromXml(XmlDeserializationVisitor $visitor, $data, array $type)
+ {
+ if ($this->isDataXmlNull($data)) {
+ return null;
+ }
+
+ return $this->parseDateTime($data, $type, true);
+ }
+
+ public function deserializeDateIntervalFromXml(XmlDeserializationVisitor $visitor, $data, array $type)
+ {
+ if ($this->isDataXmlNull($data)) {
+ return null;
+ }
+
+ return $this->parseDateInterval($data);
+ }
+
+ public function deserializeDateTimeFromJson(JsonDeserializationVisitor $visitor, $data, array $type)
+ {
+ if (null === $data) {
+ return null;
+ }
+
+ return $this->parseDateTime($data, $type);
+ }
+
+ public function deserializeDateTimeImmutableFromJson(JsonDeserializationVisitor $visitor, $data, array $type)
+ {
+ if (null === $data) {
+ return null;
+ }
+
+ return $this->parseDateTime($data, $type, true);
+ }
+
+ public function deserializeDateIntervalFromJson(JsonDeserializationVisitor $visitor, $data, array $type)
+ {
+ if (null === $data) {
+ return null;
+ }
+
+ return $this->parseDateInterval($data);
+ }
+
+ private function parseDateTime($data, array $type, $immutable = false)
+ {
+ $timezone = !empty($type['params'][1]) ? new \DateTimeZone($type['params'][1]) : $this->defaultTimezone;
+ $format = $this->getDeserializationFormat($type);
+
+ if ($immutable) {
+ $datetime = \DateTimeImmutable::createFromFormat($format, (string)$data, $timezone);
+ } else {
+ $datetime = \DateTime::createFromFormat($format, (string)$data, $timezone);
+ }
+
+ if (false === $datetime) {
+ throw new RuntimeException(sprintf('Invalid datetime "%s", expected format %s.', $data, $format));
+ }
+
+ if ($format === 'U') {
+ $datetime = $datetime->setTimezone($timezone);
+ }
+
+ return $datetime;
+ }
+
+ private function parseDateInterval($data)
+ {
+ $dateInterval = null;
+ try {
+ $dateInterval = new \DateInterval($data);
+ } catch (\Exception $e) {
+ throw new RuntimeException(sprintf('Invalid dateinterval "%s", expected ISO 8601 format', $data), null, $e);
+ }
+
+ return $dateInterval;
+ }
+
+ /**
+ * @param array $type
+ * @return string
+ */
+ private function getDeserializationFormat(array $type)
+ {
+ if (isset($type['params'][2])) {
+ return $type['params'][2];
+ }
+ if (isset($type['params'][0])) {
+ return $type['params'][0];
+ }
+ return $this->defaultFormat;
+ }
+
+ /**
+ * @return string
+ * @param array $type
+ */
+ private function getFormat(array $type)
+ {
+ return isset($type['params'][0]) ? $type['params'][0] : $this->defaultFormat;
+ }
+
+ /**
+ * @param \DateInterval $dateInterval
+ * @return string
+ */
+ public function format(\DateInterval $dateInterval)
+ {
+ $format = 'P';
+
+ if (0 < $dateInterval->y) {
+ $format .= $dateInterval->y . 'Y';
+ }
+
+ if (0 < $dateInterval->m) {
+ $format .= $dateInterval->m . 'M';
+ }
+
+ if (0 < $dateInterval->d) {
+ $format .= $dateInterval->d . 'D';
+ }
+
+ if (0 < $dateInterval->h || 0 < $dateInterval->i || 0 < $dateInterval->s) {
+ $format .= 'T';
+ }
+
+ if (0 < $dateInterval->h) {
+ $format .= $dateInterval->h . 'H';
+ }
+
+ if (0 < $dateInterval->i) {
+ $format .= $dateInterval->i . 'M';
+ }
+
+ if (0 < $dateInterval->s) {
+ $format .= $dateInterval->s . 'S';
+ }
+
+ if ($format === 'P') {
+ $format = 'P0DT0S';
+ }
+
+ return $format;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\JsonSerializationVisitor;
+use JMS\Serializer\VisitorInterface;
+use JMS\Serializer\XmlSerializationVisitor;
+use JMS\Serializer\YamlSerializationVisitor;
+use Symfony\Component\Form\Form;
+use Symfony\Component\Form\FormError;
+use Symfony\Component\Translation\TranslatorInterface;
+
+class FormErrorHandler implements SubscribingHandlerInterface
+{
+ private $translator;
+
+ private $translationDomain;
+
+ public static function getSubscribingMethods()
+ {
+ $methods = array();
+ foreach (array('xml', 'json', 'yml') as $format) {
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'type' => 'Symfony\Component\Form\Form',
+ 'format' => $format,
+ );
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'type' => 'Symfony\Component\Form\FormError',
+ 'format' => $format,
+ );
+ }
+
+ return $methods;
+ }
+
+ public function __construct(TranslatorInterface $translator = null, $translationDomain = 'validators')
+ {
+ $this->translator = $translator;
+ $this->translationDomain = $translationDomain;
+ }
+
+ public function serializeFormToXml(XmlSerializationVisitor $visitor, Form $form, array $type)
+ {
+ if (null === $visitor->document) {
+ $visitor->document = $visitor->createDocument(null, null, false);
+ $visitor->document->appendChild($formNode = $visitor->document->createElement('form'));
+ $visitor->setCurrentNode($formNode);
+ } else {
+ $visitor->getCurrentNode()->appendChild(
+ $formNode = $visitor->document->createElement('form')
+ );
+ }
+
+ $formNode->setAttribute('name', $form->getName());
+
+ $formNode->appendChild($errorsNode = $visitor->document->createElement('errors'));
+ foreach ($form->getErrors() as $error) {
+ $errorNode = $visitor->document->createElement('entry');
+ $errorNode->appendChild($this->serializeFormErrorToXml($visitor, $error, array()));
+ $errorsNode->appendChild($errorNode);
+ }
+
+ foreach ($form->all() as $child) {
+ if ($child instanceof Form) {
+ if (null !== $node = $this->serializeFormToXml($visitor, $child, array())) {
+ $formNode->appendChild($node);
+ }
+ }
+ }
+
+ return $formNode;
+ }
+
+ public function serializeFormToJson(JsonSerializationVisitor $visitor, Form $form, array $type)
+ {
+ return $this->convertFormToArray($visitor, $form);
+ }
+
+ public function serializeFormToYml(YamlSerializationVisitor $visitor, Form $form, array $type)
+ {
+ return $this->convertFormToArray($visitor, $form);
+ }
+
+ public function serializeFormErrorToXml(XmlSerializationVisitor $visitor, FormError $formError, array $type)
+ {
+ if (null === $visitor->document) {
+ $visitor->document = $visitor->createDocument(null, null, true);
+ }
+
+ return $visitor->document->createCDATASection($this->getErrorMessage($formError));
+ }
+
+ public function serializeFormErrorToJson(JsonSerializationVisitor $visitor, FormError $formError, array $type)
+ {
+ return $this->getErrorMessage($formError);
+ }
+
+ public function serializeFormErrorToYml(YamlSerializationVisitor $visitor, FormError $formError, array $type)
+ {
+ return $this->getErrorMessage($formError);
+ }
+
+ private function getErrorMessage(FormError $error)
+ {
+
+ if ($this->translator === null){
+ return $error->getMessage();
+ }
+
+ if (null !== $error->getMessagePluralization()) {
+ return $this->translator->transChoice($error->getMessageTemplate(), $error->getMessagePluralization(), $error->getMessageParameters(), $this->translationDomain);
+ }
+
+ return $this->translator->trans($error->getMessageTemplate(), $error->getMessageParameters(), $this->translationDomain);
+ }
+
+ private function convertFormToArray(VisitorInterface $visitor, Form $data)
+ {
+ $isRoot = null === $visitor->getRoot();
+
+ $form = new \ArrayObject();
+ $errors = array();
+ foreach ($data->getErrors() as $error) {
+ $errors[] = $this->getErrorMessage($error);
+ }
+
+ if ($errors) {
+ $form['errors'] = $errors;
+ }
+
+ $children = array();
+ foreach ($data->all() as $child) {
+ if ($child instanceof Form) {
+ $children[$child->getName()] = $this->convertFormToArray($visitor, $child);
+ }
+ }
+
+ if ($children) {
+ $form['children'] = $children;
+ }
+
+ if ($isRoot) {
+ $visitor->setRoot($form);
+ }
+
+ return $form;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+use JMS\Serializer\Exception\LogicException;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\GraphNavigator;
+
+class HandlerRegistry implements HandlerRegistryInterface
+{
+ protected $handlers;
+
+ public static function getDefaultMethod($direction, $type, $format)
+ {
+ if (false !== $pos = strrpos($type, '\\')) {
+ $type = substr($type, $pos + 1);
+ }
+
+ switch ($direction) {
+ case GraphNavigator::DIRECTION_DESERIALIZATION:
+ return 'deserialize' . $type . 'From' . $format;
+
+ case GraphNavigator::DIRECTION_SERIALIZATION:
+ return 'serialize' . $type . 'To' . $format;
+
+ default:
+ throw new LogicException(sprintf('The direction %s does not exist; see GraphNavigator::DIRECTION_??? constants.', json_encode($direction)));
+ }
+ }
+
+ public function __construct(array $handlers = array())
+ {
+ $this->handlers = $handlers;
+ }
+
+ public function registerSubscribingHandler(SubscribingHandlerInterface $handler)
+ {
+ foreach ($handler->getSubscribingMethods() as $methodData) {
+ if (!isset($methodData['type'], $methodData['format'])) {
+ throw new RuntimeException(sprintf('For each subscribing method a "type" and "format" attribute must be given, but only got "%s" for %s.', implode('" and "', array_keys($methodData)), get_class($handler)));
+ }
+
+ $directions = array(GraphNavigator::DIRECTION_DESERIALIZATION, GraphNavigator::DIRECTION_SERIALIZATION);
+ if (isset($methodData['direction'])) {
+ $directions = array($methodData['direction']);
+ }
+
+ foreach ($directions as $direction) {
+ $method = isset($methodData['method']) ? $methodData['method'] : self::getDefaultMethod($direction, $methodData['type'], $methodData['format']);
+ $this->registerHandler($direction, $methodData['type'], $methodData['format'], array($handler, $method));
+ }
+ }
+ }
+
+ public function registerHandler($direction, $typeName, $format, $handler)
+ {
+ if (is_string($direction)) {
+ $direction = GraphNavigator::parseDirection($direction);
+ }
+
+ $this->handlers[$direction][$typeName][$format] = $handler;
+ }
+
+ public function getHandler($direction, $typeName, $format)
+ {
+ if (!isset($this->handlers[$direction][$typeName][$format])) {
+ return null;
+ }
+
+ return $this->handlers[$direction][$typeName][$format];
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+/**
+ * Handler Registry Interface.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface HandlerRegistryInterface
+{
+ /**
+ * @param SubscribingHandlerInterface $handler
+ *
+ * @return void
+ */
+ public function registerSubscribingHandler(SubscribingHandlerInterface $handler);
+
+ /**
+ * Registers a handler in the registry.
+ *
+ * @param integer $direction one of the GraphNavigator::DIRECTION_??? constants
+ * @param string $typeName
+ * @param string $format
+ * @param callable $handler function(VisitorInterface, mixed $data, array $type): mixed
+ *
+ * @return void
+ */
+ public function registerHandler($direction, $typeName, $format, $handler);
+
+ /**
+ * @param integer $direction one of the GraphNavigator::DIRECTION_??? constants
+ * @param string $typeName
+ * @param string $format
+ *
+ * @return callable|null
+ */
+ public function getHandler($direction, $typeName, $format);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+use Psr\Container\ContainerInterface as PsrContainerInterface;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+
+class LazyHandlerRegistry extends HandlerRegistry
+{
+ private $container;
+ private $initializedHandlers = array();
+
+ public function __construct($container, array $handlers = array())
+ {
+ if (!$container instanceof PsrContainerInterface && !$container instanceof ContainerInterface) {
+ throw new \InvalidArgumentException(sprintf('The container must be an instance of %s or %s (%s given).', PsrContainerInterface::class, ContainerInterface::class, is_object($container) ? get_class($container) : gettype($container)));
+ }
+
+ parent::__construct($handlers);
+ $this->container = $container;
+ }
+
+ public function registerHandler($direction, $typeName, $format, $handler)
+ {
+ parent::registerHandler($direction, $typeName, $format, $handler);
+ unset($this->initializedHandlers[$direction][$typeName][$format]);
+ }
+
+ public function getHandler($direction, $typeName, $format)
+ {
+ if (isset($this->initializedHandlers[$direction][$typeName][$format])) {
+ return $this->initializedHandlers[$direction][$typeName][$format];
+ }
+
+ if (!isset($this->handlers[$direction][$typeName][$format])) {
+ return null;
+ }
+
+ $handler = $this->handlers[$direction][$typeName][$format];
+ if (is_array($handler) && is_string($handler[0]) && $this->container->has($handler[0])) {
+ $handler[0] = $this->container->get($handler[0]);
+ }
+
+ return $this->initializedHandlers[$direction][$typeName][$format] = $handler;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\VisitorInterface;
+use PhpCollection\Map;
+use PhpCollection\Sequence;
+
+class PhpCollectionHandler implements SubscribingHandlerInterface
+{
+ public static function getSubscribingMethods()
+ {
+ $methods = array();
+ $formats = array('json', 'xml', 'yml');
+ $collectionTypes = array(
+ 'PhpCollection\Sequence' => 'Sequence',
+ 'PhpCollection\Map' => 'Map',
+ );
+
+ foreach ($collectionTypes as $type => $shortName) {
+ foreach ($formats as $format) {
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'type' => $type,
+ 'format' => $format,
+ 'method' => 'serialize' . $shortName,
+ );
+
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
+ 'type' => $type,
+ 'format' => $format,
+ 'method' => 'deserialize' . $shortName,
+ );
+ }
+ }
+
+ return $methods;
+ }
+
+ public function serializeMap(VisitorInterface $visitor, Map $map, array $type, Context $context)
+ {
+ $type['name'] = 'array';
+
+ return $visitor->visitArray(iterator_to_array($map), $type, $context);
+ }
+
+ public function deserializeMap(VisitorInterface $visitor, $data, array $type, Context $context)
+ {
+ $type['name'] = 'array';
+
+ return new Map($visitor->visitArray($data, $type, $context));
+ }
+
+ public function serializeSequence(VisitorInterface $visitor, Sequence $sequence, array $type, Context $context)
+ {
+ // We change the base type, and pass through possible parameters.
+ $type['name'] = 'array';
+
+ return $visitor->visitArray($sequence->all(), $type, $context);
+ }
+
+ public function deserializeSequence(VisitorInterface $visitor, $data, array $type, Context $context)
+ {
+ // See above.
+ $type['name'] = 'array';
+
+ return new Sequence($visitor->visitArray($data, $type, $context));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\VisitorInterface;
+use PropelCollection;
+
+class PropelCollectionHandler implements SubscribingHandlerInterface
+{
+ public static function getSubscribingMethods()
+ {
+ $methods = array();
+ $formats = array('json', 'xml', 'yml');
+ //Note: issue when handling inheritance
+ $collectionTypes = array(
+ 'PropelCollection',
+ 'PropelObjectCollection',
+ 'PropelArrayCollection',
+ 'PropelOnDemandCollection'
+ );
+
+ foreach ($collectionTypes as $type) {
+ foreach ($formats as $format) {
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'type' => $type,
+ 'format' => $format,
+ 'method' => 'serializeCollection',
+ );
+
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
+ 'type' => $type,
+ 'format' => $format,
+ 'method' => 'deserializeCollection',
+ );
+ }
+ }
+
+ return $methods;
+ }
+
+ public function serializeCollection(VisitorInterface $visitor, PropelCollection $collection, array $type, Context $context)
+ {
+ // We change the base type, and pass through possible parameters.
+ $type['name'] = 'array';
+
+ return $visitor->visitArray($collection->getData(), $type, $context);
+ }
+
+ public function deserializeCollection(VisitorInterface $visitor, $data, array $type, Context $context)
+ {
+ // See above. Set parameter type to PropelCollection<T> or PropelCollection<K,V>
+ $type['name'] = 'array';
+
+ $collection = new PropelCollection();
+ $collection->setData($visitor->visitArray($data, $type, $context));
+
+ return $collection;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Metadata\StaticPropertyMetadata;
+use JMS\Serializer\VisitorInterface;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+class StdClassHandler implements SubscribingHandlerInterface
+{
+ public static function getSubscribingMethods()
+ {
+ $methods = array();
+ $formats = array('json', 'xml', 'yml');
+
+ foreach ($formats as $format) {
+ $methods[] = array(
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'type' => 'stdClass',
+ 'format' => $format,
+ 'method' => 'serializeStdClass',
+ );
+ }
+
+ return $methods;
+ }
+
+ public function serializeStdClass(VisitorInterface $visitor, \stdClass $stdClass, array $type, Context $context)
+ {
+ $classMetadata = $context->getMetadataFactory()->getMetadataForClass('stdClass');
+ $visitor->startVisitingObject($classMetadata, $stdClass, array('name' => 'stdClass'), $context);
+
+ foreach ((array)$stdClass as $name => $value) {
+ $metadata = new StaticPropertyMetadata('stdClass', $name, $value);
+ $visitor->visitProperty($metadata, $value, $context);
+ }
+
+ return $visitor->endVisitingObject($classMetadata, $stdClass, array('name' => 'stdClass'), $context);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Handler;
+
+interface SubscribingHandlerInterface
+{
+ /**
+ * Return format:
+ *
+ * array(
+ * array(
+ * 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ * 'format' => 'json',
+ * 'type' => 'DateTime',
+ * 'method' => 'serializeDateTimeToJson',
+ * ),
+ * )
+ *
+ * The direction and method keys can be omitted.
+ *
+ * @return array
+ */
+ public static function getSubscribingMethods();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Exception\RuntimeException;
+
+class JsonDeserializationVisitor extends GenericDeserializationVisitor
+{
+ protected function decode($str)
+ {
+ $decoded = json_decode($str, true);
+
+ switch (json_last_error()) {
+ case JSON_ERROR_NONE:
+ return $decoded;
+
+ case JSON_ERROR_DEPTH:
+ throw new RuntimeException('Could not decode JSON, maximum stack depth exceeded.');
+
+ case JSON_ERROR_STATE_MISMATCH:
+ throw new RuntimeException('Could not decode JSON, underflow or the nodes mismatch.');
+
+ case JSON_ERROR_CTRL_CHAR:
+ throw new RuntimeException('Could not decode JSON, unexpected control character found.');
+
+ case JSON_ERROR_SYNTAX:
+ throw new RuntimeException('Could not decode JSON, syntax error - malformed JSON.');
+
+ case JSON_ERROR_UTF8:
+ throw new RuntimeException('Could not decode JSON, malformed UTF-8 characters (incorrectly encoded?)');
+
+ default:
+ throw new RuntimeException('Could not decode JSON.');
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Exception\InvalidArgumentException;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Naming\AdvancedNamingStrategyInterface;
+
+class JsonSerializationVisitor extends GenericSerializationVisitor
+{
+ private $options = 0;
+
+ private $navigator;
+ private $root;
+ private $dataStack;
+ private $data;
+
+ public function setNavigator(GraphNavigator $navigator)
+ {
+ $this->navigator = $navigator;
+ $this->root = null;
+ $this->dataStack = new \SplStack;
+ }
+
+ /**
+ * @return GraphNavigator
+ */
+ public function getNavigator()
+ {
+ return $this->navigator;
+ }
+
+ public function visitNull($data, array $type, Context $context)
+ {
+ return null;
+ }
+
+ public function visitString($data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = $data;
+ }
+
+ return (string)$data;
+ }
+
+ public function visitBoolean($data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = $data;
+ }
+
+ return (boolean)$data;
+ }
+
+ public function visitInteger($data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = $data;
+ }
+
+ return (int)$data;
+ }
+
+ public function visitDouble($data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = $data;
+ }
+
+ return (float)$data;
+ }
+
+ /**
+ * @param array $data
+ * @param array $type
+ * @param Context $context
+ * @return mixed
+ */
+ public function visitArray($data, array $type, Context $context)
+ {
+ $this->dataStack->push($data);
+
+ $isHash = isset($type['params'][1]);
+
+ if (null === $this->root) {
+ $this->root = $isHash ? new \ArrayObject() : array();
+ $rs = &$this->root;
+ } else {
+ $rs = $isHash ? new \ArrayObject() : array();
+ }
+
+ $isList = isset($type['params'][0]) && !isset($type['params'][1]);
+
+ foreach ($data as $k => $v) {
+ $v = $this->navigator->accept($v, $this->getElementType($type), $context);
+
+ if (null === $v && $context->shouldSerializeNull() !== true) {
+ continue;
+ }
+
+ if ($isList) {
+ $rs[] = $v;
+ } else {
+ $rs[$k] = $v;
+ }
+ }
+
+ $this->dataStack->pop();
+ return $rs;
+ }
+
+ public function startVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ if (null === $this->root) {
+ $this->root = new \stdClass;
+ }
+
+ $this->dataStack->push($this->data);
+ $this->data = array();
+ }
+
+ public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ $rs = $this->data;
+ $this->data = $this->dataStack->pop();
+
+ // Force JSON output to "{}" instead of "[]" if it contains either no properties or all properties are null.
+ if (empty($rs)) {
+ $rs = new \ArrayObject();
+ }
+
+ if ($this->root instanceof \stdClass && 0 === $this->dataStack->count()) {
+ $this->root = $rs;
+ }
+
+ return $rs;
+ }
+
+ public function visitProperty(PropertyMetadata $metadata, $data, Context $context)
+ {
+ $v = $this->accessor->getValue($data, $metadata);
+
+ $v = $this->navigator->accept($v, $metadata->type, $context);
+ if ((null === $v && $context->shouldSerializeNull() !== true)
+ || (true === $metadata->skipWhenEmpty && ($v instanceof \ArrayObject || is_array($v)) && 0 === count($v))
+ ) {
+ return;
+ }
+
+ if ($this->namingStrategy instanceof AdvancedNamingStrategyInterface) {
+ $k = $this->namingStrategy->getPropertyName($metadata, $context);
+ } else {
+ $k = $this->namingStrategy->translateName($metadata);
+ }
+
+ if ($metadata->inline) {
+ if (is_array($v) || ($v instanceof \ArrayObject)) {
+ $this->data = array_merge($this->data, (array) $v);
+ }
+ } else {
+ $this->data[$k] = $v;
+ }
+ }
+
+ /**
+ * Allows you to add additional data to the current object/root element.
+ * @deprecated use setData instead
+ * @param string $key
+ * @param integer|float|boolean|string|array|null $value This value must either be a regular scalar, or an array.
+ * It must not contain any objects anymore.
+ */
+ public function addData($key, $value)
+ {
+ if (isset($this->data[$key])) {
+ throw new InvalidArgumentException(sprintf('There is already data for "%s".', $key));
+ }
+
+ $this->data[$key] = $value;
+ }
+
+ /**
+ * Checks if some data key exists.
+ *
+ * @param string $key
+ * @return boolean
+ */
+ public function hasData($key)
+ {
+ return isset($this->data[$key]);
+ }
+
+ /**
+ * Allows you to replace existing data on the current object/root element.
+ *
+ * @param string $key
+ * @param integer|float|boolean|string|array|null $value This value must either be a regular scalar, or an array.
+ * It must not contain any objects anymore.
+ */
+ public function setData($key, $value)
+ {
+ $this->data[$key] = $value;
+ }
+
+ public function getRoot()
+ {
+ return $this->root;
+ }
+
+ /**
+ * @param array|\ArrayObject $data the passed data must be understood by whatever encoding function is applied later.
+ */
+ public function setRoot($data)
+ {
+ $this->root = $data;
+ }
+
+
+ public function getResult()
+ {
+ $result = @json_encode($this->getRoot(), $this->options);
+
+ switch (json_last_error()) {
+ case JSON_ERROR_NONE:
+ return $result;
+
+ case JSON_ERROR_UTF8:
+ throw new \RuntimeException('Your data could not be encoded because it contains invalid UTF8 characters.');
+
+ default:
+ throw new \RuntimeException(sprintf('An error occurred while encoding your data (error code %d).', json_last_error()));
+ }
+ }
+
+ public function getOptions()
+ {
+ return $this->options;
+ }
+
+ public function setOptions($options)
+ {
+ $this->options = (integer)$options;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata;
+
+use JMS\Serializer\Exception\InvalidArgumentException;
+use Metadata\MergeableClassMetadata;
+use Metadata\MergeableInterface;
+use Metadata\MethodMetadata;
+use Metadata\PropertyMetadata as BasePropertyMetadata;
+
+/**
+ * Class Metadata used to customize the serialization process.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class ClassMetadata extends MergeableClassMetadata
+{
+ const ACCESSOR_ORDER_UNDEFINED = 'undefined';
+ const ACCESSOR_ORDER_ALPHABETICAL = 'alphabetical';
+ const ACCESSOR_ORDER_CUSTOM = 'custom';
+
+ /** @var \ReflectionMethod[] */
+ public $preSerializeMethods = array();
+
+ /** @var \ReflectionMethod[] */
+ public $postSerializeMethods = array();
+
+ /** @var \ReflectionMethod[] */
+ public $postDeserializeMethods = array();
+
+ public $xmlRootName;
+ public $xmlRootNamespace;
+ public $xmlNamespaces = array();
+ public $accessorOrder;
+ public $customOrder;
+ public $usingExpression = false;
+ public $handlerCallbacks = array();
+
+ public $discriminatorDisabled = false;
+ public $discriminatorBaseClass;
+ public $discriminatorFieldName;
+ public $discriminatorValue;
+ public $discriminatorMap = array();
+ public $discriminatorGroups = array();
+
+ public $xmlDiscriminatorAttribute = false;
+ public $xmlDiscriminatorCData = true;
+ public $xmlDiscriminatorNamespace;
+
+ public function setDiscriminator($fieldName, array $map, array $groups = array())
+ {
+ if (empty($fieldName)) {
+ throw new \InvalidArgumentException('The $fieldName cannot be empty.');
+ }
+
+ if (empty($map)) {
+ throw new \InvalidArgumentException('The discriminator map cannot be empty.');
+ }
+
+ $this->discriminatorBaseClass = $this->name;
+ $this->discriminatorFieldName = $fieldName;
+ $this->discriminatorMap = $map;
+ $this->discriminatorGroups = $groups;
+ }
+
+ /**
+ * Sets the order of properties in the class.
+ *
+ * @param string $order
+ * @param array $customOrder
+ *
+ * @throws InvalidArgumentException When the accessor order is not valid
+ * @throws InvalidArgumentException When the custom order is not valid
+ */
+ public function setAccessorOrder($order, array $customOrder = array())
+ {
+ if (!in_array($order, array(self::ACCESSOR_ORDER_UNDEFINED, self::ACCESSOR_ORDER_ALPHABETICAL, self::ACCESSOR_ORDER_CUSTOM), true)) {
+ throw new InvalidArgumentException(sprintf('The accessor order "%s" is invalid.', $order));
+ }
+
+ foreach ($customOrder as $name) {
+ if (!is_string($name)) {
+ throw new InvalidArgumentException(sprintf('$customOrder is expected to be a list of strings, but got element of value %s.', json_encode($name)));
+ }
+ }
+
+ $this->accessorOrder = $order;
+ $this->customOrder = array_flip($customOrder);
+ $this->sortProperties();
+ }
+
+ public function addPropertyMetadata(BasePropertyMetadata $metadata)
+ {
+ parent::addPropertyMetadata($metadata);
+ $this->sortProperties();
+ if ($metadata instanceof PropertyMetadata && $metadata->excludeIf) {
+ $this->usingExpression = true;
+ }
+ }
+
+ public function addPreSerializeMethod(MethodMetadata $method)
+ {
+ $this->preSerializeMethods[] = $method;
+ }
+
+ public function addPostSerializeMethod(MethodMetadata $method)
+ {
+ $this->postSerializeMethods[] = $method;
+ }
+
+ public function addPostDeserializeMethod(MethodMetadata $method)
+ {
+ $this->postDeserializeMethods[] = $method;
+ }
+
+ /**
+ * @param integer $direction
+ * @param string|integer $format
+ * @param string $methodName
+ */
+ public function addHandlerCallback($direction, $format, $methodName)
+ {
+ $this->handlerCallbacks[$direction][$format] = $methodName;
+ }
+
+ public function merge(MergeableInterface $object)
+ {
+ if (!$object instanceof ClassMetadata) {
+ throw new InvalidArgumentException('$object must be an instance of ClassMetadata.');
+ }
+ parent::merge($object);
+
+ $this->preSerializeMethods = array_merge($this->preSerializeMethods, $object->preSerializeMethods);
+ $this->postSerializeMethods = array_merge($this->postSerializeMethods, $object->postSerializeMethods);
+ $this->postDeserializeMethods = array_merge($this->postDeserializeMethods, $object->postDeserializeMethods);
+ $this->xmlRootName = $object->xmlRootName;
+ $this->xmlRootNamespace = $object->xmlRootNamespace;
+ $this->xmlNamespaces = array_merge($this->xmlNamespaces, $object->xmlNamespaces);
+
+ // Handler methods are taken from the outer class completely.
+ $this->handlerCallbacks = $object->handlerCallbacks;
+
+ if ($object->accessorOrder) {
+ $this->accessorOrder = $object->accessorOrder;
+ $this->customOrder = $object->customOrder;
+ }
+
+ if ($object->discriminatorFieldName && $this->discriminatorFieldName) {
+ throw new \LogicException(sprintf(
+ 'The discriminator of class "%s" would overwrite the discriminator of the parent class "%s". Please define all possible sub-classes in the discriminator of %s.',
+ $object->name,
+ $this->discriminatorBaseClass,
+ $this->discriminatorBaseClass
+ ));
+ } elseif (!$this->discriminatorFieldName && $object->discriminatorFieldName) {
+ $this->discriminatorFieldName = $object->discriminatorFieldName;
+ $this->discriminatorMap = $object->discriminatorMap;
+ }
+
+ if ($object->discriminatorDisabled !== null) {
+ $this->discriminatorDisabled = $object->discriminatorDisabled;
+ }
+
+ if ($object->discriminatorMap) {
+ $this->discriminatorFieldName = $object->discriminatorFieldName;
+ $this->discriminatorMap = $object->discriminatorMap;
+ $this->discriminatorBaseClass = $object->discriminatorBaseClass;
+ }
+
+ if ($this->discriminatorMap && !$this->reflection->isAbstract()) {
+ if (false === $typeValue = array_search($this->name, $this->discriminatorMap, true)) {
+ throw new \LogicException(sprintf(
+ 'The sub-class "%s" is not listed in the discriminator of the base class "%s".',
+ $this->name,
+ $this->discriminatorBaseClass
+ ));
+ }
+
+ $this->discriminatorValue = $typeValue;
+
+ if (isset($this->propertyMetadata[$this->discriminatorFieldName])
+ && !$this->propertyMetadata[$this->discriminatorFieldName] instanceof StaticPropertyMetadata
+ ) {
+ throw new \LogicException(sprintf(
+ 'The discriminator field name "%s" of the base-class "%s" conflicts with a regular property of the sub-class "%s".',
+ $this->discriminatorFieldName,
+ $this->discriminatorBaseClass,
+ $this->name
+ ));
+ }
+
+ $discriminatorProperty = new StaticPropertyMetadata(
+ $this->name,
+ $this->discriminatorFieldName,
+ $typeValue,
+ $this->discriminatorGroups
+ );
+ $discriminatorProperty->serializedName = $this->discriminatorFieldName;
+ $discriminatorProperty->xmlAttribute = $this->xmlDiscriminatorAttribute;
+ $discriminatorProperty->xmlElementCData = $this->xmlDiscriminatorCData;
+ $discriminatorProperty->xmlNamespace = $this->xmlDiscriminatorNamespace;
+ $this->propertyMetadata[$this->discriminatorFieldName] = $discriminatorProperty;
+ }
+
+ $this->sortProperties();
+ }
+
+ public function registerNamespace($uri, $prefix = null)
+ {
+ if (!is_string($uri)) {
+ throw new InvalidArgumentException(sprintf('$uri is expected to be a strings, but got value %s.', json_encode($uri)));
+ }
+
+ if ($prefix !== null) {
+ if (!is_string($prefix)) {
+ throw new InvalidArgumentException(sprintf('$prefix is expected to be a strings, but got value %s.', json_encode($prefix)));
+ }
+ } else {
+ $prefix = "";
+ }
+
+ $this->xmlNamespaces[$prefix] = $uri;
+
+ }
+
+ public function serialize()
+ {
+ $this->sortProperties();
+
+ return serialize(array(
+ $this->preSerializeMethods,
+ $this->postSerializeMethods,
+ $this->postDeserializeMethods,
+ $this->xmlRootName,
+ $this->xmlRootNamespace,
+ $this->xmlNamespaces,
+ $this->accessorOrder,
+ $this->customOrder,
+ $this->handlerCallbacks,
+ $this->discriminatorDisabled,
+ $this->discriminatorBaseClass,
+ $this->discriminatorFieldName,
+ $this->discriminatorValue,
+ $this->discriminatorMap,
+ $this->discriminatorGroups,
+ parent::serialize(),
+ 'discriminatorGroups' => $this->discriminatorGroups,
+ 'xmlDiscriminatorAttribute' => $this->xmlDiscriminatorAttribute,
+ 'xmlDiscriminatorCData' => $this->xmlDiscriminatorCData,
+ 'usingExpression' => $this->usingExpression,
+ 'xmlDiscriminatorNamespace' => $this->xmlDiscriminatorNamespace,
+ ));
+ }
+
+ public function unserialize($str)
+ {
+ $unserialized = unserialize($str);
+
+ list(
+ $this->preSerializeMethods,
+ $this->postSerializeMethods,
+ $this->postDeserializeMethods,
+ $this->xmlRootName,
+ $this->xmlRootNamespace,
+ $this->xmlNamespaces,
+ $this->accessorOrder,
+ $this->customOrder,
+ $this->handlerCallbacks,
+ $this->discriminatorDisabled,
+ $this->discriminatorBaseClass,
+ $this->discriminatorFieldName,
+ $this->discriminatorValue,
+ $this->discriminatorMap,
+ $this->discriminatorGroups,
+ $parentStr
+ ) = $unserialized;
+
+ if (isset($unserialized['discriminatorGroups'])) {
+ $this->discriminatorGroups = $unserialized['discriminatorGroups'];
+ }
+ if (isset($unserialized['usingExpression'])) {
+ $this->usingExpression = $unserialized['usingExpression'];
+ }
+
+ if (isset($unserialized['xmlDiscriminatorAttribute'])) {
+ $this->xmlDiscriminatorAttribute = $unserialized['xmlDiscriminatorAttribute'];
+ }
+
+ if (isset($unserialized['xmlDiscriminatorNamespace'])) {
+ $this->xmlDiscriminatorNamespace = $unserialized['xmlDiscriminatorNamespace'];
+ }
+
+ if (isset($unserialized['xmlDiscriminatorCData'])) {
+ $this->xmlDiscriminatorCData = $unserialized['xmlDiscriminatorCData'];
+ }
+
+ parent::unserialize($parentStr);
+ }
+
+ private function sortProperties()
+ {
+ switch ($this->accessorOrder) {
+ case self::ACCESSOR_ORDER_ALPHABETICAL:
+ ksort($this->propertyMetadata);
+ break;
+
+ case self::ACCESSOR_ORDER_CUSTOM:
+ $order = $this->customOrder;
+ $currentSorting = $this->propertyMetadata ? array_combine(array_keys($this->propertyMetadata), range(1, count($this->propertyMetadata))) : [];
+ uksort($this->propertyMetadata, function ($a, $b) use ($order, $currentSorting) {
+ $existsA = isset($order[$a]);
+ $existsB = isset($order[$b]);
+
+ if (!$existsA && !$existsB) {
+ return $currentSorting[$a] - $currentSorting[$b];
+ }
+
+ if (!$existsA) {
+ return 1;
+ }
+
+ if (!$existsB) {
+ return -1;
+ }
+
+ return $order[$a] < $order[$b] ? -1 : 1;
+ });
+ break;
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata\Driver;
+
+use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\Common\Persistence\Mapping\ClassMetadata as DoctrineClassMetadata;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Metadata\StaticPropertyMetadata;
+use JMS\Serializer\Metadata\VirtualPropertyMetadata;
+use Metadata\Driver\DriverInterface;
+
+/**
+ * This class decorates any other driver. If the inner driver does not provide a
+ * a property type, the decorator will guess based on Doctrine 2 metadata.
+ */
+abstract class AbstractDoctrineTypeDriver implements DriverInterface
+{
+ /**
+ * Map of doctrine 2 field types to JMS\Serializer types
+ * @var array
+ */
+ protected $fieldMapping = array(
+ 'string' => 'string',
+ 'text' => 'string',
+ 'blob' => 'string',
+ 'guid' => 'string',
+
+ 'integer' => 'integer',
+ 'smallint' => 'integer',
+ 'bigint' => 'integer',
+
+ 'datetime' => 'DateTime',
+ 'datetimetz' => 'DateTime',
+ 'time' => 'DateTime',
+ 'date' => 'DateTime',
+
+ 'float' => 'float',
+ 'decimal' => 'float',
+
+ 'boolean' => 'boolean',
+
+ 'array' => 'array',
+ 'json_array' => 'array',
+ 'simple_array' => 'array<string>',
+ );
+
+ /**
+ * @var DriverInterface
+ */
+ protected $delegate;
+
+ /**
+ * @var ManagerRegistry
+ */
+ protected $registry;
+
+ public function __construct(DriverInterface $delegate, ManagerRegistry $registry)
+ {
+ $this->delegate = $delegate;
+ $this->registry = $registry;
+ }
+
+ public function loadMetadataForClass(\ReflectionClass $class)
+ {
+ /** @var $classMetadata ClassMetadata */
+ $classMetadata = $this->delegate->loadMetadataForClass($class);
+
+ // Abort if the given class is not a mapped entity
+ if (!$doctrineMetadata = $this->tryLoadingDoctrineMetadata($class->name)) {
+ return $classMetadata;
+ }
+
+ $this->setDiscriminator($doctrineMetadata, $classMetadata);
+
+ // We base our scan on the internal driver's property list so that we
+ // respect any internal white/blacklisting like in the AnnotationDriver
+ foreach ($classMetadata->propertyMetadata as $key => $propertyMetadata) {
+ /** @var $propertyMetadata PropertyMetadata */
+
+ // If the inner driver provides a type, don't guess anymore.
+ if ($propertyMetadata->type || $this->isVirtualProperty($propertyMetadata)) {
+ continue;
+ }
+
+ if ($this->hideProperty($doctrineMetadata, $propertyMetadata)) {
+ unset($classMetadata->propertyMetadata[$key]);
+ }
+
+ $this->setPropertyType($doctrineMetadata, $propertyMetadata);
+ }
+
+ return $classMetadata;
+ }
+
+ private function isVirtualProperty(PropertyMetadata $propertyMetadata)
+ {
+ return $propertyMetadata instanceof VirtualPropertyMetadata
+ || $propertyMetadata instanceof StaticPropertyMetadata
+ || $propertyMetadata instanceof ExpressionPropertyMetadata;
+ }
+
+ /**
+ * @param DoctrineClassMetadata $doctrineMetadata
+ * @param ClassMetadata $classMetadata
+ */
+ protected function setDiscriminator(DoctrineClassMetadata $doctrineMetadata, ClassMetadata $classMetadata)
+ {
+ }
+
+ /**
+ * @param DoctrineClassMetadata $doctrineMetadata
+ * @param PropertyMetadata $propertyMetadata
+ */
+ protected function hideProperty(DoctrineClassMetadata $doctrineMetadata, PropertyMetadata $propertyMetadata)
+ {
+ return false;
+ }
+
+ /**
+ * @param DoctrineClassMetadata $doctrineMetadata
+ * @param PropertyMetadata $propertyMetadata
+ */
+ protected function setPropertyType(DoctrineClassMetadata $doctrineMetadata, PropertyMetadata $propertyMetadata)
+ {
+ }
+
+ /**
+ * @param string $className
+ *
+ * @return null|DoctrineClassMetadata
+ */
+ protected function tryLoadingDoctrineMetadata($className)
+ {
+ if (!$manager = $this->registry->getManagerForClass($className)) {
+ return null;
+ }
+
+ if ($manager->getMetadataFactory()->isTransient($className)) {
+ return null;
+ }
+
+ return $manager->getClassMetadata($className);
+ }
+
+ /**
+ * @param string $type
+ */
+ protected function normalizeFieldType($type)
+ {
+ if (!isset($this->fieldMapping[$type])) {
+ return;
+ }
+
+ return $this->fieldMapping[$type];
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata\Driver;
+
+use Doctrine\Common\Annotations\Reader;
+use JMS\Serializer\Annotation\Accessor;
+use JMS\Serializer\Annotation\AccessorOrder;
+use JMS\Serializer\Annotation\AccessType;
+use JMS\Serializer\Annotation\Discriminator;
+use JMS\Serializer\Annotation\Exclude;
+use JMS\Serializer\Annotation\ExcludeIf;
+use JMS\Serializer\Annotation\ExclusionPolicy;
+use JMS\Serializer\Annotation\Expose;
+use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\HandlerCallback;
+use JMS\Serializer\Annotation\Inline;
+use JMS\Serializer\Annotation\MaxDepth;
+use JMS\Serializer\Annotation\PostDeserialize;
+use JMS\Serializer\Annotation\PostSerialize;
+use JMS\Serializer\Annotation\PreSerialize;
+use JMS\Serializer\Annotation\ReadOnly;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Since;
+use JMS\Serializer\Annotation\SkipWhenEmpty;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\Until;
+use JMS\Serializer\Annotation\VirtualProperty;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlAttributeMap;
+use JMS\Serializer\Annotation\XmlDiscriminator;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlKeyValuePairs;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlMap;
+use JMS\Serializer\Annotation\XmlNamespace;
+use JMS\Serializer\Annotation\XmlRoot;
+use JMS\Serializer\Annotation\XmlValue;
+use JMS\Serializer\Exception\InvalidArgumentException;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Metadata\VirtualPropertyMetadata;
+use Metadata\Driver\DriverInterface;
+use Metadata\MethodMetadata;
+
+class AnnotationDriver implements DriverInterface
+{
+ private $reader;
+
+ public function __construct(Reader $reader)
+ {
+ $this->reader = $reader;
+ }
+
+ public function loadMetadataForClass(\ReflectionClass $class)
+ {
+ $classMetadata = new ClassMetadata($name = $class->name);
+ $classMetadata->fileResources[] = $class->getFilename();
+
+ $propertiesMetadata = array();
+ $propertiesAnnotations = array();
+
+ $exclusionPolicy = 'NONE';
+ $excludeAll = false;
+ $classAccessType = PropertyMetadata::ACCESS_TYPE_PROPERTY;
+ $readOnlyClass = false;
+ foreach ($this->reader->getClassAnnotations($class) as $annot) {
+ if ($annot instanceof ExclusionPolicy) {
+ $exclusionPolicy = $annot->policy;
+ } elseif ($annot instanceof XmlRoot) {
+ $classMetadata->xmlRootName = $annot->name;
+ $classMetadata->xmlRootNamespace = $annot->namespace;
+ } elseif ($annot instanceof XmlNamespace) {
+ $classMetadata->registerNamespace($annot->uri, $annot->prefix);
+ } elseif ($annot instanceof Exclude) {
+ $excludeAll = true;
+ } elseif ($annot instanceof AccessType) {
+ $classAccessType = $annot->type;
+ } elseif ($annot instanceof ReadOnly) {
+ $readOnlyClass = true;
+ } elseif ($annot instanceof AccessorOrder) {
+ $classMetadata->setAccessorOrder($annot->order, $annot->custom);
+ } elseif ($annot instanceof Discriminator) {
+ if ($annot->disabled) {
+ $classMetadata->discriminatorDisabled = true;
+ } else {
+ $classMetadata->setDiscriminator($annot->field, $annot->map, $annot->groups);
+ }
+ } elseif ($annot instanceof XmlDiscriminator) {
+ $classMetadata->xmlDiscriminatorAttribute = (bool)$annot->attribute;
+ $classMetadata->xmlDiscriminatorCData = (bool)$annot->cdata;
+ $classMetadata->xmlDiscriminatorNamespace = $annot->namespace ? (string)$annot->namespace : null;
+ } elseif ($annot instanceof VirtualProperty) {
+ $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, $annot->name, $annot->exp);
+ $propertiesMetadata[] = $virtualPropertyMetadata;
+ $propertiesAnnotations[] = $annot->options;
+ }
+ }
+
+ foreach ($class->getMethods() as $method) {
+ if ($method->class !== $name) {
+ continue;
+ }
+
+ $methodAnnotations = $this->reader->getMethodAnnotations($method);
+
+ foreach ($methodAnnotations as $annot) {
+ if ($annot instanceof PreSerialize) {
+ $classMetadata->addPreSerializeMethod(new MethodMetadata($name, $method->name));
+ continue 2;
+ } elseif ($annot instanceof PostDeserialize) {
+ $classMetadata->addPostDeserializeMethod(new MethodMetadata($name, $method->name));
+ continue 2;
+ } elseif ($annot instanceof PostSerialize) {
+ $classMetadata->addPostSerializeMethod(new MethodMetadata($name, $method->name));
+ continue 2;
+ } elseif ($annot instanceof VirtualProperty) {
+ $virtualPropertyMetadata = new VirtualPropertyMetadata($name, $method->name);
+ $propertiesMetadata[] = $virtualPropertyMetadata;
+ $propertiesAnnotations[] = $methodAnnotations;
+ continue 2;
+ } elseif ($annot instanceof HandlerCallback) {
+ $classMetadata->addHandlerCallback(GraphNavigator::parseDirection($annot->direction), $annot->format, $method->name);
+ continue 2;
+ }
+ }
+ }
+
+ if (!$excludeAll) {
+ foreach ($class->getProperties() as $property) {
+ if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) {
+ continue;
+ }
+ $propertiesMetadata[] = new PropertyMetadata($name, $property->getName());
+ $propertiesAnnotations[] = $this->reader->getPropertyAnnotations($property);
+ }
+
+ foreach ($propertiesMetadata as $propertyKey => $propertyMetadata) {
+ $isExclude = false;
+ $isExpose = $propertyMetadata instanceof VirtualPropertyMetadata
+ || $propertyMetadata instanceof ExpressionPropertyMetadata;
+ $propertyMetadata->readOnly = $propertyMetadata->readOnly || $readOnlyClass;
+ $accessType = $classAccessType;
+ $accessor = array(null, null);
+
+ $propertyAnnotations = $propertiesAnnotations[$propertyKey];
+
+ foreach ($propertyAnnotations as $annot) {
+ if ($annot instanceof Since) {
+ $propertyMetadata->sinceVersion = $annot->version;
+ } elseif ($annot instanceof Until) {
+ $propertyMetadata->untilVersion = $annot->version;
+ } elseif ($annot instanceof SerializedName) {
+ $propertyMetadata->serializedName = $annot->name;
+ } elseif ($annot instanceof SkipWhenEmpty) {
+ $propertyMetadata->skipWhenEmpty = true;
+ } elseif ($annot instanceof Expose) {
+ $isExpose = true;
+ if (null !== $annot->if) {
+ $propertyMetadata->excludeIf = "!(" . $annot->if . ")";
+ }
+ } elseif ($annot instanceof Exclude) {
+ if (null !== $annot->if) {
+ $propertyMetadata->excludeIf = $annot->if;
+ } else {
+ $isExclude = true;
+ }
+ } elseif ($annot instanceof Type) {
+ $propertyMetadata->setType($annot->name);
+ } elseif ($annot instanceof XmlElement) {
+ $propertyMetadata->xmlAttribute = false;
+ $propertyMetadata->xmlElementCData = $annot->cdata;
+ $propertyMetadata->xmlNamespace = $annot->namespace;
+ } elseif ($annot instanceof XmlList) {
+ $propertyMetadata->xmlCollection = true;
+ $propertyMetadata->xmlCollectionInline = $annot->inline;
+ $propertyMetadata->xmlEntryName = $annot->entry;
+ $propertyMetadata->xmlEntryNamespace = $annot->namespace;
+ $propertyMetadata->xmlCollectionSkipWhenEmpty = $annot->skipWhenEmpty;
+ } elseif ($annot instanceof XmlMap) {
+ $propertyMetadata->xmlCollection = true;
+ $propertyMetadata->xmlCollectionInline = $annot->inline;
+ $propertyMetadata->xmlEntryName = $annot->entry;
+ $propertyMetadata->xmlEntryNamespace = $annot->namespace;
+ $propertyMetadata->xmlKeyAttribute = $annot->keyAttribute;
+ } elseif ($annot instanceof XmlKeyValuePairs) {
+ $propertyMetadata->xmlKeyValuePairs = true;
+ } elseif ($annot instanceof XmlAttribute) {
+ $propertyMetadata->xmlAttribute = true;
+ $propertyMetadata->xmlNamespace = $annot->namespace;
+ } elseif ($annot instanceof XmlValue) {
+ $propertyMetadata->xmlValue = true;
+ $propertyMetadata->xmlElementCData = $annot->cdata;
+ } elseif ($annot instanceof XmlElement) {
+ $propertyMetadata->xmlElementCData = $annot->cdata;
+ } elseif ($annot instanceof AccessType) {
+ $accessType = $annot->type;
+ } elseif ($annot instanceof ReadOnly) {
+ $propertyMetadata->readOnly = $annot->readOnly;
+ } elseif ($annot instanceof Accessor) {
+ $accessor = array($annot->getter, $annot->setter);
+ } elseif ($annot instanceof Groups) {
+ $propertyMetadata->groups = $annot->groups;
+ foreach ((array)$propertyMetadata->groups as $groupName) {
+ if (false !== strpos($groupName, ',')) {
+ throw new InvalidArgumentException(sprintf(
+ 'Invalid group name "%s" on "%s", did you mean to create multiple groups?',
+ implode(', ', $propertyMetadata->groups),
+ $propertyMetadata->class . '->' . $propertyMetadata->name
+ ));
+ }
+ }
+ } elseif ($annot instanceof Inline) {
+ $propertyMetadata->inline = true;
+ } elseif ($annot instanceof XmlAttributeMap) {
+ $propertyMetadata->xmlAttributeMap = true;
+ } elseif ($annot instanceof MaxDepth) {
+ $propertyMetadata->maxDepth = $annot->depth;
+ }
+ }
+
+
+ if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude)
+ || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose)
+ ) {
+ $propertyMetadata->setAccessor($accessType, $accessor[0], $accessor[1]);
+ $classMetadata->addPropertyMetadata($propertyMetadata);
+ }
+ }
+ }
+
+ return $classMetadata;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata\Driver;
+
+use Doctrine\Common\Persistence\Mapping\ClassMetadata as DoctrineClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * This class decorates any other driver. If the inner driver does not provide a
+ * a property type, the decorator will guess based on Doctrine 2 metadata.
+ */
+class DoctrinePHPCRTypeDriver extends AbstractDoctrineTypeDriver
+{
+ /**
+ * @param DoctrineClassMetadata $doctrineMetadata
+ * @param PropertyMetadata $propertyMetadata
+ */
+ protected function hideProperty(DoctrineClassMetadata $doctrineMetadata, PropertyMetadata $propertyMetadata)
+ {
+ return 'lazyPropertiesDefaults' === $propertyMetadata->name
+ || $doctrineMetadata->parentMapping === $propertyMetadata->name
+ || $doctrineMetadata->node === $propertyMetadata->name;
+ }
+
+ protected function setPropertyType(DoctrineClassMetadata $doctrineMetadata, PropertyMetadata $propertyMetadata)
+ {
+ $propertyName = $propertyMetadata->name;
+ if ($doctrineMetadata->hasField($propertyName) && $fieldType = $this->normalizeFieldType($doctrineMetadata->getTypeOfField($propertyName))) {
+ $field = $doctrineMetadata->getFieldMapping($propertyName);
+ if (!empty($field['multivalue'])) {
+ $fieldType = 'array';
+ }
+
+ $propertyMetadata->setType($fieldType);
+ } elseif ($doctrineMetadata->hasAssociation($propertyName)) {
+ try {
+ $targetEntity = $doctrineMetadata->getAssociationTargetClass($propertyName);
+ } catch (\Exception $e) {
+ return;
+ }
+
+ if (null === $this->tryLoadingDoctrineMetadata($targetEntity)) {
+ return;
+ }
+
+ if (!$doctrineMetadata->isSingleValuedAssociation($propertyName)) {
+ $targetEntity = "ArrayCollection<{$targetEntity}>";
+ }
+
+ $propertyMetadata->setType($targetEntity);
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata\Driver;
+
+use Doctrine\Common\Persistence\Mapping\ClassMetadata as DoctrineClassMetadata;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * This class decorates any other driver. If the inner driver does not provide a
+ * a property type, the decorator will guess based on Doctrine 2 metadata.
+ */
+class DoctrineTypeDriver extends AbstractDoctrineTypeDriver
+{
+ protected function setDiscriminator(DoctrineClassMetadata $doctrineMetadata, ClassMetadata $classMetadata)
+ {
+ if (empty($classMetadata->discriminatorMap) && !$classMetadata->discriminatorDisabled
+ && !empty($doctrineMetadata->discriminatorMap) && $doctrineMetadata->isRootEntity()
+ ) {
+ $classMetadata->setDiscriminator(
+ $doctrineMetadata->discriminatorColumn['name'],
+ $doctrineMetadata->discriminatorMap
+ );
+ }
+ }
+
+ protected function setPropertyType(DoctrineClassMetadata $doctrineMetadata, PropertyMetadata $propertyMetadata)
+ {
+ $propertyName = $propertyMetadata->name;
+ if ($doctrineMetadata->hasField($propertyName) && $fieldType = $this->normalizeFieldType($doctrineMetadata->getTypeOfField($propertyName))) {
+ $propertyMetadata->setType($fieldType);
+ } elseif ($doctrineMetadata->hasAssociation($propertyName)) {
+ $targetEntity = $doctrineMetadata->getAssociationTargetClass($propertyName);
+
+ if (null === $targetMetadata = $this->tryLoadingDoctrineMetadata($targetEntity)) {
+ return;
+ }
+
+ // For inheritance schemes, we cannot add any type as we would only add the super-type of the hierarchy.
+ // On serialization, this would lead to only the supertype being serialized, and properties of subtypes
+ // being ignored.
+ if ($targetMetadata instanceof DoctrineClassMetadata && !$targetMetadata->isInheritanceTypeNone()) {
+ return;
+ }
+
+ if (!$doctrineMetadata->isSingleValuedAssociation($propertyName)) {
+ $targetEntity = "ArrayCollection<{$targetEntity}>";
+ }
+
+ $propertyMetadata->setType($targetEntity);
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata\Driver;
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use Metadata\Driver\DriverInterface;
+
+class NullDriver implements DriverInterface
+{
+ public function loadMetadataForClass(\ReflectionClass $class)
+ {
+ $classMetadata = new ClassMetadata($name = $class->name);
+ $classMetadata->fileResources[] = $class->getFilename();
+
+ return $classMetadata;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata\Driver;
+
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\Metadata\ClassMetadata;
+use Metadata\Driver\AbstractFileDriver;
+
+class PhpDriver extends AbstractFileDriver
+{
+ protected function loadMetadataFromFile(\ReflectionClass $class, $file)
+ {
+ $metadata = require $file;
+
+ if (!$metadata instanceof ClassMetadata) {
+ throw new RuntimeException(sprintf('The file %s was expected to return an instance of ClassMetadata, but returned %s.', $file, json_encode($metadata)));
+ }
+ if ($metadata->name !== $class->name) {
+ throw new RuntimeException(sprintf('The file %s was expected to return metadata for class %s, but instead returned metadata for class %s.', $class->name, $metadata->name));
+ }
+
+ return $metadata;
+ }
+
+ protected function getExtension()
+ {
+ return 'php';
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata\Driver;
+
+use JMS\Serializer\Annotation\ExclusionPolicy;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\Exception\XmlErrorException;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Metadata\VirtualPropertyMetadata;
+use Metadata\Driver\AbstractFileDriver;
+use Metadata\MethodMetadata;
+
+class XmlDriver extends AbstractFileDriver
+{
+ protected function loadMetadataFromFile(\ReflectionClass $class, $path)
+ {
+ $previous = libxml_use_internal_errors(true);
+ libxml_clear_errors();
+
+ $elem = simplexml_load_file($path);
+ libxml_use_internal_errors($previous);
+
+ if (false === $elem) {
+ throw new XmlErrorException(libxml_get_last_error());
+ }
+
+ $metadata = new ClassMetadata($name = $class->name);
+ if (!$elems = $elem->xpath("./class[@name = '" . $name . "']")) {
+ throw new RuntimeException(sprintf('Could not find class %s inside XML element.', $name));
+ }
+ $elem = reset($elems);
+
+ $metadata->fileResources[] = $path;
+ $metadata->fileResources[] = $class->getFileName();
+ $exclusionPolicy = strtoupper($elem->attributes()->{'exclusion-policy'}) ?: 'NONE';
+ $excludeAll = null !== ($exclude = $elem->attributes()->exclude) ? 'true' === strtolower($exclude) : false;
+ $classAccessType = (string)($elem->attributes()->{'access-type'} ?: PropertyMetadata::ACCESS_TYPE_PROPERTY);
+
+ $propertiesMetadata = array();
+ $propertiesNodes = array();
+
+ if (null !== $accessorOrder = $elem->attributes()->{'accessor-order'}) {
+ $metadata->setAccessorOrder((string)$accessorOrder, preg_split('/\s*,\s*/', (string)$elem->attributes()->{'custom-accessor-order'}));
+ }
+
+ if (null !== $xmlRootName = $elem->attributes()->{'xml-root-name'}) {
+ $metadata->xmlRootName = (string)$xmlRootName;
+ }
+
+ if (null !== $xmlRootNamespace = $elem->attributes()->{'xml-root-namespace'}) {
+ $metadata->xmlRootNamespace = (string)$xmlRootNamespace;
+ }
+
+ $readOnlyClass = 'true' === strtolower($elem->attributes()->{'read-only'});
+
+ $discriminatorFieldName = (string)$elem->attributes()->{'discriminator-field-name'};
+ $discriminatorMap = array();
+ foreach ($elem->xpath('./discriminator-class') as $entry) {
+ if (!isset($entry->attributes()->value)) {
+ throw new RuntimeException('Each discriminator-class element must have a "value" attribute.');
+ }
+
+ $discriminatorMap[(string)$entry->attributes()->value] = (string)$entry;
+ }
+
+ if ('true' === (string)$elem->attributes()->{'discriminator-disabled'}) {
+ $metadata->discriminatorDisabled = true;
+ } elseif (!empty($discriminatorFieldName) || !empty($discriminatorMap)) {
+
+ $discriminatorGroups = array();
+ foreach ($elem->xpath('./discriminator-groups/group') as $entry) {
+ $discriminatorGroups[] = (string)$entry;
+ }
+ $metadata->setDiscriminator($discriminatorFieldName, $discriminatorMap, $discriminatorGroups);
+ }
+
+ foreach ($elem->xpath('./xml-namespace') as $xmlNamespace) {
+ if (!isset($xmlNamespace->attributes()->uri)) {
+ throw new RuntimeException('The prefix attribute must be set for all xml-namespace elements.');
+ }
+
+ if (isset($xmlNamespace->attributes()->prefix)) {
+ $prefix = (string)$xmlNamespace->attributes()->prefix;
+ } else {
+ $prefix = null;
+ }
+
+ $metadata->registerNamespace((string)$xmlNamespace->attributes()->uri, $prefix);
+ }
+
+ foreach ($elem->xpath('./xml-discriminator') as $xmlDiscriminator) {
+ if (isset($xmlDiscriminator->attributes()->attribute)) {
+ $metadata->xmlDiscriminatorAttribute = (string)$xmlDiscriminator->attributes()->attribute === 'true';
+ }
+ if (isset($xmlDiscriminator->attributes()->cdata)) {
+ $metadata->xmlDiscriminatorCData = (string)$xmlDiscriminator->attributes()->cdata === 'true';
+ }
+ if (isset($xmlDiscriminator->attributes()->namespace)) {
+ $metadata->xmlDiscriminatorNamespace = (string)$xmlDiscriminator->attributes()->namespace;
+ }
+ }
+
+ foreach ($elem->xpath('./virtual-property') as $method) {
+
+ if (isset($method->attributes()->expression)) {
+ $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, (string)$method->attributes()->name, (string)$method->attributes()->expression);
+ } else {
+ if (!isset($method->attributes()->method)) {
+ throw new RuntimeException('The method attribute must be set for all virtual-property elements.');
+ }
+ $virtualPropertyMetadata = new VirtualPropertyMetadata($name, (string)$method->attributes()->method);
+ }
+
+ $propertiesMetadata[] = $virtualPropertyMetadata;
+ $propertiesNodes[] = $method;
+ }
+
+ if (!$excludeAll) {
+
+ foreach ($class->getProperties() as $property) {
+ if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) {
+ continue;
+ }
+
+ $propertiesMetadata[] = new PropertyMetadata($name, $pName = $property->getName());
+ $pElems = $elem->xpath("./property[@name = '" . $pName . "']");
+
+ $propertiesNodes[] = $pElems ? reset($pElems) : null;
+ }
+
+ foreach ($propertiesMetadata as $propertyKey => $pMetadata) {
+
+ $isExclude = false;
+ $isExpose = $pMetadata instanceof VirtualPropertyMetadata
+ || $pMetadata instanceof ExpressionPropertyMetadata;
+
+ $pElem = $propertiesNodes[$propertyKey];
+ if (!empty($pElem)) {
+
+ if (null !== $exclude = $pElem->attributes()->exclude) {
+ $isExclude = 'true' === strtolower($exclude);
+ }
+
+ if ($isExclude) {
+ continue;
+ }
+
+ if (null !== $expose = $pElem->attributes()->expose) {
+ $isExpose = 'true' === strtolower($expose);
+ }
+
+ if (null !== $excludeIf = $pElem->attributes()->{'exclude-if'}) {
+ $pMetadata->excludeIf = $excludeIf;
+ }
+
+ if (null !== $skip = $pElem->attributes()->{'skip-when-empty'}) {
+ $pMetadata->skipWhenEmpty = 'true' === strtolower($skip);
+ }
+
+ if (null !== $excludeIf = $pElem->attributes()->{'expose-if'}) {
+ $pMetadata->excludeIf = "!(" . $excludeIf . ")";
+ $isExpose = true;
+ }
+
+ if (null !== $version = $pElem->attributes()->{'since-version'}) {
+ $pMetadata->sinceVersion = (string)$version;
+ }
+
+ if (null !== $version = $pElem->attributes()->{'until-version'}) {
+ $pMetadata->untilVersion = (string)$version;
+ }
+
+ if (null !== $serializedName = $pElem->attributes()->{'serialized-name'}) {
+ $pMetadata->serializedName = (string)$serializedName;
+ }
+
+ if (null !== $type = $pElem->attributes()->type) {
+ $pMetadata->setType((string)$type);
+ } elseif (isset($pElem->type)) {
+ $pMetadata->setType((string)$pElem->type);
+ }
+
+ if (null !== $groups = $pElem->attributes()->groups) {
+ $pMetadata->groups = preg_split('/\s*,\s*/', (string) trim($groups));
+ } elseif (isset($pElem->groups)) {
+ $pMetadata->groups = (array) $pElem->groups->value;
+ }
+
+ if (isset($pElem->{'xml-list'})) {
+
+ $pMetadata->xmlCollection = true;
+
+ $colConfig = $pElem->{'xml-list'};
+ if (isset($colConfig->attributes()->inline)) {
+ $pMetadata->xmlCollectionInline = 'true' === (string)$colConfig->attributes()->inline;
+ }
+
+ if (isset($colConfig->attributes()->{'entry-name'})) {
+ $pMetadata->xmlEntryName = (string)$colConfig->attributes()->{'entry-name'};
+ }
+
+ if (isset($colConfig->attributes()->{'skip-when-empty'})) {
+ $pMetadata->xmlCollectionSkipWhenEmpty = 'true' === (string)$colConfig->attributes()->{'skip-when-empty'};
+ } else {
+ $pMetadata->xmlCollectionSkipWhenEmpty = true;
+ }
+
+ if (isset($colConfig->attributes()->namespace)) {
+ $pMetadata->xmlEntryNamespace = (string)$colConfig->attributes()->namespace;
+ }
+ }
+
+ if (isset($pElem->{'xml-map'})) {
+ $pMetadata->xmlCollection = true;
+
+ $colConfig = $pElem->{'xml-map'};
+ if (isset($colConfig->attributes()->inline)) {
+ $pMetadata->xmlCollectionInline = 'true' === (string)$colConfig->attributes()->inline;
+ }
+
+ if (isset($colConfig->attributes()->{'entry-name'})) {
+ $pMetadata->xmlEntryName = (string)$colConfig->attributes()->{'entry-name'};
+ }
+
+ if (isset($colConfig->attributes()->namespace)) {
+ $pMetadata->xmlEntryNamespace = (string)$colConfig->attributes()->namespace;
+ }
+
+ if (isset($colConfig->attributes()->{'key-attribute-name'})) {
+ $pMetadata->xmlKeyAttribute = (string)$colConfig->attributes()->{'key-attribute-name'};
+ }
+ }
+
+ if (isset($pElem->{'xml-element'})) {
+ $colConfig = $pElem->{'xml-element'};
+ if (isset($colConfig->attributes()->cdata)) {
+ $pMetadata->xmlElementCData = 'true' === (string)$colConfig->attributes()->cdata;
+ }
+
+ if (isset($colConfig->attributes()->namespace)) {
+ $pMetadata->xmlNamespace = (string)$colConfig->attributes()->namespace;
+ }
+ }
+
+ if (isset($pElem->attributes()->{'xml-attribute'})) {
+ $pMetadata->xmlAttribute = 'true' === (string)$pElem->attributes()->{'xml-attribute'};
+ }
+
+ if (isset($pElem->attributes()->{'xml-attribute-map'})) {
+ $pMetadata->xmlAttributeMap = 'true' === (string)$pElem->attributes()->{'xml-attribute-map'};
+ }
+
+ if (isset($pElem->attributes()->{'xml-value'})) {
+ $pMetadata->xmlValue = 'true' === (string)$pElem->attributes()->{'xml-value'};
+ }
+
+ if (isset($pElem->attributes()->{'xml-key-value-pairs'})) {
+ $pMetadata->xmlKeyValuePairs = 'true' === (string)$pElem->attributes()->{'xml-key-value-pairs'};
+ }
+
+ if (isset($pElem->attributes()->{'max-depth'})) {
+ $pMetadata->maxDepth = (int)$pElem->attributes()->{'max-depth'};
+ }
+
+ //we need read-only before setter and getter set, because that method depends on flag being set
+ if (null !== $readOnly = $pElem->attributes()->{'read-only'}) {
+ $pMetadata->readOnly = 'true' === strtolower($readOnly);
+ } else {
+ $pMetadata->readOnly = $pMetadata->readOnly || $readOnlyClass;
+ }
+
+ $getter = $pElem->attributes()->{'accessor-getter'};
+ $setter = $pElem->attributes()->{'accessor-setter'};
+ $pMetadata->setAccessor(
+ (string)($pElem->attributes()->{'access-type'} ?: $classAccessType),
+ $getter ? (string)$getter : null,
+ $setter ? (string)$setter : null
+ );
+
+ if (null !== $inline = $pElem->attributes()->inline) {
+ $pMetadata->inline = 'true' === strtolower($inline);
+ }
+
+ }
+
+ if ((ExclusionPolicy::NONE === (string)$exclusionPolicy && !$isExclude)
+ || (ExclusionPolicy::ALL === (string)$exclusionPolicy && $isExpose)
+ ) {
+
+ $metadata->addPropertyMetadata($pMetadata);
+ }
+ }
+ }
+
+ foreach ($elem->xpath('./callback-method') as $method) {
+ if (!isset($method->attributes()->type)) {
+ throw new RuntimeException('The type attribute must be set for all callback-method elements.');
+ }
+ if (!isset($method->attributes()->name)) {
+ throw new RuntimeException('The name attribute must be set for all callback-method elements.');
+ }
+
+ switch ((string)$method->attributes()->type) {
+ case 'pre-serialize':
+ $metadata->addPreSerializeMethod(new MethodMetadata($name, (string)$method->attributes()->name));
+ break;
+
+ case 'post-serialize':
+ $metadata->addPostSerializeMethod(new MethodMetadata($name, (string)$method->attributes()->name));
+ break;
+
+ case 'post-deserialize':
+ $metadata->addPostDeserializeMethod(new MethodMetadata($name, (string)$method->attributes()->name));
+ break;
+
+ case 'handler':
+ if (!isset($method->attributes()->format)) {
+ throw new RuntimeException('The format attribute must be set for "handler" callback methods.');
+ }
+ if (!isset($method->attributes()->direction)) {
+ throw new RuntimeException('The direction attribute must be set for "handler" callback methods.');
+ }
+
+ $direction = GraphNavigator::parseDirection((string)$method->attributes()->direction);
+ $format = (string)$method->attributes()->format;
+ $metadata->addHandlerCallback($direction, $format, (string)$method->attributes()->name);
+
+ break;
+
+ default:
+ throw new RuntimeException(sprintf('The type "%s" is not supported.', $method->attributes()->name));
+ }
+ }
+
+ return $metadata;
+ }
+
+ protected function getExtension()
+ {
+ return 'xml';
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata\Driver;
+
+use JMS\Serializer\Annotation\ExclusionPolicy;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Metadata\VirtualPropertyMetadata;
+use Metadata\Driver\AbstractFileDriver;
+use Metadata\MethodMetadata;
+use Symfony\Component\Yaml\Yaml;
+
+class YamlDriver extends AbstractFileDriver
+{
+ protected function loadMetadataFromFile(\ReflectionClass $class, $file)
+ {
+ $config = Yaml::parse(file_get_contents($file));
+
+ if (!isset($config[$name = $class->name])) {
+ throw new RuntimeException(sprintf('Expected metadata for class %s to be defined in %s.', $class->name, $file));
+ }
+
+ $config = $config[$name];
+ $metadata = new ClassMetadata($name);
+ $metadata->fileResources[] = $file;
+ $metadata->fileResources[] = $class->getFileName();
+ $exclusionPolicy = isset($config['exclusion_policy']) ? strtoupper($config['exclusion_policy']) : 'NONE';
+ $excludeAll = isset($config['exclude']) ? (Boolean)$config['exclude'] : false;
+ $classAccessType = isset($config['access_type']) ? $config['access_type'] : PropertyMetadata::ACCESS_TYPE_PROPERTY;
+ $readOnlyClass = isset($config['read_only']) ? (Boolean)$config['read_only'] : false;
+ $this->addClassProperties($metadata, $config);
+
+ $propertiesMetadata = array();
+ if (array_key_exists('virtual_properties', $config)) {
+ foreach ($config['virtual_properties'] as $methodName => $propertySettings) {
+ if (isset($propertySettings['exp'])) {
+ $virtualPropertyMetadata = new ExpressionPropertyMetadata($name, $methodName, $propertySettings['exp']);
+ unset($propertySettings['exp']);
+
+ } else {
+
+ if (!$class->hasMethod($methodName)) {
+ throw new RuntimeException('The method ' . $methodName . ' not found in class ' . $class->name);
+ }
+ $virtualPropertyMetadata = new VirtualPropertyMetadata($name, $methodName);
+ }
+ $propertiesMetadata[$methodName] = $virtualPropertyMetadata;
+ $config['properties'][$methodName] = $propertySettings;
+ }
+ }
+
+ if (!$excludeAll) {
+ foreach ($class->getProperties() as $property) {
+ if ($property->class !== $name || (isset($property->info) && $property->info['class'] !== $name)) {
+ continue;
+ }
+
+ $pName = $property->getName();
+ $propertiesMetadata[$pName] = new PropertyMetadata($name, $pName);
+ }
+
+ foreach ($propertiesMetadata as $pName => $pMetadata) {
+ $isExclude = false;
+ $isExpose = $pMetadata instanceof VirtualPropertyMetadata
+ || $pMetadata instanceof ExpressionPropertyMetadata
+ || (isset($config['properties']) && array_key_exists($pName, $config['properties']));
+
+ if (isset($config['properties'][$pName])) {
+ $pConfig = $config['properties'][$pName];
+
+ if (isset($pConfig['exclude'])) {
+ $isExclude = (Boolean)$pConfig['exclude'];
+ }
+
+ if ($isExclude) {
+ continue;
+ }
+
+ if (isset($pConfig['expose'])) {
+ $isExpose = (Boolean)$pConfig['expose'];
+ }
+
+ if (isset($pConfig['skip_when_empty'])) {
+ $pMetadata->skipWhenEmpty = (Boolean)$pConfig['skip_when_empty'];
+ }
+
+ if (isset($pConfig['since_version'])) {
+ $pMetadata->sinceVersion = (string)$pConfig['since_version'];
+ }
+
+ if (isset($pConfig['until_version'])) {
+ $pMetadata->untilVersion = (string)$pConfig['until_version'];
+ }
+
+ if (isset($pConfig['exclude_if'])) {
+ $pMetadata->excludeIf = (string)$pConfig['exclude_if'];
+ }
+
+ if (isset($pConfig['expose_if'])) {
+ $pMetadata->excludeIf = "!(" . $pConfig['expose_if'] . ")";
+ }
+
+ if (isset($pConfig['serialized_name'])) {
+ $pMetadata->serializedName = (string)$pConfig['serialized_name'];
+ }
+
+ if (isset($pConfig['type'])) {
+ $pMetadata->setType((string)$pConfig['type']);
+ }
+
+ if (isset($pConfig['groups'])) {
+ $pMetadata->groups = $pConfig['groups'];
+ }
+
+ if (isset($pConfig['xml_list'])) {
+ $pMetadata->xmlCollection = true;
+
+ $colConfig = $pConfig['xml_list'];
+ if (isset($colConfig['inline'])) {
+ $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline'];
+ }
+
+ if (isset($colConfig['entry_name'])) {
+ $pMetadata->xmlEntryName = (string)$colConfig['entry_name'];
+ }
+
+ if (isset($colConfig['skip_when_empty'])) {
+ $pMetadata->xmlCollectionSkipWhenEmpty = (Boolean)$colConfig['skip_when_empty'];
+ } else {
+ $pMetadata->xmlCollectionSkipWhenEmpty = true;
+ }
+
+ if (isset($colConfig['namespace'])) {
+ $pMetadata->xmlEntryNamespace = (string)$colConfig['namespace'];
+ }
+ }
+
+ if (isset($pConfig['xml_map'])) {
+ $pMetadata->xmlCollection = true;
+
+ $colConfig = $pConfig['xml_map'];
+ if (isset($colConfig['inline'])) {
+ $pMetadata->xmlCollectionInline = (Boolean)$colConfig['inline'];
+ }
+
+ if (isset($colConfig['entry_name'])) {
+ $pMetadata->xmlEntryName = (string)$colConfig['entry_name'];
+ }
+
+ if (isset($colConfig['namespace'])) {
+ $pMetadata->xmlEntryNamespace = (string)$colConfig['namespace'];
+ }
+
+ if (isset($colConfig['key_attribute_name'])) {
+ $pMetadata->xmlKeyAttribute = $colConfig['key_attribute_name'];
+ }
+
+ }
+
+ if (isset($pConfig['xml_element'])) {
+ $colConfig = $pConfig['xml_element'];
+ if (isset($colConfig['cdata'])) {
+ $pMetadata->xmlElementCData = (Boolean)$colConfig['cdata'];
+ }
+
+ if (isset($colConfig['namespace'])) {
+ $pMetadata->xmlNamespace = (string)$colConfig['namespace'];
+ }
+ }
+
+ if (isset($pConfig['xml_attribute'])) {
+ $pMetadata->xmlAttribute = (Boolean)$pConfig['xml_attribute'];
+ }
+
+ if (isset($pConfig['xml_attribute_map'])) {
+ $pMetadata->xmlAttributeMap = (Boolean)$pConfig['xml_attribute_map'];
+ }
+
+ if (isset($pConfig['xml_value'])) {
+ $pMetadata->xmlValue = (Boolean)$pConfig['xml_value'];
+ }
+
+ if (isset($pConfig['xml_key_value_pairs'])) {
+ $pMetadata->xmlKeyValuePairs = (Boolean)$pConfig['xml_key_value_pairs'];
+ }
+
+ //we need read_only before setter and getter set, because that method depends on flag being set
+ if (isset($pConfig['read_only'])) {
+ $pMetadata->readOnly = (Boolean)$pConfig['read_only'];
+ } else {
+ $pMetadata->readOnly = $pMetadata->readOnly || $readOnlyClass;
+ }
+
+ $pMetadata->setAccessor(
+ isset($pConfig['access_type']) ? $pConfig['access_type'] : $classAccessType,
+ isset($pConfig['accessor']['getter']) ? $pConfig['accessor']['getter'] : null,
+ isset($pConfig['accessor']['setter']) ? $pConfig['accessor']['setter'] : null
+ );
+
+ if (isset($pConfig['inline'])) {
+ $pMetadata->inline = (Boolean)$pConfig['inline'];
+ }
+
+ if (isset($pConfig['max_depth'])) {
+ $pMetadata->maxDepth = (int)$pConfig['max_depth'];
+ }
+ }
+ if ((ExclusionPolicy::NONE === $exclusionPolicy && !$isExclude)
+ || (ExclusionPolicy::ALL === $exclusionPolicy && $isExpose)
+ ) {
+ $metadata->addPropertyMetadata($pMetadata);
+ }
+ }
+ }
+
+ if (isset($config['handler_callbacks'])) {
+ foreach ($config['handler_callbacks'] as $directionName => $formats) {
+ $direction = GraphNavigator::parseDirection($directionName);
+ foreach ($formats as $format => $methodName) {
+ $metadata->addHandlerCallback($direction, $format, $methodName);
+ }
+ }
+ }
+
+ if (isset($config['callback_methods'])) {
+ $cConfig = $config['callback_methods'];
+
+ if (isset($cConfig['pre_serialize'])) {
+ $metadata->preSerializeMethods = $this->getCallbackMetadata($class, $cConfig['pre_serialize']);
+ }
+ if (isset($cConfig['post_serialize'])) {
+ $metadata->postSerializeMethods = $this->getCallbackMetadata($class, $cConfig['post_serialize']);
+ }
+ if (isset($cConfig['post_deserialize'])) {
+ $metadata->postDeserializeMethods = $this->getCallbackMetadata($class, $cConfig['post_deserialize']);
+ }
+ }
+
+ return $metadata;
+ }
+
+ protected function getExtension()
+ {
+ return 'yml';
+ }
+
+ private function addClassProperties(ClassMetadata $metadata, array $config)
+ {
+ if (isset($config['custom_accessor_order']) && !isset($config['accessor_order'])) {
+ $config['accessor_order'] = 'custom';
+ }
+
+ if (isset($config['accessor_order'])) {
+ $metadata->setAccessorOrder($config['accessor_order'], isset($config['custom_accessor_order']) ? $config['custom_accessor_order'] : array());
+ }
+
+ if (isset($config['xml_root_name'])) {
+ $metadata->xmlRootName = (string)$config['xml_root_name'];
+ }
+
+ if (isset($config['xml_root_namespace'])) {
+ $metadata->xmlRootNamespace = (string)$config['xml_root_namespace'];
+ }
+
+ if (array_key_exists('xml_namespaces', $config)) {
+
+ foreach ($config['xml_namespaces'] as $prefix => $uri) {
+ $metadata->registerNamespace($uri, $prefix);
+ }
+
+ }
+
+ if (isset($config['discriminator'])) {
+ if (isset($config['discriminator']['disabled']) && true === $config['discriminator']['disabled']) {
+ $metadata->discriminatorDisabled = true;
+ } else {
+ if (!isset($config['discriminator']['field_name'])) {
+ throw new RuntimeException('The "field_name" attribute must be set for discriminators.');
+ }
+
+ if (!isset($config['discriminator']['map']) || !is_array($config['discriminator']['map'])) {
+ throw new RuntimeException('The "map" attribute must be set, and be an array for discriminators.');
+ }
+ $groups = isset($config['discriminator']['groups']) ? $config['discriminator']['groups'] : array();
+ $metadata->setDiscriminator($config['discriminator']['field_name'], $config['discriminator']['map'], $groups);
+
+ if (isset($config['discriminator']['xml_attribute'])) {
+ $metadata->xmlDiscriminatorAttribute = (bool)$config['discriminator']['xml_attribute'];
+ }
+ if (isset($config['discriminator']['xml_element'])) {
+ if (isset($config['discriminator']['xml_element']['cdata'])) {
+ $metadata->xmlDiscriminatorCData = (bool)$config['discriminator']['xml_element']['cdata'];
+ }
+ if (isset($config['discriminator']['xml_element']['namespace'])) {
+ $metadata->xmlDiscriminatorNamespace = (string)$config['discriminator']['xml_element']['namespace'];
+ }
+ }
+
+ }
+ }
+ }
+
+ private function getCallbackMetadata(\ReflectionClass $class, $config)
+ {
+ if (is_string($config)) {
+ $config = array($config);
+ } elseif (!is_array($config)) {
+ throw new RuntimeException(sprintf('callback methods expects a string, or an array of strings that represent method names, but got %s.', json_encode($config['pre_serialize'])));
+ }
+
+ $methods = array();
+ foreach ($config as $name) {
+ if (!$class->hasMethod($name)) {
+ throw new RuntimeException(sprintf('The method %s does not exist in class %s.', $name, $class->name));
+ }
+
+ $methods[] = new MethodMetadata($class->name, $name);
+ }
+
+ return $methods;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata;
+
+use JMS\Serializer\Exception\ExpressionLanguageRequiredException;
+
+/**
+ * @Annotation
+ * @Target("METHOD")
+ *
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+class ExpressionPropertyMetadata extends PropertyMetadata
+{
+ /**
+ * @var string
+ */
+ public $expression;
+
+ public function __construct($class, $fieldName, $expression)
+ {
+ $this->class = $class;
+ $this->name = $fieldName;
+ $this->expression = $expression;
+ $this->readOnly = true;
+ }
+
+ public function setAccessor($type, $getter = null, $setter = null)
+ {
+ }
+
+ /**
+ * @param object $object
+ * @return mixed
+ */
+ public function getValue($object)
+ {
+ throw new ExpressionLanguageRequiredException(sprintf('The property %s on %s requires the expression accessor strategy to be enabled.', $this->name, $this->class));
+ }
+
+ public function setValue($obj, $value)
+ {
+ throw new \LogicException('ExpressionPropertyMetadata is immutable.');
+ }
+
+ public function serialize()
+ {
+ return serialize(array(
+ $this->sinceVersion,
+ $this->untilVersion,
+ $this->groups,
+ $this->serializedName,
+ $this->type,
+ $this->xmlCollection,
+ $this->xmlCollectionInline,
+ $this->xmlEntryName,
+ $this->xmlKeyAttribute,
+ $this->xmlAttribute,
+ $this->xmlValue,
+ $this->xmlNamespace,
+ $this->xmlKeyValuePairs,
+ $this->xmlElementCData,
+ $this->xmlAttributeMap,
+ $this->maxDepth,
+ $this->getter,
+ $this->setter,
+ $this->inline,
+ $this->readOnly,
+ $this->class,
+ $this->name,
+ 'excludeIf' => $this->excludeIf,
+ 'expression' => $this->expression,
+ ));
+ }
+
+ public function unserialize($str)
+ {
+ $unserialized = unserialize($str);
+ list(
+ $this->sinceVersion,
+ $this->untilVersion,
+ $this->groups,
+ $this->serializedName,
+ $this->type,
+ $this->xmlCollection,
+ $this->xmlCollectionInline,
+ $this->xmlEntryName,
+ $this->xmlKeyAttribute,
+ $this->xmlAttribute,
+ $this->xmlValue,
+ $this->xmlNamespace,
+ $this->xmlKeyValuePairs,
+ $this->xmlElementCData,
+ $this->xmlAttributeMap,
+ $this->maxDepth,
+ $this->getter,
+ $this->setter,
+ $this->inline,
+ $this->readOnly,
+ $this->class,
+ $this->name
+ ) = $unserialized;
+
+ if (isset($unserialized['excludeIf'])) {
+ $this->excludeIf = $unserialized['excludeIf'];
+ }
+ if (isset($unserialized['expression'])) {
+ $this->expression = $unserialized['expression'];
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata;
+
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\TypeParser;
+use Metadata\PropertyMetadata as BasePropertyMetadata;
+
+class PropertyMetadata extends BasePropertyMetadata
+{
+ const ACCESS_TYPE_PROPERTY = 'property';
+ const ACCESS_TYPE_PUBLIC_METHOD = 'public_method';
+
+ public $sinceVersion;
+ public $untilVersion;
+ public $groups;
+ public $serializedName;
+ public $type;
+ public $xmlCollection = false;
+ public $xmlCollectionInline = false;
+ public $xmlCollectionSkipWhenEmpty = true;
+ public $xmlEntryName;
+ public $xmlEntryNamespace;
+ public $xmlKeyAttribute;
+ public $xmlAttribute = false;
+ public $xmlValue = false;
+ public $xmlNamespace;
+ public $xmlKeyValuePairs = false;
+ public $xmlElementCData = true;
+ public $getter;
+ public $setter;
+ public $inline = false;
+ public $skipWhenEmpty = false;
+ public $readOnly = false;
+ public $xmlAttributeMap = false;
+ public $maxDepth = null;
+ public $excludeIf = null;
+
+ private static $typeParser;
+
+ public function setAccessor($type, $getter = null, $setter = null)
+ {
+ if (self::ACCESS_TYPE_PUBLIC_METHOD === $type) {
+ $class = $this->reflection->getDeclaringClass();
+
+ if (empty($getter)) {
+ if ($class->hasMethod('get' . $this->name) && $class->getMethod('get' . $this->name)->isPublic()) {
+ $getter = 'get' . $this->name;
+ } elseif ($class->hasMethod('is' . $this->name) && $class->getMethod('is' . $this->name)->isPublic()) {
+ $getter = 'is' . $this->name;
+ } elseif ($class->hasMethod('has' . $this->name) && $class->getMethod('has' . $this->name)->isPublic()) {
+ $getter = 'has' . $this->name;
+ } else {
+ throw new RuntimeException(sprintf('There is neither a public %s method, nor a public %s method, nor a public %s method in class %s. Please specify which public method should be used for retrieving the value of the property %s.', 'get' . ucfirst($this->name), 'is' . ucfirst($this->name), 'has' . ucfirst($this->name), $this->class, $this->name));
+ }
+ }
+
+ if (empty($setter) && !$this->readOnly) {
+ if ($class->hasMethod('set' . $this->name) && $class->getMethod('set' . $this->name)->isPublic()) {
+ $setter = 'set' . $this->name;
+ } else {
+ throw new RuntimeException(sprintf('There is no public %s method in class %s. Please specify which public method should be used for setting the value of the property %s.', 'set' . ucfirst($this->name), $this->class, $this->name));
+ }
+ }
+ }
+
+ $this->getter = $getter;
+ $this->setter = $setter;
+ }
+
+ public function getValue($obj)
+ {
+ if (null === $this->getter) {
+ return parent::getValue($obj);
+ }
+
+ return $obj->{$this->getter}();
+ }
+
+ public function setValue($obj, $value)
+ {
+ if (null === $this->setter) {
+ parent::setValue($obj, $value);
+ return;
+ }
+
+ $obj->{$this->setter}($value);
+ }
+
+ public function setType($type)
+ {
+ if (null === self::$typeParser) {
+ self::$typeParser = new TypeParser();
+ }
+
+ $this->type = self::$typeParser->parse($type);
+ }
+
+ public function serialize()
+ {
+ return serialize(array(
+ $this->sinceVersion,
+ $this->untilVersion,
+ $this->groups,
+ $this->serializedName,
+ $this->type,
+ $this->xmlCollection,
+ $this->xmlCollectionInline,
+ $this->xmlEntryName,
+ $this->xmlKeyAttribute,
+ $this->xmlAttribute,
+ $this->xmlValue,
+ $this->xmlNamespace,
+ $this->xmlKeyValuePairs,
+ $this->xmlElementCData,
+ $this->getter,
+ $this->setter,
+ $this->inline,
+ $this->readOnly,
+ $this->xmlAttributeMap,
+ $this->maxDepth,
+ parent::serialize(),
+ 'xmlEntryNamespace' => $this->xmlEntryNamespace,
+ 'xmlCollectionSkipWhenEmpty' => $this->xmlCollectionSkipWhenEmpty,
+ 'excludeIf' => $this->excludeIf,
+ 'skipWhenEmpty' => $this->skipWhenEmpty,
+ ));
+ }
+
+ public function unserialize($str)
+ {
+ $unserialized = unserialize($str);
+ list(
+ $this->sinceVersion,
+ $this->untilVersion,
+ $this->groups,
+ $this->serializedName,
+ $this->type,
+ $this->xmlCollection,
+ $this->xmlCollectionInline,
+ $this->xmlEntryName,
+ $this->xmlKeyAttribute,
+ $this->xmlAttribute,
+ $this->xmlValue,
+ $this->xmlNamespace,
+ $this->xmlKeyValuePairs,
+ $this->xmlElementCData,
+ $this->getter,
+ $this->setter,
+ $this->inline,
+ $this->readOnly,
+ $this->xmlAttributeMap,
+ $this->maxDepth,
+ $parentStr
+ ) = $unserialized;
+
+ if (isset($unserialized['xmlEntryNamespace'])) {
+ $this->xmlEntryNamespace = $unserialized['xmlEntryNamespace'];
+ }
+ if (isset($unserialized['xmlCollectionSkipWhenEmpty'])) {
+ $this->xmlCollectionSkipWhenEmpty = $unserialized['xmlCollectionSkipWhenEmpty'];
+ }
+ if (isset($unserialized['excludeIf'])) {
+ $this->excludeIf = $unserialized['excludeIf'];
+ }
+ if (isset($unserialized['skipWhenEmpty'])) {
+ $this->skipWhenEmpty = $unserialized['skipWhenEmpty'];
+ }
+
+ parent::unserialize($parentStr);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata;
+
+class StaticPropertyMetadata extends PropertyMetadata
+{
+ private $value;
+
+ public function __construct($className, $fieldName, $fieldValue, array $groups = array())
+ {
+ $this->class = $className;
+ $this->name = $fieldName;
+ $this->value = $fieldValue;
+ $this->readOnly = true;
+ $this->groups = $groups;
+ }
+
+ public function getValue($obj)
+ {
+ return $this->value;
+ }
+
+ public function setValue($obj, $value)
+ {
+ throw new \LogicException('StaticPropertyMetadata is immutable.');
+ }
+
+ public function setAccessor($type, $getter = null, $setter = null)
+ {
+ }
+
+ public function serialize()
+ {
+ return serialize(array(
+ $this->sinceVersion,
+ $this->untilVersion,
+ $this->groups,
+ $this->serializedName,
+ $this->type,
+ $this->xmlCollection,
+ $this->xmlCollectionInline,
+ $this->xmlEntryName,
+ $this->xmlKeyAttribute,
+ $this->xmlAttribute,
+ $this->xmlValue,
+ $this->xmlNamespace,
+ $this->xmlKeyValuePairs,
+ $this->xmlElementCData,
+ $this->getter,
+ $this->setter,
+ $this->inline,
+ $this->readOnly,
+ $this->class,
+ $this->name,
+ $this->value
+ ));
+ }
+
+ public function unserialize($str)
+ {
+ list(
+ $this->sinceVersion,
+ $this->untilVersion,
+ $this->groups,
+ $this->serializedName,
+ $this->type,
+ $this->xmlCollection,
+ $this->xmlCollectionInline,
+ $this->xmlEntryName,
+ $this->xmlKeyAttribute,
+ $this->xmlAttribute,
+ $this->xmlValue,
+ $this->xmlNamespace,
+ $this->xmlKeyValuePairs,
+ $this->xmlElementCData,
+ $this->getter,
+ $this->setter,
+ $this->inline,
+ $this->readOnly,
+ $this->class,
+ $this->name,
+ $this->value
+ ) = unserialize($str);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Metadata;
+
+class VirtualPropertyMetadata extends PropertyMetadata
+{
+ public function __construct($class, $methodName)
+ {
+ if (0 === strpos($methodName, 'get')) {
+ $fieldName = lcfirst(substr($methodName, 3));
+ } else {
+ $fieldName = $methodName;
+ }
+
+ $this->class = $class;
+ $this->name = $fieldName;
+ $this->getter = $methodName;
+ $this->readOnly = true;
+ }
+
+ public function setValue($obj, $value)
+ {
+ throw new \LogicException('VirtualPropertyMetadata is immutable.');
+ }
+
+ public function setAccessor($type, $getter = null, $setter = null)
+ {
+ }
+
+ public function serialize()
+ {
+ return serialize(array(
+ $this->sinceVersion,
+ $this->untilVersion,
+ $this->groups,
+ $this->serializedName,
+ $this->type,
+ $this->xmlCollection,
+ $this->xmlCollectionInline,
+ $this->xmlEntryName,
+ $this->xmlKeyAttribute,
+ $this->xmlAttribute,
+ $this->xmlValue,
+ $this->xmlNamespace,
+ $this->xmlKeyValuePairs,
+ $this->xmlElementCData,
+ $this->xmlAttributeMap,
+ $this->maxDepth,
+ $this->getter,
+ $this->setter,
+ $this->inline,
+ $this->readOnly,
+ $this->class,
+ $this->name,
+ 'excludeIf' => $this->excludeIf,
+ ));
+ }
+
+ public function unserialize($str)
+ {
+ $unserialized = unserialize($str);
+ list(
+ $this->sinceVersion,
+ $this->untilVersion,
+ $this->groups,
+ $this->serializedName,
+ $this->type,
+ $this->xmlCollection,
+ $this->xmlCollectionInline,
+ $this->xmlEntryName,
+ $this->xmlKeyAttribute,
+ $this->xmlAttribute,
+ $this->xmlValue,
+ $this->xmlNamespace,
+ $this->xmlKeyValuePairs,
+ $this->xmlElementCData,
+ $this->xmlAttributeMap,
+ $this->maxDepth,
+ $this->getter,
+ $this->setter,
+ $this->inline,
+ $this->readOnly,
+ $this->class,
+ $this->name
+ ) = $unserialized;
+
+ if (isset($unserialized['excludeIf'])) {
+ $this->excludeIf = $unserialized['excludeIf'];
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Naming;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * Interface for advanced property naming strategies.
+ *
+ * Implementations translate the property name to a serialized name that is
+ * displayed. It allows advanced strategy thanks to context parameter.
+ *
+ * @author Vincent Rasquier <vincent.rsbs@gmail.com>
+ */
+interface AdvancedNamingStrategyInterface
+{
+ /**
+ * Translates the name of the property to the serialized version.
+ *
+ * @param PropertyMetadata $property
+ * @param Context $context
+ *
+ * @return string
+ */
+ public function getPropertyName(PropertyMetadata $property, Context $context);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Naming;
+
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+class CacheNamingStrategy implements PropertyNamingStrategyInterface
+{
+ private $delegate;
+ private $cache;
+
+ public function __construct(PropertyNamingStrategyInterface $delegate)
+ {
+ $this->delegate = $delegate;
+ $this->cache = new \SplObjectStorage();
+ }
+
+ public function translateName(PropertyMetadata $property)
+ {
+ if (isset($this->cache[$property])) {
+ return $this->cache[$property];
+ }
+
+ return $this->cache[$property] = $this->delegate->translateName($property);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Naming;
+
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * Generic naming strategy which translates a camel-cased property name.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class CamelCaseNamingStrategy implements PropertyNamingStrategyInterface
+{
+ private $separator;
+ private $lowerCase;
+
+ public function __construct($separator = '_', $lowerCase = true)
+ {
+ $this->separator = $separator;
+ $this->lowerCase = $lowerCase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function translateName(PropertyMetadata $property)
+ {
+ $name = preg_replace('/[A-Z]/', $this->separator . '\\0', $property->name);
+
+ if ($this->lowerCase) {
+ return strtolower($name);
+ }
+
+ return ucfirst($name);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Naming;
+
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+class IdenticalPropertyNamingStrategy implements PropertyNamingStrategyInterface
+{
+ public function translateName(PropertyMetadata $property)
+ {
+ return $property->name;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Naming;
+
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * Interface for property naming strategies.
+ *
+ * Implementations translate the property name to a serialized name that is
+ * displayed.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface PropertyNamingStrategyInterface
+{
+ /**
+ * Translates the name of the property to the serialized version.
+ *
+ * @param PropertyMetadata $property
+ *
+ * @return string
+ */
+ public function translateName(PropertyMetadata $property);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Naming;
+
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * Naming strategy which uses an annotation to translate the property name.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class SerializedNameAnnotationStrategy implements PropertyNamingStrategyInterface
+{
+ private $delegate;
+
+ public function __construct(PropertyNamingStrategyInterface $namingStrategy)
+ {
+ $this->delegate = $namingStrategy;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function translateName(PropertyMetadata $property)
+ {
+ if (null !== $name = $property->serializedName) {
+ return $name;
+ }
+
+ return $this->delegate->translateName($property);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+interface NullAwareVisitorInterface extends VisitorInterface
+{
+ /**
+ * Determine if a value conveys a null value.
+ * An example could be an xml element (Dom, SimpleXml, ...) that is tagged with a xsi:nil attribute
+ *
+ * @param mixed $value
+ *
+ * @return bool
+ */
+ public function isNull($value);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Exception\RuntimeException;
+use Metadata\MetadataFactoryInterface;
+
+class SerializationContext extends Context
+{
+ /** @var \SplObjectStorage */
+ private $visitingSet;
+
+ /** @var \SplStack */
+ private $visitingStack;
+
+ /**
+ * @var string
+ */
+ private $initialType;
+
+ public static function create()
+ {
+ return new self();
+ }
+
+ /**
+ * @param string $format
+ */
+ public function initialize($format, VisitorInterface $visitor, GraphNavigator $navigator, MetadataFactoryInterface $factory)
+ {
+ parent::initialize($format, $visitor, $navigator, $factory);
+
+ $this->visitingSet = new \SplObjectStorage();
+ $this->visitingStack = new \SplStack();
+ }
+
+ public function startVisiting($object)
+ {
+ if (!is_object($object)) {
+ return;
+ }
+ $this->visitingSet->attach($object);
+ $this->visitingStack->push($object);
+ }
+
+ public function stopVisiting($object)
+ {
+ if (!is_object($object)) {
+ return;
+ }
+ $this->visitingSet->detach($object);
+ $poppedObject = $this->visitingStack->pop();
+
+ if ($object !== $poppedObject) {
+ throw new RuntimeException('Context visitingStack not working well');
+ }
+ }
+
+ public function isVisiting($object)
+ {
+ if (!is_object($object)) {
+ return false;
+ }
+
+ return $this->visitingSet->contains($object);
+ }
+
+ public function getPath()
+ {
+ $path = array();
+ foreach ($this->visitingStack as $obj) {
+ $path[] = get_class($obj);
+ }
+
+ if (!$path) {
+ return null;
+ }
+
+ return implode(' -> ', $path);
+ }
+
+ public function getDirection()
+ {
+ return GraphNavigator::DIRECTION_SERIALIZATION;
+ }
+
+ public function getDepth()
+ {
+ return $this->visitingStack->count();
+ }
+
+ public function getObject()
+ {
+ return !$this->visitingStack->isEmpty() ? $this->visitingStack->top() : null;
+ }
+
+ public function getVisitingStack()
+ {
+ return $this->visitingStack;
+ }
+
+ public function getVisitingSet()
+ {
+ return $this->visitingSet;
+ }
+
+ /**
+ * @param string $type
+ * @return $this
+ */
+ public function setInitialType($type)
+ {
+ $this->initialType = $type;
+ $this->attributes->set('initial_type', $type);
+ return $this;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getInitialType()
+ {
+ return $this->initialType
+ ? $this->initialType
+ : $this->attributes->containsKey('initial_type') ? $this->attributes->get('initial_type')->get() : null;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Construction\ObjectConstructorInterface;
+use JMS\Serializer\ContextFactory\DefaultDeserializationContextFactory;
+use JMS\Serializer\ContextFactory\DefaultSerializationContextFactory;
+use JMS\Serializer\ContextFactory\DeserializationContextFactoryInterface;
+use JMS\Serializer\ContextFactory\SerializationContextFactoryInterface;
+use JMS\Serializer\EventDispatcher\EventDispatcherInterface;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\Exception\UnsupportedFormatException;
+use JMS\Serializer\Expression\ExpressionEvaluatorInterface;
+use JMS\Serializer\Handler\HandlerRegistryInterface;
+use Metadata\MetadataFactoryInterface;
+use PhpCollection\MapInterface;
+
+/**
+ * Serializer Implementation.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class Serializer implements SerializerInterface, ArrayTransformerInterface
+{
+ private $factory;
+ private $handlerRegistry;
+ private $objectConstructor;
+ private $dispatcher;
+ private $typeParser;
+
+ /** @var \PhpCollection\MapInterface */
+ private $serializationVisitors;
+
+ /** @var \PhpCollection\MapInterface */
+ private $deserializationVisitors;
+
+ private $navigator;
+
+ /**
+ * @var SerializationContextFactoryInterface
+ */
+ private $serializationContextFactory;
+
+ /**
+ * @var DeserializationContextFactoryInterface
+ */
+ private $deserializationContextFactory;
+
+ /**
+ * Constructor.
+ *
+ * @param \Metadata\MetadataFactoryInterface $factory
+ * @param Handler\HandlerRegistryInterface $handlerRegistry
+ * @param Construction\ObjectConstructorInterface $objectConstructor
+ * @param \PhpCollection\MapInterface $serializationVisitors of VisitorInterface
+ * @param \PhpCollection\MapInterface $deserializationVisitors of VisitorInterface
+ * @param EventDispatcher\EventDispatcherInterface $dispatcher
+ * @param TypeParser $typeParser
+ * @param ExpressionEvaluatorInterface|null $expressionEvaluator
+ */
+ public function __construct(
+ MetadataFactoryInterface $factory,
+ HandlerRegistryInterface $handlerRegistry,
+ ObjectConstructorInterface $objectConstructor,
+ MapInterface $serializationVisitors,
+ MapInterface $deserializationVisitors,
+ EventDispatcherInterface $dispatcher = null,
+ TypeParser $typeParser = null,
+ ExpressionEvaluatorInterface $expressionEvaluator = null
+ )
+ {
+ $this->factory = $factory;
+ $this->handlerRegistry = $handlerRegistry;
+ $this->objectConstructor = $objectConstructor;
+ $this->dispatcher = $dispatcher;
+ $this->typeParser = $typeParser ?: new TypeParser();
+ $this->serializationVisitors = $serializationVisitors;
+ $this->deserializationVisitors = $deserializationVisitors;
+
+ $this->navigator = new GraphNavigator($this->factory, $this->handlerRegistry, $this->objectConstructor, $this->dispatcher, $expressionEvaluator);
+
+ $this->serializationContextFactory = new DefaultSerializationContextFactory();
+ $this->deserializationContextFactory = new DefaultDeserializationContextFactory();
+ }
+
+ public function serialize($data, $format, SerializationContext $context = null)
+ {
+ if (null === $context) {
+ $context = $this->serializationContextFactory->createSerializationContext();
+ }
+
+ return $this->serializationVisitors->get($format)
+ ->map(function (VisitorInterface $visitor) use ($context, $data, $format) {
+ $type = $context->getInitialType() !== null ? $this->typeParser->parse($context->getInitialType()) : null;
+
+ $this->visit($visitor, $context, $visitor->prepare($data), $format, $type);
+
+ return $visitor->getResult();
+ })
+ ->getOrThrow(new UnsupportedFormatException(sprintf('The format "%s" is not supported for serialization.', $format)));
+ }
+
+ public function deserialize($data, $type, $format, DeserializationContext $context = null)
+ {
+ if (null === $context) {
+ $context = $this->deserializationContextFactory->createDeserializationContext();
+ }
+
+ return $this->deserializationVisitors->get($format)
+ ->map(function (VisitorInterface $visitor) use ($context, $data, $format, $type) {
+ $preparedData = $visitor->prepare($data);
+ $navigatorResult = $this->visit($visitor, $context, $preparedData, $format, $this->typeParser->parse($type));
+
+ return $this->handleDeserializeResult($visitor->getResult(), $navigatorResult);
+ })
+ ->getOrThrow(new UnsupportedFormatException(sprintf('The format "%s" is not supported for deserialization.', $format)));
+ }
+
+ /**
+ * {@InheritDoc}
+ */
+ public function toArray($data, SerializationContext $context = null)
+ {
+ if (null === $context) {
+ $context = $this->serializationContextFactory->createSerializationContext();
+ }
+
+ return $this->serializationVisitors->get('json')
+ ->map(function (JsonSerializationVisitor $visitor) use ($context, $data) {
+ $type = $context->getInitialType() !== null ? $this->typeParser->parse($context->getInitialType()) : null;
+
+ $this->visit($visitor, $context, $data, 'json', $type);
+ $result = $this->convertArrayObjects($visitor->getRoot());
+
+ if (!is_array($result)) {
+ throw new RuntimeException(sprintf(
+ 'The input data of type "%s" did not convert to an array, but got a result of type "%s".',
+ is_object($data) ? get_class($data) : gettype($data),
+ is_object($result) ? get_class($result) : gettype($result)
+ ));
+ }
+
+ return $result;
+ })
+ ->get();
+ }
+
+ /**
+ * {@InheritDoc}
+ */
+ public function fromArray(array $data, $type, DeserializationContext $context = null)
+ {
+ if (null === $context) {
+ $context = $this->deserializationContextFactory->createDeserializationContext();
+ }
+
+ return $this->deserializationVisitors->get('json')
+ ->map(function (JsonDeserializationVisitor $visitor) use ($data, $type, $context) {
+ $navigatorResult = $this->visit($visitor, $context, $data, 'json', $this->typeParser->parse($type));
+
+ return $this->handleDeserializeResult($visitor->getResult(), $navigatorResult);
+ })
+ ->get();
+ }
+
+ private function visit(VisitorInterface $visitor, Context $context, $data, $format, array $type = null)
+ {
+ $context->initialize(
+ $format,
+ $visitor,
+ $this->navigator,
+ $this->factory
+ );
+
+ $visitor->setNavigator($this->navigator);
+
+ return $this->navigator->accept($data, $type, $context);
+ }
+
+ private function handleDeserializeResult($visitorResult, $navigatorResult)
+ {
+ // This is a special case if the root is handled by a callback on the object itself.
+ if (null === $visitorResult && null !== $navigatorResult) {
+ return $navigatorResult;
+ }
+
+ return $visitorResult;
+ }
+
+ private function convertArrayObjects($data)
+ {
+ if ($data instanceof \ArrayObject || $data instanceof \stdClass) {
+ $data = (array)$data;
+ }
+ if (is_array($data)) {
+ foreach ($data as $k => $v) {
+ $data[$k] = $this->convertArrayObjects($v);
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * @return MetadataFactoryInterface
+ */
+ public function getMetadataFactory()
+ {
+ return $this->factory;
+ }
+
+ /**
+ * @param SerializationContextFactoryInterface $serializationContextFactory
+ *
+ * @return self
+ */
+ public function setSerializationContextFactory(SerializationContextFactoryInterface $serializationContextFactory)
+ {
+ $this->serializationContextFactory = $serializationContextFactory;
+
+ return $this;
+ }
+
+ /**
+ * @param DeserializationContextFactoryInterface $deserializationContextFactory
+ *
+ * @return self
+ */
+ public function setDeserializationContextFactory(DeserializationContextFactoryInterface $deserializationContextFactory)
+ {
+ $this->deserializationContextFactory = $deserializationContextFactory;
+
+ return $this;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use Doctrine\Common\Annotations\CachedReader;
+use Doctrine\Common\Annotations\Reader;
+use Doctrine\Common\Cache\FilesystemCache;
+use JMS\Serializer\Accessor\AccessorStrategyInterface;
+use JMS\Serializer\Accessor\DefaultAccessorStrategy;
+use JMS\Serializer\Accessor\ExpressionAccessorStrategy;
+use JMS\Serializer\Builder\DefaultDriverFactory;
+use JMS\Serializer\Builder\DriverFactoryInterface;
+use JMS\Serializer\Construction\ObjectConstructorInterface;
+use JMS\Serializer\Construction\UnserializeObjectConstructor;
+use JMS\Serializer\ContextFactory\CallableDeserializationContextFactory;
+use JMS\Serializer\ContextFactory\CallableSerializationContextFactory;
+use JMS\Serializer\ContextFactory\DeserializationContextFactoryInterface;
+use JMS\Serializer\ContextFactory\SerializationContextFactoryInterface;
+use JMS\Serializer\EventDispatcher\EventDispatcher;
+use JMS\Serializer\EventDispatcher\Subscriber\DoctrineProxySubscriber;
+use JMS\Serializer\Exception\InvalidArgumentException;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\Expression\ExpressionEvaluatorInterface;
+use JMS\Serializer\Handler\ArrayCollectionHandler;
+use JMS\Serializer\Handler\DateHandler;
+use JMS\Serializer\Handler\HandlerRegistry;
+use JMS\Serializer\Handler\PhpCollectionHandler;
+use JMS\Serializer\Handler\PropelCollectionHandler;
+use JMS\Serializer\Handler\StdClassHandler;
+use JMS\Serializer\Naming\AdvancedNamingStrategyInterface;
+use JMS\Serializer\Naming\CamelCaseNamingStrategy;
+use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
+use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
+use Metadata\Cache\FileCache;
+use Metadata\MetadataFactory;
+use PhpCollection\Map;
+
+/**
+ * Builder for serializer instances.
+ *
+ * This object makes serializer construction a breeze for projects that do not use
+ * any special dependency injection container.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class SerializerBuilder
+{
+ private $metadataDirs = array();
+ private $handlerRegistry;
+ private $handlersConfigured = false;
+ private $eventDispatcher;
+ private $listenersConfigured = false;
+ private $objectConstructor;
+ private $serializationVisitors;
+ private $deserializationVisitors;
+ private $visitorsAdded = false;
+ private $propertyNamingStrategy;
+ private $debug = false;
+ private $cacheDir;
+ private $annotationReader;
+ private $includeInterfaceMetadata = false;
+ private $driverFactory;
+ private $serializationContextFactory;
+ private $deserializationContextFactory;
+
+ /**
+ * @var ExpressionEvaluatorInterface
+ */
+ private $expressionEvaluator;
+
+ /**
+ * @var AccessorStrategyInterface
+ */
+ private $accessorStrategy;
+
+ public static function create()
+ {
+ return new static();
+ }
+
+ public function __construct()
+ {
+ $this->handlerRegistry = new HandlerRegistry();
+ $this->eventDispatcher = new EventDispatcher();
+ $this->driverFactory = new DefaultDriverFactory();
+ $this->serializationVisitors = new Map();
+ $this->deserializationVisitors = new Map();
+ }
+
+ public function setAccessorStrategy(AccessorStrategyInterface $accessorStrategy)
+ {
+ $this->accessorStrategy = $accessorStrategy;
+ }
+
+ protected function getAccessorStrategy()
+ {
+ if (!$this->accessorStrategy) {
+ $this->accessorStrategy = new DefaultAccessorStrategy();
+
+ if ($this->expressionEvaluator) {
+ $this->accessorStrategy = new ExpressionAccessorStrategy($this->expressionEvaluator, $this->accessorStrategy);
+ }
+ }
+ return $this->accessorStrategy;
+ }
+
+ public function setExpressionEvaluator(ExpressionEvaluatorInterface $expressionEvaluator)
+ {
+ $this->expressionEvaluator = $expressionEvaluator;
+
+ return $this;
+ }
+
+ public function setAnnotationReader(Reader $reader)
+ {
+ $this->annotationReader = $reader;
+
+ return $this;
+ }
+
+ public function setDebug($bool)
+ {
+ $this->debug = (boolean)$bool;
+
+ return $this;
+ }
+
+ public function setCacheDir($dir)
+ {
+ if (!is_dir($dir)) {
+ $this->createDir($dir);
+ }
+ if (!is_writable($dir)) {
+ throw new InvalidArgumentException(sprintf('The cache directory "%s" is not writable.', $dir));
+ }
+
+ $this->cacheDir = $dir;
+
+ return $this;
+ }
+
+ public function addDefaultHandlers()
+ {
+ $this->handlersConfigured = true;
+ $this->handlerRegistry->registerSubscribingHandler(new DateHandler());
+ $this->handlerRegistry->registerSubscribingHandler(new StdClassHandler());
+ $this->handlerRegistry->registerSubscribingHandler(new PhpCollectionHandler());
+ $this->handlerRegistry->registerSubscribingHandler(new ArrayCollectionHandler());
+ $this->handlerRegistry->registerSubscribingHandler(new PropelCollectionHandler());
+
+ return $this;
+ }
+
+ public function configureHandlers(\Closure $closure)
+ {
+ $this->handlersConfigured = true;
+ $closure($this->handlerRegistry);
+
+ return $this;
+ }
+
+ public function addDefaultListeners()
+ {
+ $this->listenersConfigured = true;
+ $this->eventDispatcher->addSubscriber(new DoctrineProxySubscriber());
+
+ return $this;
+ }
+
+ public function configureListeners(\Closure $closure)
+ {
+ $this->listenersConfigured = true;
+ $closure($this->eventDispatcher);
+
+ return $this;
+ }
+
+ public function setObjectConstructor(ObjectConstructorInterface $constructor)
+ {
+ $this->objectConstructor = $constructor;
+
+ return $this;
+ }
+
+ public function setPropertyNamingStrategy(PropertyNamingStrategyInterface $propertyNamingStrategy)
+ {
+ $this->propertyNamingStrategy = $propertyNamingStrategy;
+
+ return $this;
+ }
+
+ public function setAdvancedNamingStrategy(AdvancedNamingStrategyInterface $advancedNamingStrategy)
+ {
+ $this->propertyNamingStrategy = $advancedNamingStrategy;
+
+ return $this;
+ }
+
+ public function setSerializationVisitor($format, VisitorInterface $visitor)
+ {
+ $this->visitorsAdded = true;
+ $this->serializationVisitors->set($format, $visitor);
+
+ return $this;
+ }
+
+ public function setDeserializationVisitor($format, VisitorInterface $visitor)
+ {
+ $this->visitorsAdded = true;
+ $this->deserializationVisitors->set($format, $visitor);
+
+ return $this;
+ }
+
+ public function addDefaultSerializationVisitors()
+ {
+ $this->initializePropertyNamingStrategy();
+
+ $this->visitorsAdded = true;
+ $this->serializationVisitors->setAll(array(
+ 'xml' => new XmlSerializationVisitor($this->propertyNamingStrategy, $this->getAccessorStrategy()),
+ 'yml' => new YamlSerializationVisitor($this->propertyNamingStrategy, $this->getAccessorStrategy()),
+ 'json' => new JsonSerializationVisitor($this->propertyNamingStrategy, $this->getAccessorStrategy()),
+ ));
+
+ return $this;
+ }
+
+ public function addDefaultDeserializationVisitors()
+ {
+ $this->initializePropertyNamingStrategy();
+
+ $this->visitorsAdded = true;
+ $this->deserializationVisitors->setAll(array(
+ 'xml' => new XmlDeserializationVisitor($this->propertyNamingStrategy),
+ 'json' => new JsonDeserializationVisitor($this->propertyNamingStrategy),
+ ));
+
+ return $this;
+ }
+
+ /**
+ * @param Boolean $include Whether to include the metadata from the interfaces
+ *
+ * @return SerializerBuilder
+ */
+ public function includeInterfaceMetadata($include)
+ {
+ $this->includeInterfaceMetadata = (Boolean)$include;
+
+ return $this;
+ }
+
+ /**
+ * Sets a map of namespace prefixes to directories.
+ *
+ * This method overrides any previously defined directories.
+ *
+ * @param array <string,string> $namespacePrefixToDirMap
+ *
+ * @return SerializerBuilder
+ *
+ * @throws InvalidArgumentException When a directory does not exist
+ */
+ public function setMetadataDirs(array $namespacePrefixToDirMap)
+ {
+ foreach ($namespacePrefixToDirMap as $dir) {
+ if (!is_dir($dir)) {
+ throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir));
+ }
+ }
+
+ $this->metadataDirs = $namespacePrefixToDirMap;
+
+ return $this;
+ }
+
+ /**
+ * Adds a directory where the serializer will look for class metadata.
+ *
+ * The namespace prefix will make the names of the actual metadata files a bit shorter. For example, let's assume
+ * that you have a directory where you only store metadata files for the ``MyApplication\Entity`` namespace.
+ *
+ * If you use an empty prefix, your metadata files would need to look like:
+ *
+ * ``my-dir/MyApplication.Entity.SomeObject.yml``
+ * ``my-dir/MyApplication.Entity.OtherObject.xml``
+ *
+ * If you use ``MyApplication\Entity`` as prefix, your metadata files would need to look like:
+ *
+ * ``my-dir/SomeObject.yml``
+ * ``my-dir/OtherObject.yml``
+ *
+ * Please keep in mind that you currently may only have one directory per namespace prefix.
+ *
+ * @param string $dir The directory where metadata files are located.
+ * @param string $namespacePrefix An optional prefix if you only store metadata for specific namespaces in this directory.
+ *
+ * @return SerializerBuilder
+ *
+ * @throws InvalidArgumentException When a directory does not exist
+ * @throws InvalidArgumentException When a directory has already been registered
+ */
+ public function addMetadataDir($dir, $namespacePrefix = '')
+ {
+ if (!is_dir($dir)) {
+ throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir));
+ }
+
+ if (isset($this->metadataDirs[$namespacePrefix])) {
+ throw new InvalidArgumentException(sprintf('There is already a directory configured for the namespace prefix "%s". Please use replaceMetadataDir() to override directories.', $namespacePrefix));
+ }
+
+ $this->metadataDirs[$namespacePrefix] = $dir;
+
+ return $this;
+ }
+
+ /**
+ * Adds a map of namespace prefixes to directories.
+ *
+ * @param array <string,string> $namespacePrefixToDirMap
+ *
+ * @return SerializerBuilder
+ */
+ public function addMetadataDirs(array $namespacePrefixToDirMap)
+ {
+ foreach ($namespacePrefixToDirMap as $prefix => $dir) {
+ $this->addMetadataDir($dir, $prefix);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Similar to addMetadataDir(), but overrides an existing entry.
+ *
+ * @param string $dir
+ * @param string $namespacePrefix
+ *
+ * @return SerializerBuilder
+ *
+ * @throws InvalidArgumentException When a directory does not exist
+ * @throws InvalidArgumentException When no directory is configured for the ns prefix
+ */
+ public function replaceMetadataDir($dir, $namespacePrefix = '')
+ {
+ if (!is_dir($dir)) {
+ throw new InvalidArgumentException(sprintf('The directory "%s" does not exist.', $dir));
+ }
+
+ if (!isset($this->metadataDirs[$namespacePrefix])) {
+ throw new InvalidArgumentException(sprintf('There is no directory configured for namespace prefix "%s". Please use addMetadataDir() for adding new directories.', $namespacePrefix));
+ }
+
+ $this->metadataDirs[$namespacePrefix] = $dir;
+
+ return $this;
+ }
+
+ public function setMetadataDriverFactory(DriverFactoryInterface $driverFactory)
+ {
+ $this->driverFactory = $driverFactory;
+
+ return $this;
+ }
+
+ /**
+ * @param SerializationContextFactoryInterface|callable $serializationContextFactory
+ *
+ * @return self
+ */
+ public function setSerializationContextFactory($serializationContextFactory)
+ {
+ if ($serializationContextFactory instanceof SerializationContextFactoryInterface) {
+ $this->serializationContextFactory = $serializationContextFactory;
+ } elseif (is_callable($serializationContextFactory)) {
+ $this->serializationContextFactory = new CallableSerializationContextFactory(
+ $serializationContextFactory
+ );
+ } else {
+ throw new InvalidArgumentException('expected SerializationContextFactoryInterface or callable.');
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param DeserializationContextFactoryInterface|callable $deserializationContextFactory
+ *
+ * @return self
+ */
+ public function setDeserializationContextFactory($deserializationContextFactory)
+ {
+ if ($deserializationContextFactory instanceof DeserializationContextFactoryInterface) {
+ $this->deserializationContextFactory = $deserializationContextFactory;
+ } elseif (is_callable($deserializationContextFactory)) {
+ $this->deserializationContextFactory = new CallableDeserializationContextFactory(
+ $deserializationContextFactory
+ );
+ } else {
+ throw new InvalidArgumentException('expected DeserializationContextFactoryInterface or callable.');
+ }
+
+ return $this;
+ }
+
+ public function build()
+ {
+ $annotationReader = $this->annotationReader;
+ if (null === $annotationReader) {
+ $annotationReader = new AnnotationReader();
+
+ if (null !== $this->cacheDir) {
+ $this->createDir($this->cacheDir . '/annotations');
+ $annotationsCache = new FilesystemCache($this->cacheDir . '/annotations');
+ $annotationReader = new CachedReader($annotationReader, $annotationsCache, $this->debug);
+ }
+ }
+
+ $metadataDriver = $this->driverFactory->createDriver($this->metadataDirs, $annotationReader);
+ $metadataFactory = new MetadataFactory($metadataDriver, null, $this->debug);
+
+ $metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);
+
+ if (null !== $this->cacheDir) {
+ $this->createDir($this->cacheDir . '/metadata');
+ $metadataFactory->setCache(new FileCache($this->cacheDir . '/metadata'));
+ }
+
+ if (!$this->handlersConfigured) {
+ $this->addDefaultHandlers();
+ }
+
+ if (!$this->listenersConfigured) {
+ $this->addDefaultListeners();
+ }
+
+ if (!$this->visitorsAdded) {
+ $this->addDefaultSerializationVisitors();
+ $this->addDefaultDeserializationVisitors();
+ }
+
+ $serializer = new Serializer(
+ $metadataFactory,
+ $this->handlerRegistry,
+ $this->objectConstructor ?: new UnserializeObjectConstructor(),
+ $this->serializationVisitors,
+ $this->deserializationVisitors,
+ $this->eventDispatcher,
+ null,
+ $this->expressionEvaluator
+ );
+
+ if (null !== $this->serializationContextFactory) {
+ $serializer->setSerializationContextFactory($this->serializationContextFactory);
+ }
+
+ if (null !== $this->deserializationContextFactory) {
+ $serializer->setDeserializationContextFactory($this->deserializationContextFactory);
+ }
+
+ return $serializer;
+ }
+
+ private function initializePropertyNamingStrategy()
+ {
+ if (null !== $this->propertyNamingStrategy) {
+ return;
+ }
+
+ $this->propertyNamingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
+ }
+
+ private function createDir($dir)
+ {
+ if (is_dir($dir)) {
+ return;
+ }
+
+ if (false === @mkdir($dir, 0777, true) && false === is_dir($dir)) {
+ throw new RuntimeException(sprintf('Could not create directory "%s".', $dir));
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+/**
+ * Serializer Interface.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface SerializerInterface
+{
+ /**
+ * Serializes the given data to the specified output format.
+ *
+ * @param object|array|scalar $data
+ * @param string $format
+ * @param Context $context
+ *
+ * @return string
+ */
+ public function serialize($data, $format, SerializationContext $context = null);
+
+ /**
+ * Deserializes the given data to the specified type.
+ *
+ * @param string $data
+ * @param string $type
+ * @param string $format
+ * @param Context $context
+ *
+ * @return object|array|scalar
+ */
+ public function deserialize($data, $type, $format, DeserializationContext $context = null);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Twig;
+
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\SerializerInterface;
+
+/**
+ * Serializer helper twig extension
+ *
+ * Basically provides access to JMSSerializer from Twig
+ */
+class SerializerExtension extends \Twig_Extension
+{
+ protected $serializer;
+
+ public function getName()
+ {
+ return 'jms_serializer';
+ }
+
+ public function __construct(SerializerInterface $serializer)
+ {
+ $this->serializer = $serializer;
+ }
+
+ public function getFilters()
+ {
+ return array(
+ new \Twig_SimpleFilter('serialize', array($this, 'serialize')),
+ );
+ }
+
+ public function getFunctions()
+ {
+ return array(
+ new \Twig_SimpleFunction('serialization_context', '\JMS\Serializer\SerializationContext::create'),
+ );
+ }
+
+ /**
+ * @param object $object
+ * @param string $type
+ * @param SerializationContext $context
+ */
+ public function serialize($object, $type = 'json', SerializationContext $context = null)
+ {
+ return $this->serializer->serialize($object, $type, $context);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Twig;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+final class SerializerRuntimeExtension extends \Twig_Extension
+{
+
+ public function getName()
+ {
+ return 'jms_serializer';
+ }
+
+ public function getFilters()
+ {
+ return array(
+ new \Twig_SimpleFilter('serialize', array(SerializerRuntimeHelper::class, 'serialize')),
+ );
+ }
+
+ public function getFunctions()
+ {
+ return array(
+ new \Twig_SimpleFunction('serialization_context', '\JMS\Serializer\SerializationContext::create'),
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Twig;
+
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\SerializerInterface;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+final class SerializerRuntimeHelper
+{
+ protected $serializer;
+
+ public function __construct(SerializerInterface $serializer)
+ {
+ $this->serializer = $serializer;
+ }
+
+ /**
+ * @param $object
+ * @param string $type
+ * @param SerializationContext|null $context
+ * @return string
+ */
+ public function serialize($object, $type = 'json', SerializationContext $context = null)
+ {
+ return $this->serializer->serialize($object, $type, $context);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+/**
+ * Parses a serializer type.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+final class TypeParser extends \JMS\Parser\AbstractParser
+{
+ const T_NAME = 1;
+ const T_STRING = 2;
+ const T_OPEN_BRACKET = 3;
+ const T_CLOSE_BRACKET = 4;
+ const T_COMMA = 5;
+ const T_NONE = 6;
+
+ public function __construct()
+ {
+ parent::__construct(new \JMS\Parser\SimpleLexer(
+ '/
+ # PHP Class Names
+ ((?:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\\\)*[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)
+
+ # Strings
+ |("(?:[^"]|"")*"|\'(?:[^\']|\'\')*\')
+
+ # Ignore whitespace
+ |\s*
+
+ # Terminals
+ |(.)
+ /x',
+ array(self::T_NAME => 'T_NAME', self::T_STRING => 'T_STRING', self::T_OPEN_BRACKET => 'T_OPEN_BRACKET',
+ self::T_CLOSE_BRACKET => 'T_CLOSE_BRACKET', self::T_COMMA => 'T_COMMA', self::T_NONE => 'T_NONE'),
+ function ($value) {
+ switch ($value[0]) {
+ case '"':
+ case "'":
+ return array(TypeParser::T_STRING, substr($value, 1, -1));
+
+ case '<':
+ return array(TypeParser::T_OPEN_BRACKET, '<');
+
+ case '>':
+ return array(TypeParser::T_CLOSE_BRACKET, '>');
+
+ case ',':
+ return array(TypeParser::T_COMMA, ',');
+
+ default:
+ if (preg_match('/^(?:[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*\\\\)*[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $value)) {
+ return array(TypeParser::T_NAME, $value);
+ }
+
+ return array(TypeParser::T_NONE, $value);
+ }
+ }
+ ));
+ }
+
+ /**
+ * @return array of the format ["name" => string, "params" => array]
+ */
+ protected function parseInternal()
+ {
+ $typeName = $this->match(self::T_NAME);
+ if (!$this->lexer->isNext(self::T_OPEN_BRACKET)) {
+ return array('name' => $typeName, 'params' => array());
+ }
+
+ $this->match(self::T_OPEN_BRACKET);
+ $params = array();
+ do {
+ if ($this->lexer->isNext(self::T_NAME)) {
+ $params[] = $this->parseInternal();
+ } else if ($this->lexer->isNext(self::T_STRING)) {
+ $params[] = $this->match(self::T_STRING);
+ } else {
+ $this->matchAny(array(self::T_NAME, self::T_STRING)); // Will throw an exception.
+ }
+ } while ($this->lexer->isNext(self::T_COMMA) && $this->lexer->moveNext());
+
+ $this->match(self::T_CLOSE_BRACKET);
+
+ return array('name' => $typeName, 'params' => $params);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Util;
+
+use JMS\Serializer\Exception\RuntimeException;
+
+/**
+ * A writer implementation.
+ *
+ * This may be used to simplify writing well-formatted code.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class Writer
+{
+ public $indentationSpaces = 4;
+ public $indentationLevel = 0;
+ public $content = '';
+ public $changeCount = 0;
+
+ private $changes = array();
+
+ public function indent()
+ {
+ $this->indentationLevel += 1;
+
+ return $this;
+ }
+
+ public function outdent()
+ {
+ $this->indentationLevel -= 1;
+
+ if ($this->indentationLevel < 0) {
+ throw new RuntimeException('The identation level cannot be less than zero.');
+ }
+
+ return $this;
+ }
+
+ /**
+ * @param string $content
+ *
+ * @return Writer
+ */
+ public function writeln($content)
+ {
+ $this->write($content . "\n");
+
+ return $this;
+ }
+
+ public function revert()
+ {
+ $change = array_pop($this->changes);
+ $this->changeCount -= 1;
+ $this->content = substr($this->content, 0, -1 * strlen($change));
+ }
+
+ /**
+ * @param string $content
+ *
+ * @return Writer
+ */
+ public function write($content)
+ {
+ $addition = '';
+
+ $lines = explode("\n", $content);
+ for ($i = 0, $c = count($lines); $i < $c; $i++) {
+ if ($this->indentationLevel > 0
+ && !empty($lines[$i])
+ && ((empty($addition) && "\n" === substr($this->content, -1)) || "\n" === substr($addition, -1))
+ ) {
+ $addition .= str_repeat(' ', $this->indentationLevel * $this->indentationSpaces);
+ }
+
+ $addition .= $lines[$i];
+
+ if ($i + 1 < $c) {
+ $addition .= "\n";
+ }
+ }
+
+ $this->content .= $addition;
+ $this->changes[] = $addition;
+ $this->changeCount += 1;
+
+ return $this;
+ }
+
+ public function rtrim($preserveNewLines = true)
+ {
+ if (!$preserveNewLines) {
+ $this->content = rtrim($this->content);
+
+ return $this;
+ }
+
+ $addNl = "\n" === substr($this->content, -1);
+ $this->content = rtrim($this->content);
+
+ if ($addNl) {
+ $this->content .= "\n";
+ }
+
+ return $this;
+ }
+
+ public function reset()
+ {
+ $this->content = '';
+ $this->indentationLevel = 0;
+
+ return $this;
+ }
+
+ public function getContent()
+ {
+ return $this->content;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ * Interface for visitors.
+ *
+ * This contains the minimal set of values that must be supported for any
+ * output format.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface VisitorInterface
+{
+ /**
+ * Allows visitors to convert the input data to a different representation
+ * before the actual serialization/deserialization process starts.
+ *
+ * @param mixed $data
+ *
+ * @return mixed
+ */
+ public function prepare($data);
+
+ /**
+ * @param mixed $data
+ * @param array $type
+ *
+ * @return mixed
+ */
+ public function visitNull($data, array $type, Context $context);
+
+ /**
+ * @param mixed $data
+ * @param array $type
+ *
+ * @return mixed
+ */
+ public function visitString($data, array $type, Context $context);
+
+ /**
+ * @param mixed $data
+ * @param array $type
+ *
+ * @return mixed
+ */
+ public function visitBoolean($data, array $type, Context $context);
+
+ /**
+ * @param mixed $data
+ * @param array $type
+ *
+ * @return mixed
+ */
+ public function visitDouble($data, array $type, Context $context);
+
+ /**
+ * @param mixed $data
+ * @param array $type
+ *
+ * @return mixed
+ */
+ public function visitInteger($data, array $type, Context $context);
+
+ /**
+ * @param mixed $data
+ * @param array $type
+ *
+ * @return mixed
+ */
+ public function visitArray($data, array $type, Context $context);
+
+ /**
+ * Called before the properties of the object are being visited.
+ *
+ * @param ClassMetadata $metadata
+ * @param mixed $data
+ * @param array $type
+ *
+ * @return void
+ */
+ public function startVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context);
+
+ /**
+ * @param PropertyMetadata $metadata
+ * @param mixed $data
+ *
+ * @return void
+ */
+ public function visitProperty(PropertyMetadata $metadata, $data, Context $context);
+
+ /**
+ * Called after all properties of the object have been visited.
+ *
+ * @param ClassMetadata $metadata
+ * @param mixed $data
+ * @param array $type
+ *
+ * @return mixed
+ */
+ public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context);
+
+ /**
+ * Called before serialization/deserialization starts.
+ *
+ * @param GraphNavigator $navigator
+ *
+ * @return void
+ */
+ public function setNavigator(GraphNavigator $navigator);
+
+ /**
+ * @deprecated use Context::getNavigator/Context::accept instead
+ * @return GraphNavigator
+ */
+ public function getNavigator();
+
+ /**
+ * @return object|array|scalar
+ */
+ public function getResult();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Exception\InvalidArgumentException;
+use JMS\Serializer\Exception\LogicException;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\Exception\XmlErrorException;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Naming\AdvancedNamingStrategyInterface;
+
+class XmlDeserializationVisitor extends AbstractVisitor implements NullAwareVisitorInterface
+{
+ private $objectStack;
+ private $metadataStack;
+ private $objectMetadataStack;
+ private $currentObject;
+ private $currentMetadata;
+ private $result;
+ private $navigator;
+ private $disableExternalEntities = true;
+ private $doctypeWhitelist = array();
+
+ public function enableExternalEntities()
+ {
+ $this->disableExternalEntities = false;
+ }
+
+ public function setNavigator(GraphNavigator $navigator)
+ {
+ $this->navigator = $navigator;
+ $this->objectStack = new \SplStack;
+ $this->metadataStack = new \SplStack;
+ $this->objectMetadataStack = new \SplStack;
+ $this->result = null;
+ }
+
+ public function getNavigator()
+ {
+ return $this->navigator;
+ }
+
+ public function prepare($data)
+ {
+ $data = $this->emptyStringToSpaceCharacter($data);
+
+ $previous = libxml_use_internal_errors(true);
+ libxml_clear_errors();
+
+ $previousEntityLoaderState = libxml_disable_entity_loader($this->disableExternalEntities);
+
+ if (false !== stripos($data, '<!doctype')) {
+ $internalSubset = $this->getDomDocumentTypeEntitySubset($data);
+ if (!in_array($internalSubset, $this->doctypeWhitelist, true)) {
+ throw new InvalidArgumentException(sprintf(
+ 'The document type "%s" is not allowed. If it is safe, you may add it to the whitelist configuration.',
+ $internalSubset
+ ));
+ }
+ }
+
+ $doc = simplexml_load_string($data);
+
+ libxml_use_internal_errors($previous);
+ libxml_disable_entity_loader($previousEntityLoaderState);
+
+ if (false === $doc) {
+ throw new XmlErrorException(libxml_get_last_error());
+ }
+
+ return $doc;
+ }
+
+ private function emptyStringToSpaceCharacter($data)
+ {
+ return $data === '' ? ' ' : (string)$data;
+ }
+
+ public function visitNull($data, array $type, Context $context)
+ {
+ return null;
+ }
+
+ public function visitString($data, array $type, Context $context)
+ {
+ $data = (string)$data;
+
+ if (null === $this->result) {
+ $this->result = $data;
+ }
+
+ return $data;
+ }
+
+ public function visitBoolean($data, array $type, Context $context)
+ {
+ $data = (string)$data;
+
+ if ('true' === $data || '1' === $data) {
+ $data = true;
+ } elseif ('false' === $data || '0' === $data) {
+ $data = false;
+ } else {
+ throw new RuntimeException(sprintf('Could not convert data to boolean. Expected "true", "false", "1" or "0", but got %s.', json_encode($data)));
+ }
+
+ if (null === $this->result) {
+ $this->result = $data;
+ }
+
+ return $data;
+ }
+
+ public function visitInteger($data, array $type, Context $context)
+ {
+ $data = (integer)$data;
+
+ if (null === $this->result) {
+ $this->result = $data;
+ }
+
+ return $data;
+ }
+
+ public function visitDouble($data, array $type, Context $context)
+ {
+ $data = (double)$data;
+
+ if (null === $this->result) {
+ $this->result = $data;
+ }
+
+ return $data;
+ }
+
+ public function visitArray($data, array $type, Context $context)
+ {
+ // handle key-value-pairs
+ if (null !== $this->currentMetadata && $this->currentMetadata->xmlKeyValuePairs) {
+ if (2 !== count($type['params'])) {
+ throw new RuntimeException('The array type must be specified as "array<K,V>" for Key-Value-Pairs.');
+ }
+ $this->revertCurrentMetadata();
+
+ list($keyType, $entryType) = $type['params'];
+
+ $result = [];
+ foreach ($data as $key => $v) {
+ $k = $this->navigator->accept($key, $keyType, $context);
+ $result[$k] = $this->navigator->accept($v, $entryType, $context);
+ }
+
+ return $result;
+ }
+
+ $entryName = null !== $this->currentMetadata && $this->currentMetadata->xmlEntryName ? $this->currentMetadata->xmlEntryName : 'entry';
+ $namespace = null !== $this->currentMetadata && $this->currentMetadata->xmlEntryNamespace ? $this->currentMetadata->xmlEntryNamespace : null;
+
+ if ($namespace === null && $this->objectMetadataStack->count()) {
+ $classMetadata = $this->objectMetadataStack->top();
+ $namespace = isset($classMetadata->xmlNamespaces['']) ? $classMetadata->xmlNamespaces[''] : $namespace;
+ if ($namespace === null) {
+ $namespaces = $data->getDocNamespaces();
+ if (isset($namespaces[''])) {
+ $namespace = $namespaces[''];
+ }
+ }
+ }
+
+ if (null !== $namespace) {
+ $prefix = uniqid('ns-');
+ $data->registerXPathNamespace($prefix, $namespace);
+ $nodes = $data->xpath("$prefix:$entryName");
+ } else {
+ $nodes = $data->xpath($entryName);
+ }
+
+ if (!count($nodes)) {
+ if (null === $this->result) {
+ return $this->result = array();
+ }
+
+ return array();
+ }
+
+ switch (count($type['params'])) {
+ case 0:
+ throw new RuntimeException(sprintf('The array type must be specified either as "array<T>", or "array<K,V>".'));
+
+ case 1:
+ $result = array();
+
+ if (null === $this->result) {
+ $this->result = &$result;
+ }
+
+ foreach ($nodes as $v) {
+ $result[] = $this->navigator->accept($v, $type['params'][0], $context);
+ }
+
+ return $result;
+
+ case 2:
+ if (null === $this->currentMetadata) {
+ throw new RuntimeException('Maps are not supported on top-level without metadata.');
+ }
+
+ list($keyType, $entryType) = $type['params'];
+ $result = array();
+ if (null === $this->result) {
+ $this->result = &$result;
+ }
+
+ $nodes = $data->children($namespace)->$entryName;
+ foreach ($nodes as $v) {
+ $attrs = $v->attributes();
+ if (!isset($attrs[$this->currentMetadata->xmlKeyAttribute])) {
+ throw new RuntimeException(sprintf('The key attribute "%s" must be set for each entry of the map.', $this->currentMetadata->xmlKeyAttribute));
+ }
+
+ $k = $this->navigator->accept($attrs[$this->currentMetadata->xmlKeyAttribute], $keyType, $context);
+ $result[$k] = $this->navigator->accept($v, $entryType, $context);
+ }
+
+ return $result;
+
+ default:
+ throw new LogicException(sprintf('The array type does not support more than 2 parameters, but got %s.', json_encode($type['params'])));
+ }
+ }
+
+ public function startVisitingObject(ClassMetadata $metadata, $object, array $type, Context $context)
+ {
+ $this->setCurrentObject($object);
+ $this->objectMetadataStack->push($metadata);
+ if (null === $this->result) {
+ $this->result = $this->currentObject;
+ }
+ }
+
+ public function visitProperty(PropertyMetadata $metadata, $data, Context $context)
+ {
+ if ($this->namingStrategy instanceof AdvancedNamingStrategyInterface) {
+ $name = $this->namingStrategy->getPropertyName($metadata, $context);
+ } else {
+ $name = $this->namingStrategy->translateName($metadata);
+ }
+
+ if (!$metadata->type) {
+ throw new RuntimeException(sprintf('You must define a type for %s::$%s.', $metadata->reflection->class, $metadata->name));
+ }
+
+ if ($metadata->xmlAttribute) {
+
+ $attributes = $data->attributes($metadata->xmlNamespace);
+ if (isset($attributes[$name])) {
+ $v = $this->navigator->accept($attributes[$name], $metadata->type, $context);
+ $this->accessor->setValue($this->currentObject, $v, $metadata);
+ }
+
+ return;
+ }
+
+ if ($metadata->xmlValue) {
+ $v = $this->navigator->accept($data, $metadata->type, $context);
+ $this->accessor->setValue($this->currentObject, $v, $metadata);
+
+ return;
+ }
+
+ if ($metadata->xmlCollection) {
+ $enclosingElem = $data;
+ if (!$metadata->xmlCollectionInline) {
+ $enclosingElem = $data->children($metadata->xmlNamespace)->$name;
+ }
+
+ $this->setCurrentMetadata($metadata);
+ $v = $this->navigator->accept($enclosingElem, $metadata->type, $context);
+ $this->revertCurrentMetadata();
+ $this->accessor->setValue($this->currentObject, $v, $metadata);
+
+ return;
+ }
+
+ if ($metadata->xmlNamespace) {
+ $node = $data->children($metadata->xmlNamespace)->$name;
+ if (!$node->count()) {
+ return;
+ }
+ } else {
+
+ $namespaces = $data->getDocNamespaces();
+
+ if (isset($namespaces[''])) {
+ $prefix = uniqid('ns-');
+ $data->registerXPathNamespace($prefix, $namespaces['']);
+ $nodes = $data->xpath('./' . $prefix . ':' . $name);
+ } else {
+ $nodes = $data->xpath('./' . $name);
+ }
+ if (empty($nodes)) {
+ return;
+ }
+ $node = reset($nodes);
+ }
+
+ if ($metadata->xmlKeyValuePairs) {
+ $this->setCurrentMetadata($metadata);
+ }
+
+ $v = $this->navigator->accept($node, $metadata->type, $context);
+
+ $this->accessor->setValue($this->currentObject, $v, $metadata);
+ }
+
+ public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ $rs = $this->currentObject;
+ $this->objectMetadataStack->pop();
+ $this->revertCurrentObject();
+
+ return $rs;
+ }
+
+ public function setCurrentObject($object)
+ {
+ $this->objectStack->push($this->currentObject);
+ $this->currentObject = $object;
+ }
+
+ public function getCurrentObject()
+ {
+ return $this->currentObject;
+ }
+
+ public function revertCurrentObject()
+ {
+ return $this->currentObject = $this->objectStack->pop();
+ }
+
+ public function setCurrentMetadata(PropertyMetadata $metadata)
+ {
+ $this->metadataStack->push($this->currentMetadata);
+ $this->currentMetadata = $metadata;
+ }
+
+ public function getCurrentMetadata()
+ {
+ return $this->currentMetadata;
+ }
+
+ public function revertCurrentMetadata()
+ {
+ return $this->currentMetadata = $this->metadataStack->pop();
+ }
+
+ public function getResult()
+ {
+ return $this->result;
+ }
+
+ /**
+ * @param array <string> $doctypeWhitelist
+ */
+ public function setDoctypeWhitelist(array $doctypeWhitelist)
+ {
+ $this->doctypeWhitelist = $doctypeWhitelist;
+ }
+
+ /**
+ * @return array<string>
+ */
+ public function getDoctypeWhitelist()
+ {
+ return $this->doctypeWhitelist;
+ }
+
+ /**
+ * Retrieves internalSubset even in bugfixed php versions
+ *
+ * @param \DOMDocumentType $child
+ * @param string $data
+ * @return string
+ */
+ private function getDomDocumentTypeEntitySubset($data)
+ {
+ $startPos = $endPos = stripos($data, '<!doctype');
+ $braces = 0;
+ do {
+ $char = $data[$endPos++];
+ if ($char === '<') {
+ ++$braces;
+ }
+ if ($char === '>') {
+ --$braces;
+ }
+ } while ($braces > 0);
+
+ $internalSubset = substr($data, $startPos, $endPos - $startPos);
+ $internalSubset = str_replace(array("\n", "\r"), '', $internalSubset);
+ $internalSubset = preg_replace('/\s{2,}/', ' ', $internalSubset);
+ $internalSubset = str_replace(array("[ <!", "> ]>"), array('[<!', '>]>'), $internalSubset);
+
+ return $internalSubset;
+ }
+
+ /**
+ * @param mixed $value
+ *
+ * @return bool
+ */
+ public function isNull($value)
+ {
+ if ($value instanceof \SimpleXMLElement) {
+ // Workaround for https://bugs.php.net/bug.php?id=75168 and https://github.com/schmittjoh/serializer/issues/817
+ // If the "name" is empty means that we are on an not-existent node and subsequent operations on the object will trigger the warning:
+ // "Node no longer exists"
+ if ($value->getName() === "") {
+ // @todo should be "true", but for collections needs a default collection value. maybe something for the 2.0
+ return false;
+ }
+
+ $xsiAttributes = $value->attributes('http://www.w3.org/2001/XMLSchema-instance');
+ if (isset($xsiAttributes['nil'])
+ && ((string) $xsiAttributes['nil'] === 'true' || (string) $xsiAttributes['nil'] === '1')
+ ) {
+ return true;
+ }
+ }
+
+ return $value === null;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Accessor\AccessorStrategyInterface;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Naming\AdvancedNamingStrategyInterface;
+use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
+
+/**
+ * XmlSerializationVisitor.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class XmlSerializationVisitor extends AbstractVisitor
+{
+ public $document;
+
+ private $navigator;
+ private $defaultRootName = 'result';
+ private $defaultRootNamespace;
+ private $defaultVersion = '1.0';
+ private $defaultEncoding = 'UTF-8';
+ private $stack;
+ private $metadataStack;
+ private $currentNode;
+ private $currentMetadata;
+ private $hasValue;
+ private $nullWasVisited;
+ private $objectMetadataStack;
+
+ /** @var boolean */
+ private $formatOutput;
+
+ public function __construct($namingStrategy, AccessorStrategyInterface $accessorStrategy = null)
+ {
+ parent::__construct($namingStrategy, $accessorStrategy);
+ $this->objectMetadataStack = new \SplStack;
+ $this->formatOutput = true;
+ }
+
+ public function setDefaultRootName($name, $namespace = null)
+ {
+ $this->defaultRootName = $name;
+ $this->defaultRootNamespace = $namespace;
+ }
+
+ /**
+ * @return boolean
+ */
+ public function hasDefaultRootName()
+ {
+ return 'result' === $this->defaultRootName;
+ }
+
+ public function setDefaultVersion($version)
+ {
+ $this->defaultVersion = $version;
+ }
+
+ public function setDefaultEncoding($encoding)
+ {
+ $this->defaultEncoding = $encoding;
+ }
+
+ public function setNavigator(GraphNavigator $navigator)
+ {
+ $this->navigator = $navigator;
+ $this->document = null;
+ $this->stack = new \SplStack;
+ $this->metadataStack = new \SplStack;
+ }
+
+ public function getNavigator()
+ {
+ return $this->navigator;
+ }
+
+ public function visitNull($data, array $type, Context $context)
+ {
+ if (null === $this->document) {
+ $this->document = $this->createDocument(null, null, true);
+ $node = $this->document->createAttribute('xsi:nil');
+ $node->value = 'true';
+ $this->currentNode->appendChild($node);
+
+ $this->attachNullNamespace();
+
+ return;
+ }
+
+ $node = $this->document->createAttribute('xsi:nil');
+ $node->value = 'true';
+ $this->attachNullNamespace();
+
+ return $node;
+ }
+
+ public function visitString($data, array $type, Context $context)
+ {
+
+ if (null !== $this->currentMetadata) {
+ $doCData = $this->currentMetadata->xmlElementCData;
+ } else {
+ $doCData = true;
+ }
+
+ if (null === $this->document) {
+ $this->document = $this->createDocument(null, null, true);
+ $this->currentNode->appendChild($doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string)$data));
+
+ return;
+ }
+
+ return $doCData ? $this->document->createCDATASection($data) : $this->document->createTextNode((string)$data);
+ }
+
+ public function visitSimpleString($data, array $type, Context $context)
+ {
+ if (null === $this->document) {
+ $this->document = $this->createDocument(null, null, true);
+ $this->currentNode->appendChild($this->document->createTextNode((string)$data));
+
+ return;
+ }
+
+ return $this->document->createTextNode((string)$data);
+ }
+
+ public function visitBoolean($data, array $type, Context $context)
+ {
+ if (null === $this->document) {
+ $this->document = $this->createDocument(null, null, true);
+ $this->currentNode->appendChild($this->document->createTextNode($data ? 'true' : 'false'));
+
+ return;
+ }
+
+ return $this->document->createTextNode($data ? 'true' : 'false');
+ }
+
+ public function visitInteger($data, array $type, Context $context)
+ {
+ return $this->visitNumeric($data, $type);
+ }
+
+ public function visitDouble($data, array $type, Context $context)
+ {
+ return $this->visitNumeric($data, $type);
+ }
+
+ public function visitArray($data, array $type, Context $context)
+ {
+ if (null === $this->document) {
+ $this->document = $this->createDocument(null, null, true);
+ }
+
+ $entryName = (null !== $this->currentMetadata && null !== $this->currentMetadata->xmlEntryName) ? $this->currentMetadata->xmlEntryName : 'entry';
+ $keyAttributeName = (null !== $this->currentMetadata && null !== $this->currentMetadata->xmlKeyAttribute) ? $this->currentMetadata->xmlKeyAttribute : null;
+ $namespace = (null !== $this->currentMetadata && null !== $this->currentMetadata->xmlEntryNamespace) ? $this->currentMetadata->xmlEntryNamespace : null;
+
+ foreach ($data as $k => $v) {
+
+ if (null === $v && $context->shouldSerializeNull() !== true) {
+ continue;
+ }
+
+ $tagName = (null !== $this->currentMetadata && $this->currentMetadata->xmlKeyValuePairs && $this->isElementNameValid($k)) ? $k : $entryName;
+
+ $entryNode = $this->createElement($tagName, $namespace);
+ $this->currentNode->appendChild($entryNode);
+ $this->setCurrentNode($entryNode);
+
+ if (null !== $keyAttributeName) {
+ $entryNode->setAttribute($keyAttributeName, (string)$k);
+ }
+
+ if (null !== $node = $this->navigator->accept($v, $this->getElementType($type), $context)) {
+ $this->currentNode->appendChild($node);
+ }
+
+ $this->revertCurrentNode();
+ }
+ }
+
+ public function startVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ $this->objectMetadataStack->push($metadata);
+
+ if (null === $this->document) {
+ $this->document = $this->createDocument(null, null, false);
+ if ($metadata->xmlRootName) {
+ $rootName = $metadata->xmlRootName;
+ $rootNamespace = $metadata->xmlRootNamespace ?: $this->getClassDefaultNamespace($metadata);
+ } else {
+ $rootName = $this->defaultRootName;
+ $rootNamespace = $this->defaultRootNamespace;
+ }
+
+ if ($rootNamespace) {
+ $this->currentNode = $this->document->createElementNS($rootNamespace, $rootName);
+ } else {
+ $this->currentNode = $this->document->createElement($rootName);
+ }
+
+ $this->document->appendChild($this->currentNode);
+ }
+
+ $this->addNamespaceAttributes($metadata, $this->currentNode);
+
+ $this->hasValue = false;
+ }
+
+ public function visitProperty(PropertyMetadata $metadata, $object, Context $context)
+ {
+ $v = $this->accessor->getValue($object, $metadata);
+
+ if (null === $v && $context->shouldSerializeNull() !== true) {
+ return;
+ }
+
+ if ($metadata->xmlAttribute) {
+ $this->setCurrentMetadata($metadata);
+ $node = $this->navigator->accept($v, $metadata->type, $context);
+ $this->revertCurrentMetadata();
+
+ if (!$node instanceof \DOMCharacterData) {
+ throw new RuntimeException(sprintf('Unsupported value for XML attribute for %s. Expected character data, but got %s.', $metadata->name, json_encode($v)));
+ }
+ if ($this->namingStrategy instanceof AdvancedNamingStrategyInterface) {
+ $attributeName = $this->namingStrategy->getPropertyName($metadata, $context);
+ } else {
+ $attributeName = $this->namingStrategy->translateName($metadata);
+ }
+ $this->setAttributeOnNode($this->currentNode, $attributeName, $node->nodeValue, $metadata->xmlNamespace);
+
+ return;
+ }
+
+ if (($metadata->xmlValue && $this->currentNode->childNodes->length > 0)
+ || (!$metadata->xmlValue && $this->hasValue)
+ ) {
+ throw new RuntimeException(sprintf('If you make use of @XmlValue, all other properties in the class must have the @XmlAttribute annotation. Invalid usage detected in class %s.', $metadata->class));
+ }
+
+ if ($metadata->xmlValue) {
+ $this->hasValue = true;
+
+ $this->setCurrentMetadata($metadata);
+ $node = $this->navigator->accept($v, $metadata->type, $context);
+ $this->revertCurrentMetadata();
+
+ if (!$node instanceof \DOMCharacterData) {
+ throw new RuntimeException(sprintf('Unsupported value for property %s::$%s. Expected character data, but got %s.', $metadata->reflection->class, $metadata->reflection->name, is_object($node) ? get_class($node) : gettype($node)));
+ }
+
+ $this->currentNode->appendChild($node);
+
+ return;
+ }
+
+ if ($metadata->xmlAttributeMap) {
+ if (!is_array($v)) {
+ throw new RuntimeException(sprintf('Unsupported value type for XML attribute map. Expected array but got %s.', gettype($v)));
+ }
+
+ foreach ($v as $key => $value) {
+ $this->setCurrentMetadata($metadata);
+ $node = $this->navigator->accept($value, null, $context);
+ $this->revertCurrentMetadata();
+
+ if (!$node instanceof \DOMCharacterData) {
+ throw new RuntimeException(sprintf('Unsupported value for a XML attribute map value. Expected character data, but got %s.', json_encode($v)));
+ }
+
+ $this->setAttributeOnNode($this->currentNode, $key, $node->nodeValue, $metadata->xmlNamespace);
+ }
+
+ return;
+ }
+
+ if ($addEnclosingElement = !$this->isInLineCollection($metadata) && !$metadata->inline) {
+ if ($this->namingStrategy instanceof AdvancedNamingStrategyInterface) {
+ $elementName = $this->namingStrategy->getPropertyName($metadata, $context);
+ } else {
+ $elementName = $this->namingStrategy->translateName($metadata);
+ }
+
+ $namespace = null !== $metadata->xmlNamespace
+ ? $metadata->xmlNamespace
+ : $this->getClassDefaultNamespace($this->objectMetadataStack->top());
+
+ $element = $this->createElement($elementName, $namespace);
+ $this->currentNode->appendChild($element);
+ $this->setCurrentNode($element);
+ }
+
+ $this->setCurrentMetadata($metadata);
+
+ if (null !== $node = $this->navigator->accept($v, $metadata->type, $context)) {
+ $this->currentNode->appendChild($node);
+ }
+
+ $this->revertCurrentMetadata();
+
+ if ($addEnclosingElement) {
+ $this->revertCurrentNode();
+
+ if ($this->isElementEmpty($element) && ($v === null || $this->isSkippableCollection($metadata) || $this->isSkippableEmptyObject($node, $metadata) || $this->isCircularRef($context, $v))) {
+ $this->currentNode->removeChild($element);
+ }
+ }
+
+ $this->hasValue = false;
+ }
+
+ private function isInLineCollection(PropertyMetadata $metadata)
+ {
+ return $metadata->xmlCollection && $metadata->xmlCollectionInline;
+ }
+
+ private function isCircularRef(SerializationContext $context, $v)
+ {
+ return $context->isVisiting($v);
+ }
+
+ private function isSkippableEmptyObject($node, PropertyMetadata $metadata)
+ {
+ return $node === null && !$metadata->xmlCollection && $metadata->skipWhenEmpty;
+ }
+
+ private function isSkippableCollection(PropertyMetadata $metadata)
+ {
+ return $metadata->xmlCollection && $metadata->xmlCollectionSkipWhenEmpty;
+ }
+
+ private function isElementEmpty(\DOMElement $element)
+ {
+ return !$element->hasChildNodes() && !$element->hasAttributes();
+ }
+
+ public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ $this->objectMetadataStack->pop();
+ }
+
+ public function getResult()
+ {
+ return $this->document->saveXML();
+ }
+
+ public function getCurrentNode()
+ {
+ return $this->currentNode;
+ }
+
+ public function getCurrentMetadata()
+ {
+ return $this->currentMetadata;
+ }
+
+ public function getDocument()
+ {
+ return $this->document;
+ }
+
+ public function setCurrentMetadata(PropertyMetadata $metadata)
+ {
+ $this->metadataStack->push($this->currentMetadata);
+ $this->currentMetadata = $metadata;
+ }
+
+ public function setCurrentNode(\DOMNode $node)
+ {
+ $this->stack->push($this->currentNode);
+ $this->currentNode = $node;
+ }
+
+ public function revertCurrentNode()
+ {
+ return $this->currentNode = $this->stack->pop();
+ }
+
+ public function revertCurrentMetadata()
+ {
+ return $this->currentMetadata = $this->metadataStack->pop();
+ }
+
+ public function createDocument($version = null, $encoding = null, $addRoot = true)
+ {
+ $doc = new \DOMDocument($version ?: $this->defaultVersion, $encoding ?: $this->defaultEncoding);
+ $doc->formatOutput = $this->isFormatOutput();
+
+ if ($addRoot) {
+ if ($this->defaultRootNamespace) {
+ $rootNode = $doc->createElementNS($this->defaultRootNamespace, $this->defaultRootName);
+ } else {
+ $rootNode = $doc->createElement($this->defaultRootName);
+ }
+ $this->setCurrentNode($rootNode);
+ $doc->appendChild($rootNode);
+ }
+
+ return $doc;
+ }
+
+ public function prepare($data)
+ {
+ $this->nullWasVisited = false;
+
+ return $data;
+ }
+
+ private function visitNumeric($data, array $type)
+ {
+ if (null === $this->document) {
+ $this->document = $this->createDocument(null, null, true);
+ $this->currentNode->appendChild($textNode = $this->document->createTextNode((string)$data));
+
+ return $textNode;
+ }
+
+ return $this->document->createTextNode((string)$data);
+ }
+
+ /**
+ * Checks that the name is a valid XML element name.
+ *
+ * @param string $name
+ *
+ * @return boolean
+ */
+ private function isElementNameValid($name)
+ {
+ return $name && false === strpos($name, ' ') && preg_match('#^[\pL_][\pL0-9._-]*$#ui', $name);
+ }
+
+ private function attachNullNamespace()
+ {
+ if (!$this->nullWasVisited) {
+ $this->document->documentElement->setAttributeNS(
+ 'http://www.w3.org/2000/xmlns/',
+ 'xmlns:xsi',
+ 'http://www.w3.org/2001/XMLSchema-instance'
+ );
+ $this->nullWasVisited = true;
+ }
+ }
+
+ /**
+ * Adds namespace attributes to the XML root element
+ *
+ * @param \JMS\Serializer\Metadata\ClassMetadata $metadata
+ * @param \DOMElement $element
+ */
+ private function addNamespaceAttributes(ClassMetadata $metadata, \DOMElement $element)
+ {
+ foreach ($metadata->xmlNamespaces as $prefix => $uri) {
+ $attribute = 'xmlns';
+ if ($prefix !== '') {
+ $attribute .= ':' . $prefix;
+ } elseif ($element->namespaceURI === $uri) {
+ continue;
+ }
+ $element->setAttributeNS('http://www.w3.org/2000/xmlns/', $attribute, $uri);
+ }
+ }
+
+ private function createElement($tagName, $namespace = null)
+ {
+ if (null === $namespace) {
+ return $this->document->createElement($tagName);
+ }
+ if ($this->currentNode->isDefaultNamespace($namespace)) {
+ return $this->document->createElementNS($namespace, $tagName);
+ }
+ if (!($prefix = $this->currentNode->lookupPrefix($namespace)) && !($prefix = $this->document->lookupPrefix($namespace))) {
+ $prefix = 'ns-' . substr(sha1($namespace), 0, 8);
+ }
+ return $this->document->createElementNS($namespace, $prefix . ':' . $tagName);
+ }
+
+ private function setAttributeOnNode(\DOMElement $node, $name, $value, $namespace = null)
+ {
+ if (null !== $namespace) {
+ if (!$prefix = $node->lookupPrefix($namespace)) {
+ $prefix = 'ns-' . substr(sha1($namespace), 0, 8);
+ }
+ $node->setAttributeNS($namespace, $prefix . ':' . $name, $value);
+ } else {
+ $node->setAttribute($name, $value);
+ }
+ }
+
+ private function getClassDefaultNamespace(ClassMetadata $metadata)
+ {
+ return (isset($metadata->xmlNamespaces['']) ? $metadata->xmlNamespaces[''] : null);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isFormatOutput()
+ {
+ return $this->formatOutput;
+ }
+
+ /**
+ * @param bool $formatOutput
+ */
+ public function setFormatOutput($formatOutput)
+ {
+ $this->formatOutput = (boolean)$formatOutput;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer;
+
+use JMS\Serializer\Accessor\AccessorStrategyInterface;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Naming\AdvancedNamingStrategyInterface;
+use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
+use JMS\Serializer\Util\Writer;
+use Symfony\Component\Yaml\Inline;
+
+/**
+ * Serialization Visitor for the YAML format.
+ *
+ * @see http://www.yaml.org/spec/
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class YamlSerializationVisitor extends AbstractVisitor
+{
+ public $writer;
+
+ private $navigator;
+ private $stack;
+ private $metadataStack;
+ private $currentMetadata;
+
+ public function __construct($namingStrategy, AccessorStrategyInterface $accessorStrategy = null)
+ {
+ parent::__construct($namingStrategy, $accessorStrategy);
+
+ $this->writer = new Writer();
+ }
+
+ public function setNavigator(GraphNavigator $navigator)
+ {
+ $this->navigator = $navigator;
+ $this->writer->reset();
+ $this->stack = new \SplStack;
+ $this->metadataStack = new \SplStack;
+ }
+
+ public function visitNull($data, array $type, Context $context)
+ {
+ if ('' === $this->writer->content) {
+ $this->writer->writeln('null');
+ }
+
+ return 'null';
+ }
+
+ public function visitString($data, array $type, Context $context)
+ {
+ $v = Inline::dump($data);
+
+ if ('' === $this->writer->content) {
+ $this->writer->writeln($v);
+ }
+
+ return $v;
+ }
+
+ /**
+ * @param array $data
+ * @param array $type
+ */
+ public function visitArray($data, array $type, Context $context)
+ {
+ $isHash = isset($type['params'][1]);
+
+ $count = $this->writer->changeCount;
+ $isList = (isset($type['params'][0]) && !isset($type['params'][1]))
+ || array_keys($data) === range(0, count($data) - 1);
+
+ foreach ($data as $k => $v) {
+ if (null === $v && $context->shouldSerializeNull() !== true) {
+ continue;
+ }
+
+ if ($isList && !$isHash) {
+ $this->writer->writeln('-');
+ } else {
+ $this->writer->writeln(Inline::dump($k) . ':');
+ }
+
+ $this->writer->indent();
+
+ if (null !== $v = $this->navigator->accept($v, $this->getElementType($type), $context)) {
+ $this->writer
+ ->rtrim(false)
+ ->writeln(' ' . $v);
+ }
+
+ $this->writer->outdent();
+ }
+
+ if ($count === $this->writer->changeCount && isset($type['params'][1])) {
+ $this->writer
+ ->rtrim(false)
+ ->writeln(' {}');
+ } elseif (empty($data)) {
+ $this->writer
+ ->rtrim(false)
+ ->writeln(' []');
+ }
+ }
+
+ public function visitBoolean($data, array $type, Context $context)
+ {
+ $v = $data ? 'true' : 'false';
+
+ if ('' === $this->writer->content) {
+ $this->writer->writeln($v);
+ }
+
+ return $v;
+ }
+
+ public function visitDouble($data, array $type, Context $context)
+ {
+ $v = (string)$data;
+
+ if ('' === $this->writer->content) {
+ $this->writer->writeln($v);
+ }
+
+ return $v;
+ }
+
+ public function visitInteger($data, array $type, Context $context)
+ {
+ $v = (string)$data;
+
+ if ('' === $this->writer->content) {
+ $this->writer->writeln($v);
+ }
+
+ return $v;
+ }
+
+ public function startVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ }
+
+ public function visitProperty(PropertyMetadata $metadata, $data, Context $context)
+ {
+ $v = $this->accessor->getValue($data, $metadata);
+
+ if (null === $v && $context->shouldSerializeNull() !== true) {
+ return;
+ }
+
+ if ($this->namingStrategy instanceof AdvancedNamingStrategyInterface) {
+ $name = $this->namingStrategy->getPropertyName($metadata, $context);
+ } else {
+ $name = $this->namingStrategy->translateName($metadata);
+ }
+
+ if (!$metadata->inline) {
+ $this->writer
+ ->writeln(Inline::dump($name) . ':')
+ ->indent();
+ }
+
+ $this->setCurrentMetadata($metadata);
+
+ $count = $this->writer->changeCount;
+
+ if (null !== $v = $this->navigator->accept($v, $metadata->type, $context)) {
+ $this->writer
+ ->rtrim(false)
+ ->writeln(' ' . $v);
+ } elseif ($count === $this->writer->changeCount && !$metadata->inline) {
+ $this->writer->revert();
+ }
+
+ if (!$metadata->inline) {
+ $this->writer->outdent();
+ }
+ $this->revertCurrentMetadata();
+ }
+
+ public function endVisitingObject(ClassMetadata $metadata, $data, array $type, Context $context)
+ {
+ }
+
+ public function setCurrentMetadata(PropertyMetadata $metadata)
+ {
+ $this->metadataStack->push($this->currentMetadata);
+ $this->currentMetadata = $metadata;
+ }
+
+ public function revertCurrentMetadata()
+ {
+ return $this->currentMetadata = $this->metadataStack->pop();
+ }
+
+ public function getNavigator()
+ {
+ return $this->navigator;
+ }
+
+ public function getResult()
+ {
+ return $this->writer->getContent();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Exclusion;
+
+use JMS\Serializer\Exclusion\DisjunctExclusionStrategy;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\StaticPropertyMetadata;
+use JMS\Serializer\SerializationContext;
+
+class DisjunctExclusionStrategyTest extends \PHPUnit_Framework_TestCase
+{
+ public function testShouldSkipClassShortCircuiting()
+ {
+ $metadata = new ClassMetadata('stdClass');
+ $context = SerializationContext::create();
+
+ $strat = new DisjunctExclusionStrategy(array(
+ $first = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ $last = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ ));
+
+ $first->expects($this->once())
+ ->method('shouldSkipClass')
+ ->with($metadata, $context)
+ ->will($this->returnValue(true));
+
+ $last->expects($this->never())
+ ->method('shouldSkipClass');
+
+ $this->assertTrue($strat->shouldSkipClass($metadata, $context));
+ }
+
+ public function testShouldSkipClassDisjunctBehavior()
+ {
+ $metadata = new ClassMetadata('stdClass');
+ $context = SerializationContext::create();
+
+ $strat = new DisjunctExclusionStrategy(array(
+ $first = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ $last = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ ));
+
+ $first->expects($this->once())
+ ->method('shouldSkipClass')
+ ->with($metadata, $context)
+ ->will($this->returnValue(false));
+
+ $last->expects($this->once())
+ ->method('shouldSkipClass')
+ ->with($metadata, $context)
+ ->will($this->returnValue(true));
+
+ $this->assertTrue($strat->shouldSkipClass($metadata, $context));
+ }
+
+ public function testShouldSkipClassReturnsFalseIfNoPredicateMatched()
+ {
+ $metadata = new ClassMetadata('stdClass');
+ $context = SerializationContext::create();
+
+ $strat = new DisjunctExclusionStrategy(array(
+ $first = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ $last = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ ));
+
+ $first->expects($this->once())
+ ->method('shouldSkipClass')
+ ->with($metadata, $context)
+ ->will($this->returnValue(false));
+
+ $last->expects($this->once())
+ ->method('shouldSkipClass')
+ ->with($metadata, $context)
+ ->will($this->returnValue(false));
+
+ $this->assertFalse($strat->shouldSkipClass($metadata, $context));
+ }
+
+ public function testShouldSkipPropertyShortCircuiting()
+ {
+ $metadata = new StaticPropertyMetadata('stdClass', 'foo', 'bar');
+ $context = SerializationContext::create();
+
+ $strat = new DisjunctExclusionStrategy(array(
+ $first = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ $last = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ ));
+
+ $first->expects($this->once())
+ ->method('shouldSkipProperty')
+ ->with($metadata, $context)
+ ->will($this->returnValue(true));
+
+ $last->expects($this->never())
+ ->method('shouldSkipProperty');
+
+ $this->assertTrue($strat->shouldSkipProperty($metadata, $context));
+ }
+
+ public function testShouldSkipPropertyDisjunct()
+ {
+ $metadata = new StaticPropertyMetadata('stdClass', 'foo', 'bar');
+ $context = SerializationContext::create();
+
+ $strat = new DisjunctExclusionStrategy(array(
+ $first = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ $last = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ ));
+
+ $first->expects($this->once())
+ ->method('shouldSkipProperty')
+ ->with($metadata, $context)
+ ->will($this->returnValue(false));
+
+ $last->expects($this->once())
+ ->method('shouldSkipProperty')
+ ->with($metadata, $context)
+ ->will($this->returnValue(true));
+
+ $this->assertTrue($strat->shouldSkipProperty($metadata, $context));
+ }
+
+ public function testShouldSkipPropertyReturnsFalseIfNoPredicateMatches()
+ {
+ $metadata = new StaticPropertyMetadata('stdClass', 'foo', 'bar');
+ $context = SerializationContext::create();
+
+ $strat = new DisjunctExclusionStrategy(array(
+ $first = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ $last = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock(),
+ ));
+
+ $first->expects($this->once())
+ ->method('shouldSkipProperty')
+ ->with($metadata, $context)
+ ->will($this->returnValue(false));
+
+ $last->expects($this->once())
+ ->method('shouldSkipProperty')
+ ->with($metadata, $context)
+ ->will($this->returnValue(false));
+
+ $this->assertFalse($strat->shouldSkipProperty($metadata, $context));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Exclusion;
+
+use JMS\Serializer\Exclusion\ExpressionLanguageExclusionStrategy;
+use JMS\Serializer\Expression\ExpressionEvaluator;
+use JMS\Serializer\Metadata\StaticPropertyMetadata;
+use JMS\Serializer\SerializationContext;
+
+/**
+ * @author Asmir Mustafic <goetas@gmail.com>
+ */
+class ExpressionLanguageExclusionStrategyTest extends \PHPUnit_Framework_TestCase
+{
+ private $visitedObject;
+ private $context;
+ private $expressionEvaluator;
+ private $exclusionStrategy;
+
+ public function setUp()
+ {
+ $this->visitedObject = new \stdClass();
+
+ $this->context = $this->getMockBuilder(SerializationContext::class)->getMock();
+ $this->context->method('getObject')->willReturn($this->visitedObject);
+
+ $this->expressionEvaluator = $this->getMockBuilder(ExpressionEvaluator::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->exclusionStrategy = new ExpressionLanguageExclusionStrategy($this->expressionEvaluator);
+ }
+
+ public function testExpressionLanguageExclusionWorks()
+ {
+ $metadata = new StaticPropertyMetadata('stdClass', 'prop', 'propVal');
+ $metadata->excludeIf = 'foo';
+
+ $this->expressionEvaluator->expects($this->once())
+ ->method('evaluate')
+ ->with('foo', array(
+ 'context' => $this->context,
+ 'property_metadata' => $metadata,
+ 'object' => $this->visitedObject,
+ ))
+ ->willReturn(true);
+
+ $this->assertSame(true, $this->exclusionStrategy->shouldSkipProperty($metadata, $this->context));
+ }
+
+ public function testExpressionLanguageSkipsWhenNoExpression()
+ {
+ $metadata = new StaticPropertyMetadata('stdClass', 'prop', 'propVal');
+
+ $this->expressionEvaluator->expects($this->never())->method('evaluate');
+
+ $this->assertSame(false, $this->exclusionStrategy->shouldSkipProperty($metadata, $this->context));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Exclusion;
+
+use JMS\Serializer\Exclusion\GroupsExclusionStrategy;
+use JMS\Serializer\Metadata\StaticPropertyMetadata;
+use JMS\Serializer\SerializationContext;
+
+class GroupsExclusionStrategyTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @dataProvider getExclusionRules
+ * @param array $propertyGroups
+ * @param array $groups
+ * @param $exclude
+ */
+ public function testUninitializedContextIsWorking(array $propertyGroups, array $groups, $exclude)
+ {
+ $metadata = new StaticPropertyMetadata('stdClass', 'prop', 'propVal');
+ $metadata->groups = $propertyGroups;
+
+ $strat = new GroupsExclusionStrategy($groups);
+ $this->assertEquals($strat->shouldSkipProperty($metadata, SerializationContext::create()), $exclude);
+ }
+
+ public function getExclusionRules()
+ {
+ return [
+ [['foo'], ['foo'], false],
+ [['foo'], [], true],
+ [[], ['foo'], true],
+ [['foo'], ['bar'], true],
+ [['bar'], ['foo'], true],
+
+ [['foo', GroupsExclusionStrategy::DEFAULT_GROUP], [], false],
+ [['foo', 'bar'], [], true],
+ [['foo', 'bar'], [GroupsExclusionStrategy::DEFAULT_GROUP], true],
+ [['foo', 'bar'], ['foo'], false],
+
+ [['foo', GroupsExclusionStrategy::DEFAULT_GROUP], ['test'], true],
+ [['foo', GroupsExclusionStrategy::DEFAULT_GROUP, 'test'], ['test'], false],
+
+ [['foo'], [GroupsExclusionStrategy::DEFAULT_GROUP], true],
+ [[GroupsExclusionStrategy::DEFAULT_GROUP], [], false],
+ [[], [GroupsExclusionStrategy::DEFAULT_GROUP], false],
+ [[GroupsExclusionStrategy::DEFAULT_GROUP], [GroupsExclusionStrategy::DEFAULT_GROUP], false],
+ [[GroupsExclusionStrategy::DEFAULT_GROUP, 'foo'], [GroupsExclusionStrategy::DEFAULT_GROUP], false],
+ [[GroupsExclusionStrategy::DEFAULT_GROUP], [GroupsExclusionStrategy::DEFAULT_GROUP, 'foo'], false],
+ [['foo'], [GroupsExclusionStrategy::DEFAULT_GROUP, 'foo'], false],
+ ];
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/** @Serializer\AccessorOrder("custom", custom = {"c", "d", "a", "b"}) */
+class AccessorOrderChild extends AccessorOrderParent
+{
+ private $c = 'c', $d = 'd';
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/** @Serializer\AccessorOrder("custom", custom = {"method", "b", "a"}) */
+class AccessorOrderMethod
+{
+ private $b = 'b', $a = 'a';
+
+ /**
+ * @Serializer\VirtualProperty
+ * @Serializer\SerializedName("foo")
+ *
+ * @return string
+ */
+ public function getMethod()
+ {
+ return 'c';
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/** @Serializer\AccessorOrder("alphabetical") */
+class AccessorOrderParent
+{
+ private $b = 'b', $a = 'a';
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class AccessorSetter
+{
+ /**
+ * @var \stdClass
+ * @Serializer\Type("JMS\Serializer\Tests\Fixtures\AccessorSetterElement")
+ * @Serializer\Accessor(setter="setElementDifferent")
+ */
+ protected $element;
+
+ /**
+ * @var array
+ * @Serializer\Type("array<string>")
+ * @Serializer\Accessor(setter="setCollectionDifferent")
+ * @Serializer\XmlList(inline=false)
+ */
+ protected $collection;
+
+ /**
+ * @return \stdClass
+ */
+ public function getElement()
+ {
+ return $this->element;
+ }
+
+ /**
+ * @param AccessorSetterElement $element
+ */
+ public function setElementDifferent(AccessorSetterElement $element)
+ {
+ $this->element = new \stdClass();
+ $this->element->element = $element;
+ }
+
+ /**
+ * @return array
+ */
+ public function getCollection()
+ {
+ return $this->collection;
+ }
+
+ /**
+ * @param array $collection
+ */
+ public function setCollectionDifferent($collection)
+ {
+ $this->collection = array_combine($collection, $collection);
+ }
+}
+
+class AccessorSetterElement
+{
+ /**
+ * @var string
+ * @Serializer\Type("string")
+ * @Serializer\Accessor(setter="setAttributeDifferent")
+ * @Serializer\XmlAttribute
+ */
+ protected $attribute;
+
+ /**
+ * @var string
+ * @Serializer\Type("string")
+ * @Serializer\Accessor(setter="setElementDifferent")
+ * @Serializer\XmlValue
+ */
+ protected $element;
+
+ /**
+ * @return string
+ */
+ public function getAttribute()
+ {
+ return $this->attribute;
+ }
+
+ /**
+ * @param string $attribute
+ */
+ public function setAttributeDifferent($attribute)
+ {
+ $this->attribute = $attribute . "-different";
+ }
+
+
+ /**
+ * @param string $element
+ */
+ public function setElementDifferent($element)
+ {
+ $this->element = $element . "-different";
+ }
+
+ /**
+ * @return string
+ */
+ public function getElement()
+ {
+ return $this->element;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\ExclusionPolicy;
+use JMS\Serializer\Annotation\Expose;
+
+/**
+ * @ExclusionPolicy("all")
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class AllExcludedObject
+{
+ private $foo = 'foo';
+
+ /**
+ * @Expose
+ */
+ private $bar = 'bar';
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\HandlerCallback;
+use JMS\Serializer\Context;
+use JMS\Serializer\JsonDeserializationVisitor;
+use JMS\Serializer\JsonSerializationVisitor;
+use JMS\Serializer\XmlDeserializationVisitor;
+use JMS\Serializer\XmlSerializationVisitor;
+use JMS\Serializer\YamlSerializationVisitor;
+use Symfony\Component\Yaml\Inline;
+
+class Article
+{
+ public $element;
+ public $value;
+
+ /** @HandlerCallback("xml", direction = "serialization") */
+ public function serializeToXml(XmlSerializationVisitor $visitor, $data, Context $context)
+ {
+ if (null === $visitor->document) {
+ $visitor->document = $visitor->createDocument(null, null, false);
+ }
+
+ $visitor->document->appendChild($visitor->document->createElement($this->element, $this->value));
+ }
+
+ /** @HandlerCallback("json", direction = "serialization") */
+ public function serializeToJson(JsonSerializationVisitor $visitor)
+ {
+ $visitor->setRoot(array($this->element => $this->value));
+ }
+
+ /** @HandlerCallback("yml", direction = "serialization") */
+ public function serializeToYml(YamlSerializationVisitor $visitor)
+ {
+ $visitor->writer->writeln(Inline::dump($this->element) . ': ' . Inline::dump($this->value));
+ }
+
+ /** @HandlerCallback("xml", direction = "deserialization") */
+ public function deserializeFromXml(XmlDeserializationVisitor $visitor, \SimpleXMLElement $data)
+ {
+ $this->element = $data->getName();
+ $this->value = (string)$data;
+ }
+
+ /** @HandlerCallback("json", direction = "deserialization") */
+ public function deserializeFromJson(JsonDeserializationVisitor $visitor, array $data)
+ {
+ $this->element = key($data);
+ $this->value = reset($data);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+
+class Author
+{
+ /**
+ * @Type("string")
+ * @SerializedName("full_name")
+ */
+ private $name;
+
+ public function __construct($name)
+ {
+ $this->name = $name;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\VirtualProperty("firstName", exp="object.getFirstName()", options={@Serializer\SerializedName("my_first_name")})
+ */
+class AuthorExpressionAccess
+{
+ private $id;
+ /**
+ * @Serializer\Exclude()
+ */
+ private $firstName;
+
+ /**
+ * @Serializer\Exclude()
+ */
+ private $lastName;
+
+ public function __construct($id, $firstName, $lastName)
+ {
+ $this->id = $id;
+ $this->firstName = $firstName;
+ $this->lastName = $lastName;
+ }
+
+ public function getFirstName()
+ {
+ return $this->firstName;
+ }
+
+ /**
+ * @Serializer\VirtualProperty()
+ */
+ public function getLastName()
+ {
+ return $this->lastName;
+ }
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * An array-acting object that holds many author instances.
+ */
+class AuthorList implements \IteratorAggregate, \Countable, \ArrayAccess
+{
+ /**
+ * @Serializer\Type("array<JMS\Serializer\Tests\Fixtures\Author>")
+ * @var array
+ */
+ protected $authors = array();
+
+ /**
+ * @param Author $author
+ */
+ public function add(Author $author)
+ {
+ $this->authors[] = $author;
+ }
+
+ /**
+ * @see IteratorAggregate
+ */
+ public function getIterator()
+ {
+ return new \ArrayIterator($this->authors);
+ }
+
+ /**
+ * @see Countable
+ */
+ public function count()
+ {
+ return count($this->authors);
+ }
+
+ /**
+ * @see ArrayAccess
+ */
+ public function offsetExists($offset)
+ {
+ return isset($this->authors[$offset]);
+ }
+
+ /**
+ * @see ArrayAccess
+ */
+ public function offsetGet($offset)
+ {
+ return isset($this->authors[$offset]) ? $this->authors[$offset] : null;
+ }
+
+ /**
+ * @see ArrayAccess
+ */
+ public function offsetSet($offset, $value)
+ {
+ if (null === $offset) {
+ $this->authors[] = $value;
+ } else {
+ $this->authors[$offset] = $value;
+ }
+ }
+
+ /**
+ * @see ArrayAccess
+ */
+ public function offsetUnset($offset)
+ {
+ unset($this->authors[$offset]);
+ }
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Accessor;
+use JMS\Serializer\Annotation\ReadOnly;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/** @XmlRoot("author") */
+class AuthorReadOnly
+{
+ /**
+ * @ReadOnly
+ * @SerializedName("id")
+ */
+ private $id;
+
+ /**
+ * @Type("string")
+ * @SerializedName("full_name")
+ * @Accessor("getName")
+ */
+ private $name;
+
+ public function __construct($id, $name)
+ {
+ $this->id = $id;
+ $this->name = $name;
+ }
+
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Accessor;
+use JMS\Serializer\Annotation\ReadOnly;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("author")
+ * @ReadOnly
+ */
+class AuthorReadOnlyPerClass
+{
+ /**
+ * @ReadOnly
+ * @SerializedName("id")
+ */
+ private $id;
+
+ /**
+ * @Type("string")
+ * @SerializedName("full_name")
+ * @Accessor("getName")
+ * @ReadOnly(false)
+ */
+ private $name;
+
+ public function __construct($id, $name)
+ {
+ $this->id = $id;
+ $this->name = $name;
+ }
+
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlMap;
+use JMS\Serializer\Annotation\XmlNamespace;
+use JMS\Serializer\Annotation\XmlRoot;
+use PhpCollection\Map;
+use PhpCollection\Sequence;
+
+/**
+ * @XmlRoot("blog-post")
+ * @XmlNamespace(uri="http://example.com/namespace")
+ * @XmlNamespace(uri="http://schemas.google.com/g/2005", prefix="gd")
+ * @XmlNamespace(uri="http://www.w3.org/2005/Atom", prefix="atom")
+ * @XmlNamespace(uri="http://purl.org/dc/elements/1.1/", prefix="dc")
+ */
+class BlogPost
+{
+ /**
+ * @Type("string")
+ * @XmlElement(cdata=false)
+ * @Groups({"comments","post"})
+ */
+ private $id = 'what_a_nice_id';
+
+ /**
+ * @Type("string")
+ * @Groups({"comments","post"})
+ * @XmlElement(namespace="http://purl.org/dc/elements/1.1/");
+ */
+ private $title;
+
+ /**
+ * @Type("DateTime")
+ * @XmlAttribute
+ */
+ private $createdAt;
+
+ /**
+ * @Type("boolean")
+ * @SerializedName("is_published")
+ * @XmlAttribute
+ * @Groups({"post"})
+ */
+ private $published;
+
+ /**
+ * @Type("bool")
+ * @SerializedName("is_reviewed")
+ * @XmlAttribute
+ * @Groups({"post"})
+ */
+ private $reviewed;
+
+ /**
+ * @Type("string")
+ * @XmlAttribute(namespace="http://schemas.google.com/g/2005")
+ * @Groups({"post"})
+ */
+ private $etag;
+
+ /**
+ * @Type("ArrayCollection<JMS\Serializer\Tests\Fixtures\Comment>")
+ * @XmlList(inline=true, entry="comment")
+ * @Groups({"comments"})
+ */
+ private $comments;
+
+ /**
+ * @Type("PhpCollection\Sequence<JMS\Serializer\Tests\Fixtures\Comment>")
+ * @XmlList(inline=true, entry="comment2")
+ * @Groups({"comments"})
+ */
+ private $comments2;
+
+ /**
+ * @Type("PhpCollection\Map<string,string>")
+ * @XmlMap(keyAttribute = "key")
+ */
+ private $metadata;
+
+ /**
+ * @Type("JMS\Serializer\Tests\Fixtures\Author")
+ * @Groups({"post"})
+ * @XmlElement(namespace="http://www.w3.org/2005/Atom")
+ */
+ private $author;
+
+ /**
+ * @Type("JMS\Serializer\Tests\Fixtures\Publisher")
+ */
+ private $publisher;
+
+ /**
+ * @Type("array<JMS\Serializer\Tests\Fixtures\Tag>")
+ * @XmlList(inline=true, entry="tag", namespace="http://purl.org/dc/elements/1.1/");
+ */
+ private $tag;
+
+ public function __construct($title, Author $author, \DateTime $createdAt, Publisher $publisher)
+ {
+ $this->title = $title;
+ $this->author = $author;
+ $this->publisher = $publisher;
+ $this->published = false;
+ $this->reviewed = false;
+ $this->comments = new ArrayCollection();
+ $this->comments2 = new Sequence();
+ $this->metadata = new Map();
+ $this->metadata->set('foo', 'bar');
+ $this->createdAt = $createdAt;
+ $this->etag = sha1($this->createdAt->format(\DateTime::ISO8601));
+ }
+
+ public function setPublished()
+ {
+ $this->published = true;
+ }
+
+ public function getMetadata()
+ {
+ return $this->metadata;
+ }
+
+ public function addComment(Comment $comment)
+ {
+ $this->comments->add($comment);
+ $this->comments2->add($comment);
+ }
+
+ public function addTag(Tag $tag)
+ {
+ $this->tag[] = $tag;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+class CircularReferenceChild
+{
+ /** @Type("string") */
+ private $name;
+
+ /** @Type("JMS\Serializer\Tests\Fixtures\CircularReferenceParent") */
+ private $parent;
+
+ public function __construct($name, CircularReferenceParent $parent)
+ {
+ $this->name = $name;
+ $this->parent = $parent;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function getParent()
+ {
+ return $this->parent;
+ }
+
+ public function setParent(CircularReferenceParent $parent)
+ {
+ $this->parent = $parent;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use JMS\Serializer\Annotation\PostDeserialize;
+use JMS\Serializer\Annotation\Type;
+
+/** No annotation */
+class CircularReferenceParent
+{
+ /** @Type("array<JMS\Serializer\Tests\Fixtures\CircularReferenceChild>") */
+ protected $collection = array();
+
+ /** @Type("ArrayCollection<JMS\Serializer\Tests\Fixtures\CircularReferenceChild>") */
+ private $anotherCollection;
+
+ public function __construct()
+ {
+ $this->collection[] = new CircularReferenceChild('child1', $this);
+ $this->collection[] = new CircularReferenceChild('child2', $this);
+
+ $this->anotherCollection = new ArrayCollection();
+ $this->anotherCollection->add(new CircularReferenceChild('child1', $this));
+ $this->anotherCollection->add(new CircularReferenceChild('child2', $this));
+ }
+
+ /** @PostDeserialize */
+ private function afterDeserialization()
+ {
+ if (!$this->collection) {
+ $this->collection = array();
+ }
+ foreach ($this->collection as $v) {
+ $v->setParent($this);
+ }
+
+ if (!$this->anotherCollection) {
+ $this->anotherCollection = new ArrayCollection();
+ }
+ foreach ($this->anotherCollection as $v) {
+ $v->setParent($this);
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+class Comment
+{
+ /**
+ * @Type("JMS\Serializer\Tests\Fixtures\Author")
+ */
+ private $author;
+
+ /**
+ * @Type("string")
+ */
+ private $text;
+
+ public function __construct(Author $author = null, $text)
+ {
+ $this->author = $author;
+ $this->text = $text;
+ }
+
+ public function getAuthor()
+ {
+ return $this->author;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Naming\AdvancedNamingStrategyInterface;
+
+/**
+ * Class ContextualNamingStrategy
+ *
+ * Only use this class for testing purpose
+ */
+class ContextualNamingStrategy implements AdvancedNamingStrategyInterface
+{
+ public function getPropertyName(PropertyMetadata $property, Context $context)
+ {
+ if ($context->getDirection() == GraphNavigator::DIRECTION_SERIALIZATION) {
+ return strtoupper($property->name);
+ }
+ return ucfirst($property->name);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/** @XmlRoot("order") */
+class CurrencyAwareOrder
+{
+ /** @Type("JMS\Serializer\Tests\Fixtures\CurrencyAwarePrice") */
+ private $cost;
+
+ public function __construct(CurrencyAwarePrice $price = null)
+ {
+ $this->cost = $price ?: new CurrencyAwarePrice(5);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/** @Serializer\XmlRoot("price") */
+class CurrencyAwarePrice
+{
+ /**
+ * @Serializer\XmlAttribute
+ * @Serializer\Type("string")
+ */
+ private $currency;
+
+ /**
+ * @Serializer\XmlValue
+ * @Serializer\Type("double")
+ */
+ private $amount;
+
+ public function __construct($amount, $currency = 'EUR')
+ {
+ $this->currency = $currency;
+ $this->amount = $amount;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+class CustomDeserializationObject
+{
+ /**
+ * @Type("string")
+ */
+ public $someProperty;
+
+ public function __construct($value)
+ {
+ $this->someProperty = $value;
+ }
+}
--- /dev/null
+<?php
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+
+class DateTimeArraysObject
+{
+ /**
+ * @var \DateTime[]
+ * @Type("array<DateTime>")
+ */
+ private $arrayWithDefaultDateTime;
+
+ /**
+ * @var \DateTime[]
+ * @Type("array<DateTime<'d.m.Y H:i:s'>>")
+ */
+ private $arrayWithFormattedDateTime;
+
+
+ function __construct($arrayWithDefaultDateTime, $arrayWithFormattedDateTime)
+ {
+ $this->arrayWithDefaultDateTime = $arrayWithDefaultDateTime;
+ $this->arrayWithFormattedDateTime = $arrayWithFormattedDateTime;
+ }
+
+ /**
+ * @return \DateTime[]
+ */
+ public function getArrayWithDefaultDateTime()
+ {
+ return $this->arrayWithDefaultDateTime;
+ }
+
+ /**
+ * @return \DateTime[]
+ */
+ public function getArrayWithFormattedDateTime()
+ {
+ return $this->arrayWithFormattedDateTime;
+ }
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+class Car extends Vehicle implements VehicleInterface
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+class Moped extends Vehicle implements VehicleInterface
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Björn Bösel <bjoern.boesel@twt.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+class ObjectWithXmlAttributeDiscriminatorChild extends ObjectWithXmlAttributeDiscriminatorParent
+{
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Björn Bösel <bjoern.boesel@twt.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\Discriminator(field = "type", map = {
+ * "child": "JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorChild"
+ * })
+ * @Serializer\XmlDiscriminator(attribute=true, cdata=false)
+ */
+class ObjectWithXmlAttributeDiscriminatorParent
+{
+
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Björn Bösel <bjoern.boesel@twt.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+class ObjectWithXmlNamespaceDiscriminatorChild extends ObjectWithXmlNamespaceDiscriminatorParent
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Björn Bösel <bjoern.boesel@twt.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\Discriminator(field = "type", map = {
+ * "child": "JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorChild"
+ * })
+ * @Serializer\XmlDiscriminator(namespace="http://example.com/", cdata=false)
+ * @Serializer\XmlNamespace(prefix="foo", uri="http://example.com/")
+ */
+class ObjectWithXmlNamespaceDiscriminatorParent
+{
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Björn Bösel <bjoern.boesel@twt.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+class ObjectWithXmlNotCDataDiscriminatorChild extends ObjectWithXmlNotCDataDiscriminatorParent
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Björn Bösel <bjoern.boesel@twt.de>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\Discriminator(field = "type", map = {
+ * "child": "JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNotCDataDiscriminatorChild"
+ * })
+ * @Serializer\XmlDiscriminator(cdata=false)
+ */
+class ObjectWithXmlNotCDataDiscriminatorParent
+{
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\Discriminator(field = "type", map = {
+ * "car": "JMS\Serializer\Tests\Fixtures\Discriminator\Car",
+ * "moped": "JMS\Serializer\Tests\Fixtures\Discriminator\Moped",
+ * })
+ */
+abstract class Vehicle
+{
+ /** @Serializer\Type("integer") */
+ public $km;
+
+ public function __construct($km)
+ {
+ $this->km = (integer)$km;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Discriminator;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\Discriminator(field = "type", map = {
+ * "car": "JMS\Serializer\Tests\Fixtures\Discriminator\Car",
+ * "moped": "JMS\Serializer\Tests\Fixtures\Discriminator\Moped",
+ * })
+ */
+interface VehicleInterface
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\DiscriminatorGroup;
+
+class Car extends Vehicle
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\DiscriminatorGroup;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\Discriminator(field = "type", groups={"foo"}, map = {
+ * "car": "JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Car"
+ * })
+ */
+abstract class Vehicle
+{
+ /**
+ * @Serializer\Type("integer")
+ * @Serializer\Groups({"foo"})
+ */
+ public $km;
+
+ public function __construct($km)
+ {
+ $this->km = (integer)$km;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine;
+
+use Doctrine\ORM\Mapping as ORM;
+use JMS\Serializer\Annotation\SerializedName;
+
+/** @ORM\Entity */
+class Author
+{
+ /**
+ * @ORM\Id @ORM\Column(type="integer")
+ */
+ protected $id;
+
+ /**
+ * @ORM\Column(type="string")
+ * @SerializedName("full_name")
+ */
+ private $name;
+
+ public function __construct($name, $id = null)
+ {
+ $this->name = $name;
+ $this->id = $id;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Mapping as ORM;
+use JMS\Serializer\Annotation as Serializer;
+use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @ORM\Entity
+ * @XmlRoot("blog-post")
+ */
+class BlogPost
+{
+ /**
+ * @ORM\Id @ORM\Column(type="guid") @ORM\GeneratedValue(strategy="UUID")
+ */
+ protected $id;
+
+ /**
+ * @ORM\Column(type="string")
+ * @Groups({"comments","post"})
+ */
+ private $title;
+
+ /**
+ * @ORM\Column(type="some_custom_type")
+ */
+ protected $slug;
+
+ /**
+ * @ORM\Column(type="datetime")
+ * @XmlAttribute
+ */
+ private $createdAt;
+
+ /**
+ * @ORM\Column(type="boolean")
+ * @Type("integer")
+ * This boolean to integer conversion is one of the few changes between this
+ * and the standard BlogPost class. It's used to test the override behavior
+ * of the DoctrineTypeDriver so notice it, but please don't change it.
+ *
+ * @SerializedName("is_published")
+ * @Groups({"post"})
+ * @XmlAttribute
+ */
+ private $published;
+
+ /**
+ * @ORM\OneToMany(targetEntity="Comment", mappedBy="blogPost")
+ * @XmlList(inline=true, entry="comment")
+ * @Groups({"comments"})
+ */
+ private $comments;
+
+ /**
+ * @ORM\OneToOne(targetEntity="Author")
+ * @Groups({"post"})
+ */
+ private $author;
+
+ /**
+ * @ORM\Column(type="integer")
+ * @Serializer\Exclude()
+ */
+ private $ref;
+
+ public function __construct($title, Author $author, \DateTime $createdAt)
+ {
+ $this->title = $title;
+ $this->author = $author;
+ $this->published = false;
+ $this->comments = new ArrayCollection();
+ $this->createdAt = $createdAt;
+ }
+
+ public function setPublished()
+ {
+ $this->published = true;
+ }
+
+ public function addComment(Comment $comment)
+ {
+ $this->comments->add($comment);
+ }
+
+ /**
+ * @Serializer\VirtualProperty()
+ */
+ public function getRef()
+ {
+ return $this->ref;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Mapping as ORM;
+
+/** @ORM\Entity */
+class Comment
+{
+ /**
+ * @ORM\Id @ORM\Column(type="integer")
+ */
+ protected $id;
+
+ /**
+ * @ORM\Column(type="Author")
+ */
+ private $author;
+
+ /** @ORM\ManyToOne(targetEntity="BlogPost") */
+ private $blogPost;
+
+ /**
+ * @ORM\Column(type="string")
+ */
+ private $text;
+
+ public function __construct(Author $author, $text)
+ {
+ $this->author = $author;
+ $this->text = $text;
+ $this->blogPost = new ArrayCollection();
+ }
+
+ public function getAuthor()
+ {
+ return $this->author;
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance;
+
+/**
+ * Abstract base class without Entity annotation
+ */
+abstract class AbstractModel
+{
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity
+ */
+class Clazz extends AbstractModel
+{
+ /** @ORM\Id @ORM\GeneratedValue(strategy = "AUTO") @ORM\Column(type = "integer") */
+ private $id;
+
+ /** @ORM\ManyToOne(targetEntity = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Teacher") */
+ private $teacher;
+
+ /** @ORM\ManyToMany(targetEntity = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Student") */
+ private $students;
+
+ public function __construct(Teacher $teacher, array $students)
+ {
+ $this->teacher = $teacher;
+ $this->students = new ArrayCollection($students);
+ }
+
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ public function getTeacher()
+ {
+ return $this->teacher;
+ }
+
+ public function getStudents()
+ {
+ return $this->students;
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity
+ * @ORM\InheritanceType("SINGLE_TABLE")
+ * @ORM\DiscriminatorColumn(name="type", type="string")
+ * @ORM\DiscriminatorMap({
+ * "school" = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\School"
+ * })
+ */
+abstract class Organization
+{
+ /** @ORM\Id @ORM\GeneratedValue(strategy = "AUTO") @ORM\Column(type = "integer") */
+ private $id;
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity
+ * @ORM\InheritanceType("SINGLE_TABLE")
+ * @ORM\DiscriminatorColumn(name="type", type="string")
+ * @ORM\DiscriminatorMap({
+ * "student" = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Student",
+ * "teacher" = "JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Teacher",
+ * })
+ */
+abstract class Person extends AbstractModel
+{
+ /** @ORM\Id @ORM\GeneratedValue(strategy = "AUTO") @ORM\Column(type = "integer") */
+ private $id;
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity
+ */
+class School extends Organization
+{
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity
+ */
+class Student extends Person
+{
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * @ORM\Entity
+ */
+class Teacher extends Person
+{
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\DoctrinePHPCR;
+
+use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
+use JMS\Serializer\Annotation\SerializedName;
+
+/** @PHPCRODM\Document */
+class Author
+{
+ /**
+ * @PHPCRODM\Id()
+ */
+ protected $id;
+
+ /**
+ * @PHPCRODM\Field(type="string")
+ * @SerializedName("full_name")
+ */
+ private $name;
+
+ public function __construct($name)
+ {
+ $this->name = $name;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\DoctrinePHPCR;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
+use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @PHPCRODM\Document
+ * @XmlRoot("blog-post")
+ */
+class BlogPost
+{
+ /**
+ * @PHPCRODM\Id()
+ */
+ protected $id;
+
+ /**
+ * @PHPCRODM\Field(type="string")
+ * @Groups({"comments","post"})
+ */
+ private $title;
+
+ /**
+ * @PHPCRODM\Field(type="string")
+ */
+ protected $slug;
+
+ /**
+ * @PHPCRODM\Field(type="date")
+ * @XmlAttribute
+ */
+ private $createdAt;
+
+ /**
+ * @PHPCRODM\Field(type="boolean")
+ * @Type("integer")
+ * This boolean to integer conversion is one of the few changes between this
+ * and the standard BlogPost class. It's used to test the override behavior
+ * of the DoctrineTypeDriver so notice it, but please don't change it.
+ *
+ * @SerializedName("is_published")
+ * @Groups({"post"})
+ * @XmlAttribute
+ */
+ private $published;
+
+ /**
+ * @PHPCRODM\ReferenceMany(targetDocument="Comment", property="blogPost")
+ * @XmlList(inline=true, entry="comment")
+ * @Groups({"comments"})
+ */
+ private $comments;
+
+ /**
+ * @PHPCRODM\ReferenceOne(targetDocument="Author")
+ * @Groups({"post"})
+ */
+ private $author;
+
+ public function __construct($title, Author $author, \DateTime $createdAt)
+ {
+ $this->title = $title;
+ $this->author = $author;
+ $this->published = false;
+ $this->comments = new ArrayCollection();
+ $this->createdAt = $createdAt;
+ }
+
+ public function setPublished()
+ {
+ $this->published = true;
+ }
+
+ public function addComment(Comment $comment)
+ {
+ $this->comments->add($comment);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures\DoctrinePHPCR;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCRODM;
+
+/** @PHPCRODM\Document */
+class Comment
+{
+ /**
+ * @PHPCRODM\Id()
+ */
+ protected $id;
+
+ /**
+ * @PHPCRODM\ReferenceOne(targetDocument="Author")
+ */
+ private $author;
+
+ /** @PHPCRODM\ReferenceOne(targetDocument="BlogPost") */
+ private $blogPost;
+
+ /**
+ * @PHPCRODM\Field(type="string")
+ */
+ private $text;
+
+ public function __construct(Author $author, $text)
+ {
+ $this->author = $author;
+ $this->text = $text;
+ $this->blogPost = new ArrayCollection();
+ }
+
+ public function getAuthor()
+ {
+ return $this->author;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\AccessType;
+use JMS\Serializer\Annotation\Exclude;
+use JMS\Serializer\Annotation\ReadOnly;
+
+/**
+ */
+
+/**
+ * @AccessType("public_method")
+ * @ReadOnly
+ */
+class ExcludePublicAccessor
+{
+ /**
+ * @Exclude
+ *
+ * @var mixed
+ */
+ private $iShallNotBeAccessed;
+
+ /**
+ * @var int
+ */
+ private $id = 1;
+
+ public function getId()
+ {
+ return $this->id;
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\ExclusionStrategy;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\Exclusion\ExclusionStrategyInterface;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+class AlwaysExcludeExclusionStrategy implements ExclusionStrategyInterface
+{
+ public function shouldSkipClass(ClassMetadata $metadata, Context $context)
+ {
+ return true;
+ }
+
+ public function shouldSkipProperty(PropertyMetadata $property, Context $context)
+ {
+ return false;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+class Garage
+{
+ /**
+ * @Type("array<JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle>")
+ */
+ public $vehicles;
+
+ public function __construct($vehicles)
+ {
+ $this->vehicles = $vehicles;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\AccessType;
+use JMS\Serializer\Annotation\Exclude;
+use JMS\Serializer\Annotation\ReadOnly;
+use JMS\Serializer\Annotation\Type;
+
+/** @AccessType("public_method") */
+class GetSetObject
+{
+ /** @AccessType("property") @Type("integer") */
+ private $id = 1;
+
+ /** @Type("string") */
+ private $name = 'Foo';
+
+ /**
+ * @ReadOnly
+ */
+ private $readOnlyProperty = 42;
+
+ /**
+ * This property should be exlcluded
+ * @Exclude()
+ */
+ private $excludedProperty;
+
+ public function getId()
+ {
+ throw new \RuntimeException('This should not be called.');
+ }
+
+ public function getName()
+ {
+ return 'Johannes';
+ }
+
+ public function setName($name)
+ {
+ $this->name = $name;
+ }
+
+ public function getReadOnlyProperty()
+ {
+ return $this->readOnlyProperty;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\Type;
+
+/** blablub */
+class GroupsObject
+{
+ /**
+ * @Groups({"foo"})
+ * @Type("string")
+ */
+ private $foo;
+
+ /**
+ * @Groups({"foo","bar"})
+ * @Type("string")
+ */
+ private $foobar;
+
+ /**
+ * @Groups({"bar", "Default"})
+ * @Type("string")
+ */
+ private $bar;
+
+ /**
+ * @Type("string")
+ */
+ private $none;
+
+ public function __construct()
+ {
+ $this->foo = "foo";
+ $this->bar = "bar";
+ $this->foobar = "foobar";
+ $this->none = "none";
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\Groups;
+
+class GroupsTrim
+{
+ /**
+ * @var int
+ */
+ private $amount;
+
+ /**
+ * @var string
+ */
+ private $currency;
+
+ public function __construct($amount, $currency)
+ {
+ $this->amount = (int) $amount;
+ $this->currency = $currency;
+ }
+
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ public function getCurrency()
+ {
+ return $this->currency;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Groups;
+
+class GroupsUser
+{
+ private $name;
+
+ /**
+ * @Groups({"nickname_group"})
+ */
+ private $nickname = 'nickname';
+
+ /**
+ * @Groups({"manager_group"})
+ */
+ private $manager;
+
+ /**
+ * @Groups({"friends_group"})
+ */
+ private $friends;
+
+ public function __construct($name, GroupsUser $manager = null, array $friends = array())
+ {
+ $this->name = $name;
+ $this->manager = $manager;
+ $this->friends = $friends;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Accessor;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlMap;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/** @XmlRoot("post") */
+class IndexedCommentsBlogPost
+{
+ /**
+ * @XmlMap(keyAttribute="author-name", inline=true, entry="comments")
+ * @Accessor(getter="getCommentsIndexedByAuthor")
+ */
+ private $comments = array();
+
+ public function __construct()
+ {
+ $author = new Author('Foo');
+ $this->comments[] = new Comment($author, 'foo');
+ $this->comments[] = new Comment($author, 'bar');
+ }
+
+ public function getCommentsIndexedByAuthor()
+ {
+ $indexedComments = array();
+ foreach ($this->comments as $comment) {
+ $authorName = $comment->getAuthor()->getName();
+
+ if (!isset($indexedComments[$authorName])) {
+ $indexedComments[$authorName] = new IndexedCommentsList();
+ }
+
+ $indexedComments[$authorName]->addComment($comment);
+ }
+
+ return $indexedComments;
+ }
+}
+
+class IndexedCommentsList
+{
+ /** @XmlList(inline=true, entry="comment") */
+ private $comments = array();
+
+ /** @XmlAttribute */
+ private $count = 0;
+
+ public function addComment(Comment $comment)
+ {
+ $this->comments[] = $comment;
+ $this->count += 1;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Construction\UnserializeObjectConstructor;
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\VisitorInterface;
+
+class InitializedBlogPostConstructor extends UnserializeObjectConstructor
+{
+ public function construct(VisitorInterface $visitor, ClassMetadata $metadata, $data, array $type, DeserializationContext $context)
+ {
+ if ($type['name'] !== 'JMS\Serializer\Tests\Fixtures\BlogPost') {
+ return parent::construct($visitor, $metadata, $data, $type);
+ }
+
+ return new BlogPost('This is a nice title.', new Author('Foo Bar'), new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), new Publisher('Bar Foo'));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Construction\ObjectConstructorInterface;
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\VisitorInterface;
+
+/**
+ * Object constructor that allows deserialization into already constructed
+ * objects passed through the deserialization context
+ */
+class InitializedObjectConstructor implements ObjectConstructorInterface
+{
+ private $fallbackConstructor;
+
+ /**
+ * Constructor.
+ *
+ * @param ObjectConstructorInterface $fallbackConstructor Fallback object constructor
+ */
+ public function __construct(ObjectConstructorInterface $fallbackConstructor)
+ {
+ $this->fallbackConstructor = $fallbackConstructor;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function construct(VisitorInterface $visitor, ClassMetadata $metadata, $data, array $type, DeserializationContext $context)
+ {
+ if ($context->attributes->containsKey('target') && $context->getDepth() === 1) {
+ return $context->attributes->get('target')->get();
+ }
+
+ return $this->fallbackConstructor->construct($visitor, $metadata, $data, $type, $context);
+ }
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+class InlineChild
+{
+ /**
+ * @Type("string")
+ */
+ public $a = 'a';
+
+ /**
+ * @Type("string")
+ */
+ public $b = 'b';
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+class InlineChildEmpty
+{
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+use JMS\Serializer\Annotation\Type;
+
+class InlineChildWithGroups
+{
+ /**
+ * @Type("string")
+ * @Serializer\Groups({"a"})
+ */
+ public $a = 'a';
+
+ /**
+ * @Type("string")
+ * @Serializer\Groups({"b"})
+ */
+ public $b = 'b';
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+use JMS\Serializer\Annotation\Type;
+
+/** @Serializer\AccessorOrder("alphabetical") */
+class InlineParent
+{
+ /**
+ * @Type("string")
+ */
+ private $c = 'c';
+
+ /**
+ * @Type("string")
+ */
+ private $d = 'd';
+
+ /**
+ * @Serializer\Inline
+ */
+ private $child;
+
+ public function __construct($child = null)
+ {
+ $this->child = $child ?: new InlineChild();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\XmlRoot("input")
+ */
+class Input
+{
+ /**
+ * @Serializer\XmlAttributeMap
+ */
+ private $attributes;
+
+ public function __construct($attributes = null)
+ {
+ $this->attributes = $attributes ?: array(
+ 'type' => 'text',
+ 'name' => 'firstname',
+ 'value' => 'Adrien',
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\Type;
+
+class InvalidGroupsObject
+{
+ /**
+ * @Groups({"foo, bar"})
+ * @Type("string")
+ */
+ private $foo;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\XmlValue;
+
+/** Dummy */
+class InvalidUsageOfXmlValue
+{
+ /** @XmlValue */
+ private $value = 'bar';
+
+ private $element = 'foo';
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlMap;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/** @XmlRoot("log") */
+class Log
+{
+ /**
+ * @SerializedName("author_list")
+ * @XmlMap
+ * @Type("AuthorList")
+ */
+ private $authors;
+
+ /**
+ * @XmlList(inline=true, entry = "comment")
+ * @Type("array<JMS\Serializer\Tests\Fixtures\Comment>")
+ */
+ private $comments;
+
+ public function __construct()
+ {
+ $this->authors = new AuthorList();
+ $this->authors->add(new Author('Johannes Schmitt'));
+ $this->authors->add(new Author('John Doe'));
+
+ $author = new Author('Foo Bar');
+ $this->comments = array();
+ $this->comments[] = new Comment($author, 'foo');
+ $this->comments[] = new Comment($author, 'bar');
+ $this->comments[] = new Comment($author, 'baz');
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\MaxDepth;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class Gh236Bar
+{
+ /**
+ * @Serializer\Expose()
+ */
+ public $xxx = 'yyy';
+
+ /**
+ * @Serializer\Expose()
+ * @Serializer\SkipWhenEmpty()
+ */
+ public $inner;
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures\MaxDepth;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class Gh236Foo
+{
+ /**
+ * @Serializer\MaxDepth(1)
+ */
+ public $a;
+
+ public function __construct()
+ {
+ $this->a = new Gh236Bar();
+ $this->a->inner = new Gh236Bar();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\Groups;
+
+class MultilineGroupsFormat
+{
+ /**
+ * @var int
+ */
+ private $amount;
+
+ /**
+ * @var string
+ */
+ private $currency;
+
+ public function __construct($amount, $currency)
+ {
+ $this->amount = (int) $amount;
+ $this->currency = $currency;
+ }
+
+ public function getAmount()
+ {
+ return $this->amount;
+ }
+
+ public function getCurrency()
+ {
+ return $this->currency;
+ }
+}
--- /dev/null
+<?php
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlKeyValuePairs;
+
+
+class NamedDateTimeArraysObject
+{
+ /**
+ * @var \DateTime[]
+ * @Type("array<string,DateTime<'d.m.Y H:i:s'>>")
+ * @XmlKeyValuePairs
+ */
+ private $namedArrayWithFormattedDate;
+
+ function __construct($namedArrayWithFormattedDate)
+ {
+ $this->namedArrayWithFormattedDate = $namedArrayWithFormattedDate;
+ }
+
+ /**
+ * @return \DateTime[]
+ */
+ public function getNamedArrayWithFormattedDate()
+ {
+ return $this->namedArrayWithFormattedDate;
+ }
+}
--- /dev/null
+<?php
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlKeyValuePairs;
+
+class NamedDateTimeImmutableArraysObject
+{
+ /**
+ * @var \DateTime[]
+ * @Type("array<string,DateTimeImmutable<'d.m.Y H:i:s'>>")
+ * @XmlKeyValuePairs
+ */
+ private $namedArrayWithFormattedDate;
+
+ function __construct($namedArrayWithFormattedDate)
+ {
+ $this->namedArrayWithFormattedDate = $namedArrayWithFormattedDate;
+ }
+
+ /**
+ * @return \DateTimeImmutable[]
+ */
+ public function getNamedArrayWithFormattedDate()
+ {
+ return $this->namedArrayWithFormattedDate;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class Node
+{
+ /**
+ * @Serializer\MaxDepth(2)
+ */
+ public $children;
+
+ public $foo = 'bar';
+
+ public function __construct($children = array())
+ {
+ $this->children = $children;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class ObjectWithAbsentXmlListNode
+{
+ /**
+ * @Serializer\XmlList(inline=false, entry="comment", skipWhenEmpty=true)
+ * @Serializer\Type("array<string>")
+ */
+ public $absent;
+ /**
+ * @Serializer\XmlList(inline=false, entry="comment", skipWhenEmpty=false)
+ * @Serializer\Type("array<string>")
+ */
+ public $present;
+
+ /**
+ * @Serializer\XmlList(inline=false, entry="comment")
+ * @Serializer\Type("array<string>")
+ */
+ public $skipDefault;
+
+ /**
+ * @Serializer\XmlList(inline=false, namespace="http://www.example.com")
+ * @Serializer\Type("array<string>")
+ */
+ public $absentAndNs;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class ObjectWithEmptyArrayAndHash
+{
+ /**
+ * @Serializer\Type("array<string,string>")
+ * @Serializer\SkipWhenEmpty()
+ */
+ private $hash = array();
+ /**
+ * @Serializer\Type("array<string>")
+ * @Serializer\SkipWhenEmpty()
+ */
+ private $array = array();
+
+ /**
+ * @Serializer\SkipWhenEmpty()
+ */
+ private $object = array();
+
+ public function __construct()
+ {
+ $this->object = new InlineChildEmpty();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class ObjectWithEmptyHash
+{
+ /**
+ * @Serializer\Type("array<string,string>")
+ * @Serializer\XmlList(skipWhenEmpty=false)
+ */
+ private $hash = array();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class ObjectWithEmptyNullableAndEmptyArrays
+{
+ /**
+ * @Serializer\XmlList(inline = true, entry = "comment")
+ * @Serializer\Type("array")
+ */
+ public $null_inline = null;
+
+ /**
+ * @Serializer\XmlList(inline = true, entry = "comment")
+ * @Serializer\Type("array")
+ */
+ public $empty_inline = [];
+
+
+ /**
+ * @Serializer\XmlList(inline = true, entry = "comment")
+ * @Serializer\Type("array")
+ */
+ public $not_empty_inline = ['not_empty_inline'];
+
+ /**
+ * @Serializer\XmlList(inline = false, entry = "comment")
+ * @Serializer\Type("array")
+ */
+ public $null_not_inline = null;
+
+ /**
+ * @Serializer\XmlList(inline = false, entry = "comment")
+ * @Serializer\Type("array")
+ */
+ public $empty_not_inline = [];
+
+ /**
+ * @Serializer\XmlList(inline = false, entry = "comment", skipWhenEmpty=false)
+ * @Serializer\Type("array")
+ */
+ public $not_empty_not_inline = ['not_empty_not_inline'];
+
+ /**
+ * @Serializer\XmlList(inline = false, entry = "comment", skipWhenEmpty=false)
+ * @Serializer\Type("array")
+ */
+ public $null_not_inline_skip = null;
+
+ /**
+ * @Serializer\XmlList(inline = false, entry = "comment", skipWhenEmpty=false)
+ * @Serializer\Type("array")
+ */
+ public $empty_not_inline_skip = [];
+
+
+ /**
+ * @Serializer\XmlList(inline = false, entry = "comment", skipWhenEmpty=false)
+ * @Serializer\Type("array")
+ */
+ public $not_empty_not_inline_skip = ['not_empty_not_inline_skip'];
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\ExclusionPolicy;
+use JMS\Serializer\Annotation\VirtualProperty;
+
+/**
+ * @VirtualProperty(
+ * "virtualValue",
+ * exp="object.getVirtualValue()"
+ * )
+ * @ExclusionPolicy("all")
+ */
+class ObjectWithExpressionVirtualPropertiesAndExcludeAll
+{
+
+ public function getVirtualValue()
+ {
+ return 'value';
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\HandlerCallback;
+use JMS\Serializer\Annotation\Type;
+
+class ObjectWithHandlerCallbacks
+{
+ /**
+ * @Type("string")
+ */
+ public $name;
+
+ /**
+ * @HandlerCallback(direction="serialization", format="json")
+ */
+ public function toJson()
+ {
+ return $this->name;
+ }
+
+ /**
+ * @HandlerCallback(direction="serialization", format="xml")
+ */
+ public function toXml()
+ {
+ return $this->name;
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class ObjectWithIntListAndIntMap
+{
+ /** @Serializer\Type("array<integer>") @Serializer\XmlList */
+ private $list;
+
+ /** @Serializer\Type("array<integer,integer>") @Serializer\XmlMap */
+ private $map;
+
+ public function __construct(array $list, array $map)
+ {
+ $this->list = $list;
+ $this->map = $map;
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Exclude;
+use JMS\Serializer\Annotation\PostDeserialize;
+use JMS\Serializer\Annotation\PostSerialize;
+use JMS\Serializer\Annotation\PreSerialize;
+use JMS\Serializer\Annotation\Type;
+
+class ObjectWithLifecycleCallbacks
+{
+ /**
+ * @Exclude
+ */
+ private $firstname;
+
+ /**
+ * @Exclude
+ */
+ private $lastname;
+
+ /**
+ * @Type("string")
+ */
+ private $name;
+
+ public function __construct($firstname = 'Foo', $lastname = 'Bar')
+ {
+ $this->firstname = $firstname;
+ $this->lastname = $lastname;
+ }
+
+ /**
+ * @PreSerialize
+ */
+ private function prepareForSerialization()
+ {
+ $this->name = $this->firstname . ' ' . $this->lastname;
+ }
+
+ /**
+ * @PostSerialize
+ */
+ private function cleanUpAfterSerialization()
+ {
+ $this->name = null;
+ }
+
+ /**
+ * @PostDeserialize
+ */
+ private function afterDeserialization()
+ {
+ list($this->firstname, $this->lastname) = explode(' ', $this->name);
+ $this->name = null;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlMap;
+use JMS\Serializer\Annotation\XmlNamespace;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("ObjectWithNamespacesAndList", namespace="http://example.com/namespace")
+ * @XmlNamespace(uri="http://example.com/namespace")
+ * @XmlNamespace(uri="http://example.com/namespace2", prefix="x")
+ */
+class ObjectWithNamespacesAndList
+{
+ /**
+ * @Type("string")
+ * @SerializedName("name")
+ * @XmlElement(namespace="http://example.com/namespace")
+ */
+ public $name;
+ /**
+ * @Type("string")
+ * @SerializedName("name")
+ * @XmlElement(namespace="http://example.com/namespace2")
+ */
+ public $nameAlternativeB;
+
+ /**
+ * @Type("array<string>")
+ * @SerializedName("phones")
+ * @XmlElement(namespace="http://example.com/namespace2")
+ * @XmlList(inline = false, entry = "phone", namespace="http://example.com/namespace2")
+ */
+ public $phones;
+ /**
+ * @Type("array<string,string>")
+ * @SerializedName("addresses")
+ * @XmlElement(namespace="http://example.com/namespace2")
+ * @XmlMap(inline = false, entry = "address", keyAttribute = "id", namespace="http://example.com/namespace2")
+ */
+ public $addresses;
+
+ /**
+ * @Type("array<string>")
+ * @SerializedName("phones")
+ * @XmlList(inline = true, entry = "phone", namespace="http://example.com/namespace")
+ */
+ public $phonesAlternativeB;
+ /**
+ * @Type("array<string,string>")
+ * @SerializedName("addresses")
+ * @XmlMap(inline = true, entry = "address", keyAttribute = "id", namespace="http://example.com/namespace")
+ */
+ public $addressesAlternativeB;
+
+ /**
+ * @Type("array<string>")
+ * @SerializedName("phones")
+ * @XmlList(inline = true, entry = "phone", namespace="http://example.com/namespace2")
+ */
+ public $phonesAlternativeC;
+ /**
+ * @Type("array<string,string>")
+ * @SerializedName("addresses")
+ * @XmlMap(inline = true, entry = "address", keyAttribute = "id", namespace="http://example.com/namespace2")
+ */
+ public $addressesAlternativeC;
+
+ /**
+ * @Type("array<string>")
+ * @SerializedName("phones")
+ * @XmlList(inline = false, entry = "phone")
+ */
+ public $phonesAlternativeD;
+ /**
+ * @Type("array<string,string>")
+ * @SerializedName("addresses")
+ * @XmlMap(inline = false, entry = "address", keyAttribute = "id")
+ */
+ public $addressesAlternativeD;
+
+}
+
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlMap;
+use JMS\Serializer\Annotation\XmlNamespace;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("ObjectWithNamespacesAndNestedList", namespace="http://example.com/namespace")
+ * @XmlNamespace(uri="http://example.com/namespace")
+ * @XmlNamespace(uri="http://example.com/namespace2", prefix="x")
+ */
+class ObjectWithNamespacesAndNestedList
+{
+ /**
+ * @Type("JMS\Serializer\Tests\Fixtures\PersonCollection")
+ * @SerializedName("person_collection")
+ */
+ public $personCollection;
+}
+
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+class ObjectWithNullProperty extends SimpleObject
+{
+ /**
+ * @var null
+ * @Type("string")
+ */
+ private $nullProperty = null;
+
+ /**
+ * @return null
+ */
+ public function getNullProperty()
+ {
+ return $this->nullProperty;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+
+class ObjectWithObjectProperty
+{
+ /**
+ * @Type("string")
+ */
+ private $foo;
+
+ /**
+ * @Type("JMS\Serializer\Tests\Fixtures\Author")
+ */
+ private $author;
+
+ /**
+ * @return string
+ */
+ public function getFoo()
+ {
+ return $this->foo;
+ }
+
+ /**
+ * @return \JMS\Serializer\Tests\Fixtures\Author
+ */
+ public function getAuthor()
+ {
+ return $this->author;
+ }
+
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+class ObjectWithToString
+{
+ private $input;
+
+ public function __construct($input)
+ {
+ $this->input = $input;
+ }
+
+ public function __toString()
+ {
+ return $this->input;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Since;
+use JMS\Serializer\Annotation\Until;
+use JMS\Serializer\Annotation\VirtualProperty;
+
+/**
+ * dummy comment
+ */
+class ObjectWithVersionedVirtualProperties
+{
+ /**
+ * @Groups({"versions"})
+ * @VirtualProperty
+ * @SerializedName("low")
+ * @Until("8")
+ */
+ public function getVirualLowValue()
+ {
+ return 1;
+ }
+
+ /**
+ * @Groups({"versions"})
+ * @VirtualProperty
+ * @SerializedName("high")
+ * @Since("6")
+ */
+ public function getVirualHighValue()
+ {
+ return 8;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\AccessorOrder;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\VirtualProperty;
+
+/**
+ * @AccessorOrder("custom", custom = {"prop_name", "existField", "foo" })
+ */
+class ObjectWithVirtualProperties
+{
+
+ /**
+ * @Type("string")
+ */
+ protected $existField = 'value';
+
+ /**
+ *
+ * @VirtualProperty
+ */
+ public function getVirtualValue()
+ {
+ return 'value';
+ }
+
+ /**
+ * @VirtualProperty
+ * @SerializedName("test")
+ */
+ public function getVirtualSerializedValue()
+ {
+ return 'other-name';
+ }
+
+ /**
+ * @VirtualProperty
+ * @Type("integer")
+ */
+ public function getTypedVirtualProperty()
+ {
+ return '1';
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\ExclusionPolicy;
+use JMS\Serializer\Annotation\VirtualProperty;
+
+/**
+ * @ExclusionPolicy("all")
+ */
+class ObjectWithVirtualPropertiesAndExcludeAll
+{
+ /**
+ * @VirtualProperty
+ */
+ public function getVirtualValue()
+ {
+ return 'value';
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Groups;
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Since;
+use JMS\Serializer\Annotation\Until;
+use JMS\Serializer\Annotation\VirtualProperty;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlMap;
+use JMS\Serializer\Annotation\XmlValue;
+
+class ObjectWithVirtualXmlProperties
+{
+
+ /**
+ *
+ * @VirtualProperty
+ * @SerializedName("foo")
+ * @Groups({"attributes"})
+ * @XmlAttribute
+ */
+ public function getVirualXmlAttributeValue()
+ {
+ return 'bar';
+ }
+
+ /**
+ *
+ * @VirtualProperty
+ * @SerializedName("xml-value")
+ * @Groups({"values"})
+ * @XmlValue
+ */
+ public function getVirualXmlValue()
+ {
+ return 'xml-value';
+ }
+
+ /**
+ *
+ * @VirtualProperty
+ * @SerializedName("list")
+ * @Groups({"list"})
+ * @XmlList(inline = true, entry = "val")
+ */
+ public function getVirualXmlList()
+ {
+ return array('One', 'Two');
+ }
+
+ /**
+ *
+ * @VirtualProperty
+ * @SerializedName("map")
+ * @Groups({"map"})
+ * @XmlMap(keyAttribute = "key")
+ */
+ public function getVirualXmlMap()
+ {
+ return array(
+ 'key-one' => 'One',
+ 'key-two' => 'Two'
+ );
+ }
+
+ /**
+ *
+ * @VirtualProperty
+ * @SerializedName("low")
+ * @Groups({"versions"})
+ * @Until("8")
+ */
+ public function getVirualLowValue()
+ {
+ return 1;
+ }
+
+ /**
+ * @VirtualProperty
+ * @SerializedName("hight")
+ * @Groups({"versions"})
+ * @Since("8")
+ */
+ public function getVirualHighValue()
+ {
+ return 8;
+ }
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\XmlKeyValuePairs;
+
+class ObjectWithXmlKeyValuePairs
+{
+ /**
+ * @var array
+ * @XmlKeyValuePairs
+ */
+ private $array = array(
+ 'key-one' => 'foo',
+ 'key-two' => 1,
+ 'nested-array' => array(
+ 'bar' => 'foo',
+ ),
+ 'without-keys' => array(
+ 1,
+ 'test'
+ ),
+ 'mixed' => array(
+ 'test',
+ 'foo' => 'bar',
+ '1_foo' => 'bar'
+ ),
+ 1 => 'foo'
+ );
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlKeyValuePairs;
+
+class ObjectWithXmlKeyValuePairsWithObjectType
+{
+ /**
+ * @var array
+ * @Type("array<string,JMS\Serializer\Tests\Fixtures\ObjectWithXmlKeyValuePairsWithType>")
+ * @XmlKeyValuePairs
+ */
+ private $list;
+
+ public function __construct(array $list)
+ {
+ $this->list = $list;
+ }
+
+ public static function create1()
+ {
+ return new self(
+ [
+ 'key_first' => ObjectWithXmlKeyValuePairsWithType::create1(),
+ 'key_second' => ObjectWithXmlKeyValuePairsWithType::create2(),
+ ]
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlKeyValuePairs;
+
+class ObjectWithXmlKeyValuePairsWithType
+{
+ /**
+ * @var array
+ * @Type("array<string,string>")
+ * @XmlKeyValuePairs
+ */
+ private $list;
+
+ /**
+ * @var array
+ * @Type("array<string>")
+ */
+ private $list2;
+
+ public function __construct(array $list, array $list2 = [])
+ {
+ $this->list = $list;
+ $this->list2 = $list2;
+ }
+
+ public static function create1()
+ {
+ return new self(
+ [
+ 'key-one' => 'foo',
+ 'key-two' => 'bar',
+ ]
+ );
+ }
+
+ public static function create2()
+ {
+ return new self(
+ [
+ 'key_01' => 'One',
+ 'key_02' => 'Two',
+ 'key_03' => 'Three',
+ ],
+ [
+ 'Four',
+ ]
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlNamespace;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("test-object", namespace="http://example.com/namespace")
+ * @XmlNamespace(uri="http://example.com/namespace")
+ * @XmlNamespace(uri="http://schemas.google.com/g/2005", prefix="gd")
+ * @XmlNamespace(uri="http://www.w3.org/2005/Atom", prefix="atom")
+ */
+class ObjectWithXmlNamespaces
+{
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://purl.org/dc/elements/1.1/");
+ */
+ private $title;
+
+ /**
+ * @Type("DateTime")
+ * @XmlAttribute
+ */
+ private $createdAt;
+
+ /**
+ * @Type("string")
+ * @XmlAttribute(namespace="http://schemas.google.com/g/2005")
+ */
+ private $etag;
+
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://www.w3.org/2005/Atom")
+ */
+ private $author;
+
+ /**
+ * @Type("string")
+ * @XmlAttribute(namespace="http://purl.org/dc/elements/1.1/");
+ */
+ private $language;
+
+ public function __construct($title, $author, \DateTime $createdAt, $language)
+ {
+ $this->title = $title;
+ $this->author = $author;
+ $this->createdAt = $createdAt;
+ $this->language = $language;
+ $this->etag = sha1($this->createdAt->format(\DateTime::ISO8601));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlNamespace;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("property:test-object", namespace="http://example.com/namespace-property")
+ * @XmlNamespace(uri="http://example.com/namespace-property", prefix="property")
+ */
+class ObjectWithXmlNamespacesAndObjectProperty
+{
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://example.com/namespace-property");
+ */
+ private $title;
+
+ /**
+ * @Type("JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespacesAndObjectPropertyAuthor")
+ * @XmlElement(namespace="http://example.com/namespace-property")
+ */
+ private $author;
+
+ public function __construct($title, $author)
+ {
+ $this->title = $title;
+ $this->author = $author;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlNamespace;
+
+/**
+ * @XmlNamespace(uri="http://example.com/namespace-author")
+ */
+class ObjectWithXmlNamespacesAndObjectPropertyAuthor
+{
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://example.com/namespace-modified");
+ */
+ private $author;
+
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://example.com/namespace-author");
+ */
+ private $info = "hidden-info";
+
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://example.com/namespace-property")
+ */
+ private $name;
+
+ public function __construct($name, $author)
+ {
+ $this->name = $name;
+ $this->author = $author;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlNamespace;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("property:test-object", namespace="http://example.com/namespace-property")
+ * @XmlNamespace(uri="http://example.com/namespace-property", prefix="property")
+ */
+class ObjectWithXmlNamespacesAndObjectPropertyVirtual
+{
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://example.com/namespace-property");
+ */
+ private $title;
+
+ /**
+ * @Type("ObjectWithXmlNamespacesAndObjectPropertyAuthorVirtual")
+ * @XmlElement(namespace="http://example.com/namespace-property")
+ */
+ private $author;
+
+ public function __construct($title, $author)
+ {
+ $this->title = $title;
+ $this->author = $author;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("test-object", namespace="http://example.com/namespace")
+ */
+class ObjectWithXmlRootNamespace
+{
+ /**
+ * @Type("string")
+ */
+ private $title;
+
+ /**
+ * @Type("DateTime")
+ * @XmlAttribute
+ */
+ private $createdAt;
+
+ /**
+ * @Type("string")
+ * @XmlAttribute
+ */
+ private $etag;
+
+ /**
+ * @Type("string")
+ */
+ private $author;
+
+ /**
+ * @Type("string")
+ * @XmlAttribute
+ */
+ private $language;
+
+ public function __construct($title, $author, \DateTime $createdAt, $language)
+ {
+ $this->title = $title;
+ $this->author = $author;
+ $this->createdAt = $createdAt;
+ $this->language = $language;
+ $this->etag = sha1($this->createdAt->format(\DateTime::ISO8601));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/** @XmlRoot("order") */
+class Order
+{
+ /** @Type("JMS\Serializer\Tests\Fixtures\Price") */
+ private $cost;
+
+ public function __construct(Price $price = null)
+ {
+ $this->cost = $price ?: new Price(5);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+class ParentDoNotSkipWithEmptyChild
+{
+ private $c = 'c';
+
+ private $d = 'd';
+
+ /**
+ * @var InlineChild
+ */
+ private $child;
+
+ public function __construct($child = null)
+ {
+ $this->child = $child ?: new InlineChild();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class ParentSkipWithEmptyChild
+{
+ private $c = 'c';
+
+ private $d = 'd';
+
+ /**
+ * @Serializer\SkipWhenEmpty()
+ * @var InlineChild
+ */
+ private $child;
+
+ public function __construct($child = null)
+ {
+ $this->child = $child ?: new InlineChild();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlRoot;
+use JMS\Serializer\Annotation\XmlValue;
+
+/**
+ * @XmlRoot("child")
+ */
+class Person
+{
+ /**
+ * @Type("string")
+ * @XmlValue(cdata=false)
+ */
+ public $name;
+
+ /**
+ * @Type("int")
+ * @XmlAttribute
+ */
+ public $age;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlList;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("person_collection")
+ */
+class PersonCollection
+{
+ /**
+ * @Type("ArrayCollection<JMS\Serializer\Tests\Fixtures\Person>")
+ * @XmlList(entry = "person", inline = true)
+ */
+ public $persons;
+
+ /**
+ * @Type("string")
+ */
+ public $location;
+
+ public function __construct()
+ {
+ $this->persons = new ArrayCollection;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("person_location")
+ */
+class PersonLocation
+{
+ /**
+ * @Type("JMS\Serializer\Tests\Fixtures\Person")
+ */
+ public $person;
+
+ /**
+ * @Type("string")
+ */
+ public $location;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\ExclusionPolicy("NONE")
+ * @Serializer\AccessorOrder("custom",custom = {"name", "gender" ,"age"})
+ */
+class PersonSecret
+{
+ /**
+ * @Serializer\Type("string")
+ */
+ public $name;
+
+ /**
+ * @Serializer\Type("string")
+ * @Serializer\Exclude(if="show_data('gender')")
+ */
+ public $gender;
+
+ /**
+ * @Serializer\Type("string")
+ * @Serializer\Expose(if="show_data('age')")
+ */
+ public $age;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\ExclusionPolicy("ALL")
+ * @Serializer\AccessorOrder("custom",custom = {"name", "gender"})
+ */
+class PersonSecretMore
+{
+ /**
+ * @Serializer\Type("string")
+ * @Serializer\Expose()
+ */
+ public $name;
+
+ /**
+ * @Serializer\Type("string")
+ * @Serializer\Expose(if="show_data('gender')")
+ */
+ public $gender;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\ExclusionPolicy("ALL")
+ * @Serializer\AccessorOrder("custom",custom = {"name", "gender"})
+ */
+class PersonSecretMoreVirtual
+{
+ /**
+ * @Serializer\Type("string")
+ * @Serializer\Expose()
+ */
+ public $name;
+
+ public $gender;
+
+ /**
+ * @Serializer\VirtualProperty()
+ * @Serializer\Type("string")
+ * @Serializer\Expose(if="show_data('gender')")
+ */
+ public function getGender()
+ {
+ return $this->gender;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+/**
+ * @Serializer\ExclusionPolicy("NONE")
+ * @Serializer\AccessorOrder("custom",custom = {"name", "gender", "age"})
+ */
+class PersonSecretVirtual
+{
+ /**
+ * @Serializer\Type("string")
+ */
+ public $name;
+
+ /**
+ * @Serializer\Exclude()
+ */
+ public $gender;
+
+ /**
+ * @Serializer\Type("string")
+ * @Serializer\Expose(if="show_data('age')")
+ */
+ public $age;
+
+ /**
+ * @Serializer\VirtualProperty()
+ * @Serializer\Type("string")
+ * @Serializer\Exclude(if="show_data('gender')")
+ */
+ public function getGender()
+ {
+ return $this->gender;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+use JMS\Serializer\Context;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+/**
+ */
+class PersonSecretWithVariables
+{
+ /**
+ * @Serializer\Type("string")
+ */
+ public $name;
+
+ /**
+ * @Serializer\Type("string")
+ * @Serializer\Expose(if="context.getDirection()==2 || object.test(property_metadata, context)")
+ */
+ public $gender;
+
+
+ public function test(PropertyMetadata $propertyMetadata, Context $context)
+ {
+ return true;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlRoot;
+use JMS\Serializer\Annotation\XmlValue;
+
+/**
+ * @XmlRoot("price")
+ */
+class Price
+{
+ /**
+ * @Type("float")
+ * @XmlValue
+ */
+ private $price;
+
+ public function __construct($price)
+ {
+ $this->price = $price;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlNamespace;
+use JMS\Serializer\Annotation\XmlRoot;
+
+/**
+ * @XmlRoot("publisher")
+ * @XmlNamespace(uri="http://example.com/namespace2", prefix="ns2")
+ */
+class Publisher
+{
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://example.com/namespace2")
+ * @SerializedName("pub_name")
+ */
+ private $name;
+
+ public function __construct($name)
+ {
+ $this->name = $name;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlAttribute;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlNamespace;
+
+/**
+ * @XmlNamespace(prefix="old_foo", uri="http://old.foo.example.org");
+ * @XmlNamespace(prefix="foo", uri="http://foo.example.org");
+ * @XmlNamespace(prefix="new_foo", uri="http://new.foo.example.org");
+ */
+class SimpleClassObject
+{
+ /**
+ * @Type("string")
+ * @XmlAttribute(namespace="http://old.foo.example.org")
+ */
+ public $foo;
+
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://foo.example.org")
+ */
+ public $bar;
+
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://new.foo.example.org")
+ */
+ public $moo;
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Type;
+
+class SimpleObject
+{
+ /** @Type("string") */
+ private $foo;
+
+ /**
+ * @SerializedName("moo")
+ * @Type("string")
+ */
+ private $bar;
+
+ /** @Type("string") */
+ protected $camelCase = 'boo';
+
+ public function __construct($foo, $bar)
+ {
+ $this->foo = $foo;
+ $this->bar = $bar;
+ }
+
+ public function getFoo()
+ {
+ return $this->foo;
+ }
+
+ public function getBar()
+ {
+ return $this->bar;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use Doctrine\Common\Persistence\Proxy;
+
+class SimpleObjectProxy extends SimpleObject implements Proxy
+{
+ public $__isInitialized__ = false;
+
+ private $baz = 'baz';
+
+ public function __load()
+ {
+ if (!$this->__isInitialized__) {
+ $this->camelCase = 'proxy-boo';
+ $this->__isInitialized__ = true;
+ }
+ }
+
+ public function __isInitialized()
+ {
+ return $this->__isInitialized__;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+use JMS\Serializer\Annotation\XmlElement;
+use JMS\Serializer\Annotation\XmlNamespace;
+
+/**
+ * @XmlNamespace(prefix="old_foo", uri="http://foo.example.org");
+ * @XmlNamespace(prefix="foo", uri="http://better.foo.example.org");
+ */
+class SimpleSubClassObject
+ extends SimpleClassObject
+{
+
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://better.foo.example.org")
+ */
+ public $moo;
+
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://foo.example.org")
+ */
+ public $baz;
+
+ /**
+ * @Type("string")
+ * @XmlElement(namespace="http://new.foo.example.org")
+ */
+ public $qux;
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as JMS;
+
+
+/**
+ * @JMS\XmlRoot("tag")
+ * @JMS\XmlNamespace(uri="http://purl.org/dc/elements/1.1/", prefix="dc")
+ */
+class Tag
+{
+
+ /**
+ * @JMS\XmlElement(cdata=false)
+ * @JMS\Type("string")
+ */
+ public $name;
+
+ function __construct($name)
+ {
+ $this->name = $name;
+ }
+
+
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+class Timestamp
+{
+ /**
+ * @Type("DateTime<'U'>")
+ */
+ private $timestamp;
+
+ public function __construct($timestamp)
+ {
+ $this->timestamp = $timestamp;
+ }
+
+ public function getTimestamp()
+ {
+ return $this->timestamp;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+class Tree
+{
+ /**
+ * @Serializer\MaxDepth(10)
+ */
+ public $tree;
+
+ public function __construct($tree)
+ {
+ $this->tree = $tree;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\Type;
+
+class VehicleInterfaceGarage
+{
+ /**
+ * @Type("array<JMS\Serializer\Tests\Fixtures\Discriminator\VehicleInterface>")
+ */
+ public $vehicles;
+
+ public function __construct($vehicles)
+ {
+ $this->vehicles = $vehicles;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation\SerializedName;
+use JMS\Serializer\Annotation\Since;
+use JMS\Serializer\Annotation\Until;
+
+class VersionedObject
+{
+ /**
+ * @Until("1.0.0")
+ */
+ private $name;
+
+ /**
+ * @Since("1.0.1")
+ * @SerializedName("name")
+ */
+ private $name2;
+
+ public function __construct($name, $name2)
+ {
+ $this->name = $name;
+ $this->name2 = $name2;
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Handler;
+
+use Doctrine\Common\Collections\ArrayCollection;
+use JMS\Serializer\Handler\ArrayCollectionHandler;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\Tests\Fixtures\ExclusionStrategy\AlwaysExcludeExclusionStrategy;
+use JMS\Serializer\VisitorInterface;
+use Metadata\MetadataFactoryInterface;
+
+class ArrayCollectionHandlerTest extends \PHPUnit_Framework_TestCase
+{
+ public function testSerializeArray()
+ {
+ $handler = new ArrayCollectionHandler();
+
+ $visitor = $this->getMockBuilder(VisitorInterface::class)->getMock();
+ $visitor->method('visitArray')->with(['foo'])->willReturn(['foo']);
+
+ $context = $this->getMockBuilder(SerializationContext::class)->getMock();
+ $type = ['name' => 'ArrayCollection', 'params' => []];
+
+ $collection = new ArrayCollection(['foo']);
+
+ $handler->serializeCollection($visitor, $collection, $type, $context);
+ }
+
+ public function testSerializeArraySkipByExclusionStrategy()
+ {
+ $handler = new ArrayCollectionHandler(false);
+
+ $visitor = $this->getMockBuilder(VisitorInterface::class)->getMock();
+ $visitor->method('visitArray')->with([])->willReturn([]);
+
+ $context = $this->getMockBuilder(SerializationContext::class)->getMock();
+
+ $factoryMock = $this->getMockBuilder(MetadataFactoryInterface::class)->getMock();
+ $factoryMock->method('getMetadataForClass')->willReturn(new ClassMetadata(ArrayCollection::class));
+
+ $context->method('getExclusionStrategy')->willReturn(new AlwaysExcludeExclusionStrategy());
+ $context->method('getMetadataFactory')->willReturn($factoryMock);
+
+
+ $type = ['name' => 'ArrayCollection', 'params' => []];
+
+ $collection = new ArrayCollection(['foo']);
+
+ $handler->serializeCollection($visitor, $collection, $type, $context);
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Handler;
+
+use JMS\Serializer\Handler\DateHandler;
+use JMS\Serializer\JsonDeserializationVisitor;
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\VisitorInterface;
+
+class DateHandlerTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var DateHandler
+ */
+ private $handler;
+ /**
+ * @var \DateTimeZone
+ */
+ private $timezone;
+
+ public function setUp()
+ {
+ $this->handler = new DateHandler();
+ $this->timezone = new \DateTimeZone('UTC');
+ }
+
+ public function getParams()
+ {
+ return [
+ [['Y-m-d']],
+ [['Y-m-d', '', 'Y-m-d|']],
+ [['Y-m-d', '', 'Y']],
+ ];
+ }
+
+ /**
+ * @dataProvider getParams
+ * @param array $params
+ */
+ public function testSerializeDate(array $params)
+ {
+ $context = $this->getMockBuilder(SerializationContext::class)->getMock();
+
+ $visitor = $this->getMockBuilder(VisitorInterface::class)->getMock();
+ $visitor->method('visitString')->with('2017-06-18');
+
+ $datetime = new \DateTime('2017-06-18 14:30:59', $this->timezone);
+ $type = ['name' => 'DateTime', 'params' => $params];
+ $this->handler->serializeDateTime($visitor, $datetime, $type, $context);
+ }
+
+ public function testTimePartGetsRemoved()
+ {
+ $visitor = $this->getMockBuilder(JsonDeserializationVisitor::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $type = ['name' => 'DateTime', 'params' => ['Y-m-d', '', 'Y-m-d|']];
+ $this->assertEquals(
+ \DateTime::createFromFormat('Y-m-d|', '2017-06-18', $this->timezone),
+ $this->handler->deserializeDateTimeFromJson($visitor, '2017-06-18', $type)
+ );
+ }
+
+ public function testTimePartGetsPreserved()
+ {
+ $visitor = $this->getMockBuilder(JsonDeserializationVisitor::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $expectedDateTime = \DateTime::createFromFormat('Y-m-d', '2017-06-18', $this->timezone);
+ // if the test is executed exactly at midnight, it might not detect a possible failure since the time component will be "00:00:00
+ // I know, this is a bit paranoid
+ if ($expectedDateTime->format("H:i:s") === "00:00:00") {
+ sleep(1);
+ $expectedDateTime = \DateTime::createFromFormat('Y-m-d', '2017-06-18', $this->timezone);
+ }
+
+ // no custom deserialization format specified
+ $type = ['name' => 'DateTime', 'params' => ['Y-m-d']];
+ $this->assertEquals(
+ $expectedDateTime,
+ $this->handler->deserializeDateTimeFromJson($visitor, '2017-06-18', $type)
+ );
+
+ // custom deserialization format specified
+ $type = ['name' => 'DateTime', 'params' => ['Y-m-d', '', 'Y-m-d']];
+ $this->assertEquals(
+ $expectedDateTime,
+ $this->handler->deserializeDateTimeFromJson($visitor, '2017-06-18', $type)
+ );
+ }
+
+ public function testTimeZoneGetsPreservedWithUnixTimestamp()
+ {
+ $visitor = $this->getMockBuilder(JsonDeserializationVisitor::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+
+ $timestamp = time();
+ $timezone = 'Europe/Brussels';
+ $type = ['name' => 'DateTime', 'params' => ['U', $timezone]];
+
+ $expectedDateTime = \DateTime::createFromFormat('U', $timestamp);
+ $expectedDateTime->setTimezone(new \DateTimeZone($timezone));
+
+ $actualDateTime = $this->handler->deserializeDateTimeFromJson($visitor, $timestamp, $type);
+
+ $this->assertEquals(
+ $expectedDateTime->format(\DateTime::RFC3339),
+ $actualDateTime->format(\DateTime::RFC3339)
+ );
+ }
+
+ public function testImmutableTimeZoneGetsPreservedWithUnixTimestamp()
+ {
+ $visitor = $this->getMockBuilder(JsonDeserializationVisitor::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+
+ $timestamp = time();
+ $timezone = 'Europe/Brussels';
+ $type = ['name' => 'DateTimeImmutable', 'params' => ['U', $timezone]];
+
+ $expectedDateTime = \DateTime::createFromFormat('U', $timestamp);
+ $expectedDateTime->setTimezone(new \DateTimeZone($timezone));
+
+ $actualDateTime = $this->handler->deserializeDateTimeImmutableFromJson($visitor, $timestamp, $type);
+
+ $this->assertEquals(
+ $expectedDateTime->format(\DateTime::RFC3339),
+ $actualDateTime->format(\DateTime::RFC3339)
+ );
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Handler;
+
+use JMS\Serializer\Handler\FormErrorHandler;
+use JMS\Serializer\JsonSerializationVisitor;
+use JMS\Serializer\Naming\CamelCaseNamingStrategy;
+use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\EventDispatcherInterface;
+use Symfony\Component\Form\FormBuilder;
+use Symfony\Component\Form\FormError;
+use Symfony\Component\Form\Forms;
+use Symfony\Component\Translation\Translator;
+
+class FormErrorHandlerTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var \JMS\Serializer\Handler\FormErrorHandler
+ */
+ protected $handler;
+
+ /**
+ * @var \JMS\Serializer\VisitorInterface
+ */
+ protected $visitor;
+
+ /**
+ * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
+ */
+ protected $dispatcher;
+
+ /**
+ * @var \Symfony\Component\Form\FormFactoryInterface
+ */
+ protected $factory;
+
+ public function setUp()
+ {
+ $this->handler = new FormErrorHandler(new Translator('en'));
+ $this->visitor = new JsonSerializationVisitor(new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy()));
+ $this->dispatcher = new EventDispatcher();
+ $this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
+ }
+
+ protected function tearDown()
+ {
+ $this->handler = null;
+ $this->visitor = null;
+ $this->dispatcher = null;
+ $this->factory = null;
+ }
+
+ public function testSerializeEmptyFormError()
+ {
+ $form = $this->createForm();
+ $json = json_encode($this->handler->serializeFormToJson($this->visitor, $form, array()));
+
+ $this->assertSame('{}', $json);
+ }
+
+ public function testErrorHandlerWithoutTranslator()
+ {
+ $this->handler = new FormErrorHandler();
+ $form = $this->createForm();
+ $form->addError(new FormError('error!'));
+ $json = json_encode($this->handler->serializeFormToJson($this->visitor, $form, array()));
+
+ $this->assertSame(json_encode(array(
+ 'errors' => array(
+ 'error!',
+ ),
+ )), $json);
+ }
+
+ public function testSerializeHasFormError()
+ {
+ $form = $this->createForm();
+ $form->addError(new FormError('error!'));
+ $json = json_encode($this->handler->serializeFormToJson($this->visitor, $form, array()));
+
+ $this->assertSame(json_encode(array(
+ 'errors' => array(
+ 'error!',
+ ),
+ )), $json);
+ }
+
+
+ public function testSerializeChildElements()
+ {
+ $formFactory = Forms::createFormFactory();
+ $form = $formFactory->createBuilder()
+ ->add('child')
+ ->add('date')
+ ->getForm();
+
+ $form->addError(new FormError('error!'));
+ $form->get('date')->addError(new FormError('child-error'));
+
+ $json = json_encode($this->handler->serializeFormToJson($this->visitor, $form, array()));
+
+ $this->assertSame(json_encode(array(
+ 'errors' => array(
+ 'error!',
+ ),
+ 'children' => [
+ 'child' => new \stdClass(),
+ 'date' => ['errors' => ['child-error']]
+ ]
+ )), $json);
+
+ }
+
+ public function testDefaultTranslationDomain()
+ {
+ /** @var Translator|\PHPUnit_Framework_MockObject_MockObject $translator */
+ $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
+
+ $handler = new FormErrorHandler($translator);
+
+ $translator->expects($this->once())
+ ->method('trans')
+ ->with(
+ $this->equalTo('error!'),
+ $this->equalTo([]),
+ $this->equalTo('validators')
+ );
+
+ $formError = $this->getMockBuilder('Symfony\Component\Form\FormError')->disableOriginalConstructor()->getMock();
+ $formError->expects($this->once())->method('getMessageTemplate')->willReturn('error!');
+ $formError->expects($this->once())->method('getMessagePluralization')->willReturn(null);
+ $formError->expects($this->once())->method('getMessageParameters')->willReturn([]);
+
+ $this->invokeMethod($handler, 'getErrorMessage', [$formError,]);
+ }
+
+ public function testDefaultTranslationDomainWithPluralTranslation()
+ {
+ /** @var Translator|\PHPUnit_Framework_MockObject_MockObject $translator */
+ $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
+
+ $handler = new FormErrorHandler($translator);
+
+ $translator->expects($this->once())
+ ->method('transChoice')
+ ->with(
+ $this->equalTo('error!'),
+ $this->equalTo(0),
+ $this->equalTo([]),
+ $this->equalTo('validators')
+ );
+
+ $formError = $this->getMockBuilder('Symfony\Component\Form\FormError')->disableOriginalConstructor()->getMock();
+ $formError->expects($this->once())->method('getMessageTemplate')->willReturn('error!');
+ $formError->expects($this->exactly(2))->method('getMessagePluralization')->willReturn(0);
+ $formError->expects($this->once())->method('getMessageParameters')->willReturn([]);
+
+ $this->invokeMethod($handler, 'getErrorMessage', [$formError,]);
+ }
+
+ public function testCustomTranslationDomain()
+ {
+ /** @var Translator|\PHPUnit_Framework_MockObject_MockObject $translator */
+ $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
+
+ $handler = new FormErrorHandler($translator, 'custom_domain');
+
+ $translator->expects($this->once())
+ ->method('trans')
+ ->with(
+ $this->equalTo('error!'),
+ $this->equalTo([]),
+ $this->equalTo('custom_domain')
+ );
+
+ $formError = $this->getMockBuilder('Symfony\Component\Form\FormError')->disableOriginalConstructor()->getMock();
+ $formError->expects($this->once())->method('getMessageTemplate')->willReturn('error!');
+ $formError->expects($this->once())->method('getMessagePluralization')->willReturn(null);
+ $formError->expects($this->once())->method('getMessageParameters')->willReturn([]);
+
+ $this->invokeMethod($handler, 'getErrorMessage', [$formError,]);
+ }
+
+ public function testCustomTranslationDomainWithPluralTranslation()
+ {
+ /** @var Translator|\PHPUnit_Framework_MockObject_MockObject $translator */
+ $translator = $this->getMockBuilder('Symfony\Component\Translation\TranslatorInterface')->getMock();
+
+ $handler = new FormErrorHandler($translator, 'custom_domain');
+
+ $translator->expects($this->once())
+ ->method('transChoice')
+ ->with(
+ $this->equalTo('error!'),
+ $this->equalTo(0),
+ $this->equalTo([]),
+ $this->equalTo('custom_domain')
+ );
+
+ $formError = $this->getMockBuilder('Symfony\Component\Form\FormError')->disableOriginalConstructor()->getMock();
+ $formError->expects($this->once())->method('getMessageTemplate')->willReturn('error!');
+ $formError->expects($this->exactly(2))->method('getMessagePluralization')->willReturn(0);
+ $formError->expects($this->once())->method('getMessageParameters')->willReturn([]);
+
+ $this->invokeMethod($handler, 'getErrorMessage', [$formError,]);
+
+ }
+
+ /**
+ * @param string $name
+ * @param EventDispatcherInterface $dispatcher
+ * @param string $dataClass
+ *
+ * @return FormBuilder
+ */
+ protected function getBuilder($name = 'name', EventDispatcherInterface $dispatcher = null, $dataClass = null)
+ {
+ return new FormBuilder($name, $dataClass, $dispatcher ?: $this->dispatcher, $this->factory);
+ }
+
+ /**
+ * @param string $name
+ *
+ * @return \PHPUnit_Framework_MockObject_MockObject
+ */
+ protected function getMockForm($name = 'name')
+ {
+ $form = $this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
+ $config = $this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
+
+ $form->expects($this->any())
+ ->method('getName')
+ ->will($this->returnValue($name));
+ $form->expects($this->any())
+ ->method('getConfig')
+ ->will($this->returnValue($config));
+
+ return $form;
+ }
+
+ protected function createForm()
+ {
+ return $this->getBuilder()->getForm();
+ }
+
+ protected function invokeMethod($object, $method, array $args = [])
+ {
+ $reflectionMethod = new \ReflectionMethod($object, $method);
+ $reflectionMethod->setAccessible(true);
+
+ return $reflectionMethod->invokeArgs($object, $args);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Handler;
+
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Handler\HandlerRegistry;
+
+class HandlerRegistryTest extends \PHPUnit_Framework_TestCase
+{
+ protected $handlerRegistry;
+
+ protected function setUp()
+ {
+ $this->handlerRegistry = $this->createHandlerRegistry();
+ }
+
+ public function testRegisteredHandlersCanBeRetrieved()
+ {
+ $jsonSerializationHandler = new DummyHandler();
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_SERIALIZATION, '\stdClass', 'json', $jsonSerializationHandler);
+
+ $jsonDeserializationHandler = new DummyHandler();
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_DESERIALIZATION, '\stdClass', 'json', $jsonDeserializationHandler);
+
+ $xmlSerializationHandler = new DummyHandler();
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_SERIALIZATION, '\stdClass', 'xml', $xmlSerializationHandler);
+
+ $xmlDeserializationHandler = new DummyHandler();
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_DESERIALIZATION, '\stdClass', 'xml', $xmlDeserializationHandler);
+
+ $this->assertSame($jsonSerializationHandler, $this->handlerRegistry->getHandler(GraphNavigator::DIRECTION_SERIALIZATION, '\stdClass', 'json'));
+ $this->assertSame($jsonDeserializationHandler, $this->handlerRegistry->getHandler(GraphNavigator::DIRECTION_DESERIALIZATION, '\stdClass', 'json'));
+ $this->assertSame($xmlSerializationHandler, $this->handlerRegistry->getHandler(GraphNavigator::DIRECTION_SERIALIZATION, '\stdClass', 'xml'));
+ $this->assertSame($xmlDeserializationHandler, $this->handlerRegistry->getHandler(GraphNavigator::DIRECTION_DESERIALIZATION, '\stdClass', 'xml'));
+ }
+
+ protected function createHandlerRegistry()
+ {
+ return new HandlerRegistry();
+ }
+}
+
+class DummyHandler
+{
+ public function __call($name, $arguments)
+ {
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Handler;
+
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Handler\LazyHandlerRegistry;
+
+abstract class LazyHandlerRegistryTest extends HandlerRegistryTest
+{
+ protected $container;
+
+ protected function setUp()
+ {
+ $this->container = $this->createContainer();
+
+ parent::setUp();
+ }
+
+ protected function createHandlerRegistry()
+ {
+ return new LazyHandlerRegistry($this->container);
+ }
+
+ public function testRegisteredHandlersCanBeRetrievedWhenBeingDefinedAsServices()
+ {
+ $jsonSerializationHandler = new HandlerService();
+ $this->registerHandlerService('handler.serialization.json', $jsonSerializationHandler);
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_SERIALIZATION, '\stdClass', 'json', array('handler.serialization.json', 'handle'));
+
+ $jsonDeserializationHandler = new HandlerService();
+ $this->registerHandlerService('handler.deserialization.json', $jsonDeserializationHandler);
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_DESERIALIZATION, '\stdClass', 'json', array('handler.deserialization.json', 'handle'));
+
+ $xmlSerializationHandler = new HandlerService();
+ $this->registerHandlerService('handler.serialization.xml', $xmlSerializationHandler);
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_SERIALIZATION, '\stdClass', 'xml', array('handler.serialization.xml', 'handle'));
+
+ $xmlDeserializationHandler = new HandlerService();
+ $this->registerHandlerService('handler.deserialization.xml', $xmlDeserializationHandler);
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_DESERIALIZATION, '\stdClass', 'xml', array('handler.deserialization.xml', 'handle'));
+
+ $this->assertSame(array($jsonSerializationHandler, 'handle'), $this->handlerRegistry->getHandler(GraphNavigator::DIRECTION_SERIALIZATION, '\stdClass', 'json'));
+ $this->assertSame(array($jsonDeserializationHandler, 'handle'), $this->handlerRegistry->getHandler(GraphNavigator::DIRECTION_DESERIALIZATION, '\stdClass', 'json'));
+ $this->assertSame(array($xmlSerializationHandler, 'handle'), $this->handlerRegistry->getHandler(GraphNavigator::DIRECTION_SERIALIZATION, '\stdClass', 'xml'));
+ $this->assertSame(array($xmlDeserializationHandler, 'handle'), $this->handlerRegistry->getHandler(GraphNavigator::DIRECTION_DESERIALIZATION, '\stdClass', 'xml'));
+ }
+
+ abstract protected function createContainer();
+
+ abstract protected function registerHandlerService($serviceId, $listener);
+}
+
+class HandlerService
+{
+ public function handle()
+ {
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Handler;
+
+use Psr\Container\ContainerInterface;
+
+class LazyHandlerRegistryWithPsr11ContainerTest extends LazyHandlerRegistryTest
+{
+ protected function createContainer()
+ {
+ return new Psr11Container();
+ }
+
+ protected function registerHandlerService($serviceId, $listener)
+ {
+ $this->container->set($serviceId, $listener);
+ }
+}
+
+class Psr11Container implements ContainerInterface
+{
+ private $services;
+
+ public function get($id)
+ {
+ return $this->services[$id];
+ }
+
+ public function has($id)
+ {
+ return isset($this->services[$id]);
+ }
+
+ public function set($id, $service)
+ {
+ $this->services[$id] = $service;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Handler;
+
+use Symfony\Component\DependencyInjection\Container;
+
+class LazyHandlerRegistryWithSymfonyContainerTest extends LazyHandlerRegistryTest
+{
+ protected function createContainer()
+ {
+ return new Container();
+ }
+
+ protected function registerHandlerService($serviceId, $listener)
+ {
+ $this->container->set($serviceId, $listener);
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Handler;
+
+use JMS\Serializer\SerializerBuilder;
+
+class PropelCollectionHandlerTest extends \PHPUnit_Framework_TestCase
+{
+ /** @var $serializer \JMS\Serializer\Serializer */
+ private $serializer;
+
+ public function setUp()
+ {
+ $this->serializer = SerializerBuilder::create()
+ ->addDefaultHandlers()//load PropelCollectionHandler
+ ->build();
+ }
+
+ public function testSerializePropelObjectCollection()
+ {
+ $collection = new \PropelObjectCollection();
+ $collection->setData(array(new TestSubject('lolo'), new TestSubject('pepe')));
+ $json = $this->serializer->serialize($collection, 'json');
+
+ $data = json_decode($json, true);
+
+ $this->assertCount(2, $data); //will fail if PropelCollectionHandler not loaded
+
+ foreach ($data as $testSubject) {
+ $this->assertArrayHasKey('name', $testSubject);
+ }
+ }
+}
+
+class TestSubject
+{
+ protected $name;
+
+ public function __construct($name)
+ {
+ $this->name = $name;
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Fixtures;
+
+use JMS\Serializer\Annotation as Serializer;
+
+final class ObjectWithInlineArray
+{
+ /**
+ * @Serializer\Inline()
+ * @Serializer\Type("array<string,string>")
+ */
+ public $array;
+
+ /**
+ * @param array $array
+ */
+ public function __construct(array $array)
+ {
+ $this->array = $array;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Metadata;
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+class ClassMetadataTest extends \PHPUnit_Framework_TestCase
+{
+ public function getAccessOrderCases()
+ {
+ return [
+ [array('b', 'a'), array('b', 'a')],
+ [array('a', 'b'), array('a', 'b')],
+ [array('b'), array('b', 'a')],
+ [array('a'), array('a', 'b')],
+ [array('foo', 'bar'), array('b', 'a')],
+ ];
+ }
+
+ public function testSerialization()
+ {
+ $meta = new PropertyMetadata('JMS\Serializer\Tests\Metadata\PropertyMetadataOrder', 'b');
+ $restoredMeta = unserialize(serialize($meta));
+ $this->assertEquals($meta, $restoredMeta);
+ }
+
+ /**
+ * @dataProvider getAccessOrderCases
+ */
+ public function testSetAccessorOrderCustom(array $order, array $expected)
+ {
+ $metadata = new ClassMetadata('JMS\Serializer\Tests\Metadata\PropertyMetadataOrder');
+ $metadata->addPropertyMetadata(new PropertyMetadata('JMS\Serializer\Tests\Metadata\PropertyMetadataOrder', 'b'));
+ $metadata->addPropertyMetadata(new PropertyMetadata('JMS\Serializer\Tests\Metadata\PropertyMetadataOrder', 'a'));
+ $this->assertEquals(array('b', 'a'), array_keys($metadata->propertyMetadata));
+
+ $metadata->setAccessorOrder(ClassMetadata::ACCESSOR_ORDER_CUSTOM, $order);
+ $this->assertEquals($expected, array_keys($metadata->propertyMetadata));
+ }
+
+ public function testSetAccessorOrderAlphabetical()
+ {
+ $metadata = new ClassMetadata('JMS\Serializer\Tests\Metadata\PropertyMetadataOrder');
+ $metadata->addPropertyMetadata(new PropertyMetadata('JMS\Serializer\Tests\Metadata\PropertyMetadataOrder', 'b'));
+ $metadata->addPropertyMetadata(new PropertyMetadata('JMS\Serializer\Tests\Metadata\PropertyMetadataOrder', 'a'));
+ $this->assertEquals(array('b', 'a'), array_keys($metadata->propertyMetadata));
+
+ $metadata->setAccessorOrder(ClassMetadata::ACCESSOR_ORDER_ALPHABETICAL);
+ $this->assertEquals(array('a', 'b'), array_keys($metadata->propertyMetadata));
+ }
+
+ /**
+ * @dataProvider providerPublicMethodData
+ */
+ public function testAccessorTypePublicMethod($property, $getterInit, $setterInit, $getterName, $setterName)
+ {
+ $object = new PropertyMetadataPublicMethod();
+
+ $metadata = new PropertyMetadata(get_class($object), $property);
+ $metadata->setAccessor(PropertyMetadata::ACCESS_TYPE_PUBLIC_METHOD, $getterInit, $setterInit);
+
+ $this->assertEquals($getterName, $metadata->getter);
+ $this->assertEquals($setterName, $metadata->setter);
+
+ $metadata->setValue($object, 'x');
+
+ $this->assertEquals(sprintf('%1$s:%1$s:x', strtoupper($property)), $metadata->getValue($object));
+ }
+
+ /**
+ * @dataProvider providerPublicMethodException
+ */
+ public function testAccessorTypePublicMethodException($getter, $setter, $message)
+ {
+ $this->setExpectedException('\JMS\Serializer\Exception\RuntimeException', $message);
+
+ $object = new PropertyMetadataPublicMethod();
+
+ $metadata = new PropertyMetadata(get_class($object), 'e');
+ $metadata->setAccessor(PropertyMetadata::ACCESS_TYPE_PUBLIC_METHOD, $getter, $setter);
+ }
+
+ public function providerPublicMethodData()
+ {
+ return array(
+ array('a', null, null, 'geta', 'seta'),
+ array('b', null, null, 'isb', 'setb'),
+ array('c', null, null, 'hasc', 'setc'),
+ array('d', 'fetchd', 'saved', 'fetchd', 'saved')
+ );
+ }
+
+ public function providerPublicMethodException()
+ {
+ return array(
+ array(null, null, 'a public getE method, nor a public isE method, nor a public hasE method in class'),
+ array(null, 'setx', 'a public getE method, nor a public isE method, nor a public hasE method in class'),
+ array('getx', null, 'no public setE method in class'),
+ );
+ }
+}
+
+class PropertyMetadataOrder
+{
+ private $b, $a;
+}
+
+class PropertyMetadataPublicMethod
+{
+ private $a, $b, $c, $d, $e;
+
+ public function getA()
+ {
+ return 'A:' . $this->a;
+ }
+
+ public function setA($a)
+ {
+ $this->a = 'A:' . $a;
+ }
+
+ public function isB()
+ {
+ return 'B:' . $this->b;
+ }
+
+ public function setB($b)
+ {
+ $this->b = 'B:' . $b;
+ }
+
+ public function hasC()
+ {
+ return 'C:' . $this->c;
+ }
+
+ public function setC($c)
+ {
+ $this->c = 'C:' . $c;
+ }
+
+ public function fetchD()
+ {
+ return 'D:' . $this->d;
+ }
+
+ public function saveD($d)
+ {
+ $this->d = 'D:' . $d;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Metadata\Driver;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+
+class AnnotationDriverTest extends BaseDriverTest
+{
+ protected function getDriver()
+ {
+ return new AnnotationDriver(new AnnotationReader());
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Metadata\Driver;
+
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Metadata\VirtualPropertyMetadata;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorChild;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorParent;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorChild;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorParent;
+use JMS\Serializer\Tests\Fixtures\ParentSkipWithEmptyChild;
+use Metadata\Driver\DriverInterface;
+
+abstract class BaseDriverTest extends \PHPUnit_Framework_TestCase
+{
+ public function testLoadBlogPostMetadata()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
+
+ $this->assertNotNull($m);
+ $this->assertEquals('blog-post', $m->xmlRootName);
+ $this->assertCount(4, $m->xmlNamespaces);
+ $this->assertArrayHasKey('', $m->xmlNamespaces);
+ $this->assertEquals('http://example.com/namespace', $m->xmlNamespaces['']);
+ $this->assertArrayHasKey('gd', $m->xmlNamespaces);
+ $this->assertEquals('http://schemas.google.com/g/2005', $m->xmlNamespaces['gd']);
+ $this->assertArrayHasKey('atom', $m->xmlNamespaces);
+ $this->assertEquals('http://www.w3.org/2005/Atom', $m->xmlNamespaces['atom']);
+ $this->assertArrayHasKey('dc', $m->xmlNamespaces);
+ $this->assertEquals('http://purl.org/dc/elements/1.1/', $m->xmlNamespaces['dc']);
+
+ $p = new PropertyMetadata($m->name, 'id');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->groups = array("comments", "post");
+ $p->xmlElementCData = false;
+ $this->assertEquals($p, $m->propertyMetadata['id']);
+
+ $p = new PropertyMetadata($m->name, 'title');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->groups = array("comments", "post");
+ $p->xmlNamespace = "http://purl.org/dc/elements/1.1/";
+ $this->assertEquals($p, $m->propertyMetadata['title']);
+
+ $p = new PropertyMetadata($m->name, 'createdAt');
+ $p->type = array('name' => 'DateTime', 'params' => array());
+ $p->xmlAttribute = true;
+ $this->assertEquals($p, $m->propertyMetadata['createdAt']);
+
+ $p = new PropertyMetadata($m->name, 'published');
+ $p->type = array('name' => 'boolean', 'params' => array());
+ $p->serializedName = 'is_published';
+ $p->xmlAttribute = true;
+ $p->groups = array("post");
+ $this->assertEquals($p, $m->propertyMetadata['published']);
+
+ $p = new PropertyMetadata($m->name, 'etag');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlAttribute = true;
+ $p->groups = array("post");
+ $p->xmlNamespace = "http://schemas.google.com/g/2005";
+ $this->assertEquals($p, $m->propertyMetadata['etag']);
+
+ $p = new PropertyMetadata($m->name, 'comments');
+ $p->type = array('name' => 'ArrayCollection', 'params' => array(array('name' => 'JMS\Serializer\Tests\Fixtures\Comment', 'params' => array())));
+ $p->xmlCollection = true;
+ $p->xmlCollectionInline = true;
+ $p->xmlEntryName = 'comment';
+ $p->groups = array("comments");
+ $this->assertEquals($p, $m->propertyMetadata['comments']);
+
+ $p = new PropertyMetadata($m->name, 'author');
+ $p->type = array('name' => 'JMS\Serializer\Tests\Fixtures\Author', 'params' => array());
+ $p->groups = array("post");
+ $p->xmlNamespace = 'http://www.w3.org/2005/Atom';
+ $this->assertEquals($p, $m->propertyMetadata['author']);
+
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\Price'));
+ $this->assertNotNull($m);
+
+ $p = new PropertyMetadata($m->name, 'price');
+ $p->type = array('name' => 'float', 'params' => array());
+ $p->xmlValue = true;
+ $this->assertEquals($p, $m->propertyMetadata['price']);
+ }
+
+ public function testXMLListAbsentNode()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\ObjectWithAbsentXmlListNode'));
+
+ $this->assertArrayHasKey('absent', $m->propertyMetadata);
+ $this->assertArrayHasKey('present', $m->propertyMetadata);
+ $this->assertArrayHasKey('skipDefault', $m->propertyMetadata);
+
+ $this->assertTrue($m->propertyMetadata['absent']->xmlCollectionSkipWhenEmpty);
+ $this->assertTrue($m->propertyMetadata['skipDefault']->xmlCollectionSkipWhenEmpty);
+ $this->assertFalse($m->propertyMetadata['present']->xmlCollectionSkipWhenEmpty);
+ }
+
+ public function testVirtualProperty()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\ObjectWithVirtualProperties'));
+
+ $this->assertArrayHasKey('existField', $m->propertyMetadata);
+ $this->assertArrayHasKey('virtualValue', $m->propertyMetadata);
+ $this->assertArrayHasKey('virtualSerializedValue', $m->propertyMetadata);
+ $this->assertArrayHasKey('typedVirtualProperty', $m->propertyMetadata);
+
+ $this->assertEquals($m->propertyMetadata['virtualSerializedValue']->serializedName, 'test', 'Serialized name is missing');
+
+ $p = new VirtualPropertyMetadata($m->name, 'virtualValue');
+ $p->getter = 'getVirtualValue';
+
+ $this->assertEquals($p, $m->propertyMetadata['virtualValue']);
+ }
+
+ public function testXmlKeyValuePairs()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\ObjectWithXmlKeyValuePairs'));
+
+ $this->assertArrayHasKey('array', $m->propertyMetadata);
+ $this->assertTrue($m->propertyMetadata['array']->xmlKeyValuePairs);
+ }
+
+ public function testExpressionVirtualPropertyWithExcludeAll()
+ {
+ $a = new \JMS\Serializer\Tests\Fixtures\ObjectWithExpressionVirtualPropertiesAndExcludeAll();
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass($a));;
+
+ $this->assertArrayHasKey('virtualValue', $m->propertyMetadata);
+
+ $p = new ExpressionPropertyMetadata($m->name, 'virtualValue', 'object.getVirtualValue()');
+ $this->assertEquals($p, $m->propertyMetadata['virtualValue']);
+ }
+
+ public function testVirtualPropertyWithExcludeAll()
+ {
+ $a = new \JMS\Serializer\Tests\Fixtures\ObjectWithVirtualPropertiesAndExcludeAll();
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass($a));
+
+ $this->assertArrayHasKey('virtualValue', $m->propertyMetadata);
+
+ $p = new VirtualPropertyMetadata($m->name, 'virtualValue');
+ $p->getter = 'getVirtualValue';
+
+ $this->assertEquals($p, $m->propertyMetadata['virtualValue']);
+ }
+
+ public function testReadOnlyDefinedBeforeGetterAndSetter()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\AuthorReadOnly'));
+
+ $this->assertNotNull($m);
+ }
+
+ public function testExpressionVirtualProperty()
+ {
+ /** @var $m ClassMetadata */
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess'));
+
+ $keys = array_keys($m->propertyMetadata);
+ $this->assertEquals(['firstName', 'lastName', 'id'], $keys);
+ }
+
+ public function testLoadDiscriminator()
+ {
+ /** @var $m ClassMetadata */
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle'));
+
+ $this->assertNotNull($m);
+ $this->assertEquals('type', $m->discriminatorFieldName);
+ $this->assertEquals($m->name, $m->discriminatorBaseClass);
+ $this->assertEquals(
+ array(
+ 'car' => 'JMS\Serializer\Tests\Fixtures\Discriminator\Car',
+ 'moped' => 'JMS\Serializer\Tests\Fixtures\Discriminator\Moped',
+ ),
+ $m->discriminatorMap
+ );
+ }
+
+ public function testLoadXmlDiscriminator()
+ {
+ /** @var $m ClassMetadata */
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass(ObjectWithXmlAttributeDiscriminatorParent::class));
+
+ $this->assertNotNull($m);
+ $this->assertEquals('type', $m->discriminatorFieldName);
+ $this->assertEquals($m->name, $m->discriminatorBaseClass);
+ $this->assertEquals(
+ array(
+ 'child' => ObjectWithXmlAttributeDiscriminatorChild::class,
+ ),
+ $m->discriminatorMap
+ );
+ $this->assertTrue($m->xmlDiscriminatorAttribute);
+ $this->assertFalse($m->xmlDiscriminatorCData);
+ }
+
+ public function testLoadXmlDiscriminatorWithNamespaces()
+ {
+ /** @var $m ClassMetadata */
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass(ObjectWithXmlNamespaceDiscriminatorParent::class));
+
+ $this->assertNotNull($m);
+ $this->assertEquals('type', $m->discriminatorFieldName);
+ $this->assertEquals($m->name, $m->discriminatorBaseClass);
+ $this->assertEquals(
+ array(
+ 'child' => ObjectWithXmlNamespaceDiscriminatorChild::class,
+ ),
+ $m->discriminatorMap
+ );
+ $this->assertEquals('http://example.com/', $m->xmlDiscriminatorNamespace);
+ }
+
+ public function testLoadDiscriminatorWithGroup()
+ {
+ /** @var $m ClassMetadata */
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Vehicle'));
+
+ $this->assertNotNull($m);
+ $this->assertEquals('type', $m->discriminatorFieldName);
+ $this->assertEquals(array('foo'), $m->discriminatorGroups);
+ $this->assertEquals($m->name, $m->discriminatorBaseClass);
+ $this->assertEquals(
+ array(
+ 'car' => 'JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Car'
+ ),
+ $m->discriminatorMap
+ );
+ }
+
+ public function testSkipWhenEmptyOption()
+ {
+ /** @var $m ClassMetadata */
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass(ParentSkipWithEmptyChild::class));
+
+ $this->assertNotNull($m);
+
+ $this->assertInstanceOf(PropertyMetadata::class, $m->propertyMetadata['c']);
+ $this->assertInstanceOf(PropertyMetadata::class, $m->propertyMetadata['d']);
+ $this->assertInstanceOf(PropertyMetadata::class, $m->propertyMetadata['child']);
+ $this->assertFalse($m->propertyMetadata['c']->skipWhenEmpty);
+ $this->assertFalse($m->propertyMetadata['d']->skipWhenEmpty);
+ $this->assertTrue($m->propertyMetadata['child']->skipWhenEmpty);
+ }
+
+ public function testLoadDiscriminatorSubClass()
+ {
+ /** @var $m ClassMetadata */
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\Discriminator\Car'));
+
+ $this->assertNotNull($m);
+ $this->assertNull($m->discriminatorValue);
+ $this->assertNull($m->discriminatorBaseClass);
+ $this->assertNull($m->discriminatorFieldName);
+ $this->assertEquals(array(), $m->discriminatorMap);
+ }
+
+ public function testLoadXmlObjectWithNamespacesMetadata()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces'));
+ $this->assertNotNull($m);
+ $this->assertEquals('test-object', $m->xmlRootName);
+ $this->assertEquals('http://example.com/namespace', $m->xmlRootNamespace);
+ $this->assertCount(3, $m->xmlNamespaces);
+ $this->assertArrayHasKey('', $m->xmlNamespaces);
+ $this->assertEquals('http://example.com/namespace', $m->xmlNamespaces['']);
+ $this->assertArrayHasKey('gd', $m->xmlNamespaces);
+ $this->assertEquals('http://schemas.google.com/g/2005', $m->xmlNamespaces['gd']);
+ $this->assertArrayHasKey('atom', $m->xmlNamespaces);
+ $this->assertEquals('http://www.w3.org/2005/Atom', $m->xmlNamespaces['atom']);
+
+ $p = new PropertyMetadata($m->name, 'title');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://purl.org/dc/elements/1.1/";
+ $this->assertEquals($p, $m->propertyMetadata['title']);
+
+ $p = new PropertyMetadata($m->name, 'createdAt');
+ $p->type = array('name' => 'DateTime', 'params' => array());
+ $p->xmlAttribute = true;
+ $this->assertEquals($p, $m->propertyMetadata['createdAt']);
+
+ $p = new PropertyMetadata($m->name, 'etag');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlAttribute = true;
+ $p->xmlNamespace = "http://schemas.google.com/g/2005";
+ $this->assertEquals($p, $m->propertyMetadata['etag']);
+
+ $p = new PropertyMetadata($m->name, 'author');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlAttribute = false;
+ $p->xmlNamespace = "http://www.w3.org/2005/Atom";
+ $this->assertEquals($p, $m->propertyMetadata['author']);
+
+ $p = new PropertyMetadata($m->name, 'language');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlAttribute = true;
+ $p->xmlNamespace = "http://purl.org/dc/elements/1.1/";
+ $this->assertEquals($p, $m->propertyMetadata['language']);
+ }
+
+ public function testMaxDepth()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\Node'));
+
+ $this->assertEquals(2, $m->propertyMetadata['children']->maxDepth);
+ }
+
+ public function testPersonCData()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\Person'));
+
+ $this->assertNotNull($m);
+ $this->assertFalse($m->propertyMetadata['name']->xmlElementCData);
+ }
+
+ public function testXmlNamespaceInheritanceMetadata()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\SimpleClassObject'));
+ $this->assertNotNull($m);
+ $this->assertCount(3, $m->xmlNamespaces);
+ $this->assertArrayHasKey('old_foo', $m->xmlNamespaces);
+ $this->assertEquals('http://old.foo.example.org', $m->xmlNamespaces['old_foo']);
+ $this->assertArrayHasKey('foo', $m->xmlNamespaces);
+ $this->assertEquals('http://foo.example.org', $m->xmlNamespaces['foo']);
+ $this->assertArrayHasKey('new_foo', $m->xmlNamespaces);
+ $this->assertEquals('http://new.foo.example.org', $m->xmlNamespaces['new_foo']);
+ $this->assertCount(3, $m->propertyMetadata);
+
+ $p = new PropertyMetadata($m->name, 'foo');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://old.foo.example.org";
+ $p->xmlAttribute = true;
+ $this->assertEquals($p, $m->propertyMetadata['foo']);
+
+ $p = new PropertyMetadata($m->name, 'bar');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://foo.example.org";
+ $this->assertEquals($p, $m->propertyMetadata['bar']);
+
+ $p = new PropertyMetadata($m->name, 'moo');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://new.foo.example.org";
+ $this->assertEquals($p, $m->propertyMetadata['moo']);
+
+
+ $subm = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\SimpleSubClassObject'));
+ $this->assertNotNull($subm);
+ $this->assertCount(2, $subm->xmlNamespaces);
+ $this->assertArrayHasKey('old_foo', $subm->xmlNamespaces);
+ $this->assertEquals('http://foo.example.org', $subm->xmlNamespaces['old_foo']);
+ $this->assertArrayHasKey('foo', $subm->xmlNamespaces);
+ $this->assertEquals('http://better.foo.example.org', $subm->xmlNamespaces['foo']);
+ $this->assertCount(3, $subm->propertyMetadata);
+
+ $p = new PropertyMetadata($subm->name, 'moo');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://better.foo.example.org";
+ $this->assertEquals($p, $subm->propertyMetadata['moo']);
+
+ $p = new PropertyMetadata($subm->name, 'baz');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://foo.example.org";
+ $this->assertEquals($p, $subm->propertyMetadata['baz']);
+
+ $p = new PropertyMetadata($subm->name, 'qux');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://new.foo.example.org";
+ $this->assertEquals($p, $subm->propertyMetadata['qux']);
+
+ $m->merge($subm);
+ $this->assertNotNull($m);
+ $this->assertCount(3, $m->xmlNamespaces);
+ $this->assertArrayHasKey('old_foo', $m->xmlNamespaces);
+ $this->assertEquals('http://foo.example.org', $m->xmlNamespaces['old_foo']);
+ $this->assertArrayHasKey('foo', $m->xmlNamespaces);
+ $this->assertEquals('http://better.foo.example.org', $m->xmlNamespaces['foo']);
+ $this->assertArrayHasKey('new_foo', $m->xmlNamespaces);
+ $this->assertEquals('http://new.foo.example.org', $m->xmlNamespaces['new_foo']);
+ $this->assertCount(5, $m->propertyMetadata);
+
+ $p = new PropertyMetadata($m->name, 'foo');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://old.foo.example.org";
+ $p->xmlAttribute = true;
+ $p->class = 'JMS\Serializer\Tests\Fixtures\SimpleClassObject';
+ $this->assetMetadataEquals($p, $m->propertyMetadata['foo']);
+
+ $p = new PropertyMetadata($m->name, 'bar');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://foo.example.org";
+ $p->class = 'JMS\Serializer\Tests\Fixtures\SimpleClassObject';
+ $this->assetMetadataEquals($p, $m->propertyMetadata['bar']);
+
+ $p = new PropertyMetadata($m->name, 'moo');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://better.foo.example.org";
+ $this->assetMetadataEquals($p, $m->propertyMetadata['moo']);
+
+ $p = new PropertyMetadata($m->name, 'baz');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://foo.example.org";
+ $this->assetMetadataEquals($p, $m->propertyMetadata['baz']);
+
+ $p = new PropertyMetadata($m->name, 'qux');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->xmlNamespace = "http://new.foo.example.org";
+ $this->assetMetadataEquals($p, $m->propertyMetadata['qux']);
+ }
+
+ private function assetMetadataEquals(PropertyMetadata $expected, PropertyMetadata $actual)
+ {
+ $expectedVars = get_object_vars($expected);
+ $actualVars = get_object_vars($actual);
+
+ $expectedReflection = (array)$expectedVars['reflection'];
+ $actualReflection = (array)$actualVars['reflection'];
+
+ // HHVM bug with class property
+ unset($expectedVars['reflection'], $actualVars['reflection']);
+ $this->assertEquals($expectedVars, $actualVars);
+
+ // HHVM bug with class property
+ if (isset($expectedReflection['info']) || isset($actualReflection['info'])) {
+ $expectedReflection['class'] = $expectedReflection['info']['class'];
+ $actualReflection['class'] = $actualReflection['info']['class'];
+ }
+
+ $this->assertEquals($expectedReflection, $actualReflection);
+ }
+
+ public function testHandlerCallbacks()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\ObjectWithHandlerCallbacks'));
+
+ $this->assertEquals('toJson', $m->handlerCallbacks[GraphNavigator::DIRECTION_SERIALIZATION]['json']);
+ $this->assertEquals('toXml', $m->handlerCallbacks[GraphNavigator::DIRECTION_SERIALIZATION]['xml']);
+ }
+
+ public function testExclusionIf()
+ {
+ $class = 'JMS\Serializer\Tests\Fixtures\PersonSecret';
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass($class));
+
+ $p = new PropertyMetadata($class, 'name');
+ $p->type = array('name' => 'string', 'params' => array());
+ $this->assertEquals($p, $m->propertyMetadata['name']);
+
+ $p = new PropertyMetadata($class, 'gender');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->excludeIf = "show_data('gender')";
+ $this->assertEquals($p, $m->propertyMetadata['gender']);
+
+ $p = new PropertyMetadata($class, 'age');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->excludeIf = "!(show_data('age'))";
+ $this->assertEquals($p, $m->propertyMetadata['age']);
+ }
+
+ public function testExcludePropertyNoPublicAccessorException()
+ {
+ $first = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\ExcludePublicAccessor'));
+
+ if ($this instanceof PhpDriverTest) {
+ return;
+ }
+ $this->assertArrayHasKey('id', $first->propertyMetadata);
+ $this->assertArrayNotHasKey('iShallNotBeAccessed', $first->propertyMetadata);
+ }
+
+
+ /**
+ * @return DriverInterface
+ */
+ abstract protected function getDriver();
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Metadata\Driver;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use Doctrine\ORM\Configuration;
+use Doctrine\ORM\EntityManager;
+use Doctrine\ORM\Mapping\Driver\AnnotationDriver as DoctrineDriver;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+use JMS\Serializer\Metadata\Driver\DoctrineTypeDriver;
+
+class DoctrineDriverTest extends \PHPUnit_Framework_TestCase
+{
+ public function getMetadata()
+ {
+ $refClass = new \ReflectionClass('JMS\Serializer\Tests\Fixtures\Doctrine\BlogPost');
+ $metadata = $this->getDoctrineDriver()->loadMetadataForClass($refClass);
+
+ return $metadata;
+ }
+
+ public function testTypelessPropertyIsGivenTypeFromDoctrineMetadata()
+ {
+ $metadata = $this->getMetadata();
+
+ $this->assertEquals(
+ array('name' => 'DateTime', 'params' => array()),
+ $metadata->propertyMetadata['createdAt']->type
+ );
+ }
+
+ public function testSingleValuedAssociationIsProperlyHinted()
+ {
+ $metadata = $this->getMetadata();
+ $this->assertEquals(
+ array('name' => 'JMS\Serializer\Tests\Fixtures\Doctrine\Author', 'params' => array()),
+ $metadata->propertyMetadata['author']->type
+ );
+ }
+
+ public function testMultiValuedAssociationIsProperlyHinted()
+ {
+ $metadata = $this->getMetadata();
+
+ $this->assertEquals(
+ array('name' => 'ArrayCollection', 'params' => array(
+ array('name' => 'JMS\Serializer\Tests\Fixtures\Doctrine\Comment', 'params' => array()))
+ ),
+ $metadata->propertyMetadata['comments']->type
+ );
+ }
+
+ public function testTypeGuessByDoctrineIsOverwrittenByDelegateDriver()
+ {
+ $metadata = $this->getMetadata();
+
+ // This would be guessed as boolean but we've overriden it to integer
+ $this->assertEquals(
+ array('name' => 'integer', 'params' => array()),
+ $metadata->propertyMetadata['published']->type
+ );
+ }
+
+ public function testUnknownDoctrineTypeDoesNotResultInAGuess()
+ {
+ $metadata = $this->getMetadata();
+ $this->assertNull($metadata->propertyMetadata['slug']->type);
+ }
+
+ public function testNonDoctrineEntityClassIsNotModified()
+ {
+ // Note: Using regular BlogPost fixture here instead of Doctrine fixture
+ // because it has no Doctrine metadata.
+ $refClass = new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost');
+
+ $plainMetadata = $this->getAnnotationDriver()->loadMetadataForClass($refClass);
+ $doctrineMetadata = $this->getDoctrineDriver()->loadMetadataForClass($refClass);
+
+ // Do not compare timestamps
+ if (abs($doctrineMetadata->createdAt - $plainMetadata->createdAt) < 2) {
+ $plainMetadata->createdAt = $doctrineMetadata->createdAt;
+ }
+
+ $this->assertEquals($plainMetadata, $doctrineMetadata);
+ }
+
+ public function testExcludePropertyNoPublicAccessorException()
+ {
+ $first = $this->getAnnotationDriver()
+ ->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\ExcludePublicAccessor'));
+
+ $this->assertArrayHasKey('id', $first->propertyMetadata);
+ $this->assertArrayNotHasKey('iShallNotBeAccessed', $first->propertyMetadata);
+ }
+
+ public function testVirtualPropertiesAreNotModified()
+ {
+ $doctrineMetadata = $this->getMetadata();
+ $this->assertNull($doctrineMetadata->propertyMetadata['ref']->type);
+ }
+
+ public function testGuidPropertyIsGivenStringType()
+ {
+ $metadata = $this->getMetadata();
+
+ $this->assertEquals(
+ array('name' => 'string', 'params' => array()),
+ $metadata->propertyMetadata['id']->type
+ );
+ }
+
+ protected function getEntityManager()
+ {
+ $config = new Configuration();
+ $config->setProxyDir(sys_get_temp_dir() . '/JMSDoctrineTestProxies');
+ $config->setProxyNamespace('JMS\Tests\Proxies');
+ $config->setMetadataDriverImpl(
+ new DoctrineDriver(new AnnotationReader(), __DIR__ . '/../../Fixtures/Doctrine')
+ );
+
+ $conn = array(
+ 'driver' => 'pdo_sqlite',
+ 'memory' => true,
+ );
+
+ return EntityManager::create($conn, $config);
+ }
+
+ public function getAnnotationDriver()
+ {
+ return new AnnotationDriver(new AnnotationReader());
+ }
+
+ protected function getDoctrineDriver()
+ {
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
+ $registry->expects($this->atLeastOnce())
+ ->method('getManagerForClass')
+ ->will($this->returnValue($this->getEntityManager()));
+
+ return new DoctrineTypeDriver(
+ $this->getAnnotationDriver(),
+ $registry
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Metadata\Driver;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use Doctrine\ODM\PHPCR\Configuration;
+use Doctrine\ODM\PHPCR\DocumentManager;
+use Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver as DoctrinePHPCRDriver;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+use JMS\Serializer\Metadata\Driver\DoctrinePHPCRTypeDriver;
+
+class DoctrinePHPCRDriverTest extends \PHPUnit_Framework_TestCase
+{
+ public function getMetadata()
+ {
+ $refClass = new \ReflectionClass('JMS\Serializer\Tests\Fixtures\DoctrinePHPCR\BlogPost');
+ $metadata = $this->getDoctrinePHPCRDriver()->loadMetadataForClass($refClass);
+
+ return $metadata;
+ }
+
+ public function testTypelessPropertyIsGivenTypeFromDoctrineMetadata()
+ {
+ $metadata = $this->getMetadata();
+ $this->assertEquals(
+ array('name' => 'DateTime', 'params' => array()),
+ $metadata->propertyMetadata['createdAt']->type
+ );
+ }
+
+ public function testSingleValuedAssociationIsProperlyHinted()
+ {
+ $metadata = $this->getMetadata();
+ $this->assertEquals(
+ array('name' => 'JMS\Serializer\Tests\Fixtures\DoctrinePHPCR\Author', 'params' => array()),
+ $metadata->propertyMetadata['author']->type
+ );
+ }
+
+ public function testMultiValuedAssociationIsProperlyHinted()
+ {
+ $metadata = $this->getMetadata();
+
+ $this->assertEquals(
+ array('name' => 'ArrayCollection', 'params' => array(
+ array('name' => 'JMS\Serializer\Tests\Fixtures\DoctrinePHPCR\Comment', 'params' => array()))
+ ),
+ $metadata->propertyMetadata['comments']->type
+ );
+ }
+
+ public function testTypeGuessByDoctrineIsOverwrittenByDelegateDriver()
+ {
+ $metadata = $this->getMetadata();
+
+ // This would be guessed as boolean but we've overridden it to integer
+ $this->assertEquals(
+ array('name' => 'integer', 'params' => array()),
+ $metadata->propertyMetadata['published']->type
+ );
+ }
+
+ public function testNonDoctrineDocumentClassIsNotModified()
+ {
+ // Note: Using regular BlogPost fixture here instead of Doctrine fixture
+ // because it has no Doctrine metadata.
+ $refClass = new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost');
+
+ $plainMetadata = $this->getAnnotationDriver()->loadMetadataForClass($refClass);
+ $doctrineMetadata = $this->getDoctrinePHPCRDriver()->loadMetadataForClass($refClass);
+
+ // Do not compare timestamps
+ if (abs($doctrineMetadata->createdAt - $plainMetadata->createdAt) < 2) {
+ $plainMetadata->createdAt = $doctrineMetadata->createdAt;
+ }
+
+ $this->assertEquals($plainMetadata, $doctrineMetadata);
+ }
+
+ protected function getDocumentManager()
+ {
+ $config = new Configuration();
+ $config->setProxyDir(sys_get_temp_dir() . '/JMSDoctrineTestProxies');
+ $config->setProxyNamespace('JMS\Tests\Proxies');
+ $config->setMetadataDriverImpl(
+ new DoctrinePHPCRDriver(new AnnotationReader(), __DIR__ . '/../../Fixtures/DoctrinePHPCR')
+ );
+
+ $session = $this->getMockBuilder('PHPCR\SessionInterface')->getMock();
+
+ return DocumentManager::create($session, $config);
+ }
+
+ public function getAnnotationDriver()
+ {
+ return new AnnotationDriver(new AnnotationReader());
+ }
+
+ protected function getDoctrinePHPCRDriver()
+ {
+ $registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
+ $registry->expects($this->atLeastOnce())
+ ->method('getManagerForClass')
+ ->will($this->returnValue($this->getDocumentManager()));
+
+ return new DoctrinePHPCRTypeDriver(
+ $this->getAnnotationDriver(),
+ $registry
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Metadata\Driver;
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\Driver\NullDriver;
+
+class NullDriverTest extends \PHPUnit_Framework_TestCase
+{
+ public function testReturnsValidMetadata()
+ {
+ $driver = new NullDriver();
+
+ $metadata = $driver->loadMetadataForClass(new \ReflectionClass('stdClass'));
+
+ $this->assertInstanceOf(ClassMetadata::class, $metadata);
+ $this->assertCount(0, $metadata->propertyMetadata);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Metadata\Driver;
+
+use JMS\Serializer\Metadata\Driver\PhpDriver;
+use Metadata\Driver\FileLocator;
+
+class PhpDriverTest extends BaseDriverTest
+{
+ protected function getDriver()
+ {
+ return new PhpDriver(new FileLocator(array(
+ 'JMS\Serializer\Tests\Fixtures' => __DIR__ . '/php',
+ )));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Metadata\Driver;
+
+use JMS\Serializer\Metadata\Driver\XmlDriver;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use Metadata\Driver\FileLocator;
+
+class XmlDriverTest extends BaseDriverTest
+{
+ /**
+ * @expectedException JMS\Serializer\Exception\XmlErrorException
+ * @expectedExceptionMessage [FATAL] Start tag expected, '<' not found
+ */
+ public function testInvalidXml()
+ {
+ $driver = $this->getDriver();
+
+ $ref = new \ReflectionMethod($driver, 'loadMetadataFromFile');
+ $ref->setAccessible(true);
+ $ref->invoke($driver, new \ReflectionClass('stdClass'), __DIR__ . '/xml/invalid.xml');
+ }
+
+ public function testBlogPostExcludeAllStrategy()
+ {
+ $m = $this->getDriver('exclude_all')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
+
+ $this->assertArrayHasKey('title', $m->propertyMetadata);
+
+ $excluded = array('createdAt', 'published', 'comments', 'author');
+ foreach ($excluded as $key) {
+ $this->assertArrayNotHasKey($key, $m->propertyMetadata);
+ }
+ }
+
+ public function testBlogPostExcludeNoneStrategy()
+ {
+ $m = $this->getDriver('exclude_none')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
+
+ $this->assertArrayNotHasKey('title', $m->propertyMetadata);
+
+ $excluded = array('createdAt', 'published', 'comments', 'author');
+ foreach ($excluded as $key) {
+ $this->assertArrayHasKey($key, $m->propertyMetadata);
+ }
+ }
+
+ public function testBlogPostCaseInsensitive()
+ {
+ $m = $this->getDriver('case')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
+
+ $p = new PropertyMetadata($m->name, 'title');
+ $p->type = array('name' => 'string', 'params' => array());
+ $this->assertEquals($p, $m->propertyMetadata['title']);
+ }
+
+ public function testAccessorAttributes()
+ {
+ $m = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\GetSetObject'));
+
+ $p = new PropertyMetadata($m->name, 'name');
+ $p->type = array('name' => 'string', 'params' => array());
+ $p->getter = 'getTrimmedName';
+ $p->setter = 'setCapitalizedName';
+
+ $this->assertEquals($p, $m->propertyMetadata['name']);
+ }
+
+ public function testGroupsTrim()
+ {
+ $first = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\GroupsTrim'));
+
+ $this->assertArrayHasKey('amount', $first->propertyMetadata);
+ $this->assertArraySubset(['first.test.group', 'second.test.group'], $first->propertyMetadata['currency']->groups);
+ }
+
+ public function testMultilineGroups()
+ {
+ $first = $this->getDriver()->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\MultilineGroupsFormat'));
+
+ $this->assertArrayHasKey('amount', $first->propertyMetadata);
+ $this->assertArraySubset(['first.test.group', 'second.test.group'], $first->propertyMetadata['currency']->groups);
+ }
+
+ protected function getDriver()
+ {
+ $append = '';
+ if (func_num_args() == 1) {
+ $append = '/' . func_get_arg(0);
+ }
+
+ return new XmlDriver(new FileLocator(array(
+ 'JMS\Serializer\Tests\Fixtures' => __DIR__ . '/xml' . $append,
+ )));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Metadata\Driver;
+
+use JMS\Serializer\Metadata\Driver\YamlDriver;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use Metadata\Driver\FileLocator;
+
+class YamlDriverTest extends BaseDriverTest
+{
+ public function testAccessorOrderIsInferred()
+ {
+ $m = $this->getDriverForSubDir('accessor_inferred')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\Person'));
+ $this->assertEquals(array('age', 'name'), array_keys($m->propertyMetadata));
+ }
+
+ public function testShortExposeSyntax()
+ {
+ $m = $this->getDriverForSubDir('short_expose')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\Person'));
+
+ $this->assertArrayHasKey('name', $m->propertyMetadata);
+ $this->assertArrayNotHasKey('age', $m->propertyMetadata);
+ }
+
+ public function testBlogPost()
+ {
+ $m = $this->getDriverForSubDir('exclude_all')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
+
+ $this->assertArrayHasKey('title', $m->propertyMetadata);
+
+ $excluded = array('createdAt', 'published', 'comments', 'author');
+ foreach ($excluded as $key) {
+ $this->assertArrayNotHasKey($key, $m->propertyMetadata);
+ }
+ }
+
+ public function testBlogPostExcludeNoneStrategy()
+ {
+ $m = $this->getDriverForSubDir('exclude_none')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
+
+ $this->assertArrayNotHasKey('title', $m->propertyMetadata);
+
+ $excluded = array('createdAt', 'published', 'comments', 'author');
+ foreach ($excluded as $key) {
+ $this->assertArrayHasKey($key, $m->propertyMetadata);
+ }
+ }
+
+ public function testBlogPostCaseInsensitive()
+ {
+ $m = $this->getDriverForSubDir('case')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
+
+ $p = new PropertyMetadata($m->name, 'title');
+ $p->type = array('name' => 'string', 'params' => array());
+ $this->assertEquals($p, $m->propertyMetadata['title']);
+ }
+
+ public function testBlogPostAccessor()
+ {
+ $m = $this->getDriverForSubDir('accessor')->loadMetadataForClass(new \ReflectionClass('JMS\Serializer\Tests\Fixtures\BlogPost'));
+
+ $this->assertArrayHasKey('title', $m->propertyMetadata);
+
+ $p = new PropertyMetadata($m->name, 'title');
+ $p->getter = 'getOtherTitle';
+ $p->setter = 'setOtherTitle';
+ $this->assertEquals($p, $m->propertyMetadata['title']);
+ }
+
+ private function getDriverForSubDir($subDir = null)
+ {
+ return new YamlDriver(new FileLocator(array(
+ 'JMS\Serializer\Tests\Fixtures' => __DIR__ . '/yml' . ($subDir ? '/' . $subDir : ''),
+ )));
+ }
+
+ protected function getDriver()
+ {
+ return $this->getDriverForSubDir();
+ }
+}
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Metadata\VirtualPropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess');
+
+$p = new ExpressionPropertyMetadata('JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess', 'firstName', 'object.getFirstName()');
+$metadata->addPropertyMetadata($p);
+
+$p = new VirtualPropertyMetadata('JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess', 'getLastName');
+$metadata->addPropertyMetadata($p);
+
+$p = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess', 'id');
+$metadata->addPropertyMetadata($p);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\AuthorReadOnly');
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\AuthorReadOnlyPerClass');
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\BlogPost');
+$metadata->xmlRootName = 'blog-post';
+
+$metadata->registerNamespace('http://example.com/namespace');
+$metadata->registerNamespace('http://schemas.google.com/g/2005', 'gd');
+$metadata->registerNamespace('http://www.w3.org/2005/Atom', 'atom');
+$metadata->registerNamespace('http://purl.org/dc/elements/1.1/', 'dc');
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\BlogPost', 'id');
+$pMetadata->setType('string');
+$pMetadata->groups = array('comments', 'post');
+$pMetadata->xmlElementCData = false;
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\BlogPost', 'title');
+$pMetadata->setType('string');
+$pMetadata->groups = array('comments', 'post');
+$pMetadata->xmlNamespace = "http://purl.org/dc/elements/1.1/";
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\BlogPost', 'createdAt');
+$pMetadata->setType('DateTime');
+$pMetadata->xmlAttribute = true;
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\BlogPost', 'published');
+$pMetadata->setType('boolean');
+$pMetadata->serializedName = 'is_published';
+$pMetadata->groups = array('post');
+$pMetadata->xmlAttribute = true;
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\BlogPost', 'etag');
+$pMetadata->setType('string');
+$pMetadata->groups = array('post');
+$pMetadata->xmlAttribute = true;
+$pMetadata->xmlNamespace = 'http://schemas.google.com/g/2005';
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\BlogPost', 'comments');
+$pMetadata->setType('ArrayCollection<JMS\Serializer\Tests\Fixtures\Comment>');
+$pMetadata->xmlCollection = true;
+$pMetadata->xmlCollectionInline = true;
+$pMetadata->xmlEntryName = 'comment';
+$pMetadata->groups = array('comments');
+
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\BlogPost', 'author');
+$pMetadata->setType('JMS\Serializer\Tests\Fixtures\Author');
+$pMetadata->groups = array('post');
+$pMetadata->xmlNamespace = 'http://www.w3.org/2005/Atom';
+
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Discriminator\Car');
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Discriminator\Moped');
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorParent');
+$metadata->setDiscriminator('type', array(
+ 'child' => 'JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorChild'
+));
+$metadata->xmlDiscriminatorAttribute = true;
+$metadata->xmlDiscriminatorCData = false;
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorParent');
+$metadata->setDiscriminator('type', array(
+ 'child' => 'JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorChild'
+));
+$metadata->xmlDiscriminatorNamespace = 'http://example.com/';
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle');
+$metadata->setDiscriminator('type', array(
+ 'car' => 'JMS\Serializer\Tests\Fixtures\Discriminator\Car',
+ 'moped' => 'JMS\Serializer\Tests\Fixtures\Discriminator\Moped',
+));
+
+$km = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle', 'km');
+$km->setType('integer');
+$metadata->addPropertyMetadata($km);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Vehicle');
+$metadata->setDiscriminator('type', array(
+ 'car' => 'JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Car',
+), array('foo'));
+
+$km = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Vehicle', 'km');
+$km->setType('integer');
+$metadata->addPropertyMetadata($km);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Node');
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\Node', 'children');
+$pMetadata->maxDepth = 2;
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$className = 'JMS\Serializer\Tests\Fixtures\ObjectWithAbsentXmlListNode';
+
+$metadata = new ClassMetadata($className);
+
+$pMetadata = new PropertyMetadata($className, 'absent');
+$pMetadata->xmlCollectionSkipWhenEmpty = true;
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata($className, 'present');
+$pMetadata->xmlCollectionSkipWhenEmpty = false;
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata($className, 'skipDefault');
+$metadata->addPropertyMetadata($pMetadata);
+
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\ExpressionPropertyMetadata;
+
+$className = 'JMS\Serializer\Tests\Fixtures\ObjectWithExpressionVirtualPropertiesAndExcludeAll';
+
+$metadata = new ClassMetadata($className);
+
+$pMetadata = new ExpressionPropertyMetadata($className, 'virtualValue', 'object.getVirtualValue()');
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\ObjectWithHandlerCallbacks');
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\ObjectWithHandlerCallbacks', 'name');
+$pMetadata->type = 'string';
+$metadata->addPropertyMetadata($pMetadata);
+
+$metadata->addHandlerCallback(GraphNavigator::DIRECTION_SERIALIZATION, 'json', 'toJson');
+$metadata->addHandlerCallback(GraphNavigator::DIRECTION_SERIALIZATION, 'xml', 'toXml');
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\Metadata\VirtualPropertyMetadata;
+
+$className = 'JMS\Serializer\Tests\Fixtures\ObjectWithVirtualProperties';
+
+$metadata = new ClassMetadata($className);
+
+$pMetadata = new PropertyMetadata($className, 'existField');
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new VirtualPropertyMetadata($className, 'virtualValue');
+$pMetadata->getter = 'getVirtualValue';
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new VirtualPropertyMetadata($className, 'virtualSerializedValue');
+$pMetadata->getter = 'getVirtualSerializedValue';
+$pMetadata->serializedName = 'test';
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new VirtualPropertyMetadata($className, 'typedVirtualProperty');
+$pMetadata->getter = 'getTypedVirtualProperty';
+$pMetadata->setType('integer');
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\VirtualPropertyMetadata;
+
+$className = 'JMS\Serializer\Tests\Fixtures\ObjectWithVirtualPropertiesAndExcludeAll';
+
+$metadata = new ClassMetadata($className);
+
+$pMetadata = new VirtualPropertyMetadata($className, 'virtualValue');
+$pMetadata->getter = 'getVirtualValue';
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$className = 'JMS\Serializer\Tests\Fixtures\ObjectWithXmlKeyValuePairs';
+
+$metadata = new ClassMetadata($className);
+
+$pMetadata = new PropertyMetadata($className, 'array');
+$pMetadata->xmlKeyValuePairs = true;
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces');
+$metadata->xmlRootName = 'test-object';
+$metadata->xmlRootNamespace = 'http://example.com/namespace';
+
+$metadata->registerNamespace('http://example.com/namespace');
+$metadata->registerNamespace('http://schemas.google.com/g/2005', 'gd');
+$metadata->registerNamespace('http://www.w3.org/2005/Atom', 'atom');
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces', 'title');
+$pMetadata->setType('string');
+$pMetadata->xmlNamespace = "http://purl.org/dc/elements/1.1/";
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces', 'createdAt');
+$pMetadata->setType('DateTime');
+$pMetadata->xmlAttribute = true;
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces', 'etag');
+$pMetadata->setType('string');
+$pMetadata->xmlAttribute = true;
+$pMetadata->xmlNamespace = 'http://schemas.google.com/g/2005';
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces', 'author');
+$pMetadata->setType('string');
+$pMetadata->xmlNamespace = 'http://www.w3.org/2005/Atom';
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces', 'language');
+$pMetadata->setType('string');
+$pMetadata->xmlAttribute = true;
+$pMetadata->xmlNamespace = 'http://purl.org/dc/elements/1.1/';
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\ParentSkipWithEmptyChild');
+
+$pMeta = new PropertyMetadata($metadata->name, 'c');
+$metadata->addPropertyMetadata($pMeta);
+
+$pMeta = new PropertyMetadata($metadata->name, 'd');
+$metadata->addPropertyMetadata($pMeta);
+
+$pMeta = new PropertyMetadata($metadata->name, 'child');
+$pMeta->skipWhenEmpty = true;
+
+$metadata->addPropertyMetadata($pMeta);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Person');
+$metadata->xmlRootName = 'child';
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\Person', 'name');
+$pMetadata->setType('string');
+$pMetadata->xmlValue = true;
+$pMetadata->xmlElementCData = false;
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\Person', 'age');
+$pMetadata->setType('integer');
+$pMetadata->xmlAttribute = true;
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\PersonSecret');
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\PersonSecret', 'name');
+$pMetadata->setType('string');
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\PersonSecret', 'gender');
+$pMetadata->setType('string');
+$pMetadata->excludeIf = "show_data('gender')";
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\PersonSecret', 'age');
+$pMetadata->setType('string');
+$pMetadata->excludeIf = "!(show_data('age'))";
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\Price');
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\Price', 'price');
+$pMetadata->setType('float');
+$pMetadata->xmlValue = true;
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\SimpleClassObject');
+
+$metadata->registerNamespace('http://foo.example.org', 'foo');
+$metadata->registerNamespace('http://old.foo.example.org', 'old_foo');
+$metadata->registerNamespace('http://new.foo.example.org', 'new_foo');
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\SimpleClassObject', 'foo');
+$pMetadata->setType('string');
+$pMetadata->xmlNamespace = "http://old.foo.example.org";
+$pMetadata->xmlAttribute = true;
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\SimpleClassObject', 'bar');
+$pMetadata->setType('string');
+$pMetadata->xmlNamespace = "http://foo.example.org";
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\SimpleClassObject', 'moo');
+$pMetadata->setType('string');
+$pMetadata->xmlNamespace = "http://new.foo.example.org";
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
\ No newline at end of file
--- /dev/null
+<?php
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+
+$metadata = new ClassMetadata('JMS\Serializer\Tests\Fixtures\SimpleSubClassObject');
+
+$metadata->registerNamespace('http://better.foo.example.org', 'foo');
+$metadata->registerNamespace('http://foo.example.org', 'old_foo');
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\SimpleSubClassObject', 'moo');
+$pMetadata->setType('string');
+$pMetadata->xmlNamespace = "http://better.foo.example.org";
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\SimpleSubClassObject', 'baz');
+$pMetadata->setType('string');
+$pMetadata->xmlNamespace = "http://foo.example.org";
+$metadata->addPropertyMetadata($pMetadata);
+
+$pMetadata = new PropertyMetadata('JMS\Serializer\Tests\Fixtures\SimpleSubClassObject', 'qux');
+$pMetadata->setType('string');
+$pMetadata->xmlNamespace = "http://new.foo.example.org";
+$metadata->addPropertyMetadata($pMetadata);
+
+return $metadata;
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess">
+ <property name="id"/>
+ <virtual-property name="firstName" expression="object.getFirstName()"/>
+ <virtual-property name="lastName" method="getLastName"/>
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\AuthorReadOnly" xml-root-name="author">
+ <property name="id" read-only="true"/>
+ <property name="name" serialized-name="full_name" access-type="public_method" accessor-getter="getName" read-only="true"/>
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\AuthorReadOnlyPerClass" xml-root-name="author" read-only="true">
+ <property name="id" read-only="true"/>
+ <property name="name" serialized-name="full_name" access-type="public_method" accessor-getter="getName" read-only="false" />
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\BlogPost" xml-root-name="blog-post">
+ <xml-namespace uri="http://example.com/namespace"/>
+ <xml-namespace prefix="gd" uri="http://schemas.google.com/g/2005"/>
+ <xml-namespace prefix="atom" uri="http://www.w3.org/2005/Atom"/>
+ <xml-namespace prefix="dc" uri="http://purl.org/dc/elements/1.1/"/>
+ <property name="id" type="string" groups="comments,post">
+ <xml-element cdata="false"/>
+ </property>
+ <property name="title" type="string" groups="comments,post">
+ <xml-element namespace="http://purl.org/dc/elements/1.1/"/>
+ </property>
+ <property name="createdAt" xml-attribute="true" type="DateTime"/>
+ <property name="published" type="boolean" serialized-name="is_published" xml-attribute="true" groups="post" />
+ <property name="etag" type="string" xml-attribute="true" groups="post">
+ <xml-element namespace="http://schemas.google.com/g/2005"/>
+ </property>
+ <property name="comments" groups="comments">
+ <type><![CDATA[ArrayCollection<JMS\Serializer\Tests\Fixtures\Comment>]]></type>
+ <xml-list inline="true" entry-name="comment" />
+ </property>
+ <property name="author" groups="post" type="JMS\Serializer\Tests\Fixtures\Author">
+ <xml-element namespace="http://www.w3.org/2005/Atom"/>
+ </property>
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\Discriminator\Car">
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\Discriminator\Moped">
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorParent"
+ discriminator-field-name="type"
+ >
+ <discriminator-class value="child">JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorChild</discriminator-class>
+ <xml-discriminator attribute="true" cdata="false" />
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorParent"
+ discriminator-field-name="type"
+ >
+ <discriminator-class value="child">JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorChild</discriminator-class>
+ <xml-discriminator namespace="http://example.com/" />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle" discriminator-field-name="type">
+ <discriminator-class value="car">JMS\Serializer\Tests\Fixtures\Discriminator\Car</discriminator-class>
+ <discriminator-class value="moped">JMS\Serializer\Tests\Fixtures\Discriminator\Moped</discriminator-class>
+ <property name="km" type="integer" />
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Vehicle" discriminator-field-name="type">
+ <discriminator-class value="car">JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Car</discriminator-class>
+ <discriminator-groups>
+ <group>foo</group>
+ </discriminator-groups>
+ <property name="km" type="integer" />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\ExcludePublicAccessor" access-type="public_method" read-only="true">
+ <property name="iShallNotBeAccessed" exclude="true" />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\GetSetObject" access-type="public_method">
+ <property name="id" type="integer" access-type="property" />
+ <property name="name" type="string" accessor-getter="getTrimmedName" accessor-setter="setCapitalizedName" />
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\GroupsTrim"
+ exclusion-policy="all"
+ read-only="true"
+ >
+ <virtual-property method="getAmount" type="integer" serialized-name="amount" groups="
+ first.test.group
+ "
+ />
+ <virtual-property method="getCurrency" type="string" serialized-name="currency" groups="
+ first.test.group,
+ second.test.group
+ "
+ />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\MultilineGroupsFormat"
+ exclusion-policy="all"
+ read-only="true"
+ >
+ <virtual-property method="getAmount" type="integer" serialized-name="amount">
+ <groups>
+ <value>first.test.group</value>
+ </groups>
+ </virtual-property>
+ <virtual-property method="getCurrency" type="string" serialized-name="currency">
+ <groups>
+ <value>first.test.group</value>
+ <value>second.test.group</value>
+ </groups>
+ </virtual-property>
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\Node">
+ <property name="children" max-depth="2" />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\ObjectWithAbsentXmlListNode">
+ <property name="absent">
+ <type>array</type>
+ <xml-list skip-when-empty="true"/>
+ </property>
+ <property name="present">
+ <type>array</type>
+ <xml-list skip-when-empty="false"/>
+ </property>
+ <property name="skipDefault">
+ <type>array</type>
+ </property>
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\ObjectWithExpressionVirtualPropertiesAndExcludeAll" exclusion-policy="ALL">
+ <virtual-property name="virtualValue" expression="object.getVirtualValue()"/>
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\ObjectWithHandlerCallbacks">
+ <property name="name" type="string"/>
+ <callback-method name="toJson" type="handler" direction="serialization" format="json" />
+ <callback-method name="toXml" type="handler" direction="serialization" format="xml" />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\ObjectWithVirtualProperties">
+ <property name="existField" type="string"/>
+ <virtual-property method="getVirtualValue"/>
+ <virtual-property method="getVirtualSerializedValue" serialized-name="test"/>
+ <virtual-property method="getTypedVirtualProperty" type="integer" />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\ObjectWithVirtualPropertiesAndExcludeAll" exclusion-policy="ALL">
+ <virtual-property method="getVirtualValue"/>
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\ObjectWithXmlKeyValuePairs" >
+ <property name="array" type="array" xml-key-value-pairs="true" />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces" xml-root-name="test-object" xml-root-namespace="http://example.com/namespace">
+ <xml-namespace uri="http://example.com/namespace"/>
+ <xml-namespace prefix="gd" uri="http://schemas.google.com/g/2005"/>
+ <xml-namespace prefix="atom" uri="http://www.w3.org/2005/Atom"/>
+ <property name="title" type="string">
+ <xml-element namespace="http://purl.org/dc/elements/1.1/"/>
+ </property>
+ <property name="createdAt" xml-attribute="true" type="DateTime"/>
+ <property name="etag" type="string" xml-attribute="true">
+ <xml-element namespace="http://schemas.google.com/g/2005"/>
+ </property>
+ <property name="author" type="string">
+ <xml-element namespace="http://www.w3.org/2005/Atom"/>
+ </property>
+ <property name="language" type="string" xml-attribute="true">
+ <xml-element namespace="http://purl.org/dc/elements/1.1/"/>
+ </property>
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\ParentSkipWithEmptyChild">
+ <property name="c" type="string" />
+ <property name="c" type="string" />
+ <property name="child" skip-when-empty="true" />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\Person" xml-root-name="child">
+ <property name="name" xml-value="true" type="string">
+ <xml-element cdata="false"/>
+ </property>
+ <property name="age" xml-attribute="true" type="integer" />
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\PersonSecret">
+ <property name="name" type="string" />
+ <property name="gender" type="string" exclude-if="show_data('gender')"/>
+ <property name="age" type="string" expose-if="show_data('age')"/>
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\Price">
+ <property name="price" xml-value="true" type="float" />
+ </class>
+</serializer>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\SimpleClassObject">
+ <xml-namespace prefix="foo" uri="http://foo.example.org"/>
+ <xml-namespace prefix="old_foo" uri="http://old.foo.example.org"/>
+ <xml-namespace prefix="new_foo" uri="http://new.foo.example.org"/>
+ <property name="foo" type="string" xml-attribute="true">
+ <xml-element namespace="http://old.foo.example.org"/>
+ </property>
+ <property name="bar" type="string">
+ <xml-element namespace="http://foo.example.org"/>
+ </property>
+ <property name="moo" type="string">
+ <xml-element namespace="http://new.foo.example.org"/>
+ </property>
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\SimpleSubClassObject">
+ <xml-namespace prefix="foo" uri="http://better.foo.example.org"/>
+ <xml-namespace prefix="old_foo" uri="http://foo.example.org"/>
+ <property name="moo" type="string">
+ <xml-element namespace="http://better.foo.example.org"/>
+ </property>
+ <property name="baz" type="string">
+ <xml-element namespace="http://foo.example.org"/>
+ </property>
+ <property name="qux" type="string">
+ <xml-element namespace="http://new.foo.example.org"/>
+ </property>
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\BlogPost" xml-root-name="blog-post" exclusion-policy="all">
+ <property name="title" type="string" expose="TRUE" />
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\BlogPost" xml-root-name="blog-post" exclusion-policy="ALL">
+ <property name="title" type="string" expose="true" />
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<serializer>
+ <class name="JMS\Serializer\Tests\Fixtures\BlogPost" xml-root-name="blog-post" exclusion-policy="NONE">
+ <property name="title" type="string" exclude="true" />
+ </class>
+</serializer>
\ No newline at end of file
--- /dev/null
+This contains no valid XML markup.
\ No newline at end of file
--- /dev/null
+JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess:
+ xml_root_name: author
+ properties:
+ id:
+ expose: true
+ virtual_properties:
+ firstName:
+ exp: object.getFirstName()
+ getLastName:
+ expose: true
+
--- /dev/null
+JMS\Serializer\Tests\Fixtures\AuthorReadOnly:
+ xml_root_name: author
+ properties:
+ id:
+ read_only: true
+ name:
+ serialized_name: full_name
+ access_type: public_method
+ accessor_getter: getName
+ read_only: true
--- /dev/null
+JMS\Serializer\Tests\Fixtures\AuthorReadOnlyPerClass:
+ xml_root_name: author
+ read_only: true
+ properties:
+ id:
+
+ name:
+ serialized_name: full_name
+ access_type: public_method
+ accessor_getter: getName
+ read_only: false
--- /dev/null
+JMS\Serializer\Tests\Fixtures\BlogPost:
+ xml_root_name: blog-post
+ xml_namespaces:
+ "": http://example.com/namespace
+ gd: http://schemas.google.com/g/2005
+ atom: http://www.w3.org/2005/Atom
+ dc: http://purl.org/dc/elements/1.1/
+ properties:
+ id:
+ type: string
+ groups: [comments, post]
+ xml_element:
+ cdata: false
+ title:
+ type: string
+ groups: [comments, post]
+ xml_element:
+ namespace: http://purl.org/dc/elements/1.1/
+ createdAt:
+ type: DateTime
+ xml_attribute: true
+ published:
+ type: boolean
+ serialized_name: is_published
+ xml_attribute: true
+ groups: [post]
+ etag:
+ type: string
+ groups: [post]
+ xml_attribute: true
+ xml_element:
+ namespace: http://schemas.google.com/g/2005
+ comments:
+ type: ArrayCollection<JMS\Serializer\Tests\Fixtures\Comment>
+ groups: [comments]
+ xml_list:
+ inline: true
+ entry_name: comment
+ author:
+ type: JMS\Serializer\Tests\Fixtures\Author
+ groups: [post]
+ xml_element:
+ namespace: http://www.w3.org/2005/Atom
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Discriminator\Car: { }
\ No newline at end of file
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Discriminator\Moped: { }
\ No newline at end of file
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorParent:
+ discriminator:
+ field_name: type
+ map:
+ child: JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorChild
+ xml_attribute: true
+ xml_element:
+ cdata: false
\ No newline at end of file
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorParent:
+ discriminator:
+ field_name: type
+ map:
+ child: JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorChild
+ xml_element:
+ namespace: http://example.com/
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle:
+ discriminator:
+ field_name: type
+ map:
+ car: JMS\Serializer\Tests\Fixtures\Discriminator\Car
+ moped: JMS\Serializer\Tests\Fixtures\Discriminator\Moped
+
+ properties:
+ km:
+ type: integer
\ No newline at end of file
--- /dev/null
+JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Vehicle:
+ discriminator:
+ field_name: type
+ map:
+ car: JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Car
+ groups: [foo]
+
+ properties:
+ km:
+ type: integer
--- /dev/null
+JMS\Serializer\Tests\Fixtures\ExcludePublicAccessor:
+ access_type: public_method
+ read_only: false
+ properties:
+ iShallNotBeAccessed:
+ exclude: true
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Node:
+ properties:
+ children:
+ max_depth: 2
--- /dev/null
+JMS\Serializer\Tests\Fixtures\ObjectWithAbsentXmlListNode:
+ properties:
+ absent:
+ type: array
+ xml_list:
+ skip_when_empty: true
+ present:
+ type: array
+ xml_list:
+ skip_when_empty: false
+ skipDefault:
+ type: array
+ xml_list:
+ inline: false
--- /dev/null
+JMS\Serializer\Tests\Fixtures\ObjectWithExpressionVirtualPropertiesAndExcludeAll:
+ exclusion_policy: all
+ virtual_properties:
+ virtualValue:
+ exp: object.getVirtualValue()
--- /dev/null
+JMS\Serializer\Tests\Fixtures\ObjectWithHandlerCallbacks:
+ properties:
+ name:
+ type: string
+ handler_callbacks:
+ serialization:
+ xml: toXml
+ json: toJson
--- /dev/null
+JMS\Serializer\Tests\Fixtures\ObjectWithVirtualProperties:
+ properties:
+ existField:
+ type: string
+ virtual_properties:
+ getVirtualValue: ~
+ getVirtualSerializedValue:
+ serialized_name: test
+ getTypedVirtualProperty:
+ type: integer
--- /dev/null
+JMS\Serializer\Tests\Fixtures\ObjectWithVirtualPropertiesAndExcludeAll:
+ exclusion_policy: all
+ virtual_properties:
+ getVirtualValue: ~
\ No newline at end of file
--- /dev/null
+JMS\Serializer\Tests\Fixtures\ObjectWithXmlKeyValuePairs:
+ properties:
+ array:
+ type: array
+ xml_key_value_pairs: true
--- /dev/null
+JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces:
+ xml_root_name: test-object
+ xml_root_namespace: http://example.com/namespace
+ xml_namespaces:
+ "": http://example.com/namespace
+ gd: http://schemas.google.com/g/2005
+ atom: http://www.w3.org/2005/Atom
+ properties:
+ title:
+ type: string
+ xml_element:
+ namespace: http://purl.org/dc/elements/1.1/
+ createdAt:
+ type: DateTime
+ xml_attribute: true
+ etag:
+ type: string
+ xml_attribute: true
+ xml_element:
+ namespace: http://schemas.google.com/g/2005
+ author:
+ type: string
+ xml_element:
+ namespace: http://www.w3.org/2005/Atom
+ language:
+ type: string
+ xml_attribute: true
+ xml_element:
+ namespace: http://purl.org/dc/elements/1.1/
--- /dev/null
+JMS\Serializer\Tests\Fixtures\ParentSkipWithEmptyChild:
+ properties:
+ c:
+ type: string
+ d:
+ type: string
+ child:
+ skip_when_empty: true
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Person:
+ xml_root_name: child
+ properties:
+ name:
+ type: string
+ xml_value: true
+ xml_element:
+ cdata: false
+ age:
+ type: integer
+ xml_attribute: true
--- /dev/null
+JMS\Serializer\Tests\Fixtures\PersonSecret:
+ properties:
+ name:
+ type: string
+ gender:
+ type: string
+ exclude_if: "show_data('gender')"
+ age:
+ type: string
+ expose_if: "show_data('age')"
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Price:
+ properties:
+ price:
+ type: float
+ xml_value: true
--- /dev/null
+JMS\Serializer\Tests\Fixtures\SimpleClassObject:
+ xml_namespaces:
+ foo: http://foo.example.org
+ old_foo: http://old.foo.example.org
+ new_foo: http://new.foo.example.org
+ properties:
+ foo:
+ type: string
+ xml_attribute: true
+ xml_element:
+ namespace: http://old.foo.example.org
+ bar:
+ type: string
+ xml_element:
+ namespace: http://foo.example.org
+ moo:
+ type: string
+ xml_element:
+ namespace: http://new.foo.example.org
\ No newline at end of file
--- /dev/null
+JMS\Serializer\Tests\Fixtures\SimpleSubClassObject:
+ xml_namespaces:
+ foo: http://better.foo.example.org
+ old_foo: http://foo.example.org
+ properties:
+ moo:
+ type: string
+ xml_element:
+ namespace: http://better.foo.example.org
+ baz:
+ type: string
+ xml_element:
+ namespace: http://foo.example.org
+ qux:
+ type: string
+ xml_element:
+ namespace: http://new.foo.example.org
\ No newline at end of file
--- /dev/null
+JMS\Serializer\Tests\Fixtures\BlogPost:
+ xml_root_name: blog-post
+ properties:
+ title:
+ accessor:
+ getter: getOtherTitle
+ setter: setOtherTitle
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Person:
+ custom_accessor_order: ["age", "name"]
+
+ properties:
+ age: ~
+ name: ~
--- /dev/null
+JMS\Serializer\Tests\Fixtures\BlogPost:
+ xml_root_name: blog-post
+ exclusion_policy: all
+ properties:
+ title:
+ type: string
+ expose: TRUE
--- /dev/null
+JMS\Serializer\Tests\Fixtures\BlogPost:
+ xml_root_name: blog-post
+ exclusion_policy: ALL
+ properties:
+ title:
+ type: string
+ expose: true
--- /dev/null
+JMS\Serializer\Tests\Fixtures\BlogPost:
+ xml_root_name: blog-post
+ exclusion_policy: NONE
+ properties:
+ title:
+ type: string
+ exclude: true
--- /dev/null
+JMS\Serializer\Tests\Fixtures\Person:
+ exclusion_policy: ALL
+ properties:
+ name: ~
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use JMS\Serializer\Construction\UnserializeObjectConstructor;
+use JMS\Serializer\Handler\HandlerRegistry;
+use JMS\Serializer\JsonDeserializationVisitor;
+use JMS\Serializer\JsonSerializationVisitor;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+use JMS\Serializer\Naming\CamelCaseNamingStrategy;
+use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
+use JMS\Serializer\Serializer;
+use JMS\Serializer\Tests\Fixtures\Author;
+use JMS\Serializer\Tests\Fixtures\AuthorList;
+use JMS\Serializer\Tests\Fixtures\Order;
+use JMS\Serializer\Tests\Fixtures\Price;
+use Metadata\MetadataFactory;
+use PhpCollection\Map;
+
+class ArrayTest extends \PHPUnit_Framework_TestCase
+{
+ protected $serializer;
+
+ public function setUp()
+ {
+ $namingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
+
+ $this->serializer = new Serializer(
+ new MetadataFactory(new AnnotationDriver(new AnnotationReader())),
+ new HandlerRegistry(),
+ new UnserializeObjectConstructor(),
+ new Map(array('json' => new JsonSerializationVisitor($namingStrategy))),
+ new Map(array('json' => new JsonDeserializationVisitor($namingStrategy)))
+ );
+ }
+
+ public function testToArray()
+ {
+ $order = new Order(new Price(5));
+
+ $expected = array(
+ 'cost' => array(
+ 'price' => 5
+ )
+ );
+
+ $result = $this->serializer->toArray($order);
+
+ $this->assertEquals($expected, $result);
+ }
+
+ /**
+ * @dataProvider scalarValues
+ */
+ public function testToArrayWithScalar($input)
+ {
+ $this->setExpectedException('JMS\Serializer\Exception\RuntimeException', sprintf(
+ 'The input data of type "%s" did not convert to an array, but got a result of type "%s".',
+ gettype($input),
+ gettype($input)
+ ));
+ $result = $this->serializer->toArray($input);
+
+ $this->assertEquals(array($input), $result);
+ }
+
+ public function scalarValues()
+ {
+ return array(
+ array(42),
+ array(3.14159),
+ array('helloworld'),
+ array(true),
+ );
+ }
+
+ public function testFromArray()
+ {
+ $data = array(
+ 'cost' => array(
+ 'price' => 2.5
+ )
+ );
+
+ $expected = new Order(new Price(2.5));
+ $result = $this->serializer->fromArray($data, 'JMS\Serializer\Tests\Fixtures\Order');
+
+ $this->assertEquals($expected, $result);
+ }
+
+ public function testToArrayReturnsArrayObjectAsArray()
+ {
+ $result = $this->serializer->toArray(new Author(null));
+
+ $this->assertSame(array(), $result);
+ }
+
+ public function testToArrayConversNestedArrayObjects()
+ {
+ $list = new AuthorList();
+ $list->add(new Author(null));
+
+ $result = $this->serializer->toArray($list);
+ $this->assertSame(array('authors' => array(array())), $result);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use Doctrine\Common\Collections\ArrayCollection;
+use JMS\Serializer\Accessor\DefaultAccessorStrategy;
+use JMS\Serializer\Accessor\ExpressionAccessorStrategy;
+use JMS\Serializer\Construction\UnserializeObjectConstructor;
+use JMS\Serializer\Context;
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\EventDispatcher\EventDispatcher;
+use JMS\Serializer\EventDispatcher\Subscriber\DoctrineProxySubscriber;
+use JMS\Serializer\Exclusion\DepthExclusionStrategy;
+use JMS\Serializer\Exclusion\GroupsExclusionStrategy;
+use JMS\Serializer\Expression\ExpressionEvaluator;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Handler\ArrayCollectionHandler;
+use JMS\Serializer\Handler\ConstraintViolationHandler;
+use JMS\Serializer\Handler\DateHandler;
+use JMS\Serializer\Handler\FormErrorHandler;
+use JMS\Serializer\Handler\HandlerRegistry;
+use JMS\Serializer\Handler\PhpCollectionHandler;
+use JMS\Serializer\Handler\StdClassHandler;
+use JMS\Serializer\JsonDeserializationVisitor;
+use JMS\Serializer\JsonSerializationVisitor;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+use JMS\Serializer\Naming\CamelCaseNamingStrategy;
+use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\Serializer;
+use JMS\Serializer\Tests\Fixtures\AccessorOrderChild;
+use JMS\Serializer\Tests\Fixtures\AccessorOrderMethod;
+use JMS\Serializer\Tests\Fixtures\AccessorOrderParent;
+use JMS\Serializer\Tests\Fixtures\Article;
+use JMS\Serializer\Tests\Fixtures\Author;
+use JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess;
+use JMS\Serializer\Tests\Fixtures\AuthorList;
+use JMS\Serializer\Tests\Fixtures\AuthorReadOnly;
+use JMS\Serializer\Tests\Fixtures\AuthorReadOnlyPerClass;
+use JMS\Serializer\Tests\Fixtures\BlogPost;
+use JMS\Serializer\Tests\Fixtures\CircularReferenceParent;
+use JMS\Serializer\Tests\Fixtures\Comment;
+use JMS\Serializer\Tests\Fixtures\CurrencyAwareOrder;
+use JMS\Serializer\Tests\Fixtures\CurrencyAwarePrice;
+use JMS\Serializer\Tests\Fixtures\CustomDeserializationObject;
+use JMS\Serializer\Tests\Fixtures\DateTimeArraysObject;
+use JMS\Serializer\Tests\Fixtures\Discriminator\Car;
+use JMS\Serializer\Tests\Fixtures\Discriminator\Moped;
+use JMS\Serializer\Tests\Fixtures\Garage;
+use JMS\Serializer\Tests\Fixtures\GetSetObject;
+use JMS\Serializer\Tests\Fixtures\GroupsObject;
+use JMS\Serializer\Tests\Fixtures\GroupsUser;
+use JMS\Serializer\Tests\Fixtures\IndexedCommentsBlogPost;
+use JMS\Serializer\Tests\Fixtures\InitializedBlogPostConstructor;
+use JMS\Serializer\Tests\Fixtures\InitializedObjectConstructor;
+use JMS\Serializer\Tests\Fixtures\InlineChild;
+use JMS\Serializer\Tests\Fixtures\InlineChildEmpty;
+use JMS\Serializer\Tests\Fixtures\InlineChildWithGroups;
+use JMS\Serializer\Tests\Fixtures\InlineParent;
+use JMS\Serializer\Tests\Fixtures\Input;
+use JMS\Serializer\Tests\Fixtures\InvalidGroupsObject;
+use JMS\Serializer\Tests\Fixtures\Log;
+use JMS\Serializer\Tests\Fixtures\MaxDepth\Gh236Foo;
+use JMS\Serializer\Tests\Fixtures\NamedDateTimeArraysObject;
+use JMS\Serializer\Tests\Fixtures\NamedDateTimeImmutableArraysObject;
+use JMS\Serializer\Tests\Fixtures\Node;
+use JMS\Serializer\Tests\Fixtures\ObjectWithEmptyHash;
+use JMS\Serializer\Tests\Fixtures\ObjectWithEmptyNullableAndEmptyArrays;
+use JMS\Serializer\Tests\Fixtures\ObjectWithIntListAndIntMap;
+use JMS\Serializer\Tests\Fixtures\ObjectWithLifecycleCallbacks;
+use JMS\Serializer\Tests\Fixtures\ObjectWithNullProperty;
+use JMS\Serializer\Tests\Fixtures\ObjectWithVersionedVirtualProperties;
+use JMS\Serializer\Tests\Fixtures\ObjectWithVirtualProperties;
+use JMS\Serializer\Tests\Fixtures\Order;
+use JMS\Serializer\Tests\Fixtures\ParentDoNotSkipWithEmptyChild;
+use JMS\Serializer\Tests\Fixtures\ParentSkipWithEmptyChild;
+use JMS\Serializer\Tests\Fixtures\PersonSecret;
+use JMS\Serializer\Tests\Fixtures\PersonSecretMore;
+use JMS\Serializer\Tests\Fixtures\PersonSecretMoreVirtual;
+use JMS\Serializer\Tests\Fixtures\PersonSecretVirtual;
+use JMS\Serializer\Tests\Fixtures\Price;
+use JMS\Serializer\Tests\Fixtures\Publisher;
+use JMS\Serializer\Tests\Fixtures\SimpleObject;
+use JMS\Serializer\Tests\Fixtures\SimpleObjectProxy;
+use JMS\Serializer\Tests\Fixtures\Tag;
+use JMS\Serializer\Tests\Fixtures\Timestamp;
+use JMS\Serializer\Tests\Fixtures\Tree;
+use JMS\Serializer\Tests\Fixtures\VehicleInterfaceGarage;
+use JMS\Serializer\VisitorInterface;
+use JMS\Serializer\XmlDeserializationVisitor;
+use JMS\Serializer\XmlSerializationVisitor;
+use JMS\Serializer\YamlSerializationVisitor;
+use Metadata\MetadataFactory;
+use PhpCollection\Map;
+use PhpCollection\Sequence;
+use Symfony\Component\ExpressionLanguage\ExpressionFunction;
+use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
+use Symfony\Component\Form\Form;
+use Symfony\Component\Form\FormError;
+use Symfony\Component\Form\FormFactoryBuilder;
+use Symfony\Component\Translation\IdentityTranslator;
+use Symfony\Component\Translation\MessageSelector;
+use Symfony\Component\Validator\ConstraintViolation;
+use Symfony\Component\Validator\ConstraintViolationList;
+
+abstract class BaseSerializationTest extends \PHPUnit_Framework_TestCase
+{
+ protected $factory;
+
+ /**
+ * @var EventDispatcher
+ */
+ protected $dispatcher;
+
+ /** @var Serializer */
+ protected $serializer;
+ protected $handlerRegistry;
+ protected $serializationVisitors;
+ protected $deserializationVisitors;
+ protected $objectConstructor;
+
+ public function testSerializeNullArray()
+ {
+ $arr = array('foo' => 'bar', 'baz' => null, null);
+
+ $this->assertEquals(
+ $this->getContent('nullable'),
+ $this->serializer->serialize($arr, $this->getFormat(), SerializationContext::create()->setSerializeNull(true))
+ );
+ }
+
+ public function testSerializeNullArrayExcludingNulls()
+ {
+ $arr = array('foo' => 'bar', 'baz' => null, null);
+
+ $this->assertEquals(
+ $this->getContent('nullable_skip'),
+ $this->serializer->serialize($arr, $this->getFormat(), SerializationContext::create()->setSerializeNull(false))
+ );
+ }
+
+ public function testSerializeNullObject()
+ {
+ $obj = new ObjectWithNullProperty('foo', 'bar');
+
+ $this->assertEquals(
+ $this->getContent('simple_object_nullable'),
+ $this->serializer->serialize($obj, $this->getFormat(), SerializationContext::create()->setSerializeNull(true))
+ );
+ }
+
+ public function testDeserializeNullObject()
+ {
+ if (!$this->hasDeserializer()) {
+ $this->markTestSkipped(sprintf('No deserializer available for format `%s`', $this->getFormat()));
+ }
+
+ $obj = new ObjectWithNullProperty('foo', 'bar');
+
+ /** @var ObjectWithNullProperty $dObj */
+ $dObj = $this->serializer->deserialize(
+ $this->getContent('simple_object_nullable'),
+ ObjectWithNullProperty::class,
+ $this->getFormat()
+ );
+
+ $this->assertEquals($obj, $dObj);
+ $this->assertNull($dObj->getNullProperty());
+ }
+
+ /**
+ * @dataProvider getTypes
+ */
+ public function testNull($type)
+ {
+ $this->assertEquals($this->getContent('null'), $this->serialize(null), $type);
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals(null, $this->deserialize($this->getContent('null'), $type));
+ }
+ }
+
+ public function getTypes()
+ {
+ return array(
+ array('NULL'),
+ array('integer'),
+ array('double'),
+ array('float'),
+ array('string'),
+ array('DateTime'),
+ );
+ }
+
+ public function testString()
+ {
+ $this->assertEquals($this->getContent('string'), $this->serialize('foo'));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals('foo', $this->deserialize($this->getContent('string'), 'string'));
+ }
+ }
+
+ /**
+ * @expectedException \JMS\Serializer\Exception\ExpressionLanguageRequiredException
+ * @expectedExceptionMessage To use conditional exclude/expose in JMS\Serializer\Tests\Fixtures\PersonSecret you must configure the expression language.
+ */
+ public function testExpressionExclusionNotConfigured()
+ {
+ $person = new PersonSecret();
+ $person->gender = 'f';
+ $person->name = 'mike';
+ $this->serialize($person);
+ }
+
+
+ public function testExpressionExclusionConfiguredWithDisjunctStrategy()
+ {
+ $person = new PersonSecret();
+ $person->gender = 'f';
+ $person->name = 'mike';
+
+ $language = new ExpressionLanguage();
+ $language->addFunction(new ExpressionFunction('show_data', function () {
+ return "true";
+ }, function () {
+ return true;
+ }));
+
+ $serializer = new Serializer($this->factory, $this->handlerRegistry, $this->objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher, null, new ExpressionEvaluator($language));
+
+ $this->assertEquals($this->getContent('person_secret_hide'), $serializer->serialize($person, $this->getFormat()));
+ }
+
+ public function expressionFunctionProvider()
+ {
+ $person = new PersonSecret();
+ $person->gender = 'f';
+ $person->name = 'mike';
+
+ $personMoreSecret = new PersonSecretMore();
+ $personMoreSecret->gender = 'f';
+ $personMoreSecret->name = 'mike';
+
+ $personVirtual = new PersonSecretVirtual();
+ $personVirtual->gender = 'f';
+ $personVirtual->name = 'mike';
+
+ $personMoreSecretVirtual = new PersonSecretMoreVirtual();
+ $personMoreSecretVirtual->gender = 'f';
+ $personMoreSecretVirtual->name = 'mike';
+
+ $showGender = new ExpressionFunction('show_data', function () {
+ return "true";
+ }, function () {
+ return true;
+ });
+
+ $hideGender = new ExpressionFunction('show_data', function () {
+ return "false";
+ }, function () {
+ return false;
+ });
+
+ return [
+ [
+ $person,
+ $showGender,
+ 'person_secret_hide'
+ ],
+ [
+ $person,
+ $hideGender,
+ 'person_secret_show'
+ ],
+ [
+ $personMoreSecret,
+ $showGender,
+ 'person_secret_show'
+ ],
+ [
+ $personMoreSecret,
+ $hideGender,
+ 'person_secret_hide'
+ ],
+ [
+ $personVirtual,
+ $showGender,
+ 'person_secret_hide'
+ ],
+ [
+ $personVirtual,
+ $hideGender,
+ 'person_secret_show'
+ ],
+ [
+ $personMoreSecretVirtual,
+ $showGender,
+ 'person_secret_show'
+ ],
+ [
+ $personMoreSecretVirtual,
+ $hideGender,
+ 'person_secret_hide'
+ ]
+ ];
+ }
+
+ /**
+ * @dataProvider expressionFunctionProvider
+ * @param PersonSecret|PersonSecretMore $person
+ * @param ExpressionFunction $function
+ * @param $json
+ */
+ public function testExpressionExclusion($person, ExpressionFunction $function, $json)
+ {
+ $language = new ExpressionLanguage();
+ $language->addFunction($function);
+
+ $serializer = new Serializer($this->factory, $this->handlerRegistry, $this->objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher, null, new ExpressionEvaluator($language));
+ $this->assertEquals($this->getContent($json), $serializer->serialize($person, $this->getFormat()));
+ }
+
+ /**
+ * @dataProvider getBooleans
+ */
+ public function testBooleans($strBoolean, $boolean)
+ {
+ $this->assertEquals($this->getContent('boolean_' . $strBoolean), $this->serialize($boolean));
+
+ if ($this->hasDeserializer()) {
+ $this->assertSame($boolean, $this->deserialize($this->getContent('boolean_' . $strBoolean), 'boolean'));
+ }
+ }
+
+ public function getBooleans()
+ {
+ return array(array('true', true), array('false', false));
+ }
+
+ /**
+ * @dataProvider getNumerics
+ */
+ public function testNumerics($key, $value, $type)
+ {
+ $this->assertEquals($this->getContent($key), $this->serialize($value));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($value, $this->deserialize($this->getContent($key), $type));
+ }
+ }
+
+ public function getNumerics()
+ {
+ return array(
+ array('integer', 1, 'integer'),
+ array('float', 4.533, 'double'),
+ array('float', 4.533, 'float'),
+ array('float_trailing_zero', 1.0, 'double'),
+ array('float_trailing_zero', 1.0, 'float'),
+ );
+ }
+
+ public function testSimpleObject()
+ {
+ $this->assertEquals($this->getContent('simple_object'), $this->serialize($obj = new SimpleObject('foo', 'bar')));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($obj, $this->deserialize($this->getContent('simple_object'), get_class($obj)));
+ }
+ }
+
+ public function testArrayStrings()
+ {
+ $data = array('foo', 'bar');
+ $this->assertEquals($this->getContent('array_strings'), $this->serialize($data));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($data, $this->deserialize($this->getContent('array_strings'), 'array<string>'));
+ }
+ }
+
+ public function testArrayBooleans()
+ {
+ $data = array(true, false);
+ $this->assertEquals($this->getContent('array_booleans'), $this->serialize($data));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($data, $this->deserialize($this->getContent('array_booleans'), 'array<boolean>'));
+ }
+ }
+
+ public function testArrayIntegers()
+ {
+ $data = array(1, 3, 4);
+ $this->assertEquals($this->getContent('array_integers'), $this->serialize($data));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($data, $this->deserialize($this->getContent('array_integers'), 'array<integer>'));
+ }
+ }
+
+ public function testArrayEmpty()
+ {
+ if ('xml' === $this->getFormat()) {
+ $this->markTestSkipped('XML can\'t be tested for empty array');
+ }
+
+ $data = array('array' => []);
+ $this->assertEquals($this->getContent('array_empty'), $this->serialize($data));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($data, $this->deserialize($this->getContent('array_empty'), 'array'));
+ }
+ }
+
+ public function testArrayFloats()
+ {
+ $data = array(1.34, 3.0, 6.42);
+ $this->assertEquals($this->getContent('array_floats'), $this->serialize($data));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($data, $this->deserialize($this->getContent('array_floats'), 'array<double>'));
+ }
+ }
+
+ public function testArrayObjects()
+ {
+ $data = array(new SimpleObject('foo', 'bar'), new SimpleObject('baz', 'boo'));
+ $this->assertEquals($this->getContent('array_objects'), $this->serialize($data));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($data, $this->deserialize($this->getContent('array_objects'), 'array<JMS\Serializer\Tests\Fixtures\SimpleObject>'));
+ }
+ }
+
+ public function testArrayListAndMapDifference()
+ {
+ $arrayData = array(0 => 1, 2 => 2, 3 => 3); // Misses key 1
+ $data = new ObjectWithIntListAndIntMap($arrayData, $arrayData);
+
+ $this->assertEquals($this->getContent('array_list_and_map_difference'), $this->serialize($data));
+ }
+
+ public function testDateTimeArrays()
+ {
+ $data = array(
+ new \DateTime('2047-01-01 12:47:47', new \DateTimeZone('UTC')),
+ new \DateTime('2016-12-05 00:00:00', new \DateTimeZone('UTC'))
+ );
+
+ $object = new DateTimeArraysObject($data, $data);
+ $serializedObject = $this->serialize($object);
+
+ $this->assertEquals($this->getContent('array_datetimes_object'), $serializedObject);
+
+ if ($this->hasDeserializer()) {
+ /** @var DateTimeArraysObject $deserializedObject */
+ $deserializedObject = $this->deserialize($this->getContent('array_datetimes_object'), 'Jms\Serializer\Tests\Fixtures\DateTimeArraysObject');
+
+ /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */
+ foreach ($deserializedObject->getArrayWithDefaultDateTime() as $dateTime) {
+ $dateTime->setTimezone(new \DateTimeZone('UTC'));
+ }
+
+ foreach ($deserializedObject->getArrayWithFormattedDateTime() as $dateTime) {
+ $dateTime->setTimezone(new \DateTimeZone('UTC'));
+ }
+
+ $this->assertEquals($object, $deserializedObject);
+ }
+ }
+
+ public function testNamedDateTimeArrays()
+ {
+ $data = array(
+ new \DateTime('2047-01-01 12:47:47', new \DateTimeZone('UTC')),
+ new \DateTime('2016-12-05 00:00:00', new \DateTimeZone('UTC'))
+ );
+
+ $object = new NamedDateTimeArraysObject(array('testdate1' => $data[0], 'testdate2' => $data[1]));
+ $serializedObject = $this->serialize($object);
+
+ $this->assertEquals($this->getContent('array_named_datetimes_object'), $serializedObject);
+
+ if ($this->hasDeserializer()) {
+
+ // skip XML deserialization
+ if ($this->getFormat() === 'xml') {
+ return;
+ }
+
+ /** @var NamedDateTimeArraysObject $deserializedObject */
+ $deserializedObject = $this->deserialize($this->getContent('array_named_datetimes_object'), 'Jms\Serializer\Tests\Fixtures\NamedDateTimeArraysObject');
+
+ /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */
+ foreach ($deserializedObject->getNamedArrayWithFormattedDate() as $dateTime) {
+ $dateTime->setTimezone(new \DateTimeZone('UTC'));
+ }
+
+ $this->assertEquals($object, $deserializedObject);
+ }
+ }
+
+ /**
+ * @group datetime
+ */
+ public function testNamedDateTimeImmutableArrays()
+ {
+ $data = array(
+ new \DateTimeImmutable('2047-01-01 12:47:47', new \DateTimeZone('UTC')),
+ new \DateTimeImmutable('2016-12-05 00:00:00', new \DateTimeZone('UTC'))
+ );
+
+ $object = new NamedDateTimeImmutableArraysObject(array('testdate1' => $data[0], 'testdate2' => $data[1]));
+ $serializedObject = $this->serialize($object);
+
+ $this->assertEquals($this->getContent('array_named_datetimeimmutables_object'), $serializedObject);
+
+ if ($this->hasDeserializer()) {
+
+ if ('xml' == $this->getFormat()) {
+ $this->markTestSkipped("XML deserialization does not support key-val pairs mode");
+ }
+ /** @var NamedDateTimeArraysObject $deserializedObject */
+ $deserializedObject = $this->deserialize($this->getContent('array_named_datetimeimmutables_object'), 'Jms\Serializer\Tests\Fixtures\NamedDateTimeImmutableArraysObject');
+
+ /** deserialized object has a default timezone set depending on user's timezone settings. That's why we manually set the UTC timezone on the DateTime objects. */
+ foreach ($deserializedObject->getNamedArrayWithFormattedDate() as $dateTime) {
+ $dateTime->setTimezone(new \DateTimeZone('UTC'));
+ }
+
+ $this->assertEquals($object, $deserializedObject);
+ }
+ }
+
+
+ public function testArrayMixed()
+ {
+ $this->assertEquals($this->getContent('array_mixed'), $this->serialize(array('foo', 1, true, new SimpleObject('foo', 'bar'), array(1, 3, true))));
+ }
+
+ /**
+ * @dataProvider getDateTime
+ * @group datetime
+ */
+ public function testDateTime($key, $value, $type)
+ {
+ $this->assertEquals($this->getContent($key), $this->serialize($value));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent($key), $type);
+
+ $this->assertTrue(is_object($deserialized));
+ $this->assertEquals(get_class($value), get_class($deserialized));
+ $this->assertEquals($value->getTimestamp(), $deserialized->getTimestamp());
+ }
+ }
+
+ public function getDateTime()
+ {
+ return array(
+ array('date_time', new \DateTime('2011-08-30 00:00', new \DateTimeZone('UTC')), 'DateTime'),
+ );
+ }
+
+ /**
+ * @dataProvider getDateTimeImmutable
+ * @group datetime
+ */
+ public function testDateTimeImmutable($key, $value, $type)
+ {
+ $this->assertEquals($this->getContent($key), $this->serialize($value));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent($key), $type);
+
+ $this->assertTrue(is_object($deserialized));
+ $this->assertEquals(get_class($value), get_class($deserialized));
+ $this->assertEquals($value->getTimestamp(), $deserialized->getTimestamp());
+ }
+ }
+
+ public function getDateTimeImmutable()
+ {
+ return array(
+ array('date_time_immutable', new \DateTimeImmutable('2011-08-30 00:00', new \DateTimeZone('UTC')), 'DateTimeImmutable'),
+ );
+ }
+
+ public function testTimestamp()
+ {
+ $value = new Timestamp(new \DateTime('2016-02-11 00:00:00', new \DateTimeZone('UTC')));
+ $this->assertEquals($this->getContent('timestamp'), $this->serialize($value));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('timestamp'), Timestamp::class);
+ $this->assertEquals($value, $deserialized);
+ $this->assertEquals($value->getTimestamp()->getTimestamp(), $deserialized->getTimestamp()->getTimestamp());
+
+ $deserialized = $this->deserialize($this->getContent('timestamp_prev'), Timestamp::class);
+ $this->assertEquals($value, $deserialized);
+ $this->assertEquals($value->getTimestamp()->getTimestamp(), $deserialized->getTimestamp()->getTimestamp());
+ }
+ }
+
+ public function testDateInterval()
+ {
+ $duration = new \DateInterval('PT45M');
+
+ $this->assertEquals($this->getContent('date_interval'), $this->serializer->serialize($duration, $this->getFormat()));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('date_interval'), \DateInterval::class);
+ $this->assertEquals($duration, $deserialized);
+ $this->assertEquals($duration->i, $deserialized->i);
+ }
+ }
+
+ public function testBlogPost()
+ {
+ $post = new BlogPost('This is a nice title.', $author = new Author('Foo Bar'), new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), new Publisher('Bar Foo'));
+ $post->addComment($comment = new Comment($author, 'foo'));
+
+ $post->addTag($tag1 = New Tag("tag1"));
+ $post->addTag($tag2 = New Tag("tag2"));
+
+ $this->assertEquals($this->getContent('blog_post'), $this->serialize($post));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('blog_post'), get_class($post));
+ $this->assertEquals('2011-07-30T00:00:00+0000', $this->getField($deserialized, 'createdAt')->format(\DateTime::ISO8601));
+ $this->assertAttributeEquals('This is a nice title.', 'title', $deserialized);
+ $this->assertAttributeSame(false, 'published', $deserialized);
+ $this->assertAttributeSame(false, 'reviewed', $deserialized);
+ $this->assertAttributeSame('1edf9bf60a32d89afbb85b2be849e3ceed5f5b10', 'etag', $deserialized);
+ $this->assertAttributeEquals(new ArrayCollection(array($comment)), 'comments', $deserialized);
+ $this->assertAttributeEquals(new Sequence(array($comment)), 'comments2', $deserialized);
+ $this->assertAttributeEquals($author, 'author', $deserialized);
+ $this->assertAttributeEquals(array($tag1, $tag2), 'tag', $deserialized);
+ }
+ }
+
+ public function testDeserializingNull()
+ {
+ $objectConstructor = new InitializedBlogPostConstructor();
+ $this->serializer = new Serializer($this->factory, $this->handlerRegistry, $objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher);
+
+ $post = new BlogPost('This is a nice title.', $author = new Author('Foo Bar'), new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), new Publisher('Bar Foo'));
+
+ $this->setField($post, 'author', null);
+ $this->setField($post, 'publisher', null);
+
+ $this->assertEquals($this->getContent('blog_post_unauthored'), $this->serialize($post, SerializationContext::create()->setSerializeNull(true)));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('blog_post_unauthored'), get_class($post), DeserializationContext::create()->setSerializeNull(true));
+
+ $this->assertEquals('2011-07-30T00:00:00+0000', $this->getField($deserialized, 'createdAt')->format(\DateTime::ISO8601));
+ $this->assertAttributeEquals('This is a nice title.', 'title', $deserialized);
+ $this->assertAttributeSame(false, 'published', $deserialized);
+ $this->assertAttributeSame(false, 'reviewed', $deserialized);
+ $this->assertAttributeEquals(new ArrayCollection(), 'comments', $deserialized);
+ $this->assertEquals(null, $this->getField($deserialized, 'author'));
+ }
+ }
+
+ public function testExpressionAuthor()
+ {
+ $namingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
+
+ $evaluator = new ExpressionEvaluator(new ExpressionLanguage());
+ $accessor = new ExpressionAccessorStrategy($evaluator, new DefaultAccessorStrategy());
+
+ $this->serializationVisitors = new Map(array(
+ 'json' => new JsonSerializationVisitor($namingStrategy, $accessor),
+ 'xml' => new XmlSerializationVisitor($namingStrategy, $accessor),
+ 'yml' => new YamlSerializationVisitor($namingStrategy, $accessor),
+ ));
+
+ $serializer = new Serializer($this->factory, $this->handlerRegistry, $this->objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher, null, $evaluator);
+
+ $author = new AuthorExpressionAccess(123, "Ruud", "Kamphuis");
+ $this->assertEquals($this->getContent('author_expression'), $serializer->serialize($author, $this->getFormat()));
+ }
+
+ /**
+ * @expectedException \JMS\Serializer\Exception\ExpressionLanguageRequiredException
+ * @expectedExceptionMessage The property firstName on JMS\Serializer\Tests\Fixtures\AuthorExpressionAccess requires the expression accessor strategy to be enabled.
+ */
+ public function testExpressionAccessorStrategNotEnabled()
+ {
+ $author = new AuthorExpressionAccess(123, "Ruud", "Kamphuis");
+ $this->assertEquals($this->getContent('author_expression'), $this->serialize($author));
+ }
+
+ public function testReadOnly()
+ {
+ $author = new AuthorReadOnly(123, 'Ruud Kamphuis');
+ $this->assertEquals($this->getContent('readonly'), $this->serialize($author));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('readonly'), get_class($author));
+ $this->assertNull($this->getField($deserialized, 'id'));
+ $this->assertEquals('Ruud Kamphuis', $this->getField($deserialized, 'name'));
+ }
+ }
+
+ public function testReadOnlyClass()
+ {
+ $author = new AuthorReadOnlyPerClass(123, 'Ruud Kamphuis');
+ $this->assertEquals($this->getContent('readonly'), $this->serialize($author));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('readonly'), get_class($author));
+ $this->assertNull($this->getField($deserialized, 'id'));
+ $this->assertEquals('Ruud Kamphuis', $this->getField($deserialized, 'name'));
+ }
+ }
+
+ public function testPrice()
+ {
+ $price = new Price(3);
+ $this->assertEquals($this->getContent('price'), $this->serialize($price));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('price'), get_class($price));
+ $this->assertEquals(3, $this->getField($deserialized, 'price'));
+ }
+ }
+
+ public function testOrder()
+ {
+ $order = new Order(new Price(12.34));
+ $this->assertEquals($this->getContent('order'), $this->serialize($order));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($order, $this->deserialize($this->getContent('order'), get_class($order)));
+ }
+ }
+
+ public function testCurrencyAwarePrice()
+ {
+ $price = new CurrencyAwarePrice(2.34);
+ $this->assertEquals($this->getContent('currency_aware_price'), $this->serialize($price));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($price, $this->deserialize($this->getContent('currency_aware_price'), get_class($price)));
+ }
+ }
+
+ public function testOrderWithCurrencyAwarePrice()
+ {
+ $order = new CurrencyAwareOrder(new CurrencyAwarePrice(1.23));
+ $this->assertEquals($this->getContent('order_with_currency_aware_price'), $this->serialize($order));
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($order, $this->deserialize($this->getContent('order_with_currency_aware_price'), get_class($order)));
+ }
+ }
+
+ /**
+ * @group handlerCallback
+ */
+ public function testArticle()
+ {
+ $article = new Article();
+ $article->element = 'custom';
+ $article->value = 'serialized';
+
+ $result = $this->serialize($article);
+ $this->assertEquals($this->getContent('article'), $result);
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals($article, $this->deserialize($result, 'JMS\Serializer\Tests\Fixtures\Article'));
+ }
+ }
+
+ public function testInline()
+ {
+ $inline = new InlineParent();
+
+ $result = $this->serialize($inline);
+ $this->assertEquals($this->getContent('inline'), $result);
+
+ // no deserialization support
+ }
+
+ public function testInlineEmptyChild()
+ {
+ $inline = new InlineParent(new InlineChildEmpty());
+
+ $result = $this->serialize($inline);
+ $this->assertEquals($this->getContent('inline_child_empty'), $result);
+
+ // no deserialization support
+ }
+
+ public function testEmptyChild()
+ {
+ // by empty object
+ $inline = new ParentDoNotSkipWithEmptyChild(new InlineChildEmpty());
+ $this->assertEquals($this->getContent('empty_child'), $this->serialize($inline));
+
+ // by nulls
+ $inner = new InlineChild();
+ $inner->a = null;
+ $inner->b = null;
+ $inline = new ParentDoNotSkipWithEmptyChild($inner);
+ $this->assertEquals($this->getContent('empty_child'), $this->serialize($inline));
+
+ // by exclusion strategy
+ $context = SerializationContext::create()->setGroups(['Default']);
+ $inline = new ParentDoNotSkipWithEmptyChild(new InlineChildWithGroups());
+ $this->assertEquals($this->getContent('empty_child'), $this->serialize($inline, $context));
+ }
+
+ public function testSkipEmptyChild()
+ {
+ // by empty object
+ $inline = new ParentSkipWithEmptyChild(new InlineChildEmpty());
+ $this->assertEquals($this->getContent('empty_child_skip'), $this->serialize($inline));
+
+ // by nulls
+ $inner = new InlineChild();
+ $inner->a = null;
+ $inner->b = null;
+ $inline = new ParentSkipWithEmptyChild($inner);
+ $this->assertEquals($this->getContent('empty_child_skip'), $this->serialize($inline));
+
+ // by exclusion strategy
+ $context = SerializationContext::create()->setGroups(['Default']);
+ $inline = new ParentSkipWithEmptyChild(new InlineChildWithGroups());
+ $this->assertEquals($this->getContent('empty_child_skip'), $this->serialize($inline, $context));
+ }
+
+ /**
+ * @group log
+ */
+ public function testLog()
+ {
+ $this->assertEquals($this->getContent('log'), $this->serialize($log = new Log()));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('log'), get_class($log));
+ $this->assertEquals($log, $deserialized);
+ }
+ }
+
+ public function testCircularReference()
+ {
+ $object = new CircularReferenceParent();
+ $this->assertEquals($this->getContent('circular_reference'), $this->serialize($object));
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('circular_reference'), get_class($object));
+
+ $col = $this->getField($deserialized, 'collection');
+ $this->assertEquals(2, count($col));
+ $this->assertEquals('child1', $col[0]->getName());
+ $this->assertEquals('child2', $col[1]->getName());
+ $this->assertSame($deserialized, $col[0]->getParent());
+ $this->assertSame($deserialized, $col[1]->getParent());
+
+ $col = $this->getField($deserialized, 'anotherCollection');
+ $this->assertEquals(2, count($col));
+ $this->assertEquals('child1', $col[0]->getName());
+ $this->assertEquals('child2', $col[1]->getName());
+ $this->assertSame($deserialized, $col[0]->getParent());
+ $this->assertSame($deserialized, $col[1]->getParent());
+ }
+ }
+
+ public function testLifecycleCallbacks()
+ {
+ $object = new ObjectWithLifecycleCallbacks();
+ $this->assertEquals($this->getContent('lifecycle_callbacks'), $this->serialize($object));
+ $this->assertAttributeSame(null, 'name', $object);
+
+ if ($this->hasDeserializer()) {
+ $deserialized = $this->deserialize($this->getContent('lifecycle_callbacks'), get_class($object));
+ $this->assertEquals($object, $deserialized);
+ }
+ }
+
+ public function testFormErrors()
+ {
+ $errors = array(
+ new FormError('This is the form error'),
+ new FormError('Another error')
+ );
+
+ $this->assertEquals($this->getContent('form_errors'), $this->serialize($errors));
+ }
+
+ public function testNestedFormErrors()
+ {
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+
+ $formConfigBuilder = new \Symfony\Component\Form\FormConfigBuilder('foo', null, $dispatcher);
+ $formConfigBuilder->setCompound(true);
+ $formConfigBuilder->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock());
+ $fooConfig = $formConfigBuilder->getFormConfig();
+
+ $form = new Form($fooConfig);
+ $form->addError(new FormError('This is the form error'));
+
+ $formConfigBuilder = new \Symfony\Component\Form\FormConfigBuilder('bar', null, $dispatcher);
+ $barConfig = $formConfigBuilder->getFormConfig();
+ $child = new Form($barConfig);
+ $child->addError(new FormError('Error of the child form'));
+ $form->add($child);
+
+ $this->assertEquals($this->getContent('nested_form_errors'), $this->serialize($form));
+ }
+
+ public function testFormErrorsWithNonFormComponents()
+ {
+ if (!class_exists('Symfony\Component\Form\Extension\Core\Type\SubmitType')) {
+ $this->markTestSkipped('Not using Symfony Form >= 2.3 with submit type');
+ }
+
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
+
+ $factoryBuilder = new FormFactoryBuilder();
+ $factoryBuilder->addType(new \Symfony\Component\Form\Extension\Core\Type\SubmitType);
+ $factoryBuilder->addType(new \Symfony\Component\Form\Extension\Core\Type\ButtonType);
+ $factory = $factoryBuilder->getFormFactory();
+
+ $formConfigBuilder = new \Symfony\Component\Form\FormConfigBuilder('foo', null, $dispatcher);
+ $formConfigBuilder->setFormFactory($factory);
+ $formConfigBuilder->setCompound(true);
+ $formConfigBuilder->setDataMapper($this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock());
+ $fooConfig = $formConfigBuilder->getFormConfig();
+
+ $form = new Form($fooConfig);
+ $form->add('save', \Symfony\Component\Form\Extension\Core\Type\SubmitType::class);
+
+ try {
+ $this->serialize($form);
+ } catch (\Exception $e) {
+ $this->assertTrue(false, 'Serialization should not throw an exception');
+ }
+ }
+
+ public function testConstraintViolation()
+ {
+ $violation = new ConstraintViolation('Message of violation', 'Message of violation', array(), null, 'foo', null);
+
+ $this->assertEquals($this->getContent('constraint_violation'), $this->serialize($violation));
+ }
+
+ public function testConstraintViolationList()
+ {
+ $violations = new ConstraintViolationList();
+ $violations->add(new ConstraintViolation('Message of violation', 'Message of violation', array(), null, 'foo', null));
+ $violations->add(new ConstraintViolation('Message of another violation', 'Message of another violation', array(), null, 'bar', null));
+
+ $this->assertEquals($this->getContent('constraint_violation_list'), $this->serialize($violations));
+ }
+
+ public function testDoctrineProxy()
+ {
+ if (!class_exists('Doctrine\ORM\Version')) {
+ $this->markTestSkipped('Doctrine is not available.');
+ }
+
+ $object = new SimpleObjectProxy('foo', 'bar');
+
+ $this->assertEquals($this->getContent('orm_proxy'), $this->serialize($object));
+ }
+
+ public function testInitializedDoctrineProxy()
+ {
+ if (!class_exists('Doctrine\ORM\Version')) {
+ $this->markTestSkipped('Doctrine is not available.');
+ }
+
+ $object = new SimpleObjectProxy('foo', 'bar');
+ $object->__load();
+
+ $this->assertEquals($this->getContent('orm_proxy'), $this->serialize($object));
+ }
+
+ public function testCustomAccessor()
+ {
+ $post = new IndexedCommentsBlogPost();
+
+ $this->assertEquals($this->getContent('custom_accessor'), $this->serialize($post));
+ }
+
+ public function testMixedAccessTypes()
+ {
+ $object = new GetSetObject();
+
+ $this->assertEquals($this->getContent('mixed_access_types'), $this->serialize($object));
+
+ if ($this->hasDeserializer()) {
+ $object = $this->deserialize($this->getContent('mixed_access_types'), 'JMS\Serializer\Tests\Fixtures\GetSetObject');
+ $this->assertAttributeEquals(1, 'id', $object);
+ $this->assertAttributeEquals('Johannes', 'name', $object);
+ $this->assertAttributeEquals(42, 'readOnlyProperty', $object);
+ }
+ }
+
+ public function testAccessorOrder()
+ {
+ $this->assertEquals($this->getContent('accessor_order_child'), $this->serialize(new AccessorOrderChild()));
+ $this->assertEquals($this->getContent('accessor_order_parent'), $this->serialize(new AccessorOrderParent()));
+ $this->assertEquals($this->getContent('accessor_order_methods'), $this->serialize(new AccessorOrderMethod()));
+ }
+
+ public function testGroups()
+ {
+ $groupsObject = new GroupsObject();
+
+ $this->assertEquals($this->getContent('groups_all'), $this->serializer->serialize($groupsObject, $this->getFormat()));
+
+ $this->assertEquals(
+ $this->getContent('groups_foo'),
+ $this->serializer->serialize($groupsObject, $this->getFormat(), SerializationContext::create()->setGroups(array('foo')))
+ );
+
+ $this->assertEquals(
+ $this->getContent('groups_foobar'),
+ $this->serializer->serialize($groupsObject, $this->getFormat(), SerializationContext::create()->setGroups(array('foo', 'bar')))
+ );
+
+ $this->assertEquals(
+ $this->getContent('groups_all'),
+ $this->serializer->serialize($groupsObject, $this->getFormat())
+ );
+
+ $this->assertEquals(
+ $this->getContent('groups_default'),
+ $this->serializer->serialize($groupsObject, $this->getFormat(), SerializationContext::create()->setGroups(array(GroupsExclusionStrategy::DEFAULT_GROUP)))
+ );
+
+ $this->assertEquals(
+ $this->getContent('groups_default'),
+ $this->serializer->serialize($groupsObject, $this->getFormat(), SerializationContext::create()->setGroups(array(GroupsExclusionStrategy::DEFAULT_GROUP)))
+ );
+ }
+
+ public function testAdvancedGroups()
+ {
+ $adrien = new GroupsUser(
+ 'John',
+ new GroupsUser(
+ 'John Manager',
+ null,
+ array(
+ new GroupsUser(
+ 'John Manager friend 1',
+ new GroupsUser('John Manager friend 1 manager')
+ ),
+ new GroupsUser('John Manager friend 2'),
+ )
+ ),
+ array(
+ new GroupsUser(
+ 'John friend 1',
+ new GroupsUser('John friend 1 manager')
+ ),
+ new GroupsUser(
+ 'John friend 2',
+ new GroupsUser('John friend 2 manager')
+ )
+ )
+ );
+
+ $this->assertEquals(
+ $this->getContent('groups_advanced'),
+ $this->serializer->serialize(
+ $adrien,
+ $this->getFormat(),
+ SerializationContext::create()->setGroups(array(
+ GroupsExclusionStrategy::DEFAULT_GROUP,
+ 'manager_group',
+ 'friends_group',
+
+ 'manager' => array(
+ GroupsExclusionStrategy::DEFAULT_GROUP,
+ 'friends_group',
+
+ 'friends' => array('nickname_group'),
+ ),
+ 'friends' => array(
+ 'manager_group'
+ )
+ ))
+ )
+ );
+ }
+
+ /**
+ * @expectedException JMS\Serializer\Exception\InvalidArgumentException
+ * @expectedExceptionMessage Invalid group name "foo, bar" on "JMS\Serializer\Tests\Fixtures\InvalidGroupsObject->foo", did you mean to create multiple groups?
+ */
+ public function testInvalidGroupName()
+ {
+ $groupsObject = new InvalidGroupsObject();
+
+ $this->serializer->serialize($groupsObject, $this->getFormat());
+ }
+
+ public function testVirtualProperty()
+ {
+ $this->assertEquals($this->getContent('virtual_properties'), $this->serialize(new ObjectWithVirtualProperties()));
+ }
+
+ public function testVirtualVersions()
+ {
+ $this->assertEquals(
+ $this->getContent('virtual_properties_low'),
+ $this->serialize(new ObjectWithVersionedVirtualProperties(), SerializationContext::create()->setVersion(2))
+ );
+
+ $this->assertEquals(
+ $this->getContent('virtual_properties_all'),
+ $this->serialize(new ObjectWithVersionedVirtualProperties(), SerializationContext::create()->setVersion(7))
+ );
+
+ $this->assertEquals(
+ $this->getContent('virtual_properties_high'),
+ $this->serialize(new ObjectWithVersionedVirtualProperties(), SerializationContext::create()->setVersion(9))
+ );
+ }
+
+ public function testCustomHandler()
+ {
+ if (!$this->hasDeserializer()) {
+ return;
+ }
+
+ $handler = function () {
+ return new CustomDeserializationObject('customly_unserialized_value');
+ };
+
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_DESERIALIZATION, 'CustomDeserializationObject', $this->getFormat(), $handler);
+
+ $serialized = $this->serializer->serialize(new CustomDeserializationObject('sometext'), $this->getFormat());
+ $object = $this->serializer->deserialize($serialized, 'CustomDeserializationObject', $this->getFormat());
+ $this->assertEquals('customly_unserialized_value', $object->someProperty);
+ }
+
+ public function testInput()
+ {
+ $this->assertEquals($this->getContent('input'), $this->serializer->serialize(new Input(), $this->getFormat()));
+ }
+
+ public function testObjectWithEmptyHash()
+ {
+ $this->assertEquals($this->getContent('hash_empty'), $this->serializer->serialize(new ObjectWithEmptyHash(), $this->getFormat()));
+ }
+
+ /**
+ * @group null
+ */
+ public function testSerializeObjectWhenNull()
+ {
+ $this->assertEquals(
+ $this->getContent('object_when_null'),
+ $this->serialize(new Comment(null, 'foo'), SerializationContext::create()->setSerializeNull(false))
+ );
+
+ $this->assertEquals(
+ $this->getContent('object_when_null_and_serialized'),
+ $this->serialize(new Comment(null, 'foo'), SerializationContext::create()->setSerializeNull(true))
+ );
+ }
+
+ /**
+ * @group polymorphic
+ */
+ public function testPolymorphicObjectsWithGroup()
+ {
+ $context = SerializationContext::create();
+ $context->setGroups(array("foo"));
+
+ $this->assertEquals(
+ $this->getContent('car'),
+ $this->serialize(new \JMS\Serializer\Tests\Fixtures\DiscriminatorGroup\Car(5), $context)
+ );
+ }
+
+ /**
+ * @group polymorphic
+ */
+ public function testPolymorphicObjects()
+ {
+ $this->assertEquals(
+ $this->getContent('car'),
+ $this->serialize(new Car(5))
+ );
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals(
+ new Car(5),
+ $this->deserialize(
+ $this->getContent('car'),
+ 'JMS\Serializer\Tests\Fixtures\Discriminator\Car'
+ ),
+ 'Class is resolved correctly when concrete sub-class is used.'
+ );
+
+ $this->assertEquals(
+ new Car(5),
+ $this->deserialize(
+ $this->getContent('car'),
+ 'JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle'
+ ),
+ 'Class is resolved correctly when least supertype is used.'
+ );
+
+ $this->assertEquals(
+ new Car(5),
+ $this->deserialize(
+ $this->getContent('car_without_type'),
+ 'JMS\Serializer\Tests\Fixtures\Discriminator\Car'
+ ),
+ 'Class is resolved correctly when concrete sub-class is used and no type is defined.'
+ );
+ }
+ }
+
+ /**
+ * @group polymorphic
+ */
+ public function testNestedPolymorphicObjects()
+ {
+ $garage = new Garage(array(new Car(3), new Moped(1)));
+ $this->assertEquals(
+ $this->getContent('garage'),
+ $this->serialize($garage)
+ );
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals(
+ $garage,
+ $this->deserialize(
+ $this->getContent('garage'),
+ 'JMS\Serializer\Tests\Fixtures\Garage'
+ )
+ );
+ }
+ }
+
+ /**
+ * @group polymorphic
+ */
+ public function testNestedPolymorphicInterfaces()
+ {
+ $garage = new VehicleInterfaceGarage(array(new Car(3), new Moped(1)));
+ $this->assertEquals(
+ $this->getContent('garage'),
+ $this->serialize($garage)
+ );
+
+ if ($this->hasDeserializer()) {
+ $this->assertEquals(
+ $garage,
+ $this->deserialize(
+ $this->getContent('garage'),
+ 'JMS\Serializer\Tests\Fixtures\VehicleInterfaceGarage'
+ )
+ );
+ }
+ }
+
+ /**
+ * @group polymorphic
+ * @expectedException LogicException
+ */
+ public function testPolymorphicObjectsInvalidDeserialization()
+ {
+ if (!$this->hasDeserializer()) {
+ throw new \LogicException('No deserializer');
+ }
+
+ $this->deserialize(
+ $this->getContent('car_without_type'),
+ 'JMS\Serializer\Tests\Fixtures\Discriminator\Vehicle'
+ );
+ }
+
+ public function testDepthExclusionStrategy()
+ {
+ $context = SerializationContext::create()
+ ->addExclusionStrategy(new DepthExclusionStrategy());
+
+ $data = new Tree(
+ new Node(array(
+ new Node(array(
+ new Node(array(
+ new Node(array(
+ new Node(),
+ )),
+ )),
+ )),
+ ))
+ );
+
+ $this->assertEquals($this->getContent('tree'), $this->serializer->serialize($data, $this->getFormat(), $context));
+ }
+
+ public function testMaxDepthWithSkippableObject()
+ {
+ $data = new Gh236Foo();
+
+ $context = SerializationContext::create()->enableMaxDepthChecks();
+ $serialized = $this->serialize($data, $context);
+
+ $this->assertEquals($this->getContent('maxdepth_skippabe_object'), $serialized);
+ }
+
+ public function testDeserializingIntoExistingObject()
+ {
+ if (!$this->hasDeserializer()) {
+ return;
+ }
+
+ $objectConstructor = new InitializedObjectConstructor(new UnserializeObjectConstructor());
+ $serializer = new Serializer(
+ $this->factory, $this->handlerRegistry, $objectConstructor,
+ $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher
+ );
+
+ $order = new Order(new Price(12));
+
+ $context = new DeserializationContext();
+ $context->attributes->set('target', $order);
+
+ $deseralizedOrder = $serializer->deserialize(
+ $this->getContent('order'),
+ get_class($order),
+ $this->getFormat(),
+ $context
+ );
+
+ $this->assertSame($order, $deseralizedOrder);
+ $this->assertEquals(new Order(new Price(12.34)), $deseralizedOrder);
+ $this->assertAttributeInstanceOf('JMS\Serializer\Tests\Fixtures\Price', 'cost', $deseralizedOrder);
+ }
+
+ public function testObjectWithNullableArrays()
+ {
+ $object = new ObjectWithEmptyNullableAndEmptyArrays();
+ $this->assertEquals($this->getContent('nullable_arrays'), $this->serializer->serialize($object, $this->getFormat()));
+ }
+
+ abstract protected function getContent($key);
+
+ abstract protected function getFormat();
+
+ protected function hasDeserializer()
+ {
+ return true;
+ }
+
+ protected function serialize($data, Context $context = null)
+ {
+ return $this->serializer->serialize($data, $this->getFormat(), $context);
+ }
+
+ protected function deserialize($content, $type, Context $context = null)
+ {
+ return $this->serializer->deserialize($content, $type, $this->getFormat(), $context);
+ }
+
+ protected function setUp()
+ {
+ $this->factory = new MetadataFactory(new AnnotationDriver(new AnnotationReader()));
+
+ $this->handlerRegistry = new HandlerRegistry();
+ $this->handlerRegistry->registerSubscribingHandler(new ConstraintViolationHandler());
+ $this->handlerRegistry->registerSubscribingHandler(new StdClassHandler());
+ $this->handlerRegistry->registerSubscribingHandler(new DateHandler());
+ $this->handlerRegistry->registerSubscribingHandler(new FormErrorHandler(new IdentityTranslator(new MessageSelector())));
+ $this->handlerRegistry->registerSubscribingHandler(new PhpCollectionHandler());
+ $this->handlerRegistry->registerSubscribingHandler(new ArrayCollectionHandler());
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_SERIALIZATION, 'AuthorList', $this->getFormat(),
+ function (VisitorInterface $visitor, $object, array $type, Context $context) {
+ return $visitor->visitArray(iterator_to_array($object), $type, $context);
+ }
+ );
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_DESERIALIZATION, 'AuthorList', $this->getFormat(),
+ function (VisitorInterface $visitor, $data, $type, Context $context) {
+ $type = array(
+ 'name' => 'array',
+ 'params' => array(
+ array('name' => 'integer', 'params' => array()),
+ array('name' => 'JMS\Serializer\Tests\Fixtures\Author', 'params' => array()),
+ ),
+ );
+
+ $elements = $visitor->getNavigator()->accept($data, $type, $context);
+ $list = new AuthorList();
+ foreach ($elements as $author) {
+ $list->add($author);
+ }
+
+ return $list;
+ }
+ );
+
+ $this->dispatcher = new EventDispatcher();
+ $this->dispatcher->addSubscriber(new DoctrineProxySubscriber());
+
+ $namingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
+ $this->objectConstructor = new UnserializeObjectConstructor();
+ $this->serializationVisitors = new Map(array(
+ 'json' => new JsonSerializationVisitor($namingStrategy),
+ 'xml' => new XmlSerializationVisitor($namingStrategy),
+ 'yml' => new YamlSerializationVisitor($namingStrategy),
+ ));
+ $this->deserializationVisitors = new Map(array(
+ 'json' => new JsonDeserializationVisitor($namingStrategy),
+ 'xml' => new XmlDeserializationVisitor($namingStrategy),
+ ));
+
+ $this->serializer = new Serializer($this->factory, $this->handlerRegistry, $this->objectConstructor, $this->serializationVisitors, $this->deserializationVisitors, $this->dispatcher);
+ }
+
+ protected function getField($obj, $name)
+ {
+ $ref = new \ReflectionProperty($obj, $name);
+ $ref->setAccessible(true);
+
+ return $ref->getValue($obj);
+ }
+
+ private function setField($obj, $name, $value)
+ {
+ $ref = new \ReflectionProperty($obj, $name);
+ $ref->setAccessible(true);
+ $ref->setValue($obj, $value);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\PropertyMetadata;
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\SerializerBuilder;
+use JMS\Serializer\Tests\Fixtures\InlineChild;
+use JMS\Serializer\Tests\Fixtures\Node;
+
+class ContextTest extends \PHPUnit_Framework_TestCase
+{
+ public function testSerializationContextPathAndDepth()
+ {
+ $object = new Node(array(
+ new Node(),
+ new Node(array(
+ new Node()
+ )),
+ ));
+ $objects = array($object, $object->children[0], $object->children[1], $object->children[1]->children[0]);
+
+ $self = $this;
+
+ $exclusionStrategy = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock();
+ $exclusionStrategy->expects($this->any())
+ ->method('shouldSkipClass')
+ ->with($this->anything(), $this->callback(function (SerializationContext $context) use ($self, $objects) {
+ $expectedDepth = $expectedPath = null;
+
+ if ($context->getObject() === $objects[0]) {
+ $expectedDepth = 1;
+ $expectedPath = 'JMS\Serializer\Tests\Fixtures\Node';
+ } elseif ($context->getObject() === $objects[1]) {
+ $expectedDepth = 2;
+ $expectedPath = 'JMS\Serializer\Tests\Fixtures\Node -> JMS\Serializer\Tests\Fixtures\Node';
+ } elseif ($context->getObject() === $objects[2]) {
+ $expectedDepth = 2;
+ $expectedPath = 'JMS\Serializer\Tests\Fixtures\Node -> JMS\Serializer\Tests\Fixtures\Node';
+ } elseif ($context->getObject() === $objects[3]) {
+ $expectedDepth = 3;
+ $expectedPath = 'JMS\Serializer\Tests\Fixtures\Node -> JMS\Serializer\Tests\Fixtures\Node -> JMS\Serializer\Tests\Fixtures\Node';
+ }
+
+ $self->assertEquals($expectedDepth, $context->getDepth(), 'shouldSkipClass depth');
+ $self->assertEquals($expectedPath, $context->getPath(), 'shouldSkipClass path');
+
+ return true;
+ }))
+ ->will($this->returnValue(false));
+
+ $exclusionStrategy->expects($this->any())
+ ->method('shouldSkipProperty')
+ ->with($this->anything(), $this->callback(function (SerializationContext $context) use ($self, $objects) {
+ $expectedDepth = $expectedPath = null;
+
+ if ($context->getObject() === $objects[0]) {
+ $expectedDepth = 1;
+ $expectedPath = 'JMS\Serializer\Tests\Fixtures\Node';
+ } elseif ($context->getObject() === $objects[1]) {
+ $expectedDepth = 2;
+ $expectedPath = 'JMS\Serializer\Tests\Fixtures\Node -> JMS\Serializer\Tests\Fixtures\Node';
+ } elseif ($context->getObject() === $objects[2]) {
+ $expectedDepth = 2;
+ $expectedPath = 'JMS\Serializer\Tests\Fixtures\Node -> JMS\Serializer\Tests\Fixtures\Node';
+ } elseif ($context->getObject() === $objects[3]) {
+ $expectedDepth = 3;
+ $expectedPath = 'JMS\Serializer\Tests\Fixtures\Node -> JMS\Serializer\Tests\Fixtures\Node -> JMS\Serializer\Tests\Fixtures\Node';
+ }
+
+ $self->assertEquals($expectedDepth, $context->getDepth(), 'shouldSkipProperty depth');
+ $self->assertEquals($expectedPath, $context->getPath(), 'shouldSkipProperty path');
+
+ return true;
+ }))
+ ->will($this->returnValue(false));
+
+ $serializer = SerializerBuilder::create()->build();
+
+ $serializer->serialize($object, 'json', SerializationContext::create()->addExclusionStrategy($exclusionStrategy));
+ }
+
+ public function testSerializationMetadataStack()
+ {
+ $object = new Node(array(
+ $child = new InlineChild(),
+ ));
+ $self = $this;
+
+ $exclusionStrategy = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock();
+ $exclusionStrategy->expects($this->any())
+ ->method('shouldSkipClass')
+ ->will($this->returnCallback(function (ClassMetadata $classMetadata, SerializationContext $context) use ($self, $object, $child) {
+ $stack = $context->getMetadataStack();
+
+ if ($object === $context->getObject()) {
+ $self->assertEquals(0, $stack->count());
+ }
+
+ if ($child === $context->getObject()) {
+ $self->assertEquals(2, $stack->count());
+ $self->assertEquals('JMS\Serializer\Tests\Fixtures\Node', $stack[1]->name);
+ $self->assertEquals('children', $stack[0]->name);
+ }
+
+ return false;
+ }));
+
+ $exclusionStrategy->expects($this->any())
+ ->method('shouldSkipProperty')
+ ->will($this->returnCallback(function (PropertyMetadata $propertyMetadata, SerializationContext $context) use ($self, $object, $child) {
+ $stack = $context->getMetadataStack();
+
+ if ('JMS\Serializer\Tests\Fixtures\Node' === $propertyMetadata->class && $propertyMetadata->name === 'children') {
+ $self->assertEquals(1, $stack->count());
+ $self->assertEquals('JMS\Serializer\Tests\Fixtures\Node', $stack[0]->name);
+ }
+
+ if ('JMS\Serializer\Tests\Fixtures\InlineChild' === $propertyMetadata->class) {
+ $self->assertEquals(3, $stack->count());
+ $self->assertEquals('JMS\Serializer\Tests\Fixtures\Node', $stack[2]->name);
+ $self->assertEquals('children', $stack[1]->name);
+ $self->assertEquals('JMS\Serializer\Tests\Fixtures\InlineChild', $stack[0]->name);
+ }
+
+ return false;
+ }));
+
+ $serializer = SerializerBuilder::create()->build();
+ $serializer->serialize($object, 'json', SerializationContext::create()->addExclusionStrategy($exclusionStrategy));
+ }
+
+ public function getScalars()
+ {
+ return array(
+ array("string"),
+ array(5),
+ array(5.5),
+ array(array())
+ );
+ }
+
+ /**
+ * @dataProvider getScalars
+ */
+ public function testCanVisitScalars($scalar)
+ {
+ $context = SerializationContext::create();
+
+ $context->startVisiting($scalar);
+ $this->assertFalse($context->isVisiting($scalar));
+ $context->stopVisiting($scalar);
+ }
+
+ public function testInitialTypeCompatibility()
+ {
+ $context = SerializationContext::create();
+ $context->setInitialType('foo');
+ $this->assertEquals('foo', $context->getInitialType());
+ $this->assertEquals('foo', $context->attributes->get('initial_type')->get());
+
+ $context = SerializationContext::create();
+ $context->attributes->set('initial_type', 'foo');
+ $this->assertEquals('foo', $context->getInitialType());
+ }
+
+ public function testSerializeNullOption()
+ {
+ $context = SerializationContext::create();
+ $this->assertNull($context->shouldSerializeNull());
+
+ $context->setSerializeNull(false);
+ $this->assertFalse($context->shouldSerializeNull());
+
+ $context->setSerializeNull(true);
+ $this->assertTrue($context->shouldSerializeNull());
+
+ $context->setSerializeNull("foo");
+ $this->assertTrue($context->shouldSerializeNull());
+
+ $context->setSerializeNull("0");
+ $this->assertFalse($context->shouldSerializeNull());
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use JMS\Serializer\Handler\DateHandler;
+
+class DateIntervalFormatTest extends \PHPUnit_Framework_TestCase
+{
+ public function testFormat()
+ {
+ $dtf = new DateHandler();
+
+ $iso8601DateIntervalString = $dtf->format(new \DateInterval('P0D'));
+ $this->assertEquals($iso8601DateIntervalString, 'P0DT0S');
+
+ $iso8601DateIntervalString = $dtf->format(new \DateInterval('P0DT0S'));
+ $this->assertEquals($iso8601DateIntervalString, 'P0DT0S');
+
+ $iso8601DateIntervalString = $dtf->format(new \DateInterval('PT45M'));
+
+ $this->assertEquals($iso8601DateIntervalString, 'PT45M');
+
+ $iso8601DateIntervalString = $dtf->format(new \DateInterval('P2YT45M'));
+
+ $this->assertEquals($iso8601DateIntervalString, 'P2YT45M');
+
+ $iso8601DateIntervalString = $dtf->format(new \DateInterval('P2Y4DT6H8M16S'));
+
+ $this->assertEquals($iso8601DateIntervalString, 'P2Y4DT6H8M16S');
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Serializer\Doctrine;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use Doctrine\Common\Annotations\Reader;
+use Doctrine\Common\Persistence\AbstractManagerRegistry;
+use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\DriverManager;
+use Doctrine\ORM\Configuration;
+use Doctrine\ORM\EntityManager;
+use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
+use Doctrine\ORM\ORMException;
+use Doctrine\ORM\Tools\SchemaTool;
+use JMS\Serializer\Builder\CallbackDriverFactory;
+use JMS\Serializer\Builder\DefaultDriverFactory;
+use JMS\Serializer\Metadata\Driver\DoctrineTypeDriver;
+use JMS\Serializer\Serializer;
+use JMS\Serializer\SerializerBuilder;
+use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Clazz;
+use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Excursion;
+use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Organization;
+use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Person;
+use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\School;
+use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Student;
+use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Teacher;
+
+class IntegrationTest extends \PHPUnit_Framework_TestCase
+{
+ /** @var ManagerRegistry */
+ private $registry;
+
+ /** @var Serializer */
+ private $serializer;
+
+ public function testDiscriminatorIsInferredForEntityBaseClass()
+ {
+ $school = new School();
+ $json = $this->serializer->serialize($school, 'json');
+ $this->assertEquals('{"type":"school"}', $json);
+
+ $deserialized = $this->serializer->deserialize($json, Organization::class, 'json');
+ $this->assertEquals($school, $deserialized);
+ }
+
+ public function testDiscriminatorIsInferredForGenericBaseClass()
+ {
+ $student = new Student();
+ $json = $this->serializer->serialize($student, 'json');
+ $this->assertEquals('{"type":"student"}', $json);
+
+ $deserialized = $this->serializer->deserialize($json, Person::class, 'json');
+ $this->assertEquals($student, $deserialized);
+ }
+
+ public function testDiscriminatorIsInferredFromDoctrine()
+ {
+ /** @var EntityManager $em */
+ $em = $this->registry->getManager();
+
+ $student1 = new Student();
+ $student2 = new Student();
+ $teacher = new Teacher();
+ $class = new Clazz($teacher, array($student1, $student2));
+
+ $em->persist($student1);
+ $em->persist($student2);
+ $em->persist($teacher);
+ $em->persist($class);
+ $em->flush();
+ $em->clear();
+
+ $reloadedClass = $em->find(get_class($class), $class->getId());
+ $this->assertNotSame($class, $reloadedClass);
+
+ $json = $this->serializer->serialize($reloadedClass, 'json');
+ $this->assertEquals('{"id":1,"teacher":{"id":1,"type":"teacher"},"students":[{"id":2,"type":"student"},{"id":3,"type":"student"}]}', $json);
+ }
+
+ protected function setUp()
+ {
+ $connection = $this->createConnection();
+ $entityManager = $this->createEntityManager($connection);
+
+ $this->registry = $registry = new SimpleManagerRegistry(
+ function ($id) use ($connection, $entityManager) {
+ switch ($id) {
+ case 'default_connection':
+ return $connection;
+
+ case 'default_manager':
+ return $entityManager;
+
+ default:
+ throw new \RuntimeException(sprintf('Unknown service id "%s".', $id));
+ }
+ }
+ );
+
+ $this->serializer = SerializerBuilder::create()
+ ->setMetadataDriverFactory(new CallbackDriverFactory(
+ function (array $metadataDirs, Reader $annotationReader) use ($registry) {
+ $defaultFactory = new DefaultDriverFactory();
+
+ return new DoctrineTypeDriver($defaultFactory->createDriver($metadataDirs, $annotationReader), $registry);
+ }
+ ))
+ ->build();
+
+ $this->prepareDatabase();
+ }
+
+ private function prepareDatabase()
+ {
+ /** @var EntityManager $em */
+ $em = $this->registry->getManager();
+
+ $tool = new SchemaTool($em);
+ $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
+ }
+
+ private function createConnection()
+ {
+ $con = DriverManager::getConnection(array(
+ 'driver' => 'pdo_sqlite',
+ 'memory' => true,
+ ));
+
+ return $con;
+ }
+
+ private function createEntityManager(Connection $con)
+ {
+ $cfg = new Configuration();
+ $cfg->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), array(
+ __DIR__ . '/../../Fixtures/Doctrine/SingleTableInheritance',
+ )));
+ $cfg->setAutoGenerateProxyClasses(true);
+ $cfg->setProxyNamespace('JMS\Serializer\DoctrineProxy');
+ $cfg->setProxyDir(sys_get_temp_dir() . '/serializer-test-proxies');
+
+ $em = EntityManager::create($con, $cfg);
+
+ return $em;
+ }
+}
+
+class SimpleManagerRegistry extends AbstractManagerRegistry
+{
+ private $services = array();
+ private $serviceCreator;
+
+ public function __construct($serviceCreator, $name = 'anonymous', array $connections = array('default' => 'default_connection'), array $managers = array('default' => 'default_manager'), $defaultConnection = null, $defaultManager = null, $proxyInterface = 'Doctrine\Common\Persistence\Proxy')
+ {
+ if (null === $defaultConnection) {
+ $defaultConnection = key($connections);
+ }
+ if (null === $defaultManager) {
+ $defaultManager = key($managers);
+ }
+
+ parent::__construct($name, $connections, $managers, $defaultConnection, $defaultManager, $proxyInterface);
+
+ if (!is_callable($serviceCreator)) {
+ throw new \InvalidArgumentException('$serviceCreator must be a valid callable.');
+ }
+ $this->serviceCreator = $serviceCreator;
+ }
+
+ public function getService($name)
+ {
+ if (isset($this->services[$name])) {
+ return $this->services[$name];
+ }
+
+ return $this->services[$name] = call_user_func($this->serviceCreator, $name);
+ }
+
+ public function resetService($name)
+ {
+ unset($this->services[$name]);
+ }
+
+ public function getAliasNamespace($alias)
+ {
+ foreach (array_keys($this->getManagers()) as $name) {
+ $manager = $this->getManager($name);
+
+ if ($manager instanceof EntityManager) {
+ try {
+ return $manager->getConfiguration()->getEntityNamespace($alias);
+ } catch (ORMException $ex) {
+ // Probably mapped by another entity manager, or invalid, just ignore this here.
+ }
+ } else {
+ throw new \LogicException(sprintf('Unsupported manager type "%s".', get_class($manager)));
+ }
+ }
+
+ throw new \RuntimeException(sprintf('The namespace alias "%s" is not known to any manager.', $alias));
+ }
+}
--- /dev/null
+<?php
+
+namespace JMS\Serializer\Tests\Serializer\Doctrine;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use Doctrine\Common\Annotations\Reader;
+use Doctrine\Common\Persistence\AbstractManagerRegistry;
+use Doctrine\Common\Persistence\ManagerRegistry;
+use Doctrine\DBAL\Connection;
+use Doctrine\DBAL\DriverManager;
+use Doctrine\ORM\Configuration;
+use Doctrine\ORM\EntityManager;
+use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
+use Doctrine\ORM\ORMException;
+use Doctrine\ORM\Tools\SchemaTool;
+use JMS\Serializer\Builder\CallbackDriverFactory;
+use JMS\Serializer\Builder\DefaultDriverFactory;
+use JMS\Serializer\Construction\DoctrineObjectConstructor;
+use JMS\Serializer\Construction\ObjectConstructorInterface;
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Metadata\Driver\DoctrineTypeDriver;
+use JMS\Serializer\Serializer;
+use JMS\Serializer\SerializerBuilder;
+use JMS\Serializer\Tests\Fixtures\Doctrine\Author;
+use JMS\Serializer\Tests\Fixtures\Doctrine\SingleTableInheritance\Excursion;
+use JMS\Serializer\VisitorInterface;
+
+class ObjectConstructorTest extends \PHPUnit_Framework_TestCase
+{
+ /** @var ManagerRegistry */
+ private $registry;
+
+ /** @var Serializer */
+ private $serializer;
+
+ /** @var VisitorInterface */
+ private $visitor;
+
+ /** @var DeserializationContext */
+ private $context;
+
+ public function testFindEntity()
+ {
+ $em = $this->registry->getManager();
+
+ $author = new Author('John', 5);
+ $em->persist($author);
+ $em->flush();
+ $em->clear();
+
+ $fallback = $this->getMockBuilder(ObjectConstructorInterface::class)->getMock();
+
+ $type = array('name' => Author::class, 'params' => array());
+ $class = new ClassMetadata(Author::class);
+
+ $constructor = new DoctrineObjectConstructor($this->registry, $fallback);
+ $authorFetched = $constructor->construct($this->visitor, $class, ['id' => 5], $type, $this->context);
+
+ $this->assertEquals($author, $authorFetched);
+ }
+
+ public function testFindManagedEntity()
+ {
+ $em = $this->registry->getManager();
+
+ $author = new Author('John', 5);
+ $em->persist($author);
+ $em->flush();
+
+ $fallback = $this->getMockBuilder(ObjectConstructorInterface::class)->getMock();
+
+ $type = array('name' => Author::class, 'params' => array());
+ $class = new ClassMetadata(Author::class);
+
+ $constructor = new DoctrineObjectConstructor($this->registry, $fallback);
+ $authorFetched = $constructor->construct($this->visitor, $class, ['id' => 5], $type, $this->context);
+
+ $this->assertSame($author, $authorFetched);
+ }
+
+ public function testMissingAuthor()
+ {
+ $fallback = $this->getMockBuilder(ObjectConstructorInterface::class)->getMock();
+
+ $type = array('name' => Author::class, 'params' => array());
+ $class = new ClassMetadata(Author::class);
+
+ $constructor = new DoctrineObjectConstructor($this->registry, $fallback);
+ $author = $constructor->construct($this->visitor, $class, ['id' => 5], $type, $this->context);
+ $this->assertNull($author);
+ }
+
+ public function testMissingAuthorFallback()
+ {
+ $author = new Author('John');
+
+ $fallback = $this->getMockBuilder(ObjectConstructorInterface::class)->getMock();
+ $fallback->expects($this->once())->method('construct')->willReturn($author);
+
+ $type = array('name' => Author::class, 'params' => array());
+ $class = new ClassMetadata(Author::class);
+
+ $constructor = new DoctrineObjectConstructor($this->registry, $fallback, DoctrineObjectConstructor::ON_MISSING_FALLBACK);
+ $authorFetched = $constructor->construct($this->visitor, $class, ['id' => 5], $type, $this->context);
+ $this->assertSame($author, $authorFetched);
+ }
+
+ public function testMissingNotManaged()
+ {
+ $author = new \JMS\Serializer\Tests\Fixtures\DoctrinePHPCR\Author('foo');
+
+ $fallback = $this->getMockBuilder(ObjectConstructorInterface::class)->getMock();
+ $fallback->expects($this->once())->method('construct')->willReturn($author);
+
+ $type = array('name' => Author::class, 'params' => array());
+ $class = new ClassMetadata(Author::class);
+
+ $constructor = new DoctrineObjectConstructor($this->registry, $fallback, DoctrineObjectConstructor::ON_MISSING_FALLBACK);
+ $authorFetched = $constructor->construct($this->visitor, $class, ['id' => 5], $type, $this->context);
+ $this->assertSame($author, $authorFetched);
+ }
+
+ public function testReference()
+ {
+ $em = $this->registry->getManager();
+
+ $author = new Author('John', 5);
+ $em->persist($author);
+ $em->flush();
+
+ $fallback = $this->getMockBuilder(ObjectConstructorInterface::class)->getMock();
+
+ $type = array('name' => Author::class, 'params' => array());
+ $class = new ClassMetadata(Author::class);
+
+ $constructor = new DoctrineObjectConstructor($this->registry, $fallback, DoctrineObjectConstructor::ON_MISSING_FALLBACK);
+ $authorFetched = $constructor->construct($this->visitor, $class, 5, $type, $this->context);
+ $this->assertSame($author, $authorFetched);
+ }
+
+ /**
+ * @expectedException \JMS\Serializer\Exception\ObjectConstructionException
+ */
+ public function testMissingAuthorException()
+ {
+ $fallback = $this->getMockBuilder(ObjectConstructorInterface::class)->getMock();
+
+ $type = array('name' => Author::class, 'params' => array());
+ $class = new ClassMetadata(Author::class);
+
+ $constructor = new DoctrineObjectConstructor($this->registry, $fallback, DoctrineObjectConstructor::ON_MISSING_EXCEPTION);
+ $constructor->construct($this->visitor, $class, ['id' => 5], $type, $this->context);
+ }
+
+ /**
+ * @expectedException \JMS\Serializer\Exception\InvalidArgumentException
+ */
+ public function testInvalidArg()
+ {
+ $fallback = $this->getMockBuilder(ObjectConstructorInterface::class)->getMock();
+
+ $type = array('name' => Author::class, 'params' => array());
+ $class = new ClassMetadata(Author::class);
+
+ $constructor = new DoctrineObjectConstructor($this->registry, $fallback, 'foo');
+ $constructor->construct($this->visitor, $class, ['id' => 5], $type, $this->context);
+ }
+
+ public function testMissingData()
+ {
+ $author = new Author('John');
+
+ $fallback = $this->getMockBuilder(ObjectConstructorInterface::class)->getMock();
+ $fallback->expects($this->once())->method('construct')->willReturn($author);
+
+ $type = array('name' => Author::class, 'params' => array());
+ $class = new ClassMetadata(Author::class);
+
+ $constructor = new DoctrineObjectConstructor($this->registry, $fallback, 'foo');
+ $authorFetched = $constructor->construct($this->visitor, $class, ['foo' => 5], $type, $this->context);
+ $this->assertSame($author, $authorFetched);
+ }
+
+ protected function setUp()
+ {
+ $this->visitor = $this->getMockBuilder('JMS\Serializer\VisitorInterface')->getMock();
+ $this->context = $this->getMockBuilder('JMS\Serializer\DeserializationContext')->getMock();
+
+ $connection = $this->createConnection();
+ $entityManager = $this->createEntityManager($connection);
+
+ $this->registry = $registry = new SimpleBaseManagerRegistry(
+ function ($id) use ($connection, $entityManager) {
+ switch ($id) {
+ case 'default_connection':
+ return $connection;
+
+ case 'default_manager':
+ return $entityManager;
+
+ default:
+ throw new \RuntimeException(sprintf('Unknown service id "%s".', $id));
+ }
+ }
+ );
+
+ $this->serializer = SerializerBuilder::create()
+ ->setMetadataDriverFactory(new CallbackDriverFactory(
+ function (array $metadataDirs, Reader $annotationReader) use ($registry) {
+ $defaultFactory = new DefaultDriverFactory();
+
+ return new DoctrineTypeDriver($defaultFactory->createDriver($metadataDirs, $annotationReader), $registry);
+ }
+ ))
+ ->build();
+
+ $this->prepareDatabase();
+ }
+
+ private function prepareDatabase()
+ {
+ /** @var EntityManager $em */
+ $em = $this->registry->getManager();
+
+ $tool = new SchemaTool($em);
+ $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
+ }
+
+ private function createConnection()
+ {
+ $con = DriverManager::getConnection(array(
+ 'driver' => 'pdo_sqlite',
+ 'memory' => true,
+ ));
+
+ return $con;
+ }
+
+ private function createEntityManager(Connection $con)
+ {
+ $cfg = new Configuration();
+ $cfg->setMetadataDriverImpl(new AnnotationDriver(new AnnotationReader(), array(
+ __DIR__ . '/../../Fixtures/Doctrine',
+ )));
+ $cfg->setAutoGenerateProxyClasses(true);
+ $cfg->setProxyNamespace('JMS\Serializer\DoctrineProxy');
+ $cfg->setProxyDir(sys_get_temp_dir() . '/serializer-test-proxies');
+
+ $em = EntityManager::create($con, $cfg);
+
+ return $em;
+ }
+}
+
+\Doctrine\DBAL\Types\Type::addType('Author', 'Doctrine\DBAL\Types\StringType');
+\Doctrine\DBAL\Types\Type::addType('some_custom_type', 'Doctrine\DBAL\Types\StringType');
+
+class SimpleBaseManagerRegistry extends AbstractManagerRegistry
+{
+ private $services = array();
+ private $serviceCreator;
+
+ public function __construct($serviceCreator, $name = 'anonymous', array $connections = array('default' => 'default_connection'), array $managers = array('default' => 'default_manager'), $defaultConnection = null, $defaultManager = null, $proxyInterface = 'Doctrine\Common\Persistence\Proxy')
+ {
+ if (null === $defaultConnection) {
+ $defaultConnection = key($connections);
+ }
+ if (null === $defaultManager) {
+ $defaultManager = key($managers);
+ }
+
+ parent::__construct($name, $connections, $managers, $defaultConnection, $defaultManager, $proxyInterface);
+
+ if (!is_callable($serviceCreator)) {
+ throw new \InvalidArgumentException('$serviceCreator must be a valid callable.');
+ }
+ $this->serviceCreator = $serviceCreator;
+ }
+
+ public function getService($name)
+ {
+ if (isset($this->services[$name])) {
+ return $this->services[$name];
+ }
+
+ return $this->services[$name] = call_user_func($this->serviceCreator, $name);
+ }
+
+ public function resetService($name)
+ {
+ unset($this->services[$name]);
+ }
+
+ public function getAliasNamespace($alias)
+ {
+ foreach (array_keys($this->getManagers()) as $name) {
+ $manager = $this->getManager($name);
+
+ if ($manager instanceof EntityManager) {
+ try {
+ return $manager->getConfiguration()->getEntityNamespace($alias);
+ } catch (ORMException $ex) {
+ // Probably mapped by another entity manager, or invalid, just ignore this here.
+ }
+ } else {
+ throw new \LogicException(sprintf('Unsupported manager type "%s".', get_class($manager)));
+ }
+ }
+
+ throw new \RuntimeException(sprintf('The namespace alias "%s" is not known to any manager.', $alias));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer\EventDispatcher;
+
+use JMS\Serializer\EventDispatcher\Event;
+use JMS\Serializer\EventDispatcher\EventDispatcher;
+use JMS\Serializer\EventDispatcher\EventDispatcherInterface;
+use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
+use JMS\Serializer\EventDispatcher\ObjectEvent;
+
+class EventDispatcherTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @var EventDispatcher
+ */
+ protected $dispatcher;
+ protected $event;
+
+ public function testHasListeners()
+ {
+ $this->assertFalse($this->dispatcher->hasListeners('foo', 'Foo', 'json'));
+ $this->dispatcher->addListener('foo', function () {
+ });
+ $this->assertTrue($this->dispatcher->hasListeners('foo', 'Foo', 'json'));
+
+ $this->assertFalse($this->dispatcher->hasListeners('bar', 'Bar', 'json'));
+ $this->dispatcher->addListener('bar', function () {
+ }, 'Foo');
+ $this->assertFalse($this->dispatcher->hasListeners('bar', 'Bar', 'json'));
+ $this->dispatcher->addListener('bar', function () {
+ }, 'Bar', 'xml');
+ $this->assertFalse($this->dispatcher->hasListeners('bar', 'Bar', 'json'));
+ $this->dispatcher->addListener('bar', function () {
+ }, null, 'json');
+ $this->assertTrue($this->dispatcher->hasListeners('bar', 'Baz', 'json'));
+ $this->assertTrue($this->dispatcher->hasListeners('bar', 'Bar', 'json'));
+
+ $this->assertFalse($this->dispatcher->hasListeners('baz', 'Bar', 'xml'));
+ $this->dispatcher->addListener('baz', function () {
+ }, 'Bar');
+ $this->assertTrue($this->dispatcher->hasListeners('baz', 'Bar', 'xml'));
+ $this->assertTrue($this->dispatcher->hasListeners('baz', 'bAr', 'xml'));
+ }
+
+ public function testDispatch()
+ {
+ $a = new MockListener();
+ $this->dispatcher->addListener('foo', array($a, 'foo'));
+ $this->dispatch('bar');
+ $a->_verify('Listener is not called for other event.');
+
+ $b = new MockListener();
+ $this->dispatcher->addListener('pre', array($b, 'bar'), 'Bar');
+ $this->dispatcher->addListener('pre', array($b, 'foo'), 'Foo');
+ $this->dispatcher->addListener('pre', array($b, 'all'));
+
+ $b->bar($this->event, 'pre', 'bar', 'json', $this->dispatcher);
+ $b->all($this->event, 'pre', 'bar', 'json', $this->dispatcher);
+ $b->foo($this->event, 'pre', 'foo', 'json', $this->dispatcher);
+ $b->all($this->event, 'pre', 'foo', 'json', $this->dispatcher);
+ $b->_replay();
+ $this->dispatch('pre', 'Bar');
+ $this->dispatch('pre', 'Foo');
+ $b->_verify();
+ }
+
+ public function testListenerCanStopPropagation()
+ {
+ $listener1 = false;
+ $listener2 = false;
+
+ $this->dispatcher->addListener('pre', function (Event $event) use (&$listener1) {
+ $event->stopPropagation();
+ $listener1 = true;
+ });
+
+ $this->dispatcher->addListener('pre', function () use (&$listener2) {
+ $listener2 = true;
+ });
+
+ $this->dispatch('pre');
+
+ $this->assertTrue($listener1);
+ $this->assertFalse($listener2);
+ }
+
+ public function testListenerCanDispatchEvent()
+ {
+ $listener1 = false;
+ $listener2 = false;
+ $listener3 = false;
+
+ $this->dispatcher->addListener('pre', function (Event $event, $eventName, $loweredClass, $format, EventDispatcherInterface $dispatcher) use (&$listener1) {
+ $listener1 = true;
+
+ $event = new Event($event->getContext(), $event->getType());
+
+ $this->assertSame('pre', $eventName);
+ $this->assertSame('json', $format);
+ $this->assertSame('foo', $loweredClass);
+
+ $dispatcher->dispatch('post', 'Blah', 'xml', $event);
+ });
+
+ $this->dispatcher->addListener('pre', function () use (&$listener2) {
+ $listener2 = true;
+ });
+
+ $this->dispatcher->addListener('post', function (Event $event, $eventName, $loweredClass, $format, EventDispatcherInterface $dispatcher) use (&$listener3) {
+ $listener3 = true;
+
+ $this->assertSame('post', $eventName);
+ $this->assertSame('xml', $format);
+ $this->assertSame('blah', $loweredClass);
+ });
+
+ $this->dispatch('pre');
+
+ $this->assertTrue($listener1);
+ $this->assertTrue($listener2);
+ $this->assertTrue($listener3);
+ }
+
+ public function testAddSubscriber()
+ {
+ $subscriber = new MockSubscriber();
+ MockSubscriber::$events = array(
+ array('event' => 'foo.bar_baz', 'format' => 'foo'),
+ array('event' => 'bar', 'method' => 'bar', 'class' => 'foo'),
+ );
+
+ $this->dispatcher->addSubscriber($subscriber);
+ $this->assertAttributeEquals(array(
+ 'foo.bar_baz' => array(
+ array(array($subscriber, 'onfoobarbaz'), null, 'foo'),
+ ),
+ 'bar' => array(
+ array(array($subscriber, 'bar'), 'foo', null),
+ ),
+ ), 'listeners', $this->dispatcher);
+ }
+
+ protected function setUp()
+ {
+ $this->dispatcher = $this->createEventDispatcher();
+ $this->event = new ObjectEvent($this->getMockBuilder('JMS\Serializer\Context')->getMock(), new \stdClass(), array('name' => 'foo', 'params' => array()));
+ }
+
+ protected function createEventDispatcher()
+ {
+ return new EventDispatcher();
+ }
+
+ protected function dispatch($eventName, $class = 'Foo', $format = 'json', Event $event = null)
+ {
+ $this->dispatcher->dispatch($eventName, $class, $format, $event ?: $this->event);
+ }
+}
+
+class MockSubscriber implements EventSubscriberInterface
+{
+ public static $events = array();
+
+ public static function getSubscribedEvents()
+ {
+ return self::$events;
+ }
+}
+
+class MockListener
+{
+ private $expected = array();
+ private $actual = array();
+ private $wasReplayed = false;
+
+ public function __call($method, array $args = array())
+ {
+ if (!$this->wasReplayed) {
+ $this->expected[] = array($method, $args);
+
+ return;
+ }
+
+ $this->actual[] = array($method, $args);
+ }
+
+ public function _replay()
+ {
+ $this->wasReplayed = true;
+ }
+
+ public function _verify($message = null)
+ {
+ \PHPUnit_Framework_Assert::assertSame($this->expected, $this->actual, $message);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer\EventDispatcher;
+
+use JMS\Serializer\EventDispatcher\LazyEventDispatcher;
+
+abstract class LazyEventDispatcherTest extends EventDispatcherTest
+{
+ protected $container;
+
+ protected function setUp()
+ {
+ $this->container = $this->createContainer();
+
+ parent::setUp();
+ }
+
+ public function testHasListenersWithListenerAsService()
+ {
+ $a = new MockListener();
+ $this->registerListenerService('a', $a);
+
+ $this->assertFalse($this->dispatcher->hasListeners('foo', 'Foo', 'json'));
+ $this->dispatcher->addListener('foo', ['a', 'foo']);
+ $this->assertTrue($this->dispatcher->hasListeners('foo', 'Foo', 'json'));
+ }
+
+ public function testDispatchWithListenerAsService()
+ {
+ $a = new MockListener();
+ $this->registerListenerService('a', $a);
+
+ $this->dispatcher->addListener('foo', ['a', 'foo']);
+ $this->dispatch('bar');
+ $a->_verify('Listener is not called for other event.');
+
+ $b = new MockListener();
+ $this->registerListenerService('b', $b);
+
+ $this->dispatcher->addListener('pre', array('b', 'bar'), 'Bar');
+ $this->dispatcher->addListener('pre', array('b', 'foo'), 'Foo');
+ $this->dispatcher->addListener('pre', array('b', 'all'));
+
+ $b->bar($this->event, 'pre', 'bar', 'json', $this->dispatcher);
+ $b->all($this->event, 'pre', 'bar', 'json', $this->dispatcher);
+ $b->foo($this->event, 'pre', 'foo', 'json', $this->dispatcher);
+ $b->all($this->event, 'pre', 'foo', 'json', $this->dispatcher);
+ $b->_replay();
+ $this->dispatch('pre', 'Bar');
+ $this->dispatch('pre', 'Foo');
+ $b->_verify();
+ }
+
+ protected function createEventDispatcher()
+ {
+ return new LazyEventDispatcher($this->container);
+ }
+
+ abstract protected function createContainer();
+
+ abstract protected function registerListenerService($serviceId, MockListener $listener);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer\EventDispatcher;
+
+use Psr\Container\ContainerInterface;
+
+class LazyEventDispatcherWithPsr11ContainerTest extends LazyEventDispatcherTest
+{
+ protected function createContainer()
+ {
+ return new Psr11Container();
+ }
+
+ protected function registerListenerService($serviceId, MockListener $listener)
+ {
+ $this->container->set($serviceId, $listener);
+ }
+}
+
+class Psr11Container implements ContainerInterface
+{
+ private $services;
+
+ public function get($id)
+ {
+ return $this->services[$id];
+ }
+
+ public function has($id)
+ {
+ return isset($this->services[$id]);
+ }
+
+ public function set($id, $service)
+ {
+ $this->services[$id] = $service;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer\EventDispatcher;
+
+use Symfony\Component\DependencyInjection\Container;
+
+class LazyEventDispatcherWithSymfonyContainerTest extends LazyEventDispatcherTest
+{
+ protected function createContainer()
+ {
+ return new Container();
+ }
+
+ protected function registerListenerService($serviceId, MockListener $listener)
+ {
+ $this->container->set($serviceId, $listener);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer\EventDispatcher\Subscriber;
+
+use JMS\Serializer\EventDispatcher\EventDispatcher;
+use JMS\Serializer\EventDispatcher\PreSerializeEvent;
+use JMS\Serializer\EventDispatcher\Subscriber\DoctrineProxySubscriber;
+use JMS\Serializer\Metadata\ClassMetadata;
+use JMS\Serializer\Tests\Fixtures\ExclusionStrategy\AlwaysExcludeExclusionStrategy;
+use JMS\Serializer\Tests\Fixtures\SimpleObject;
+use JMS\Serializer\Tests\Fixtures\SimpleObjectProxy;
+use JMS\Serializer\VisitorInterface;
+use Metadata\MetadataFactoryInterface;
+
+class DoctrineProxySubscriberTest extends \PHPUnit_Framework_TestCase
+{
+ /** @var VisitorInterface */
+ private $visitor;
+
+ /** @var DoctrineProxySubscriber */
+ private $subscriber;
+
+ /**
+ * @var EventDispatcher
+ */
+ private $dispatcher;
+
+ public function testRewritesProxyClassName()
+ {
+ $event = $this->createEvent($obj = new SimpleObjectProxy('a', 'b'), array('name' => get_class($obj), 'params' => array()));
+ $this->subscriber->onPreSerialize($event);
+
+ $this->assertEquals(array('name' => get_parent_class($obj), 'params' => array()), $event->getType());
+ $this->assertTrue($obj->__isInitialized());
+ }
+
+ public function testDoesNotRewriteCustomType()
+ {
+ $event = $this->createEvent($obj = new SimpleObjectProxy('a', 'b'), array('name' => 'FakedName', 'params' => array()));
+ $this->subscriber->onPreSerialize($event);
+
+ $this->assertEquals(array('name' => 'FakedName', 'params' => array()), $event->getType());
+ $this->assertTrue($obj->__isInitialized());
+ }
+
+ public function testProxyLoadingCanBeSkippedForVirtualTypes()
+ {
+ $subscriber = new DoctrineProxySubscriber(true);
+
+ $event = $this->createEvent($obj = new SimpleObjectProxy('a', 'b'), array('name' => 'FakedName', 'params' => array()));
+ $subscriber->onPreSerialize($event);
+
+ $this->assertEquals(array('name' => 'FakedName', 'params' => array()), $event->getType());
+ $this->assertFalse($obj->__isInitialized());
+ }
+
+ public function testProxyLoadingCanBeSkippedByExclusionStrategy()
+ {
+ $subscriber = new DoctrineProxySubscriber(false, false);
+
+ $factoryMock = $this->getMockBuilder(MetadataFactoryInterface::class)->getMock();
+ $factoryMock->method('getMetadataForClass')->willReturn(new ClassMetadata(SimpleObject::class));
+
+ $this->visitor->method('getExclusionStrategy')->willReturn(new AlwaysExcludeExclusionStrategy());
+ $this->visitor->method('getMetadataFactory')->willReturn($factoryMock);
+
+ $event = $this->createEvent($obj = new SimpleObjectProxy('a', 'b'), array('name' => SimpleObjectProxy::class, 'params' => array()));
+ $subscriber->onPreSerialize($event);
+ $this->assertFalse($obj->__isInitialized());
+
+ // virtual types are still initialized
+ $event = $this->createEvent($obj = new SimpleObjectProxy('a', 'b'), array('name' => 'FakeName', 'params' => array()));
+ $subscriber->onPreSerialize($event);
+ $this->assertTrue($obj->__isInitialized());
+ }
+
+ public function testEventTriggeredOnRealClassName()
+ {
+ $proxy = new SimpleObjectProxy('foo', 'bar');
+
+ $realClassEventTriggered1 = false;
+ $this->dispatcher->addListener('serializer.pre_serialize', function () use (&$realClassEventTriggered1) {
+ $realClassEventTriggered1 = true;
+ }, get_parent_class($proxy));
+
+ $event = $this->createEvent($proxy, array('name' => get_class($proxy), 'params' => array()));
+ $this->dispatcher->dispatch('serializer.pre_serialize', get_class($proxy), 'json', $event);
+
+ $this->assertTrue($realClassEventTriggered1);
+ }
+
+ public function testListenersCanChangeType()
+ {
+ $proxy = new SimpleObjectProxy('foo', 'bar');
+
+ $realClassEventTriggered1 = false;
+ $this->dispatcher->addListener('serializer.pre_serialize', function (PreSerializeEvent $event) use (&$realClassEventTriggered1) {
+ $event->setType('foo', ['bar']);
+ }, get_parent_class($proxy));
+
+ $event = $this->createEvent($proxy, array('name' => get_class($proxy), 'params' => array()));
+ $this->dispatcher->dispatch('serializer.pre_serialize', get_class($proxy), 'json', $event);
+
+ $this->assertSame(['name' => 'foo', 'params' => ['bar']], $event->getType());
+ }
+
+ public function testListenersDoNotChangeTypeOnProxiesAndVirtualTypes()
+ {
+ $proxy = new SimpleObjectProxy('foo', 'bar');
+
+ $event = $this->createEvent($proxy, ['name' => 'foo', 'params' => []]);
+ $this->dispatcher->dispatch('serializer.pre_serialize', get_class($proxy), 'json', $event);
+
+ $this->assertSame(['name' => 'foo', 'params' => []], $event->getType());
+ }
+
+ public function testOnPreSerializeMaintainsParams()
+ {
+ $object = new SimpleObjectProxy('foo', 'bar');
+ $type = ['name' => SimpleObjectProxy::class, 'params' => ['baz']];
+
+ $event = $this->createEvent($object, $type);
+ $this->subscriber->onPreSerialize($event);
+
+ $this->assertSame(['name' => SimpleObject::class, 'params' => ['baz']], $event->getType());
+ }
+
+ protected function setUp()
+ {
+ $this->subscriber = new DoctrineProxySubscriber();
+ $this->visitor = $this->getMockBuilder('JMS\Serializer\Context')->getMock();
+
+ $this->dispatcher = new EventDispatcher();
+ $this->dispatcher->addSubscriber($this->subscriber);
+ }
+
+ private function createEvent($object, array $type)
+ {
+ return new PreSerializeEvent($this->visitor, $object, $type);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer\EventDispatcher\Subscriber;
+
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\EventDispatcher\EventDispatcher;
+use JMS\Serializer\EventDispatcher\ObjectEvent;
+use JMS\Serializer\EventDispatcher\Subscriber\SymfonyValidatorSubscriber;
+use JMS\Serializer\SerializerBuilder;
+use Symfony\Component\Validator\ConstraintViolation;
+use Symfony\Component\Validator\ConstraintViolationList;
+
+class SymfonyValidatorSubscriberTest extends \PHPUnit_Framework_TestCase
+{
+ private $validator;
+
+ /** @var SymfonyValidatorSubscriber */
+ private $subscriber;
+
+ public function testValidate()
+ {
+ $obj = new \stdClass;
+
+ $this->validator->expects($this->once())
+ ->method('validate')
+ ->with($obj, array('foo'))
+ ->will($this->returnValue(new ConstraintViolationList()));
+
+ $context = DeserializationContext::create()->setAttribute('validation_groups', array('foo'));
+
+ $this->subscriber->onPostDeserialize(new ObjectEvent($context, $obj, array()));
+ }
+
+ /**
+ * @expectedException JMS\Serializer\Exception\ValidationFailedException
+ * @expectedExceptionMessage Validation failed with 1 error(s).
+ */
+ public function testValidateThrowsExceptionWhenListIsNotEmpty()
+ {
+ $obj = new \stdClass;
+
+ $this->validator->expects($this->once())
+ ->method('validate')
+ ->with($obj, array('foo'))
+ ->will($this->returnValue(new ConstraintViolationList(array(new ConstraintViolation('foo', 'foo', array(), 'a', 'b', 'c')))));
+
+ $context = DeserializationContext::create()->setAttribute('validation_groups', array('foo'));
+
+ $this->subscriber->onPostDeserialize(new ObjectEvent($context, $obj, array()));
+ }
+
+ public function testValidatorIsNotCalledWhenNoGroupsAreSet()
+ {
+ $this->validator->expects($this->never())
+ ->method('validate');
+
+ $this->subscriber->onPostDeserialize(new ObjectEvent(DeserializationContext::create(), new \stdClass, array()));
+ }
+
+ public function testValidationIsOnlyPerformedOnRootObject()
+ {
+ $this->validator->expects($this->once())
+ ->method('validate')
+ ->with($this->isInstanceOf('JMS\Serializer\Tests\Fixtures\AuthorList'), array('Foo'))
+ ->will($this->returnValue(new ConstraintViolationList()));
+
+ $subscriber = $this->subscriber;
+ $list = SerializerBuilder::create()
+ ->configureListeners(function (EventDispatcher $dispatcher) use ($subscriber) {
+ $dispatcher->addSubscriber($subscriber);
+ })
+ ->build()
+ ->deserialize(
+ '{"authors":[{"full_name":"foo"},{"full_name":"bar"}]}',
+ 'JMS\Serializer\Tests\Fixtures\AuthorList',
+ 'json',
+ DeserializationContext::create()->setAttribute('validation_groups', array('Foo'))
+ );
+
+ $this->assertCount(2, $list);
+ }
+
+ protected function setUp()
+ {
+ if (!interface_exists('Symfony\Component\Validator\ValidatorInterface')) {
+ $this->markTestSkipped('Symfony\Component\Validator\ValidatorInterface is not available');
+ }
+
+ $this->validator = $this->getMockBuilder('Symfony\Component\Validator\ValidatorInterface')->getMock();
+ $this->subscriber = new SymfonyValidatorSubscriber($this->validator);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Asmir Mustafic <goetas@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer\EventDispatcher\Subscriber;
+
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\EventDispatcher\EventDispatcher;
+use JMS\Serializer\EventDispatcher\ObjectEvent;
+use JMS\Serializer\EventDispatcher\Subscriber\SymfonyValidatorSubscriber;
+use JMS\Serializer\EventDispatcher\Subscriber\SymfonyValidatorValidatorSubscriber;
+use JMS\Serializer\SerializerBuilder;
+use Symfony\Component\Validator\ConstraintViolation;
+use Symfony\Component\Validator\ConstraintViolationList;
+
+class SymfonyValidatorValidatorSubscriberTest extends \PHPUnit_Framework_TestCase
+{
+ private $validator;
+
+ /** @var SymfonyValidatorSubscriber */
+ private $subscriber;
+
+ public function testValidate()
+ {
+ $obj = new \stdClass;
+
+ $this->validator->expects($this->once())
+ ->method('validate')
+ ->with($obj, null, array('foo'))
+ ->will($this->returnValue(new ConstraintViolationList()));
+
+ $context = DeserializationContext::create()->setAttribute('validation_groups', array('foo'));
+
+ $this->subscriber->onPostDeserialize(new ObjectEvent($context, $obj, array()));
+ }
+
+ /**
+ * @expectedException \JMS\Serializer\Exception\ValidationFailedException
+ * @expectedExceptionMessage Validation failed with 1 error(s).
+ */
+ public function testValidateThrowsExceptionWhenListIsNotEmpty()
+ {
+ $obj = new \stdClass;
+
+ $this->validator->expects($this->once())
+ ->method('validate')
+ ->with($obj, null, array('foo'))
+ ->will($this->returnValue(new ConstraintViolationList(array(new ConstraintViolation('foo', 'foo', array(), 'a', 'b', 'c')))));
+
+ $context = DeserializationContext::create()->setAttribute('validation_groups', array('foo'));
+
+ $this->subscriber->onPostDeserialize(new ObjectEvent($context, $obj, array()));
+ }
+
+ public function testValidatorIsNotCalledWhenNoGroupsAreSet()
+ {
+ $this->validator->expects($this->never())
+ ->method('validate');
+
+ $this->subscriber->onPostDeserialize(new ObjectEvent(DeserializationContext::create(), new \stdClass, array()));
+ }
+
+ public function testValidationIsOnlyPerformedOnRootObject()
+ {
+ $this->validator->expects($this->once())
+ ->method('validate')
+ ->with($this->isInstanceOf('JMS\Serializer\Tests\Fixtures\AuthorList'), null, array('Foo'))
+ ->will($this->returnValue(new ConstraintViolationList()));
+
+ $subscriber = $this->subscriber;
+ $list = SerializerBuilder::create()
+ ->configureListeners(function (EventDispatcher $dispatcher) use ($subscriber) {
+ $dispatcher->addSubscriber($subscriber);
+ })
+ ->build()
+ ->deserialize(
+ '{"authors":[{"full_name":"foo"},{"full_name":"bar"}]}',
+ 'JMS\Serializer\Tests\Fixtures\AuthorList',
+ 'json',
+ DeserializationContext::create()->setAttribute('validation_groups', array('Foo'))
+ );
+
+ $this->assertCount(2, $list);
+ }
+
+ protected function setUp()
+ {
+ if (!interface_exists('Symfony\Component\Validator\Validator\ValidatorInterface')) {
+ $this->markTestSkipped('Symfony\Component\Validator\Validator\ValidatorInterface ^2.6|^3.0 is not available');
+ }
+
+ $this->validator = $this->getMockBuilder('Symfony\Component\Validator\Validator\ValidatorInterface')->getMock();
+ $this->subscriber = new SymfonyValidatorValidatorSubscriber($this->validator);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use JMS\Serializer\Construction\UnserializeObjectConstructor;
+use JMS\Serializer\EventDispatcher\EventDispatcher;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Handler\HandlerRegistry;
+use JMS\Serializer\Handler\SubscribingHandlerInterface;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+use Metadata\MetadataFactory;
+
+class GraphNavigatorTest extends \PHPUnit_Framework_TestCase
+{
+ private $metadataFactory;
+ private $handlerRegistry;
+ private $objectConstructor;
+ private $dispatcher;
+ private $navigator;
+ private $context;
+
+ /**
+ * @expectedException JMS\Serializer\Exception\RuntimeException
+ * @expectedExceptionMessage Resources are not supported in serialized data.
+ */
+ public function testResourceThrowsException()
+ {
+ $this->context->expects($this->any())
+ ->method('getDirection')
+ ->will($this->returnValue(GraphNavigator::DIRECTION_SERIALIZATION));
+
+ $this->navigator->accept(STDIN, null, $this->context);
+ }
+
+ public function testNavigatorPassesInstanceOnSerialization()
+ {
+ $object = new SerializableClass;
+ $metadata = $this->metadataFactory->getMetadataForClass(get_class($object));
+
+ $self = $this;
+ $context = $this->context;
+ $exclusionStrategy = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock();
+ $exclusionStrategy->expects($this->once())
+ ->method('shouldSkipClass')
+ ->will($this->returnCallback(function ($passedMetadata, $passedContext) use ($metadata, $context, $self) {
+ $self->assertSame($metadata, $passedMetadata);
+ $self->assertSame($context, $passedContext);
+ }));
+ $exclusionStrategy->expects($this->once())
+ ->method('shouldSkipProperty')
+ ->will($this->returnCallback(function ($propertyMetadata, $passedContext) use ($context, $metadata, $self) {
+ $self->assertSame($metadata->propertyMetadata['foo'], $propertyMetadata);
+ $self->assertSame($context, $passedContext);
+ }));
+
+ $this->context->expects($this->once())
+ ->method('getExclusionStrategy')
+ ->will($this->returnValue($exclusionStrategy));
+
+ $this->context->expects($this->any())
+ ->method('getDirection')
+ ->will($this->returnValue(GraphNavigator::DIRECTION_SERIALIZATION));
+
+ $this->context->expects($this->any())
+ ->method('getVisitor')
+ ->will($this->returnValue($this->getMockBuilder('JMS\Serializer\VisitorInterface')->getMock()));
+
+ $this->navigator = new GraphNavigator($this->metadataFactory, $this->handlerRegistry, $this->objectConstructor, $this->dispatcher);
+ $this->navigator->accept($object, null, $this->context);
+ }
+
+ public function testNavigatorPassesNullOnDeserialization()
+ {
+ $class = __NAMESPACE__ . '\SerializableClass';
+ $metadata = $this->metadataFactory->getMetadataForClass($class);
+
+ $context = $this->context;
+ $exclusionStrategy = $this->getMockBuilder('JMS\Serializer\Exclusion\ExclusionStrategyInterface')->getMock();
+ $exclusionStrategy->expects($this->once())
+ ->method('shouldSkipClass')
+ ->with($metadata, $this->callback(function ($navigatorContext) use ($context) {
+ return $navigatorContext === $context;
+ }));
+
+ $exclusionStrategy->expects($this->once())
+ ->method('shouldSkipProperty')
+ ->with($metadata->propertyMetadata['foo'], $this->callback(function ($navigatorContext) use ($context) {
+ return $navigatorContext === $context;
+ }));
+
+ $this->context->expects($this->once())
+ ->method('getExclusionStrategy')
+ ->will($this->returnValue($exclusionStrategy));
+
+ $this->context->expects($this->any())
+ ->method('getDirection')
+ ->will($this->returnValue(GraphNavigator::DIRECTION_DESERIALIZATION));
+
+ $this->context->expects($this->any())
+ ->method('getVisitor')
+ ->will($this->returnValue($this->getMockBuilder('JMS\Serializer\VisitorInterface')->getMock()));
+
+ $this->navigator = new GraphNavigator($this->metadataFactory, $this->handlerRegistry, $this->objectConstructor, $this->dispatcher);
+ $this->navigator->accept('random', array('name' => $class, 'params' => array()), $this->context);
+ }
+
+ public function testNavigatorChangeTypeOnSerialization()
+ {
+ $object = new SerializableClass;
+ $typeName = 'JsonSerializable';
+
+ $this->dispatcher->addListener('serializer.pre_serialize', function ($event) use ($typeName) {
+ $type = $event->getType();
+ $type['name'] = $typeName;
+ $event->setType($type['name'], $type['params']);
+ });
+
+ $this->handlerRegistry->registerSubscribingHandler(new TestSubscribingHandler());
+
+ $this->context->expects($this->any())
+ ->method('getDirection')
+ ->will($this->returnValue(GraphNavigator::DIRECTION_SERIALIZATION));
+
+ $this->context->expects($this->any())
+ ->method('getVisitor')
+ ->will($this->returnValue($this->getMockBuilder('JMS\Serializer\VisitorInterface')->getMock()));
+
+ $this->navigator = new GraphNavigator($this->metadataFactory, $this->handlerRegistry, $this->objectConstructor, $this->dispatcher);
+ $this->navigator->accept($object, null, $this->context);
+ }
+
+ protected function setUp()
+ {
+ $this->context = $this->getMockBuilder('JMS\Serializer\Context')->getMock();
+ $this->dispatcher = new EventDispatcher();
+ $this->handlerRegistry = new HandlerRegistry();
+ $this->objectConstructor = new UnserializeObjectConstructor();
+
+ $this->metadataFactory = new MetadataFactory(new AnnotationDriver(new AnnotationReader()));
+ $this->navigator = new GraphNavigator($this->metadataFactory, $this->handlerRegistry, $this->objectConstructor, $this->dispatcher);
+ }
+}
+
+class SerializableClass
+{
+ public $foo = 'bar';
+}
+
+class TestSubscribingHandler implements SubscribingHandlerInterface
+{
+ public static function getSubscribingMethods()
+ {
+ return array(array(
+ 'type' => 'JsonSerializable',
+ 'format' => 'foo',
+ 'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
+ 'method' => 'serialize'
+ ));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use JMS\Serializer\Context;
+use JMS\Serializer\EventDispatcher\Event;
+use JMS\Serializer\EventDispatcher\EventSubscriberInterface;
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\Tests\Fixtures\Author;
+use JMS\Serializer\Tests\Fixtures\AuthorList;
+use JMS\Serializer\Tests\Fixtures\ObjectWithEmptyArrayAndHash;
+use JMS\Serializer\Tests\Fixtures\ObjectWithInlineArray;
+use JMS\Serializer\Tests\Fixtures\Tag;
+use JMS\Serializer\VisitorInterface;
+
+class JsonSerializationTest extends BaseSerializationTest
+{
+ protected function getContent($key)
+ {
+ static $outputs = array();
+
+ if (!$outputs) {
+ $outputs['readonly'] = '{"id":123,"full_name":"Ruud Kamphuis"}';
+ $outputs['string'] = '"foo"';
+ $outputs['boolean_true'] = 'true';
+ $outputs['boolean_false'] = 'false';
+ $outputs['integer'] = '1';
+ $outputs['float'] = '4.533';
+ $outputs['float_trailing_zero'] = '1';
+ $outputs['simple_object'] = '{"foo":"foo","moo":"bar","camel_case":"boo"}';
+ $outputs['circular_reference'] = '{"collection":[{"name":"child1"},{"name":"child2"}],"another_collection":[{"name":"child1"},{"name":"child2"}]}';
+ $outputs['array_strings'] = '["foo","bar"]';
+ $outputs['array_booleans'] = '[true,false]';
+ $outputs['array_integers'] = '[1,3,4]';
+ $outputs['array_empty'] = '{"array":[]}';
+ $outputs['array_floats'] = '[1.34,3,6.42]';
+ $outputs['array_objects'] = '[{"foo":"foo","moo":"bar","camel_case":"boo"},{"foo":"baz","moo":"boo","camel_case":"boo"}]';
+ $outputs['array_list_and_map_difference'] = '{"list":[1,2,3],"map":{"0":1,"2":2,"3":3}}';
+ $outputs['array_mixed'] = '["foo",1,true,{"foo":"foo","moo":"bar","camel_case":"boo"},[1,3,true]]';
+ $outputs['array_datetimes_object'] = '{"array_with_default_date_time":["2047-01-01T12:47:47+0000","2016-12-05T00:00:00+0000"],"array_with_formatted_date_time":["01.01.2047 12:47:47","05.12.2016 00:00:00"]}';
+ $outputs['array_named_datetimes_object'] = '{"named_array_with_formatted_date":{"testdate1":"01.01.2047 12:47:47","testdate2":"05.12.2016 00:00:00"}}';
+ $outputs['array_datetimes_object'] = '{"array_with_default_date_time":["2047-01-01T12:47:47+0000","2016-12-05T00:00:00+0000"],"array_with_formatted_date_time":["01.01.2047 12:47:47","05.12.2016 00:00:00"]}';
+ $outputs['array_named_datetimes_object'] = '{"named_array_with_formatted_date":{"testdate1":"01.01.2047 12:47:47","testdate2":"05.12.2016 00:00:00"}}';
+ $outputs['array_named_datetimeimmutables_object'] = '{"named_array_with_formatted_date":{"testdate1":"01.01.2047 12:47:47","testdate2":"05.12.2016 00:00:00"}}';
+ $outputs['blog_post'] = '{"id":"what_a_nice_id","title":"This is a nice title.","created_at":"2011-07-30T00:00:00+0000","is_published":false,"is_reviewed":false,"etag":"1edf9bf60a32d89afbb85b2be849e3ceed5f5b10","comments":[{"author":{"full_name":"Foo Bar"},"text":"foo"}],"comments2":[{"author":{"full_name":"Foo Bar"},"text":"foo"}],"metadata":{"foo":"bar"},"author":{"full_name":"Foo Bar"},"publisher":{"pub_name":"Bar Foo"},"tag":[{"name":"tag1"},{"name":"tag2"}]}';
+ $outputs['blog_post_unauthored'] = '{"id":"what_a_nice_id","title":"This is a nice title.","created_at":"2011-07-30T00:00:00+0000","is_published":false,"is_reviewed":false,"etag":"1edf9bf60a32d89afbb85b2be849e3ceed5f5b10","comments":[],"comments2":[],"metadata":{"foo":"bar"},"author":null,"publisher":null,"tag":null}';
+ $outputs['price'] = '{"price":3}';
+ $outputs['currency_aware_price'] = '{"currency":"EUR","amount":2.34}';
+ $outputs['order'] = '{"cost":{"price":12.34}}';
+ $outputs['order_with_currency_aware_price'] = '{"cost":{"currency":"EUR","amount":1.23}}';
+ $outputs['log'] = '{"author_list":[{"full_name":"Johannes Schmitt"},{"full_name":"John Doe"}],"comments":[{"author":{"full_name":"Foo Bar"},"text":"foo"},{"author":{"full_name":"Foo Bar"},"text":"bar"},{"author":{"full_name":"Foo Bar"},"text":"baz"}]}';
+ $outputs['lifecycle_callbacks'] = '{"name":"Foo Bar"}';
+ $outputs['form_errors'] = '["This is the form error","Another error"]';
+ $outputs['nested_form_errors'] = '{"errors":["This is the form error"],"children":{"bar":{"errors":["Error of the child form"]}}}';
+ $outputs['constraint_violation'] = '{"property_path":"foo","message":"Message of violation"}';
+ $outputs['constraint_violation_list'] = '[{"property_path":"foo","message":"Message of violation"},{"property_path":"bar","message":"Message of another violation"}]';
+ $outputs['article'] = '{"custom":"serialized"}';
+ $outputs['orm_proxy'] = '{"foo":"foo","moo":"bar","camel_case":"proxy-boo"}';
+ $outputs['custom_accessor'] = '{"comments":{"Foo":{"comments":[{"author":{"full_name":"Foo"},"text":"foo"},{"author":{"full_name":"Foo"},"text":"bar"}],"count":2}}}';
+ $outputs['mixed_access_types'] = '{"id":1,"name":"Johannes","read_only_property":42}';
+ $outputs['accessor_order_child'] = '{"c":"c","d":"d","a":"a","b":"b"}';
+ $outputs['accessor_order_parent'] = '{"a":"a","b":"b"}';
+ $outputs['accessor_order_methods'] = '{"foo":"c","b":"b","a":"a"}';
+ $outputs['inline'] = '{"c":"c","a":"a","b":"b","d":"d"}';
+ $outputs['inline_child_empty'] = '{"c":"c","d":"d"}';
+ $outputs['empty_child'] = '{"c":"c","d":"d","child":{}}';
+ $outputs['empty_child_skip'] = '{"c":"c","d":"d"}';
+ $outputs['groups_all'] = '{"foo":"foo","foobar":"foobar","bar":"bar","none":"none"}';
+ $outputs['groups_foo'] = '{"foo":"foo","foobar":"foobar"}';
+ $outputs['groups_foobar'] = '{"foo":"foo","foobar":"foobar","bar":"bar"}';
+ $outputs['groups_default'] = '{"bar":"bar","none":"none"}';
+ $outputs['groups_advanced'] = '{"name":"John","manager":{"name":"John Manager","friends":[{"nickname":"nickname"},{"nickname":"nickname"}]},"friends":[{"manager":{"name":"John friend 1 manager"}},{"manager":{"name":"John friend 2 manager"}}]}';
+ $outputs['virtual_properties'] = '{"exist_field":"value","virtual_value":"value","test":"other-name","typed_virtual_property":1}';
+ $outputs['virtual_properties_low'] = '{"low":1}';
+ $outputs['virtual_properties_high'] = '{"high":8}';
+ $outputs['virtual_properties_all'] = '{"low":1,"high":8}';
+ $outputs['nullable'] = '{"foo":"bar","baz":null,"0":null}';
+ $outputs['nullable_skip'] = '{"foo":"bar"}';
+ $outputs['person_secret_show'] = '{"name":"mike","gender":"f"}';
+ $outputs['person_secret_hide'] = '{"name":"mike"}';
+ $outputs['null'] = 'null';
+ $outputs['simple_object_nullable'] = '{"foo":"foo","moo":"bar","camel_case":"boo","null_property":null}';
+ $outputs['input'] = '{"attributes":{"type":"text","name":"firstname","value":"Adrien"}}';
+ $outputs['hash_empty'] = '{"hash":{}}';
+ $outputs['object_when_null'] = '{"text":"foo"}';
+ $outputs['object_when_null_and_serialized'] = '{"author":null,"text":"foo"}';
+ $outputs['date_time'] = '"2011-08-30T00:00:00+0000"';
+ $outputs['date_time_immutable'] = '"2011-08-30T00:00:00+0000"';
+ $outputs['timestamp'] = '{"timestamp":1455148800}';
+ $outputs['timestamp_prev'] = '{"timestamp":"1455148800"}';
+ $outputs['date_interval'] = '"PT45M"';
+ $outputs['car'] = '{"km":5,"type":"car"}';
+ $outputs['car_without_type'] = '{"km":5}';
+ $outputs['garage'] = '{"vehicles":[{"km":3,"type":"car"},{"km":1,"type":"moped"}]}';
+ $outputs['tree'] = '{"tree":{"children":[{"children":[{"children":[],"foo":"bar"}],"foo":"bar"}],"foo":"bar"}}';
+ $outputs['nullable_arrays'] = '{"empty_inline":[],"not_empty_inline":["not_empty_inline"],"empty_not_inline":[],"not_empty_not_inline":["not_empty_not_inline"],"empty_not_inline_skip":[],"not_empty_not_inline_skip":["not_empty_not_inline_skip"]}';
+ $outputs['object_with_object_property_no_array_to_author'] = '{"foo": "bar", "author": "baz"}';
+ $outputs['object_with_object_property'] = '{"foo": "bar", "author": {"full_name": "baz"}}';
+ $outputs['author_expression'] = '{"my_first_name":"Ruud","last_name":"Kamphuis","id":123}';
+ $outputs['maxdepth_skippabe_object'] = '{"a":{"xxx":"yyy"}}';
+ }
+
+ if (!isset($outputs[$key])) {
+ throw new RuntimeException(sprintf('The key "%s" is not supported.', $key));
+ }
+
+ return $outputs[$key];
+ }
+
+ public function testSkipEmptyArrayAndHash()
+ {
+ $object = new ObjectWithEmptyArrayAndHash();
+
+ $this->assertEquals('{}', $this->serialize($object));
+ }
+
+ public function testAddLinksToOutput()
+ {
+ $this->dispatcher->addListener('serializer.post_serialize', function (Event $event) {
+ $this->assertFalse($event->getVisitor()->hasData('_links'));
+ }, 'JMS\Serializer\Tests\Fixtures\Author', 'json');
+
+ $this->dispatcher->addSubscriber(new LinkAddingSubscriber());
+
+ $this->dispatcher->addListener('serializer.post_serialize', function (Event $event) {
+ $this->assertTrue($event->getVisitor()->hasData('_links'));
+ }, 'JMS\Serializer\Tests\Fixtures\Author', 'json');
+
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_SERIALIZATION, 'JMS\Serializer\Tests\Fixtures\AuthorList', 'json',
+ function (VisitorInterface $visitor, AuthorList $data, array $type, Context $context) {
+ return $visitor->visitArray(iterator_to_array($data), $type, $context);
+ }
+ );
+
+ $list = new AuthorList();
+ $list->add(new Author('foo'));
+ $list->add(new Author('bar'));
+
+ $this->assertEquals('[{"full_name":"foo","_links":{"details":"http:\/\/foo.bar\/details\/foo","comments":"http:\/\/foo.bar\/details\/foo\/comments"}},{"full_name":"bar","_links":{"details":"http:\/\/foo.bar\/details\/bar","comments":"http:\/\/foo.bar\/details\/bar\/comments"}}]', $this->serialize($list));
+ }
+
+ public function testReplaceNameInOutput()
+ {
+ $this->dispatcher->addSubscriber(new ReplaceNameSubscriber());
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_SERIALIZATION, 'JMS\Serializer\Tests\Fixtures\AuthorList', 'json',
+ function (VisitorInterface $visitor, AuthorList $data, array $type, Context $context) {
+ return $visitor->visitArray(iterator_to_array($data), $type, $context);
+ }
+ );
+
+ $list = new AuthorList();
+ $list->add(new Author('foo'));
+ $list->add(new Author('bar'));
+
+ $this->assertEquals('[{"full_name":"new name"},{"full_name":"new name"}]', $this->serialize($list));
+ }
+
+ /**
+ * @expectedException RuntimeException
+ * @expectedExceptionMessage Invalid data "baz"(string), expected "JMS\Serializer\Tests\Fixtures\Author".
+ */
+ public function testDeserializingObjectWithObjectPropertyWithNoArrayToObject()
+ {
+ $content = $this->getContent('object_with_object_property_no_array_to_author');
+ $object = $this->deserialize($content, 'JMS\Serializer\Tests\Fixtures\ObjectWithObjectProperty');
+ $this->assertEquals('bar', $object->getFoo());
+ $this->assertInstanceOf('JMS\Serializer\Tests\Fixtures\Author', $object->getAuthor());
+ }
+
+ public function testDeserializingObjectWithObjectProperty()
+ {
+ $content = $this->getContent('object_with_object_property');
+ $object = $this->deserialize($content, 'JMS\Serializer\Tests\Fixtures\ObjectWithObjectProperty');
+ $this->assertEquals('bar', $object->getFoo());
+ $this->assertInstanceOf('JMS\Serializer\Tests\Fixtures\Author', $object->getAuthor());
+ $this->assertEquals('baz', $object->getAuthor()->getName());
+ }
+
+ public function getPrimitiveTypes()
+ {
+ return array(
+ array(
+ 'type' => 'boolean',
+ 'data' => true,
+ ),
+ array(
+ 'type' => 'boolean',
+ 'data' => 1,
+ ),
+ array(
+ 'type' => 'integer',
+ 'data' => 123,
+ ),
+ array(
+ 'type' => 'integer',
+ 'data' => "123",
+ ),
+ array(
+ 'type' => 'string',
+ 'data' => "hello",
+ ),
+ array(
+ 'type' => 'string',
+ 'data' => 123,
+ ),
+ array(
+ 'type' => 'double',
+ 'data' => 0.1234,
+ ),
+ array(
+ 'type' => 'double',
+ 'data' => "0.1234",
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider getPrimitiveTypes
+ */
+ public function testPrimitiveTypes($primitiveType, $data)
+ {
+ $visitor = $this->serializationVisitors->get('json')->get();
+ $functionToCall = 'visit' . ucfirst($primitiveType);
+ $result = $visitor->$functionToCall($data, array(), $this->getMockBuilder('JMS\Serializer\Context')->getMock());
+ if ($primitiveType == 'double') {
+ $primitiveType = 'float';
+ }
+ $this->assertInternalType($primitiveType, $result);
+ }
+
+ /**
+ * @group empty-object
+ */
+ public function testSerializeEmptyObject()
+ {
+ $this->assertEquals('{}', $this->serialize(new Author(null)));
+ }
+
+ /**
+ * @group encoding
+ * @expectedException RuntimeException
+ * @expectedExceptionMessage Your data could not be encoded because it contains invalid UTF8 characters.
+ */
+ public function testSerializeWithNonUtf8EncodingWhenDisplayErrorsOff()
+ {
+ ini_set('display_errors', 1);
+ $this->serialize(array('foo' => 'bar', 'bar' => pack("H*", 'c32e')));
+ }
+
+ /**
+ * @group encoding
+ * @expectedException RuntimeException
+ * @expectedExceptionMessage Your data could not be encoded because it contains invalid UTF8 characters.
+ */
+ public function testSerializeWithNonUtf8EncodingWhenDisplayErrorsOn()
+ {
+ ini_set('display_errors', 0);
+ $this->serialize(array('foo' => 'bar', 'bar' => pack("H*", 'c32e')));
+ }
+
+ public function testSerializeArrayWithEmptyObject()
+ {
+ $this->assertEquals('[{}]', $this->serialize(array(new \stdClass())));
+ }
+
+ public function testInlineArray()
+ {
+ $object = new ObjectWithInlineArray(['a' => 'b', 'c' => 'd']);
+
+ $this->assertEquals('{"a":"b","c":"d"}', $this->serialize($object));
+ }
+
+ public function testSerializeRootArrayWithDefinedKeys()
+ {
+ $author1 = new Author("Jim");
+ $author2 = new Author("Mark");
+
+ $data = array(
+ 'jim' => $author1,
+ 'mark' => $author2,
+ );
+
+ $this->assertEquals('{"jim":{"full_name":"Jim"},"mark":{"full_name":"Mark"}}', $this->serializer->serialize($data, $this->getFormat(), SerializationContext::create()->setInitialType('array')));
+ $this->assertEquals('[{"full_name":"Jim"},{"full_name":"Mark"}]', $this->serializer->serialize($data, $this->getFormat(), SerializationContext::create()->setInitialType('array<JMS\Serializer\Tests\Fixtures\Author>')));
+ $this->assertEquals('{"jim":{"full_name":"Jim"},"mark":{"full_name":"Mark"}}', $this->serializer->serialize($data, $this->getFormat(), SerializationContext::create()->setInitialType('array<string,JMS\Serializer\Tests\Fixtures\Author>')));
+
+ $data = array(
+ $author1,
+ $author2,
+ );
+ $this->assertEquals('[{"full_name":"Jim"},{"full_name":"Mark"}]', $this->serializer->serialize($data, $this->getFormat(), SerializationContext::create()->setInitialType('array')));
+ $this->assertEquals('{"0":{"full_name":"Jim"},"1":{"full_name":"Mark"}}', $this->serializer->serialize($data, $this->getFormat(), SerializationContext::create()->setInitialType('array<int,JMS\Serializer\Tests\Fixtures\Author>')));
+ $this->assertEquals('{"0":{"full_name":"Jim"},"1":{"full_name":"Mark"}}', $this->serializer->serialize($data, $this->getFormat(), SerializationContext::create()->setInitialType('array<string,JMS\Serializer\Tests\Fixtures\Author>')));
+ }
+
+ public function getTypeHintedArrays()
+ {
+ return [
+
+ [[1, 2], '[1,2]', null],
+ [['a', 'b'], '["a","b"]', null],
+ [['a' => 'a', 'b' => 'b'], '{"a":"a","b":"b"}', null],
+
+ [[], '[]', null],
+ [[], '[]', SerializationContext::create()->setInitialType('array')],
+ [[], '[]', SerializationContext::create()->setInitialType('array<integer>')],
+ [[], '{}', SerializationContext::create()->setInitialType('array<string,integer>')],
+
+
+ [[1, 2], '[1,2]', SerializationContext::create()->setInitialType('array')],
+ [[1 => 1, 2 => 2], '{"1":1,"2":2}', SerializationContext::create()->setInitialType('array')],
+ [[1 => 1, 2 => 2], '[1,2]', SerializationContext::create()->setInitialType('array<integer>')],
+ [['a', 'b'], '["a","b"]', SerializationContext::create()->setInitialType('array<string>')],
+
+ [[1 => 'a', 2 => 'b'], '["a","b"]', SerializationContext::create()->setInitialType('array<string>')],
+ [['a' => 'a', 'b' => 'b'], '["a","b"]', SerializationContext::create()->setInitialType('array<string>')],
+
+
+ [[1, 2], '{"0":1,"1":2}', SerializationContext::create()->setInitialType('array<integer,integer>')],
+ [[1, 2], '{"0":1,"1":2}', SerializationContext::create()->setInitialType('array<string,integer>')],
+ [[1, 2], '{"0":"1","1":"2"}', SerializationContext::create()->setInitialType('array<string,string>')],
+
+
+ [['a', 'b'], '{"0":"a","1":"b"}', SerializationContext::create()->setInitialType('array<integer,string>')],
+ [['a' => 'a', 'b' => 'b'], '{"a":"a","b":"b"}', SerializationContext::create()->setInitialType('array<string,string>')],
+ ];
+ }
+
+ /**
+ * @dataProvider getTypeHintedArrays
+ * @param array $array
+ * @param string $expected
+ * @param SerializationContext|null $context
+ */
+ public function testTypeHintedArraySerialization(array $array, $expected, $context = null)
+ {
+ $this->assertEquals($expected, $this->serialize($array, $context));
+ }
+
+ public function getTypeHintedArraysAndStdClass()
+ {
+ $c1 = new \stdClass();
+ $c2 = new \stdClass();
+ $c2->foo = 'bar';
+
+ $tag = new Tag("tag");
+
+ $c3 = new \stdClass();
+ $c3->foo = $tag;
+
+ return [
+
+ [[$c1], '[{}]', SerializationContext::create()->setInitialType('array<stdClass>')],
+
+ [[$c2], '[{"foo":"bar"}]', SerializationContext::create()->setInitialType('array<stdClass>')],
+
+ [[$tag], '[{"name":"tag"}]', SerializationContext::create()->setInitialType('array<JMS\Serializer\Tests\Fixtures\Tag>')],
+
+ [[$c1], '{"0":{}}', SerializationContext::create()->setInitialType('array<integer,stdClass>')],
+ [[$c2], '{"0":{"foo":"bar"}}', SerializationContext::create()->setInitialType('array<integer,stdClass>')],
+
+ [[$c3], '{"0":{"foo":{"name":"tag"}}}', SerializationContext::create()->setInitialType('array<integer,stdClass>')],
+ [[$c3], '[{"foo":{"name":"tag"}}]', SerializationContext::create()->setInitialType('array<stdClass>')],
+
+ [[$tag], '{"0":{"name":"tag"}}', SerializationContext::create()->setInitialType('array<integer,JMS\Serializer\Tests\Fixtures\Tag>')],
+ ];
+ }
+
+ /**
+ * @dataProvider getTypeHintedArraysAndStdClass
+ * @param array $array
+ * @param string $expected
+ * @param SerializationContext|null $context
+ */
+ public function testTypeHintedArrayAndStdClassSerialization(array $array, $expected, $context = null)
+ {
+ $this->assertEquals($expected, $this->serialize($array, $context));
+ }
+
+ protected function getFormat()
+ {
+ return 'json';
+ }
+}
+
+class LinkAddingSubscriber implements EventSubscriberInterface
+{
+ public function onPostSerialize(Event $event)
+ {
+ $author = $event->getObject();
+
+ $event->getVisitor()->addData('_links', array(
+ 'details' => 'http://foo.bar/details/' . $author->getName(),
+ 'comments' => 'http://foo.bar/details/' . $author->getName() . '/comments',
+ ));
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return array(
+ array('event' => 'serializer.post_serialize', 'method' => 'onPostSerialize', 'format' => 'json', 'class' => 'JMS\Serializer\Tests\Fixtures\Author'),
+ );
+ }
+}
+
+class ReplaceNameSubscriber implements EventSubscriberInterface
+{
+ public function onPostSerialize(Event $event)
+ {
+ $event->getVisitor()->setData('full_name', 'new name');
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return array(
+ array('event' => 'serializer.post_serialize', 'method' => 'onPostSerialize', 'format' => 'json', 'class' => 'JMS\Serializer\Tests\Fixtures\Author'),
+ );
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer\Naming;
+
+use JMS\Serializer\Naming\IdenticalPropertyNamingStrategy;
+
+class IdenticalPropertyNamingStrategyTest extends \PHPUnit_Framework_TestCase
+{
+ public function providePropertyNames()
+ {
+ return array(
+ array('createdAt'),
+ array('my_field'),
+ array('identical')
+ );
+ }
+
+ /**
+ * @dataProvider providePropertyNames
+ */
+ public function testTranslateName($propertyName)
+ {
+ $mockProperty = $this->getMockBuilder('JMS\Serializer\Metadata\PropertyMetadata')->disableOriginalConstructor()->getMock();
+ $mockProperty->name = $propertyName;
+
+ $strategy = new IdenticalPropertyNamingStrategy();
+ $this->assertEquals($propertyName, $strategy->translateName($mockProperty));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2013 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use Doctrine\Common\Annotations\AnnotationReader;
+use JMS\Serializer\Construction\UnserializeObjectConstructor;
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\Handler\HandlerRegistry;
+use JMS\Serializer\JsonDeserializationVisitor;
+use JMS\Serializer\JsonSerializationVisitor;
+use JMS\Serializer\Metadata\Driver\AnnotationDriver;
+use JMS\Serializer\Naming\CamelCaseNamingStrategy;
+use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\Serializer;
+use Metadata\MetadataFactory;
+use PhpCollection\Map;
+
+class SerializationContextFactoryTest extends \PHPUnit_Framework_TestCase
+{
+ protected $serializer;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $namingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
+
+ $this->serializer = new Serializer(
+ new MetadataFactory(new AnnotationDriver(new AnnotationReader())),
+ new HandlerRegistry(),
+ new UnserializeObjectConstructor(),
+ new Map(array('json' => new JsonSerializationVisitor($namingStrategy))),
+ new Map(array('json' => new JsonDeserializationVisitor($namingStrategy)))
+ );
+ }
+
+ public function testSerializeUseProvidedSerializationContext()
+ {
+ $contextFactoryMock = $this->getMockForAbstractClass('JMS\\Serializer\\ContextFactory\\SerializationContextFactoryInterface');
+ $context = new SerializationContext();
+ $context->setSerializeNull(true);
+
+ $contextFactoryMock
+ ->expects($this->once())
+ ->method('createSerializationContext')
+ ->will($this->returnValue($context));
+
+ $this->serializer->setSerializationContextFactory($contextFactoryMock);
+
+ $result = $this->serializer->serialize(array('value' => null), 'json');
+
+ $this->assertEquals('{"value":null}', $result);
+ }
+
+ public function testDeserializeUseProvidedDeserializationContext()
+ {
+ $contextFactoryMock = $this->getMockForAbstractClass('JMS\\Serializer\\ContextFactory\\DeserializationContextFactoryInterface');
+ $context = new DeserializationContext();
+
+ $contextFactoryMock
+ ->expects($this->once())
+ ->method('createDeserializationContext')
+ ->will($this->returnValue($context));
+
+ $this->serializer->setDeserializationContextFactory($contextFactoryMock);
+
+ $result = $this->serializer->deserialize('{"value":null}', 'array', 'json');
+
+ $this->assertEquals(array('value' => null), $result);
+ }
+
+ public function testToArrayUseProvidedSerializationContext()
+ {
+ $contextFactoryMock = $this->getMockForAbstractClass('JMS\\Serializer\\ContextFactory\\SerializationContextFactoryInterface');
+ $context = new SerializationContext();
+ $context->setSerializeNull(true);
+
+ $contextFactoryMock
+ ->expects($this->once())
+ ->method('createSerializationContext')
+ ->will($this->returnValue($context));
+
+ $this->serializer->setSerializationContextFactory($contextFactoryMock);
+
+ $result = $this->serializer->toArray(array('value' => null));
+
+ $this->assertEquals(array('value' => null), $result);
+ }
+
+ public function testFromArrayUseProvidedDeserializationContext()
+ {
+ $contextFactoryMock = $this->getMockForAbstractClass('JMS\\Serializer\\ContextFactory\\DeserializationContextFactoryInterface');
+ $context = new DeserializationContext();
+
+ $contextFactoryMock
+ ->expects($this->once())
+ ->method('createDeserializationContext')
+ ->will($this->returnValue($context));
+
+ $this->serializer->setDeserializationContextFactory($contextFactoryMock);
+
+ $result = $this->serializer->fromArray(array('value' => null), 'array');
+
+ $this->assertEquals(array('value' => null), $result);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use JMS\Serializer\TypeParser;
+
+class TypeParserTest extends \PHPUnit_Framework_TestCase
+{
+ private $parser;
+
+ /**
+ * @dataProvider getTypes
+ */
+ public function testParse($type, $name, array $params = array())
+ {
+ $this->assertEquals(array('name' => $name, 'params' => $params), $this->parser->parse($type));
+ }
+
+ public function getTypes()
+ {
+ $types = array();
+ $types[] = array('string', 'string');
+ $types[] = array('array<Foo>', 'array', array(array('name' => 'Foo', 'params' => array())));
+ $types[] = array('array<Foo,Bar>', 'array', array(array('name' => 'Foo', 'params' => array()), array('name' => 'Bar', 'params' => array())));
+ $types[] = array('array<Foo\Bar, Baz\Boo>', 'array', array(array('name' => 'Foo\Bar', 'params' => array()), array('name' => 'Baz\Boo', 'params' => array())));
+ $types[] = array('a<b<c,d>,e>', 'a', array(array('name' => 'b', 'params' => array(array('name' => 'c', 'params' => array()), array('name' => 'd', 'params' => array()))), array('name' => 'e', 'params' => array())));
+ $types[] = array('Foo', 'Foo');
+ $types[] = array('Foo\Bar', 'Foo\Bar');
+ $types[] = array('Foo<"asdf asdf">', 'Foo', array('asdf asdf'));
+
+ return $types;
+ }
+
+ /**
+ * @expectedException \JMS\Parser\SyntaxErrorException
+ * @expectedExceptionMessage Expected T_CLOSE_BRACKET, but got end of input.
+ */
+ public function testParamTypeMustEndWithBracket()
+ {
+ $this->parser->parse('Foo<bar');
+ }
+
+ /**
+ * @expectedException \JMS\Parser\SyntaxErrorException
+ * @expectedExceptionMessage Expected T_NAME, but got "," of type T_COMMA at beginning of input.
+ */
+ public function testMustStartWithName()
+ {
+ $this->parser->parse(',');
+ }
+
+ /**
+ * @expectedException \JMS\Parser\SyntaxErrorException
+ * @expectedExceptionMessage Expected any of T_NAME or T_STRING, but got ">" of type T_CLOSE_BRACKET at position 4 (0-based).
+ */
+ public function testEmptyParams()
+ {
+ $this->parser->parse('Foo<>');
+ }
+
+ /**
+ * @expectedException \JMS\Parser\SyntaxErrorException
+ * @expectedExceptionMessage Expected any of T_NAME or T_STRING, but got ">" of type T_CLOSE_BRACKET at position 7 (0-based).
+ */
+ public function testNoTrailingComma()
+ {
+ $this->parser->parse('Foo<aa,>');
+ }
+
+ /**
+ * @expectedException \JMS\Parser\SyntaxErrorException
+ * @expectedExceptionMessage Expected any of T_NAME or T_STRING, but got "\" of type T_NONE at position 4 (0-based).
+ */
+ public function testLeadingBackslash()
+ {
+ $this->parser->parse('Foo<\Bar>');
+ }
+
+ protected function setUp()
+ {
+ $this->parser = new TypeParser();
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use JMS\Serializer\Construction\UnserializeObjectConstructor;
+use JMS\Serializer\Context;
+use JMS\Serializer\Exception\InvalidArgumentException;
+use JMS\Serializer\GraphNavigator;
+use JMS\Serializer\Handler\DateHandler;
+use JMS\Serializer\Handler\HandlerRegistry;
+use JMS\Serializer\Metadata\StaticPropertyMetadata;
+use JMS\Serializer\Naming\CamelCaseNamingStrategy;
+use JMS\Serializer\Naming\PropertyNamingStrategyInterface;
+use JMS\Serializer\Naming\SerializedNameAnnotationStrategy;
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\Serializer;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorChild;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlAttributeDiscriminatorParent;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorChild;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNamespaceDiscriminatorParent;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNotCDataDiscriminatorChild;
+use JMS\Serializer\Tests\Fixtures\Discriminator\ObjectWithXmlNotCDataDiscriminatorParent;
+use JMS\Serializer\Tests\Fixtures\Input;
+use JMS\Serializer\Tests\Fixtures\InvalidUsageOfXmlValue;
+use JMS\Serializer\Tests\Fixtures\ObjectWithNamespacesAndList;
+use JMS\Serializer\Tests\Fixtures\ObjectWithNamespacesAndNestedList;
+use JMS\Serializer\Tests\Fixtures\ObjectWithToString;
+use JMS\Serializer\Tests\Fixtures\ObjectWithVirtualXmlProperties;
+use JMS\Serializer\Tests\Fixtures\ObjectWithXmlKeyValuePairs;
+use JMS\Serializer\Tests\Fixtures\ObjectWithXmlKeyValuePairsWithObjectType;
+use JMS\Serializer\Tests\Fixtures\ObjectWithXmlKeyValuePairsWithType;
+use JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespaces;
+use JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespacesAndObjectProperty;
+use JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespacesAndObjectPropertyAuthor;
+use JMS\Serializer\Tests\Fixtures\ObjectWithXmlNamespacesAndObjectPropertyVirtual;
+use JMS\Serializer\Tests\Fixtures\ObjectWithXmlRootNamespace;
+use JMS\Serializer\Tests\Fixtures\Person;
+use JMS\Serializer\Tests\Fixtures\PersonCollection;
+use JMS\Serializer\Tests\Fixtures\PersonLocation;
+use JMS\Serializer\Tests\Fixtures\SimpleClassObject;
+use JMS\Serializer\Tests\Fixtures\SimpleObject;
+use JMS\Serializer\Tests\Fixtures\SimpleSubClassObject;
+use JMS\Serializer\XmlDeserializationVisitor;
+use JMS\Serializer\XmlSerializationVisitor;
+use PhpCollection\Map;
+
+class XmlSerializationTest extends BaseSerializationTest
+{
+ /**
+ * @expectedException JMS\Serializer\Exception\RuntimeException
+ */
+ public function testInvalidUsageOfXmlValue()
+ {
+ $obj = new InvalidUsageOfXmlValue();
+ $this->serialize($obj);
+ }
+
+
+ /**
+ * @dataProvider getXMLBooleans
+ */
+ public function testXMLBooleans($xmlBoolean, $boolean)
+ {
+ if ($this->hasDeserializer()) {
+ $this->assertSame($boolean, $this->deserialize('<result>' . $xmlBoolean . '</result>', 'boolean'));
+ }
+ }
+
+ public function getXMLBooleans()
+ {
+ return array(array('true', true), array('false', false), array('1', true), array('0', false));
+ }
+
+ public function testAccessorSetterDeserialization()
+ {
+ /** @var \JMS\Serializer\Tests\Fixtures\AccessorSetter $object */
+ $object = $this->deserialize('<?xml version="1.0"?>
+ <AccessorSetter>
+ <element attribute="attribute">element</element>
+ <collection>
+ <entry>collectionEntry</entry>
+ </collection>
+ </AccessorSetter>',
+ 'JMS\Serializer\Tests\Fixtures\AccessorSetter'
+ );
+
+ $this->assertInstanceOf('stdClass', $object->getElement());
+ $this->assertInstanceOf('JMS\Serializer\Tests\Fixtures\AccessorSetterElement', $object->getElement()->element);
+ $this->assertEquals('attribute-different', $object->getElement()->element->getAttribute());
+ $this->assertEquals('element-different', $object->getElement()->element->getElement());
+ $this->assertEquals(['collectionEntry' => 'collectionEntry'], $object->getCollection());
+ }
+
+ public function testPropertyIsObjectWithAttributeAndValue()
+ {
+ $personCollection = new PersonLocation;
+ $person = new Person;
+ $person->name = 'Matthias Noback';
+ $person->age = 28;
+ $personCollection->person = $person;
+ $personCollection->location = 'The Netherlands';
+
+ $this->assertEquals($this->getContent('person_location'), $this->serialize($personCollection));
+ }
+
+ public function testPropertyIsCollectionOfObjectsWithAttributeAndValue()
+ {
+ $personCollection = new PersonCollection;
+ $person = new Person;
+ $person->name = 'Matthias Noback';
+ $person->age = 28;
+ $personCollection->persons->add($person);
+ $personCollection->location = 'The Netherlands';
+
+ $this->assertEquals($this->getContent('person_collection'), $this->serialize($personCollection));
+ }
+
+ /**
+ * @expectedException JMS\Serializer\Exception\InvalidArgumentException
+ * @expectedExceptionMessage The document type "<!DOCTYPE author [<!ENTITY foo SYSTEM "php://filter/read=convert.base64-encode/resource=XmlSerializationTest.php">]>" is not allowed. If it is safe, you may add it to the whitelist configuration.
+ */
+ public function testExternalEntitiesAreDisabledByDefault()
+ {
+ $this->deserialize('<?xml version="1.0"?>
+ <!DOCTYPE author [
+ <!ENTITY foo SYSTEM "php://filter/read=convert.base64-encode/resource=' . basename(__FILE__) . '">
+ ]>
+ <result>
+ &foo;
+ </result>', 'stdClass');
+ }
+
+ /**
+ * @expectedException JMS\Serializer\Exception\InvalidArgumentException
+ * @expectedExceptionMessage The document type "<!DOCTYPE foo>" is not allowed. If it is safe, you may add it to the whitelist configuration.
+ */
+ public function testDocumentTypesAreNotAllowed()
+ {
+ $this->deserialize('<?xml version="1.0"?><!DOCTYPE foo><foo></foo>', 'stdClass');
+ }
+
+ public function testWhitelistedDocumentTypesAreAllowed()
+ {
+ $this->deserializationVisitors->get('xml')->get()->setDoctypeWhitelist(array(
+ '<!DOCTYPE authorized SYSTEM "http://authorized_url.dtd">',
+ '<!DOCTYPE author [<!ENTITY foo SYSTEM "php://filter/read=convert.base64-encode/resource=' . basename(__FILE__) . '">]>'));
+
+ $this->serializer->deserialize('<?xml version="1.0"?>
+ <!DOCTYPE authorized SYSTEM "http://authorized_url.dtd">
+ <foo></foo>', 'stdClass', 'xml');
+
+ $this->serializer->deserialize('<?xml version="1.0"?>
+ <!DOCTYPE author [
+ <!ENTITY foo SYSTEM "php://filter/read=convert.base64-encode/resource=' . basename(__FILE__) . '">
+ ]>
+ <foo></foo>', 'stdClass', 'xml');
+ }
+
+ public function testVirtualAttributes()
+ {
+ $this->assertEquals(
+ $this->getContent('virtual_attributes'),
+ $this->serialize(new ObjectWithVirtualXmlProperties(), SerializationContext::create()->setGroups(array('attributes')))
+ );
+ }
+
+ public function testVirtualValues()
+ {
+ $this->assertEquals(
+ $this->getContent('virtual_values'),
+ $this->serialize(new ObjectWithVirtualXmlProperties(), SerializationContext::create()->setGroups(array('values')))
+ );
+ }
+
+ public function testVirtualXmlList()
+ {
+ $this->assertEquals(
+ $this->getContent('virtual_properties_list'),
+ $this->serialize(new ObjectWithVirtualXmlProperties(), SerializationContext::create()->setGroups(array('list')))
+ );
+ }
+
+ public function testVirtualXmlMap()
+ {
+ $this->assertEquals(
+ $this->getContent('virtual_properties_map'),
+ $this->serialize(new ObjectWithVirtualXmlProperties(), SerializationContext::create()->setGroups(array('map')))
+ );
+ }
+
+ public function testUnserializeMissingArray()
+ {
+ $xml = '<result></result>';
+ $object = $this->serializer->deserialize($xml, 'JMS\Serializer\Tests\Fixtures\ObjectWithAbsentXmlListNode', 'xml');
+ $this->assertEquals($object->absentAndNs, array());
+
+ $xml = '<result xmlns:x="http://www.example.com">
+ <absent_and_ns>
+ <x:entry>foo</x:entry>
+ </absent_and_ns>
+ </result>';
+ $object = $this->serializer->deserialize($xml, 'JMS\Serializer\Tests\Fixtures\ObjectWithAbsentXmlListNode', 'xml');
+ $this->assertEquals($object->absentAndNs, array("foo"));
+ }
+
+ public function testObjectWithNamespacesAndList()
+ {
+ $object = new ObjectWithNamespacesAndList();
+ $object->name = 'name';
+ $object->nameAlternativeB = 'nameB';
+
+ $object->phones = array('111', '222');
+ $object->addresses = array('A' => 'Street 1', 'B' => 'Street 2');
+
+ $object->phonesAlternativeB = array('555', '666');
+ $object->addressesAlternativeB = array('A' => 'Street 5', 'B' => 'Street 6');
+
+ $object->phonesAlternativeC = array('777', '888');
+ $object->addressesAlternativeC = array('A' => 'Street 7', 'B' => 'Street 8');
+
+ $object->phonesAlternativeD = array('999', 'AAA');
+ $object->addressesAlternativeD = array('A' => 'Street 9', 'B' => 'Street A');
+
+ $this->assertEquals(
+ $this->getContent('object_with_namespaces_and_list'),
+ $this->serialize($object, SerializationContext::create())
+ );
+ $this->assertEquals(
+ $object,
+ $this->deserialize($this->getContent('object_with_namespaces_and_list'), get_class($object))
+ );
+ }
+
+ public function testObjectWithNamespaceAndNestedList()
+ {
+ $object = new ObjectWithNamespacesAndNestedList();
+ $personCollection = new PersonCollection();
+ $personA = new Person();
+ $personA->age = 11;
+ $personA->name = 'AAA';
+
+ $personB = new Person();
+ $personB->age = 22;
+ $personB->name = 'BBB';
+
+ $personCollection->persons->add($personA);
+ $personCollection->persons->add($personB);
+
+ $object->personCollection = $personCollection;
+
+ $this->assertEquals(
+ $this->getContent('object_with_namespaces_and_nested_list'),
+ $this->serialize($object, SerializationContext::create())
+ );
+ $this->assertEquals(
+ $object,
+ $this->deserialize($this->getContent('object_with_namespaces_and_nested_list'), get_class($object))
+ );
+ }
+
+ public function testArrayKeyValues()
+ {
+ $this->assertEquals($this->getContent('array_key_values'), $this->serializer->serialize(new ObjectWithXmlKeyValuePairs(), 'xml'));
+ }
+
+ public function testDeserializeArrayKeyValues()
+ {
+ $xml = $this->getContent('array_key_values_with_type_1');
+ $result = $this->serializer->deserialize($xml, ObjectWithXmlKeyValuePairsWithType::class, 'xml');
+
+ $this->assertInstanceOf(ObjectWithXmlKeyValuePairsWithType::class, $result);
+ $this->assertEquals(ObjectWithXmlKeyValuePairsWithType::create1(), $result);
+
+ $xml2 = $this->getContent('array_key_values_with_type_2');
+ $result2 = $this->serializer->deserialize($xml2, ObjectWithXmlKeyValuePairsWithType::class, 'xml');
+
+ $this->assertInstanceOf(ObjectWithXmlKeyValuePairsWithType::class, $result2);
+ $this->assertEquals(ObjectWithXmlKeyValuePairsWithType::create2(), $result2);
+ }
+
+ public function testDeserializeTypedAndNestedArrayKeyValues()
+ {
+ $xml = $this->getContent('array_key_values_with_nested_type');
+ $result = $this->serializer->deserialize($xml, ObjectWithXmlKeyValuePairsWithObjectType::class, 'xml');
+
+ $this->assertInstanceOf(ObjectWithXmlKeyValuePairsWithObjectType::class, $result);
+ $this->assertEquals(ObjectWithXmlKeyValuePairsWithObjectType::create1(), $result);
+ }
+
+ /**
+ * @dataProvider getDateTime
+ * @group datetime
+ */
+ public function testDateTimeNoCData($key, $value, $type)
+ {
+ $handlerRegistry = new HandlerRegistry();
+ $handlerRegistry->registerSubscribingHandler(new DateHandler(\DateTime::ISO8601, 'UTC', false));
+ $objectConstructor = new UnserializeObjectConstructor();
+
+ $serializer = new Serializer($this->factory, $handlerRegistry, $objectConstructor, $this->serializationVisitors, $this->deserializationVisitors);
+
+ $this->assertEquals($this->getContent($key . '_no_cdata'), $serializer->serialize($value, $this->getFormat()));
+ }
+
+ /**
+ * @dataProvider getDateTimeImmutable
+ * @group datetime
+ */
+ public function testDateTimeImmutableNoCData($key, $value, $type)
+ {
+ $handlerRegistry = new HandlerRegistry();
+ $handlerRegistry->registerSubscribingHandler(new DateHandler(\DateTime::ISO8601, 'UTC', false));
+ $objectConstructor = new UnserializeObjectConstructor();
+
+ $serializer = new Serializer($this->factory, $handlerRegistry, $objectConstructor, $this->serializationVisitors, $this->deserializationVisitors);
+
+ $this->assertEquals($this->getContent($key . '_no_cdata'), $serializer->serialize($value, $this->getFormat()));
+ }
+
+ /**
+ * @expectedException JMS\Serializer\Exception\RuntimeException
+ * @expectedExceptionMessage Unsupported value type for XML attribute map. Expected array but got object
+ */
+ public function testXmlAttributeMapWithoutArray()
+ {
+ $attributes = new \ArrayObject(array(
+ 'type' => 'text',
+ ));
+
+ $this->serializer->serialize(new Input($attributes), $this->getFormat());
+ }
+
+ public function testObjectWithOnlyNamespacesAndList()
+ {
+ $object = new ObjectWithNamespacesAndList();
+
+ $object->phones = array();
+ $object->addresses = array();
+
+ $object->phonesAlternativeB = array();
+ $object->addressesAlternativeB = array();
+
+ $object->phonesAlternativeC = array('777', '888');
+ $object->addressesAlternativeC = array('A' => 'Street 7', 'B' => 'Street 8');
+
+ $object->phonesAlternativeD = array();
+ $object->addressesAlternativeD = array();
+
+ $this->assertEquals(
+ $this->getContent('object_with_only_namespaces_and_list'),
+ $this->serialize($object, SerializationContext::create())
+ );
+
+ $deserialized = $this->deserialize($this->getContent('object_with_only_namespaces_and_list'), get_class($object));
+ $this->assertEquals($object, $deserialized);
+ }
+
+ public function testDeserializingNull()
+ {
+ $this->markTestSkipped('Not supported in XML.');
+ }
+
+ public function testDeserializeWithObjectWithToStringMethod()
+ {
+ $input = new ObjectWithToString($this->getContent('simple_object'));
+
+ $object = $this->deserialize($input, SimpleObject::class);
+
+ $this->assertInstanceOf(SimpleObject::class, $object);
+ }
+
+ public function testObjectWithXmlNamespaces()
+ {
+ $object = new ObjectWithXmlNamespaces('This is a nice title.', 'Foo Bar', new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), 'en');
+
+ $serialized = $this->serialize($object);
+ $this->assertEquals($this->getContent('object_with_xml_namespaces'), $this->serialize($object));
+
+ $xml = simplexml_load_string($this->serialize($object));
+ $xml->registerXPathNamespace('ns1', "http://purl.org/dc/elements/1.1/");
+ $xml->registerXPathNamespace('ns2', "http://schemas.google.com/g/2005");
+ $xml->registerXPathNamespace('ns3', "http://www.w3.org/2005/Atom");
+
+ $this->assertEquals('2011-07-30T00:00:00+0000', $this->xpathFirstToString($xml, './@created_at'));
+ $this->assertEquals('1edf9bf60a32d89afbb85b2be849e3ceed5f5b10', $this->xpathFirstToString($xml, './@ns2:etag'));
+ $this->assertEquals('en', $this->xpathFirstToString($xml, './@ns1:language'));
+ $this->assertEquals('This is a nice title.', $this->xpathFirstToString($xml, './ns1:title'));
+ $this->assertEquals('Foo Bar', $this->xpathFirstToString($xml, './ns3:author'));
+
+ $deserialized = $this->deserialize($this->getContent('object_with_xml_namespacesalias'), get_class($object));
+ $this->assertEquals('2011-07-30T00:00:00+0000', $this->getField($deserialized, 'createdAt')->format(\DateTime::ISO8601));
+ $this->assertAttributeEquals('This is a nice title.', 'title', $deserialized);
+ $this->assertAttributeSame('1edf9bf60a32d89afbb85b2be849e3ceed5f5b10', 'etag', $deserialized);
+ $this->assertAttributeSame('en', 'language', $deserialized);
+ $this->assertAttributeEquals('Foo Bar', 'author', $deserialized);
+
+ }
+
+ public function testObjectWithXmlNamespacesAndBackReferencedNamespaces()
+ {
+ $author = new ObjectWithXmlNamespacesAndObjectPropertyAuthor('mr', 'smith');
+ $object = new ObjectWithXmlNamespacesAndObjectProperty('This is a nice title.', $author);
+
+ $serialized = $this->serialize($object);
+ $this->assertEquals($this->getContent('object_with_xml_namespaces_and_object_property'), $serialized);
+ }
+
+ public function testObjectWithXmlNamespacesAndBackReferencedNamespacesWithListeners()
+ {
+ $author = new ObjectWithXmlNamespacesAndObjectPropertyAuthor('mr', 'smith');
+ $object = new ObjectWithXmlNamespacesAndObjectPropertyVirtual('This is a nice title.', new \stdClass());
+
+ $this->handlerRegistry->registerHandler(GraphNavigator::DIRECTION_SERIALIZATION, 'ObjectWithXmlNamespacesAndObjectPropertyAuthorVirtual', $this->getFormat(),
+ function (XmlSerializationVisitor $visitor, $data, $type, Context $context) use ($author) {
+ $factory = $context->getMetadataFactory(get_class($author));
+ $classMetadata = $factory->getMetadataForClass(get_class($author));
+
+ $metadata = new StaticPropertyMetadata(get_class($author), 'foo', $author);
+ $metadata->xmlNamespace = $classMetadata->xmlRootNamespace;
+ $metadata->xmlNamespace = $classMetadata->xmlRootNamespace;
+
+ $visitor->visitProperty($metadata, $author, $context);
+ }
+ );
+
+ $serialized = $this->serialize($object);
+ $this->assertEquals($this->getContent('object_with_xml_namespaces_and_object_property_virtual'), $serialized);
+ }
+
+ public function testObjectWithXmlRootNamespace()
+ {
+ $object = new ObjectWithXmlRootNamespace('This is a nice title.', 'Foo Bar', new \DateTime('2011-07-30 00:00', new \DateTimeZone('UTC')), 'en');
+ $this->assertEquals($this->getContent('object_with_xml_root_namespace'), $this->serialize($object));
+ }
+
+ public function testXmlNamespacesInheritance()
+ {
+ $object = new SimpleClassObject();
+ $object->foo = 'foo';
+ $object->bar = 'bar';
+ $object->moo = 'moo';
+
+ $this->assertEquals($this->getContent('simple_class_object'), $this->serialize($object));
+
+ $childObject = new SimpleSubClassObject();
+ $childObject->foo = 'foo';
+ $childObject->bar = 'bar';
+ $childObject->moo = 'moo';
+ $childObject->baz = 'baz';
+ $childObject->qux = 'qux';
+
+ $this->assertEquals($this->getContent('simple_subclass_object'), $this->serialize($childObject));
+ }
+
+ public function testWithoutFormatedOutputByXmlSerializationVisitor()
+ {
+ $namingStrategy = new SerializedNameAnnotationStrategy(new CamelCaseNamingStrategy());
+ $xmlVisitor = new XmlSerializationVisitor($namingStrategy);
+ $xmlVisitor->setFormatOutput(false);
+
+ $visitors = new Map(array(
+ 'xml' => new XmlSerializationVisitor($namingStrategy),
+ ));
+
+ $serializer = new Serializer(
+ $this->factory,
+ $this->handlerRegistry,
+ new UnserializeObjectConstructor(),
+ $visitors,
+ $this->deserializationVisitors,
+ $this->dispatcher
+ );
+
+ $object = new SimpleClassObject;
+ $object->foo = 'foo';
+ $object->bar = 'bar';
+ $object->moo = 'moo';
+
+ $stringXml = $serializer->serialize($object, $this->getFormat());
+ $this->assertXmlStringEqualsXmlString($this->getContent('simple_class_object_minified'), $stringXml);
+ }
+
+ public function testDiscriminatorAsXmlAttribute()
+ {
+ $xml = $this->serialize(new ObjectWithXmlAttributeDiscriminatorChild());
+ $this->assertEquals($this->getContent('xml_discriminator_attribute'), $xml);
+ $this->assertInstanceOf(
+ ObjectWithXmlAttributeDiscriminatorChild::class,
+ $this->deserialize(
+ $xml,
+ ObjectWithXmlAttributeDiscriminatorParent::class
+ )
+ );
+ }
+
+ public function testDiscriminatorAsNotCData()
+ {
+ $xml = $this->serialize(new ObjectWithXmlNotCDataDiscriminatorChild());
+ $this->assertEquals($this->getContent('xml_discriminator_not_cdata'), $xml);
+ $this->assertInstanceOf(
+ ObjectWithXmlNotCDataDiscriminatorChild::class,
+ $this->deserialize(
+ $xml,
+ ObjectWithXmlNotCDataDiscriminatorParent::class
+ )
+ );
+ }
+
+ public function testDiscriminatorWithNamespace()
+ {
+ $xml = $this->serialize(new ObjectWithXmlNamespaceDiscriminatorChild());
+ $this->assertEquals($this->getContent('xml_discriminator_namespace'), $xml);
+
+ $this->assertInstanceOf(
+ ObjectWithXmlNamespaceDiscriminatorChild::class,
+ $this->deserialize(
+ $xml,
+ ObjectWithXmlNamespaceDiscriminatorParent::class
+ )
+ );
+ }
+
+ /**
+ * @expectedException \JMS\Serializer\Exception\XmlErrorException
+ */
+ public function testDeserializeEmptyString()
+ {
+ $this->deserialize('', 'stdClass');
+ }
+
+ public function testEvaluatesToNull()
+ {
+ $namingStrategy = $this->getMockBuilder(PropertyNamingStrategyInterface::class)->getMock();
+ $visitor = new XmlDeserializationVisitor($namingStrategy);
+ $xsdNilAsTrueElement = simplexml_load_string('<empty xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>');
+ $xsdNilAsOneElement = simplexml_load_string('<empty xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="1"/>');
+
+ $this->assertTrue($visitor->isNull($xsdNilAsTrueElement));
+ $this->assertTrue($visitor->isNull($xsdNilAsOneElement));
+ $this->assertTrue($visitor->isNull(null));
+ }
+
+ private function xpathFirstToString(\SimpleXMLElement $xml, $xpath)
+ {
+ $nodes = $xml->xpath($xpath);
+ return (string)reset($nodes);
+ }
+
+ /**
+ * @param string $key
+ */
+ protected function getContent($key)
+ {
+ if (!file_exists($file = __DIR__ . '/xml/' . $key . '.xml')) {
+ throw new InvalidArgumentException(sprintf('The key "%s" is not supported.', $key));
+ }
+
+ return file_get_contents($file);
+ }
+
+ protected function getFormat()
+ {
+ return 'xml';
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Serializer;
+
+use JMS\Serializer\Exception\RuntimeException;
+use JMS\Serializer\SerializationContext;
+
+class YamlSerializationTest extends BaseSerializationTest
+{
+ public function testEmptyChild()
+ {
+ $this->markTestSkipped('This is not available for the YAML format.');
+ }
+
+ public function testSkipEmptyChild()
+ {
+ $this->markTestSkipped('This is not available for the YAML format.');
+ }
+
+ public function testConstraintViolation()
+ {
+ $this->markTestSkipped('This is not available for the YAML format.');
+ }
+
+ public function testConstraintViolationList()
+ {
+ $this->markTestSkipped('This is not available for the YAML format.');
+ }
+
+ public function testFormErrors()
+ {
+ $this->markTestSkipped('This is not available for the YAML format.');
+ }
+
+ public function testNestedFormErrors()
+ {
+ $this->markTestSkipped('This is not available for the YAML format.');
+ }
+
+ public function testFormErrorsWithNonFormComponents()
+ {
+ $this->markTestSkipped('This is not available for the YAML format.');
+ }
+
+ protected function getContent($key)
+ {
+ if (!file_exists($file = __DIR__ . '/yml/' . $key . '.yml')) {
+ throw new RuntimeException(sprintf('The content with key "%s" does not exist.', $key));
+ }
+
+ return file_get_contents($file);
+ }
+
+ public function getTypeHintedArrays()
+ {
+ return [
+
+ [[1, 2], "- 1\n- 2\n", null],
+ [['a', 'b'], "- a\n- b\n", null],
+ [['a' => 'a', 'b' => 'b'], "a: a\nb: b\n", null],
+
+ [[], " []\n", null],
+ [[], " []\n", SerializationContext::create()->setInitialType('array')],
+ [[], " []\n", SerializationContext::create()->setInitialType('array<integer>')],
+ [[], " {}\n", SerializationContext::create()->setInitialType('array<string,integer>')],
+
+
+ [[1, 2], "- 1\n- 2\n", SerializationContext::create()->setInitialType('array')],
+ [[1 => 1, 2 => 2], "1: 1\n2: 2\n", SerializationContext::create()->setInitialType('array')],
+ [[1 => 1, 2 => 2], "- 1\n- 2\n", SerializationContext::create()->setInitialType('array<integer>')],
+ [['a', 'b'], "- a\n- b\n", SerializationContext::create()->setInitialType('array<string>')],
+
+ [[1 => 'a', 2 => 'b'], "- a\n- b\n", SerializationContext::create()->setInitialType('array<string>')],
+ [['a' => 'a', 'b' => 'b'], "- a\n- b\n", SerializationContext::create()->setInitialType('array<string>')],
+
+
+ [[1, 2], "0: 1\n1: 2\n", SerializationContext::create()->setInitialType('array<integer,integer>')],
+ [[1, 2], "0: 1\n1: 2\n", SerializationContext::create()->setInitialType('array<string,integer>')],
+ [[1, 2], "0: 1\n1: 2\n", SerializationContext::create()->setInitialType('array<string,string>')],
+
+
+ [['a', 'b'], "0: a\n1: b\n", SerializationContext::create()->setInitialType('array<integer,string>')],
+ [['a' => 'a', 'b' => 'b'], "a: a\nb: b\n", SerializationContext::create()->setInitialType('array<string,string>')],
+ ];
+ }
+
+ /**
+ * @dataProvider getTypeHintedArrays
+ * @param array $array
+ * @param string $expected
+ * @param SerializationContext|null $context
+ */
+ public function testTypeHintedArraySerialization(array $array, $expected, $context = null)
+ {
+ $this->assertEquals($expected, $this->serialize($array, $context));
+ }
+
+
+ protected function getFormat()
+ {
+ return 'yml';
+ }
+
+ protected function hasDeserializer()
+ {
+ return false;
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <c><![CDATA[c]]></c>
+ <d><![CDATA[d]]></d>
+ <a><![CDATA[a]]></a>
+ <b><![CDATA[b]]></b>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <foo><![CDATA[c]]></foo>
+ <b><![CDATA[b]]></b>
+ <a><![CDATA[a]]></a>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <a><![CDATA[a]]></a>
+ <b><![CDATA[b]]></b>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <entry>true</entry>
+ <entry>false</entry>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <array_with_default_date_time>
+ <entry><![CDATA[2047-01-01T12:47:47+0000]]></entry>
+ <entry><![CDATA[2016-12-05T00:00:00+0000]]></entry>
+ </array_with_default_date_time>
+ <array_with_formatted_date_time>
+ <entry><![CDATA[01.01.2047 12:47:47]]></entry>
+ <entry><![CDATA[05.12.2016 00:00:00]]></entry>
+ </array_with_formatted_date_time>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <entry>1.34</entry>
+ <entry>3</entry>
+ <entry>6.42</entry>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <entry>1</entry>
+ <entry>3</entry>
+ <entry>4</entry>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <array>
+ <key-one><![CDATA[foo]]></key-one>
+ <key-two>1</key-two>
+ <nested-array>
+ <bar><![CDATA[foo]]></bar>
+ </nested-array>
+ <without-keys>
+ <entry>1</entry>
+ <entry><![CDATA[test]]></entry>
+ </without-keys>
+ <mixed>
+ <entry><![CDATA[test]]></entry>
+ <foo><![CDATA[bar]]></foo>
+ <entry><![CDATA[bar]]></entry>
+ </mixed>
+ <entry><![CDATA[foo]]></entry>
+ </array>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <list>
+ <key_first>
+ <list>
+ <key-one><![CDATA[foo]]></key-one>
+ <key-two><![CDATA[bar]]></key-two>
+ </list>
+ <list2></list2>
+ </key_first>
+ <key_second>
+ <list>
+ <key_01><![CDATA[One]]></key_01>
+ <key_02><![CDATA[Two]]></key_02>
+ <key_03><![CDATA[Three]]></key_03>
+ </list>
+ <list2>
+ <entry><![CDATA[Four]]></entry>
+ </list2>
+ </key_second>
+ </list>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <list>
+ <key-one><![CDATA[foo]]></key-one>
+ <key-two><![CDATA[bar]]></key-two>
+ </list>
+ <list2></list2>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <list>
+ <key_01><![CDATA[One]]></key_01>
+ <key_02><![CDATA[Two]]></key_02>
+ <key_03><![CDATA[Three]]></key_03>
+ </list>
+ <list2>
+ <entry><![CDATA[Four]]></entry>
+ </list2>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <list>
+ <entry>1</entry>
+ <entry>2</entry>
+ <entry>3</entry>
+ </list>
+ <map>
+ <entry _key="0">1</entry>
+ <entry _key="2">2</entry>
+ <entry _key="3">3</entry>
+ </map>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <entry><![CDATA[foo]]></entry>
+ <entry>1</entry>
+ <entry>true</entry>
+ <entry>
+ <foo><![CDATA[foo]]></foo>
+ <moo><![CDATA[bar]]></moo>
+ <camel_case><![CDATA[boo]]></camel_case>
+ </entry>
+ <entry>
+ <entry>1</entry>
+ <entry>3</entry>
+ <entry>true</entry>
+ </entry>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <named_array_with_formatted_date>
+ <testdate1><![CDATA[01.01.2047 12:47:47]]></testdate1>
+ <testdate2><![CDATA[05.12.2016 00:00:00]]></testdate2>
+ </named_array_with_formatted_date>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <named_array_with_formatted_date>
+ <testdate1><![CDATA[01.01.2047 12:47:47]]></testdate1>
+ <testdate2><![CDATA[05.12.2016 00:00:00]]></testdate2>
+ </named_array_with_formatted_date>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <entry>
+ <foo><![CDATA[foo]]></foo>
+ <moo><![CDATA[bar]]></moo>
+ <camel_case><![CDATA[boo]]></camel_case>
+ </entry>
+ <entry>
+ <foo><![CDATA[baz]]></foo>
+ <moo><![CDATA[boo]]></moo>
+ <camel_case><![CDATA[boo]]></camel_case>
+ </entry>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <entry><![CDATA[foo]]></entry>
+ <entry><![CDATA[bar]]></entry>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<custom>serialized</custom>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <my_first_name><![CDATA[Ruud]]></my_first_name>
+ <last_name><![CDATA[Kamphuis]]></last_name>
+ <id>123</id>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blog-post xmlns="http://example.com/namespace" xmlns:gd="http://schemas.google.com/g/2005" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" created_at="2011-07-30T00:00:00+0000" is_published="false" is_reviewed="false" gd:etag="1edf9bf60a32d89afbb85b2be849e3ceed5f5b10">
+ <id>what_a_nice_id</id>
+ <dc:title><![CDATA[This is a nice title.]]></dc:title>
+ <comment>
+ <author>
+ <full_name><![CDATA[Foo Bar]]></full_name>
+ </author>
+ <text><![CDATA[foo]]></text>
+ </comment>
+ <comment2>
+ <author>
+ <full_name><![CDATA[Foo Bar]]></full_name>
+ </author>
+ <text><![CDATA[foo]]></text>
+ </comment2>
+ <metadata>
+ <entry key="foo"><![CDATA[bar]]></entry>
+ </metadata>
+ <atom:author>
+ <full_name><![CDATA[Foo Bar]]></full_name>
+ </atom:author>
+ <publisher xmlns:ns2="http://example.com/namespace2">
+ <ns2:pub_name><![CDATA[Bar Foo]]></ns2:pub_name>
+ </publisher>
+ <dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <name>tag1</name>
+ </dc:tag>
+ <dc:tag xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <name>tag2</name>
+ </dc:tag>
+</blog-post>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<blog-post created_at="2011-07-30T00:00:00+0000" is_published="false" is_reviewed="false" gd:etag="1edf9bf60a32d89afbb85b2be849e3ceed5f5b10">
+ <title><![CDATA[This is a nice title.]]></title>
+ <author xsi:nil="true"/>
+</blog-post>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>false</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>true</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <km>5</km>
+ <type><![CDATA[car]]></type>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <km>5</km>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <collection>
+ <entry>
+ <name><![CDATA[child1]]></name>
+ </entry>
+ <entry>
+ <name><![CDATA[child2]]></name>
+ </entry>
+ </collection>
+ <another_collection>
+ <entry>
+ <name><![CDATA[child1]]></name>
+ </entry>
+ <entry>
+ <name><![CDATA[child2]]></name>
+ </entry>
+ </another_collection>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<violation property_path="foo">
+ <message><![CDATA[Message of violation]]></message>
+</violation>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <violation property_path="foo">
+ <message><![CDATA[Message of violation]]></message>
+ </violation>
+ <violation property_path="bar">
+ <message><![CDATA[Message of another violation]]></message>
+ </violation>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<price currency="EUR">2.34</price>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<post>
+ <comments author-name="Foo" count="2">
+ <comment>
+ <author>
+ <full_name><![CDATA[Foo]]></full_name>
+ </author>
+ <text><![CDATA[foo]]></text>
+ </comment>
+ <comment>
+ <author>
+ <full_name><![CDATA[Foo]]></full_name>
+ </author>
+ <text><![CDATA[bar]]></text>
+ </comment>
+ </comments>
+</post>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result><![CDATA[PT45M]]></result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result><![CDATA[2011-08-30T00:00:00+0000]]></result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result><![CDATA[2011-08-30T00:00:00+0000]]></result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>2011-08-30T00:00:00+0000</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>2011-08-30T00:00:00+0000</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <c><![CDATA[c]]></c>
+ <d><![CDATA[d]]></d>
+ <child/>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <c><![CDATA[c]]></c>
+ <d><![CDATA[d]]></d>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>4.533</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>1</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <entry><![CDATA[This is the form error]]></entry>
+ <entry><![CDATA[Another error]]></entry>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <vehicles>
+ <entry>
+ <km>3</km>
+ <type><![CDATA[car]]></type>
+ </entry>
+ <entry>
+ <km>1</km>
+ <type><![CDATA[moped]]></type>
+ </entry>
+ </vehicles>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <name><![CDATA[John]]></name>
+ <manager>
+ <name><![CDATA[John Manager]]></name>
+ <friends>
+ <entry>
+ <nickname><![CDATA[nickname]]></nickname>
+ </entry>
+ <entry>
+ <nickname><![CDATA[nickname]]></nickname>
+ </entry>
+ </friends>
+ </manager>
+ <friends>
+ <entry>
+ <manager>
+ <name><![CDATA[John friend 1 manager]]></name>
+ </manager>
+ </entry>
+ <entry>
+ <manager>
+ <name><![CDATA[John friend 2 manager]]></name>
+ </manager>
+ </entry>
+ </friends>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <foo><![CDATA[foo]]></foo>
+ <foobar><![CDATA[foobar]]></foobar>
+ <bar><![CDATA[bar]]></bar>
+ <none><![CDATA[none]]></none>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <bar><![CDATA[bar]]></bar>
+ <none><![CDATA[none]]></none>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <foo><![CDATA[foo]]></foo>
+ <foobar><![CDATA[foobar]]></foobar>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <foo><![CDATA[foo]]></foo>
+ <foobar><![CDATA[foobar]]></foobar>
+ <bar><![CDATA[bar]]></bar>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <hash/>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <c><![CDATA[c]]></c>
+ <a><![CDATA[a]]></a>
+ <b><![CDATA[b]]></b>
+ <d><![CDATA[d]]></d>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <c><![CDATA[c]]></c>
+ <d><![CDATA[d]]></d>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<input type="text" name="firstname" value="Adrien"/>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>1</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <name><![CDATA[Foo Bar]]></name>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<log>
+ <author_list>
+ <entry _key="0">
+ <full_name><![CDATA[Johannes Schmitt]]></full_name>
+ </entry>
+ <entry _key="1">
+ <full_name><![CDATA[John Doe]]></full_name>
+ </entry>
+ </author_list>
+ <comment>
+ <author>
+ <full_name><![CDATA[Foo Bar]]></full_name>
+ </author>
+ <text><![CDATA[foo]]></text>
+ </comment>
+ <comment>
+ <author>
+ <full_name><![CDATA[Foo Bar]]></full_name>
+ </author>
+ <text><![CDATA[bar]]></text>
+ </comment>
+ <comment>
+ <author>
+ <full_name><![CDATA[Foo Bar]]></full_name>
+ </author>
+ <text><![CDATA[baz]]></text>
+ </comment>
+</log>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <a>
+ <xxx><![CDATA[yyy]]></xxx>
+ </a>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <id>1</id>
+ <name><![CDATA[Johannes]]></name>
+ <read_only_property>42</read_only_property>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<form name="foo">
+ <errors>
+ <entry><![CDATA[This is the form error]]></entry>
+ </errors>
+ <form name="bar">
+ <errors>
+ <entry><![CDATA[Error of the child form]]></entry>
+ </errors>
+ </form>
+</form>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <entry><![CDATA[bar]]></entry>
+ <entry xsi:nil="true"/>
+ <entry xsi:nil="true"/>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <comment><![CDATA[not_empty_inline]]></comment>
+ <not_empty_not_inline>
+ <comment><![CDATA[not_empty_not_inline]]></comment>
+ </not_empty_not_inline>
+ <empty_not_inline_skip/>
+ <not_empty_not_inline_skip>
+ <comment><![CDATA[not_empty_not_inline_skip]]></comment>
+ </not_empty_not_inline_skip>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <entry><![CDATA[bar]]></entry>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <text><![CDATA[foo]]></text>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <author xsi:nil="true"/>
+ <text><![CDATA[foo]]></text>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ObjectWithNamespacesAndList xmlns="http://example.com/namespace" xmlns:x="http://example.com/namespace2">
+ <name><![CDATA[name]]></name>
+ <x:name><![CDATA[nameB]]></x:name>
+ <x:phones>
+ <x:phone><![CDATA[111]]></x:phone>
+ <x:phone><![CDATA[222]]></x:phone>
+ </x:phones>
+ <x:addresses>
+ <x:address id="A"><![CDATA[Street 1]]></x:address>
+ <x:address id="B"><![CDATA[Street 2]]></x:address>
+ </x:addresses>
+ <phone><![CDATA[555]]></phone>
+ <phone><![CDATA[666]]></phone>
+ <address id="A"><![CDATA[Street 5]]></address>
+ <address id="B"><![CDATA[Street 6]]></address>
+ <x:phone><![CDATA[777]]></x:phone>
+ <x:phone><![CDATA[888]]></x:phone>
+ <x:address id="A"><![CDATA[Street 7]]></x:address>
+ <x:address id="B"><![CDATA[Street 8]]></x:address>
+ <phones>
+ <phone><![CDATA[999]]></phone>
+ <phone><![CDATA[AAA]]></phone>
+ </phones>
+ <addresses>
+ <address id="A"><![CDATA[Street 9]]></address>
+ <address id="B"><![CDATA[Street A]]></address>
+ </addresses>
+</ObjectWithNamespacesAndList>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ObjectWithNamespacesAndNestedList xmlns="http://example.com/namespace" xmlns:x="http://example.com/namespace2">
+ <person_collection>
+ <person age="11">AAA</person>
+ <person age="22">BBB</person>
+ </person_collection>
+</ObjectWithNamespacesAndNestedList>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ObjectWithNamespacesAndList xmlns="http://example.com/namespace" xmlns:x="http://example.com/namespace2">
+ <x:phone><![CDATA[777]]></x:phone>
+ <x:phone><![CDATA[888]]></x:phone>
+ <x:address id="A"><![CDATA[Street 7]]></x:address>
+ <x:address id="B"><![CDATA[Street 8]]></x:address>
+</ObjectWithNamespacesAndList>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<test-object xmlns="http://example.com/namespace" xmlns:gd="http://schemas.google.com/g/2005" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:ns-fde543a0="http://purl.org/dc/elements/1.1/" created_at="2011-07-30T00:00:00+0000" gd:etag="1edf9bf60a32d89afbb85b2be849e3ceed5f5b10" ns-fde543a0:language="en">
+ <ns-fde543a0:title xmlns:ns-fde543a0="http://purl.org/dc/elements/1.1/"><![CDATA[This is a nice title.]]></ns-fde543a0:title>
+ <atom:author><![CDATA[Foo Bar]]></atom:author>
+</test-object>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<property:test-object xmlns:property="http://example.com/namespace-property">
+ <property:title><![CDATA[This is a nice title.]]></property:title>
+ <property:author xmlns="http://example.com/namespace-author">
+ <ns-ac3651ed:author xmlns:ns-ac3651ed="http://example.com/namespace-modified"><![CDATA[smith]]></ns-ac3651ed:author>
+ <info><![CDATA[hidden-info]]></info>
+ <property:name><![CDATA[mr]]></property:name>
+ </property:author>
+</property:test-object>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<property:test-object xmlns:property="http://example.com/namespace-property">
+ <property:title><![CDATA[This is a nice title.]]></property:title>
+ <property:author>
+ <foo xmlns="http://example.com/namespace-author">
+ <ns-ac3651ed:author xmlns:ns-ac3651ed="http://example.com/namespace-modified"><![CDATA[smith]]></ns-ac3651ed:author>
+ <info><![CDATA[hidden-info]]></info>
+ <property:name><![CDATA[mr]]></property:name>
+ </foo>
+ </property:author>
+</property:test-object>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<test-object xmlns="http://example.com/namespace" xmlns:name1="http://schemas.google.com/g/2005" xmlns:name2="http://www.w3.org/2005/Atom" xmlns:name3="http://purl.org/dc/elements/1.1/" created_at="2011-07-30T00:00:00+0000" name1:etag="1edf9bf60a32d89afbb85b2be849e3ceed5f5b10" name3:language="en">
+ <name3:title><![CDATA[This is a nice title.]]></name3:title>
+ <name2:author><![CDATA[Foo Bar]]></name2:author>
+</test-object>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<test-object xmlns="http://example.com/namespace" created_at="2011-07-30T00:00:00+0000" etag="1edf9bf60a32d89afbb85b2be849e3ceed5f5b10" language="en">
+ <title><![CDATA[This is a nice title.]]></title>
+ <author><![CDATA[Foo Bar]]></author>
+</test-object>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<order>
+ <cost>12.34</cost>
+</order>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<order>
+ <cost currency="EUR">1.23</cost>
+</order>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <foo><![CDATA[foo]]></foo>
+ <moo><![CDATA[bar]]></moo>
+ <camel_case><![CDATA[proxy-boo]]></camel_case>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<person_collection>
+ <person age="28">Matthias Noback</person>
+ <location><![CDATA[The Netherlands]]></location>
+</person_collection>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<person_location>
+ <person age="28">Matthias Noback</person>
+ <location><![CDATA[The Netherlands]]></location>
+</person_location>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <name><![CDATA[mike]]></name>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <name><![CDATA[mike]]></name>
+ <gender><![CDATA[f]]></gender>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<price>3</price>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<author>
+ <id>123</id>
+ <full_name><![CDATA[Ruud Kamphuis]]></full_name>
+</author>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result xmlns:old_foo="http://old.foo.example.org" xmlns:foo="http://foo.example.org" xmlns:new_foo="http://new.foo.example.org" old_foo:foo="foo">
+ <foo:bar><![CDATA[bar]]></foo:bar>
+ <new_foo:moo><![CDATA[moo]]></new_foo:moo>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result xmlns:old_foo="http://old.foo.example.org" xmlns:foo="http://foo.example.org" xmlns:new_foo="http://new.foo.example.org" old_foo:foo="foo"><foo:bar><![CDATA[bar]]></foo:bar><new_foo:moo><![CDATA[moo]]></new_foo:moo></result>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <foo><![CDATA[foo]]></foo>
+ <moo><![CDATA[bar]]></moo>
+ <camel_case><![CDATA[boo]]></camel_case>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <foo><![CDATA[foo]]></foo>
+ <moo><![CDATA[bar]]></moo>
+ <camel_case><![CDATA[boo]]></camel_case>
+ <null_property xsi:nil="true"/>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result xmlns:old_foo="http://foo.example.org" xmlns:foo="http://better.foo.example.org" xmlns:new_foo="http://new.foo.example.org" xmlns:ns-8ae021a9="http://old.foo.example.org" ns-8ae021a9:foo="foo">
+ <old_foo:bar><![CDATA[bar]]></old_foo:bar>
+ <foo:moo><![CDATA[moo]]></foo:moo>
+ <old_foo:baz><![CDATA[baz]]></old_foo:baz>
+ <new_foo:qux><![CDATA[qux]]></new_foo:qux>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result><![CDATA[foo]]></result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <timestamp>1455148800</timestamp>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <timestamp>1455148800</timestamp>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <tree>
+ <children>
+ <entry>
+ <children>
+ <entry>
+ <children>
+ <entry/>
+ </children>
+ <foo><![CDATA[bar]]></foo>
+ </entry>
+ </children>
+ <foo><![CDATA[bar]]></foo>
+ </entry>
+ </children>
+ <foo><![CDATA[bar]]></foo>
+ </tree>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result foo="bar"/>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <exist_field><![CDATA[value]]></exist_field>
+ <virtual_value><![CDATA[value]]></virtual_value>
+ <test><![CDATA[other-name]]></test>
+ <typed_virtual_property>1</typed_virtual_property>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <low>1</low>
+ <high>8</high>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <high>8</high>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <val><![CDATA[One]]></val>
+ <val><![CDATA[Two]]></val>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <low>1</low>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <map>
+ <entry key="key-one"><![CDATA[One]]></entry>
+ <entry key="key-two"><![CDATA[Two]]></entry>
+ </map>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result><![CDATA[xml-value]]></result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result type="child"/>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result xmlns:foo="http://example.com/">
+ <foo:type>child</foo:type>
+</result>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<result>
+ <type>child</type>
+</result>
--- /dev/null
+c: c
+d: d
+a: a
+b: b
--- /dev/null
+foo: c
+b: b
+a: a
--- /dev/null
+a: a
+b: b
--- /dev/null
+- true
+- false
--- /dev/null
+array_with_default_date_time:
+ - '2047-01-01T12:47:47+0000'
+ - '2016-12-05T00:00:00+0000'
+array_with_formatted_date_time:
+ - '01.01.2047 12:47:47'
+ - '05.12.2016 00:00:00'
--- /dev/null
+- 1.34
+- 3
+- 6.42
--- /dev/null
+- 1
+- 3
+- 4
--- /dev/null
+list:
+ - 1
+ - 2
+ - 3
+map:
+ 0: 1
+ 2: 2
+ 3: 3
--- /dev/null
+- foo
+- 1
+- true
+-
+ foo: foo
+ moo: bar
+ camel_case: boo
+-
+ - 1
+ - 3
+ - true
--- /dev/null
+named_array_with_formatted_date:
+ testdate1: '01.01.2047 12:47:47'
+ testdate2: '05.12.2016 00:00:00'
--- /dev/null
+named_array_with_formatted_date:
+ testdate1: '01.01.2047 12:47:47'
+ testdate2: '05.12.2016 00:00:00'
--- /dev/null
+-
+ foo: foo
+ moo: bar
+ camel_case: boo
+-
+ foo: baz
+ moo: boo
+ camel_case: boo
--- /dev/null
+- foo
+- bar
--- /dev/null
+custom: serialized
--- /dev/null
+my_first_name: Ruud
+last_name: Kamphuis
+id: 123
--- /dev/null
+id: what_a_nice_id
+title: 'This is a nice title.'
+created_at: '2011-07-30T00:00:00+0000'
+is_published: false
+is_reviewed: false
+etag: 1edf9bf60a32d89afbb85b2be849e3ceed5f5b10
+comments:
+ -
+ author:
+ full_name: 'Foo Bar'
+ text: foo
+comments2:
+ -
+ author:
+ full_name: 'Foo Bar'
+ text: foo
+metadata:
+ foo: bar
+author:
+ full_name: 'Foo Bar'
+publisher:
+ pub_name: 'Bar Foo'
+tag:
+ -
+ name: tag1
+ -
+ name: tag2
--- /dev/null
+id: what_a_nice_id
+title: 'This is a nice title.'
+created_at: '2011-07-30T00:00:00+0000'
+is_published: false
+is_reviewed: false
+etag: 1edf9bf60a32d89afbb85b2be849e3ceed5f5b10
+comments: []
+comments2: []
+metadata:
+ foo: bar
+author: null
+publisher: null
+tag: null
--- /dev/null
+km: 5
+type: car
--- /dev/null
+collection:
+ -
+ name: child1
+ -
+ name: child2
+another_collection:
+ -
+ name: child1
+ -
+ name: child2
--- /dev/null
+currency: EUR
+amount: 2.34
--- /dev/null
+comments:
+ Foo:
+ comments:
+ -
+ author:
+ full_name: Foo
+ text: foo
+ -
+ author:
+ full_name: Foo
+ text: bar
+ count: 2
--- /dev/null
+'2011-08-30T00:00:00+0000'
--- /dev/null
+'2011-08-30T00:00:00+0000'
--- /dev/null
+vehicles:
+ -
+ km: 3
+ type: car
+ -
+ km: 1
+ type: moped
--- /dev/null
+name: John
+manager:
+ name: 'John Manager'
+ friends:
+ -
+ nickname: nickname
+ -
+ nickname: nickname
+friends:
+ -
+ manager:
+ name: 'John friend 1 manager'
+ -
+ manager:
+ name: 'John friend 2 manager'
--- /dev/null
+foo: foo
+foobar: foobar
+bar: bar
+none: none
--- /dev/null
+bar: bar
+none: none
--- /dev/null
+foo: foo
+foobar: foobar
--- /dev/null
+foo: foo
+foobar: foobar
+bar: bar
--- /dev/null
+c: c
+a: a
+b: b
+d: d
--- /dev/null
+c: c
+d: d
--- /dev/null
+attributes:
+ type: text
+ name: firstname
+ value: Adrien
--- /dev/null
+name: 'Foo Bar'
--- /dev/null
+author_list:
+ -
+ full_name: 'Johannes Schmitt'
+ -
+ full_name: 'John Doe'
+comments:
+ -
+ author:
+ full_name: 'Foo Bar'
+ text: foo
+ -
+ author:
+ full_name: 'Foo Bar'
+ text: bar
+ -
+ author:
+ full_name: 'Foo Bar'
+ text: baz
--- /dev/null
+a:
+ xxx: yyy
--- /dev/null
+id: 1
+name: Johannes
+read_only_property: 42
--- /dev/null
+foo: bar
+baz: null
+0: null
--- /dev/null
+empty_inline: []
+not_empty_inline:
+ - not_empty_inline
+empty_not_inline: []
+not_empty_not_inline:
+ - not_empty_not_inline
+empty_not_inline_skip: []
+not_empty_not_inline_skip:
+ - not_empty_not_inline_skip
--- /dev/null
+author: null
+text: foo
--- /dev/null
+cost:
+ price: 12.34
--- /dev/null
+cost:
+ currency: EUR
+ amount: 1.23
--- /dev/null
+foo: foo
+moo: bar
+camel_case: proxy-boo
--- /dev/null
+name: mike
--- /dev/null
+name: mike
+gender: f
--- /dev/null
+id: 123
+full_name: 'Ruud Kamphuis'
--- /dev/null
+foo: foo
+moo: bar
+camel_case: boo
--- /dev/null
+foo: foo
+moo: bar
+camel_case: boo
+null_property: null
--- /dev/null
+timestamp: 1455148800
--- /dev/null
+timestamp: "1455148800"
--- /dev/null
+tree:
+ children:
+ -
+ children:
+ -
+ children:
+ -
+ foo: bar
+ foo: bar
+ foo: bar
--- /dev/null
+exist_field: value
+virtual_value: value
+test: other-name
+typed_virtual_property: 1
--- /dev/null
+low: 1
+high: 8
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests;
+
+use JMS\Serializer\DeserializationContext;
+use JMS\Serializer\Expression\ExpressionEvaluator;
+use JMS\Serializer\Handler\HandlerRegistry;
+use JMS\Serializer\JsonSerializationVisitor;
+use JMS\Serializer\Naming\CamelCaseNamingStrategy;
+use JMS\Serializer\SerializationContext;
+use JMS\Serializer\SerializerBuilder;
+use JMS\Serializer\Tests\Fixtures\ContextualNamingStrategy;
+use JMS\Serializer\Tests\Fixtures\Person;
+use JMS\Serializer\Tests\Fixtures\PersonSecret;
+use JMS\Serializer\Tests\Fixtures\PersonSecretWithVariables;
+use Symfony\Component\ExpressionLanguage\ExpressionFunction;
+use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
+use Symfony\Component\Filesystem\Filesystem;
+
+class SerializerBuilderTest extends \PHPUnit_Framework_TestCase
+{
+ /** @var SerializerBuilder */
+ private $builder;
+ private $fs;
+ private $tmpDir;
+
+ public function testBuildWithoutAnythingElse()
+ {
+ $serializer = $this->builder->build();
+
+ $this->assertEquals('"foo"', $serializer->serialize('foo', 'json'));
+ $this->assertEquals('<?xml version="1.0" encoding="UTF-8"?>
+<result><![CDATA[foo]]></result>
+', $serializer->serialize('foo', 'xml'));
+ $this->assertEquals('foo
+', $serializer->serialize('foo', 'yml'));
+
+ $this->assertEquals('foo', $serializer->deserialize('"foo"', 'string', 'json'));
+ $this->assertEquals('foo', $serializer->deserialize('<?xml version="1.0" encoding="UTF-8"?><result><![CDATA[foo]]></result>', 'string', 'xml'));
+ }
+
+ public function testWithCache()
+ {
+ $this->assertFileNotExists($this->tmpDir);
+
+ $this->assertSame($this->builder, $this->builder->setCacheDir($this->tmpDir));
+ $serializer = $this->builder->build();
+
+ $this->assertFileExists($this->tmpDir);
+ $this->assertFileExists($this->tmpDir . '/annotations');
+ $this->assertFileExists($this->tmpDir . '/metadata');
+
+ $factory = $this->getField($serializer, 'factory');
+ $this->assertAttributeSame(false, 'debug', $factory);
+ $this->assertAttributeNotSame(null, 'cache', $factory);
+ }
+
+ public function testDoesAddDefaultHandlers()
+ {
+ $serializer = $this->builder->build();
+
+ $this->assertEquals('"2020-04-16T00:00:00+0000"', $serializer->serialize(new \DateTime('2020-04-16', new \DateTimeZone('UTC')), 'json'));
+ }
+
+ public function testDoesNotAddDefaultHandlersWhenExplicitlyConfigured()
+ {
+ $this->assertSame($this->builder, $this->builder->configureHandlers(function (HandlerRegistry $registry) {
+ }));
+
+ $this->assertEquals('{}', $this->builder->build()->serialize(new \DateTime('2020-04-16'), 'json'));
+ }
+
+ /**
+ * @expectedException JMS\Serializer\Exception\UnsupportedFormatException
+ * @expectedExceptionMessage The format "xml" is not supported for serialization.
+ */
+ public function testDoesNotAddOtherVisitorsWhenConfiguredExplicitly()
+ {
+ $this->assertSame(
+ $this->builder,
+ $this->builder->setSerializationVisitor('json', new JsonSerializationVisitor(new CamelCaseNamingStrategy()))
+ );
+
+ $this->builder->build()->serialize('foo', 'xml');
+ }
+
+ public function testIncludeInterfaceMetadata()
+ {
+ $this->assertFalse(
+ $this->getIncludeInterfaces($this->builder),
+ 'Interface metadata are not included by default'
+ );
+
+ $this->assertTrue(
+ $this->getIncludeInterfaces($this->builder->includeInterfaceMetadata(true)),
+ 'Force including interface metadata'
+ );
+
+ $this->assertFalse(
+ $this->getIncludeInterfaces($this->builder->includeInterfaceMetadata(false)),
+ 'Force not including interface metadata'
+ );
+
+ $this->assertSame(
+ $this->builder,
+ $this->builder->includeInterfaceMetadata(true)
+ );
+ }
+
+ public function testSetSerializationContext()
+ {
+ $contextFactoryMock = $this->getMockForAbstractClass('JMS\\Serializer\\ContextFactory\\SerializationContextFactoryInterface');
+ $context = new SerializationContext();
+ $context->setSerializeNull(true);
+
+ $contextFactoryMock
+ ->expects($this->once())
+ ->method('createSerializationContext')
+ ->will($this->returnValue($context));
+
+ $this->builder->setSerializationContextFactory($contextFactoryMock);
+
+ $serializer = $this->builder->build();
+
+ $result = $serializer->serialize(array('value' => null), 'json');
+
+ $this->assertEquals('{"value":null}', $result);
+ }
+
+ public function testSetDeserializationContext()
+ {
+ $contextFactoryMock = $this->getMockForAbstractClass('JMS\\Serializer\\ContextFactory\\DeserializationContextFactoryInterface');
+ $context = new DeserializationContext();
+
+ $contextFactoryMock
+ ->expects($this->once())
+ ->method('createDeserializationContext')
+ ->will($this->returnValue($context));
+
+ $this->builder->setDeserializationContextFactory($contextFactoryMock);
+
+ $serializer = $this->builder->build();
+
+ $result = $serializer->deserialize('{"value":null}', 'array', 'json');
+
+ $this->assertEquals(array('value' => null), $result);
+ }
+
+ public function testSetCallbackSerializationContextWithSerializeNull()
+ {
+ $this->builder->setSerializationContextFactory(function () {
+ return SerializationContext::create()
+ ->setSerializeNull(true);
+ });
+
+ $serializer = $this->builder->build();
+
+ $result = $serializer->serialize(array('value' => null), 'json');
+
+ $this->assertEquals('{"value":null}', $result);
+ }
+
+ public function testSetCallbackSerializationContextWithNotSerializeNull()
+ {
+ $this->builder->setSerializationContextFactory(function () {
+ return SerializationContext::create()
+ ->setSerializeNull(false);
+ });
+
+ $serializer = $this->builder->build();
+
+ $result = $serializer->serialize(array('value' => null, 'not_null' => 'ok'), 'json');
+
+ $this->assertEquals('{"not_null":"ok"}', $result);
+ }
+
+ public function expressionFunctionProvider()
+ {
+ return [
+ [
+ new ExpressionFunction('show_data', function () {
+ return "true";
+ }, function () {
+ return true;
+ }),
+ '{"name":"mike"}'
+ ],
+ [
+ new ExpressionFunction('show_data', function () {
+ return "false";
+ }, function () {
+ return false;
+ }),
+ '{"name":"mike","gender":"f"}'
+ ]
+ ];
+ }
+
+ /**
+ * @dataProvider expressionFunctionProvider
+ * @param ExpressionFunction $function
+ * @param $json
+ */
+ public function testExpressionEngine(ExpressionFunction $function, $json)
+ {
+ $language = new ExpressionLanguage();
+ $language->addFunction($function);
+
+ $this->builder->setExpressionEvaluator(new ExpressionEvaluator($language));
+
+ $serializer = $this->builder->build();
+
+ $person = new PersonSecret();
+ $person->gender = 'f';
+ $person->name = 'mike';
+
+ $this->assertEquals($json, $serializer->serialize($person, 'json'));
+ }
+
+ public function testExpressionEngineWhenDeserializing()
+ {
+ $language = new ExpressionLanguage();
+ $this->builder->setExpressionEvaluator(new ExpressionEvaluator($language));
+
+ $serializer = $this->builder->build();
+
+ $person = new PersonSecretWithVariables();
+ $person->gender = 'f';
+ $person->name = 'mike';
+
+ $serialized = $serializer->serialize($person, 'json');
+ $this->assertEquals('{"name":"mike","gender":"f"}', $serialized);
+
+ $object = $serializer->deserialize($serialized, PersonSecretWithVariables::class, 'json');
+ $this->assertEquals($person, $object);
+ }
+
+ public function testAdvancedNamingStrategy()
+ {
+ $this->builder->setAdvancedNamingStrategy(new ContextualNamingStrategy());
+ $serializer = $this->builder->build();
+
+ $person = new Person();
+ $person->name = "bar";
+
+ $json = $serializer->serialize($person, "json");
+ $this->assertEquals('{"NAME":"bar"}', $json);
+
+ $json = '{"Name": "bar"}';
+ $person = $serializer->deserialize($json, Person::class, "json");
+ $this->assertEquals("bar", $person->name);
+ }
+
+ protected function setUp()
+ {
+ $this->builder = SerializerBuilder::create();
+ $this->fs = new Filesystem();
+
+ $this->tmpDir = sys_get_temp_dir() . '/serializer';
+ $this->fs->remove($this->tmpDir);
+ clearstatcache();
+ }
+
+ protected function tearDown()
+ {
+ $this->fs->remove($this->tmpDir);
+ }
+
+ private function getField($obj, $name)
+ {
+ $ref = new \ReflectionProperty($obj, $name);
+ $ref->setAccessible(true);
+
+ return $ref->getValue($obj);
+ }
+
+ private function getIncludeInterfaces(SerializerBuilder $builder)
+ {
+ $factory = $this->getField($builder->build(), 'factory');
+
+ return $this->getField($factory, 'includeInterfaces');
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2016 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace JMS\Serializer\Tests\Twig;
+
+use JMS\Serializer\Twig\SerializerExtension;
+use JMS\Serializer\Twig\SerializerRuntimeExtension;
+use JMS\Serializer\Twig\SerializerRuntimeHelper;
+
+class SerializerExtensionTest extends \PHPUnit_Framework_TestCase
+{
+ public function testSerialize()
+ {
+ $mockSerializer = $this->getMockBuilder('JMS\Serializer\SerializerInterface')->getMock();
+ $obj = new \stdClass();
+ $mockSerializer
+ ->expects($this->once())
+ ->method('serialize')
+ ->with($this->equalTo($obj), $this->equalTo('json'));
+ $serializerExtension = new SerializerExtension($mockSerializer);
+ $serializerExtension->serialize($obj);
+
+ $this->assertEquals('jms_serializer', $serializerExtension->getName());
+
+ $filters = $serializerExtension->getFilters();
+ $this->assertInstanceOf('Twig_SimpleFilter', $filters[0]);
+ $this->assertSame(array($serializerExtension, 'serialize'), $filters[0]->getCallable());
+
+ $this->assertEquals(
+ array(new \Twig_SimpleFunction('serialization_context', '\JMS\Serializer\SerializationContext::create')),
+ $serializerExtension->getFunctions()
+ );
+ }
+
+ public function testRuntimeSerializerHelper()
+ {
+ $obj = new \stdClass();
+
+ $mockSerializer = $this->getMockBuilder('JMS\Serializer\SerializerInterface')->getMock();
+ $mockSerializer
+ ->expects($this->once())
+ ->method('serialize')
+ ->with($this->equalTo($obj), $this->equalTo('json'));
+
+ $serializerExtension = new SerializerRuntimeHelper($mockSerializer);
+ $serializerExtension->serialize($obj);
+ }
+
+ public function testRuntimeSerializerExtension()
+ {
+ $serializerExtension = new SerializerRuntimeExtension();
+
+ $this->assertEquals('jms_serializer', $serializerExtension->getName());
+ $this->assertEquals(
+ array(new \Twig_SimpleFilter('serialize', array(SerializerRuntimeHelper::class, 'serialize'))),
+ $serializerExtension->getFilters()
+ );
+ $this->assertEquals(
+ array(new \Twig_SimpleFunction('serialization_context', '\JMS\Serializer\SerializationContext::create')),
+ $serializerExtension->getFunctions()
+ );
+ }
+}
--- /dev/null
+<?php
+
+if (!isset($_SERVER['argv'][1], $_SERVER['argv'][2])) {
+ echo 'Usage: php benchmark.php <format> <iterations> [output-file]' . PHP_EOL;
+ exit(1);
+}
+
+list(, $format, $iterations) = $_SERVER['argv'];
+
+require_once 'bootstrap.php';
+
+function benchmark(\Closure $f, $times = 10)
+{
+ $time = microtime(true);
+ for ($i = 0; $i < $times; $i++) {
+ $f();
+ }
+
+ return (microtime(true) - $time) / $times;
+}
+
+function createCollection()
+{
+ $collection = array();
+ for ($i = 0; $i < 50; $i++) {
+ $collection[] = createObject();
+ }
+
+ return $collection;
+}
+
+function createObject()
+{
+ $p = new \JMS\Serializer\Tests\Fixtures\Publisher('bar');
+ $post = new \JMS\Serializer\Tests\Fixtures\BlogPost('FooooooooooooooooooooooBAR', new \JMS\Serializer\Tests\Fixtures\Author('Foo'), new \DateTime, $p);
+ for ($i = 0; $i < 10; $i++) {
+ $post->addComment(new \JMS\Serializer\Tests\Fixtures\Comment(new \JMS\Serializer\Tests\Fixtures\Author('foo'), 'foobar'));
+ }
+
+ return $post;
+}
+
+$serializer = \JMS\Serializer\SerializerBuilder::create()->build();
+$collection = createCollection();
+$metrics = array();
+$f = function () use ($serializer, $collection, $format) {
+ $serializer->serialize($collection, $format);
+};
+
+// Load all necessary classes into memory.
+benchmark($f, 1);
+
+printf('Benchmarking collection for format "%s".' . PHP_EOL, $format);
+$metrics['benchmark-collection-' . $format] = benchmark($f, $iterations);
+
+$output = json_encode(array('metrics' => $metrics));
+
+if (isset($_SERVER['argv'][3])) {
+ file_put_contents($_SERVER['argv'][3], $output);
+ echo "Done." . PHP_EOL;
+} else {
+ echo $output . PHP_EOL;
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+use Doctrine\Common\Annotations\AnnotationRegistry;
+
+call_user_func(function () {
+ if (!is_file($autoloadFile = __DIR__ . '/../vendor/autoload.php')) {
+ throw new \RuntimeException('Did not find vendor/autoload.php. Did you run "composer install --dev"?');
+ }
+
+ $loader = require $autoloadFile;
+ $loader->add('JMS\Serializer\Tests', __DIR__);
+
+ AnnotationRegistry::registerLoader('class_exists');
+});
--- /dev/null
+vendor/
+phpunit.xml
+
--- /dev/null
+language: php
+
+php:
+ - 5.3
+ - 5.4
+ - 5.5
+ - hhvm
+
+before_script:
+ - wget http://getcomposer.org/composer.phar
+ - php composer.phar install --dev
+
+script: phpunit --coverage-clover clover
+
+after_success:
+ - curl -sL https://bit.ly/artifact-uploader | php
+
+matrix:
+ allow_failures:
+ - php: hhvm
--- /dev/null
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
--- /dev/null
+PHP Collection
+==============
+
+Learn more about it in its [documentation](http://jmsyst.com/libs/php-collection).
--- /dev/null
+{
+ "name": "phpcollection/phpcollection",
+ "description": "General-Purpose Collection Library for PHP",
+ "keywords": ["collection", "list", "sequence", "map", "set"],
+ "license": "Apache2",
+ "authors": [
+ {"name": "Johannes M. Schmitt", "email": "schmittjoh@gmail.com"}
+ ],
+ "require": {
+ "phpoption/phpoption": "1.*"
+ },
+ "autoload": {
+ "psr-0": {
+ "PhpCollection": "src/"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "0.4-dev"
+ }
+ }
+}
--- /dev/null
+THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.\r
+\r
+BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.\r
+\r
+1. Definitions\r
+\r
+ "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.\r
+ "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License.\r
+ "Distribute" means to make available to the public the original and copies of the Work through sale or other transfer of ownership.\r
+ "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.\r
+ "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.\r
+ "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.\r
+ "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.\r
+ "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.\r
+ "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.\r
+\r
+2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.\r
+\r
+3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:\r
+\r
+ to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; and,\r
+ to Distribute and Publicly Perform the Work including as incorporated in Collections.\r
+\r
+The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats, but otherwise you have no rights to make Adaptations. Subject to 8(f), all rights not expressly granted by Licensor are hereby reserved, including but not limited to the rights set forth in Section 4(d).\r
+\r
+4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:\r
+\r
+ You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested.\r
+ You may not exercise any of the rights granted to You in Section 3 above in any manner that is primarily intended for or directed toward commercial advantage or private monetary compensation. The exchange of the Work for other copyrighted works by means of digital file-sharing or otherwise shall not be considered to be intended for or directed toward commercial advantage or private monetary compensation, provided there is no payment of any monetary compensation in connection with the exchange of copyrighted works.\r
+ If You Distribute, or Publicly Perform the Work or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work. The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Collection, at a minimum such credit will appear, if a credit for all contributing authors of Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.\r
+\r
+ For the avoidance of doubt:\r
+ Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;\r
+ Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License if Your exercise of such rights is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b) and otherwise waives the right to collect royalties through any statutory or compulsory licensing scheme; and,\r
+ Voluntary License Schemes. The Licensor reserves the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License that is for a purpose or use which is otherwise than noncommercial as permitted under Section 4(b).\r
+ Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation.\r
+\r
+5. Representations, Warranties and Disclaimer\r
+\r
+UNLESS OTHERWISE MUTUALLY AGREED BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.\r
+\r
+6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
+\r
+7. Termination\r
+\r
+ This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.\r
+ Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.\r
+\r
+8. Miscellaneous\r
+\r
+ Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.\r
+ If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.\r
+ No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.\r
+ This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.\r
+ The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.\r
--- /dev/null
+PHP Collection
+==============
+This library adds basic collections for PHP.
+
+Collections can be seen as more specialized arrays for which certain contracts are guaranteed.
+
+Supported Collections:
+
+- Sequences
+
+ - Keys: numerical, consequentially increasing, no gaps
+ - Values: anything, duplicates allowed
+ - Classes: ``Sequence``, ``SortedSequence``
+
+
+- Maps
+
+ - Keys: strings or objects, duplicate keys not allowed
+ - Values: anything, duplicates allowed
+ - Classes: ``Map``, ``ObjectMap`` (not yet implemented)
+
+
+- Sets
+
+ - Keys: not meaningful
+ - Values: objects, or scalars, each value is guaranteed to be unique (see Set usage below for details)
+ - Classes: ``Set``
+
+General Characteristics:
+
+- Collections are mutable (new elements may be added, existing elements may be modified or removed). Specialized
+ immutable versions may be added in the future though.
+- Equality comparison between elements are always performed using the shallow comparison operator (===).
+- Sorting algorithms are unstable, that means the order for equal elements is undefined (the default, and only PHP behavior).
+
+
+Installation
+------------
+PHP Collection can easily be installed via composer
+
+.. code-block :: bash
+
+ composer require phpcollection/phpcollection
+
+or add it to your ``composer.json`` file.
+
+Usage
+-----
+Collection classes provide a rich API.
+
+Sets
+~~~~
+In a Set each value is guaranteed to be unique. The ``Set`` class supports objects, and scalars as value. Equality
+is determined via the following steps.
+
+**Equality of Objects**
+
+ 1. If an object implements ``ObjectBasics``, equality is determined by the ``equals()`` method.
+ 2. If an object has an external handler like the ``DateTime`` that was registered via ``ObjectBasicsHandlerRegistry::registerHandlerFor``,
+ equality is determined by that handler's ``equals()`` method.
+ 3. If none of the above is applicable, equality is determined by identity ``$a === $b``.
+
+**Equality of Scalars**
+
+ Scalar are considered equal if ``$a === $b`` is true.
+
+
+.. code-block :: php
+
+ $set = new Set();
+ $set->add(new \DateTime('today'));
+ $set->add(new \DateTime('today'));
+
+ var_dump(count($set)); // int(1) -> the same date is not added twice
+
+ foreach ($set as $date) {
+ var_dump($date);
+ }
+
+ $set->all();
+ $set->addSet($otherSet);
+ $set->addAll($someElements);
+
+
+Sequences
+~~~~~~~~~
+
+.. code-block :: php
+
+ // Read Operations
+ $seq = new Sequence([0, 2, 3, 2]);
+ $seq->get(2); // int(3)
+ $seq->all(); // [0, 2, 3, 2]
+
+ $seq->first(); // Some(0)
+ $seq->last(); // Some(2)
+
+ // Write Operations
+ $seq = new Sequence([1, 5]);
+ $seq->get(0); // int(1)
+ $seq->update(0, 4);
+ $seq->get(0); // int(4)
+ $seq->remove(0);
+ $seq->get(0); // int(5)
+
+ $seq = new Sequence([1, 4]);
+ $seq->add(2);
+ $seq->all(); // [1, 4, 2]
+ $seq->addAll(array(4, 5, 2));
+ $seq->all(); // [1, 4, 2, 4, 5, 2]
+
+ // Sort
+ $seq = new Sequence([0, 5, 4, 2]);
+ $seq->sortWith(function($a, $b) { return $a - $b; });
+ $seq->all(); // [0, 2, 4, 5]
+
+Maps
+~~~~
+
+.. code-block :: php
+
+ // Read Operations
+ $map = new Map(['foo' => 'bar', 'baz' => 'boo']);
+ $map->get('foo'); // Some('bar')
+ $map->get('foo')->get(); // string('bar')
+ $map->keys(); // ['foo', 'baz']
+ $map->values(); // ['bar', 'boo']
+ iterator_to_array($map); // ['foo' => 'bar', 'baz' => 'boo']
+
+ $map->first()->get(); // ['foo', 'bar']
+ $map->last()->get(); // ['baz', 'boo']
+
+ // Write Operations
+ $map = new Map();
+ $map->set('foo', 'bar');
+ $map->setAll(array('bar' => 'baz', 'baz' => 'boo'));
+ $map->remove('foo');
+
+ // Sort
+ $map->sortWith('strcmp');
+
+License
+-------
+
+The code is released under the business-friendly `Apache2 license`_.
+
+Documentation is subject to the `Attribution-NonCommercial-NoDerivs 3.0 Unported
+license`_.
+
+.. _Apache2 license: http://www.apache.org/licenses/LICENSE-2.0.html
+.. _Attribution-NonCommercial-NoDerivs 3.0 Unported license: http://creativecommons.org/licenses/by-nc-nd/3.0/
+
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false"
+ syntaxCheck="false"
+ bootstrap="tests/bootstrap.php"
+>
+ <testsuites>
+ <testsuite name="PhpCollection Test Suite">
+ <directory>./tests/PhpCollection/</directory>
+ </testsuite>
+ </testsuites>
+
+ <groups>
+ <exclude>
+ <group>performance</group>
+ </exclude>
+ </groups>
+</phpunit>
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+use PhpOption\LazyOption;
+use PhpOption\Some;
+use PhpOption\None;
+
+abstract class AbstractCollection
+{
+ public function contains($searchedElem)
+ {
+ foreach ($this as $elem) {
+ if ($elem === $searchedElem) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public function find($callable)
+ {
+ $self = $this;
+
+ return new LazyOption(function() use ($callable, $self) {
+ foreach ($self as $elem) {
+ if (call_user_func($callable, $elem) === true) {
+ return new Some($elem);
+ }
+ }
+
+ return None::create();
+ });
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+use PhpOption\Some;
+use PhpOption\None;
+
+/**
+ * A simple map implementation which basically wraps an array with an object oriented interface.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class AbstractMap extends AbstractCollection implements \IteratorAggregate, MapInterface
+{
+ protected $elements;
+
+ public function __construct(array $elements = array())
+ {
+ $this->elements = $elements;
+ }
+
+ public function set($key, $value)
+ {
+ $this->elements[$key] = $value;
+ }
+
+ public function exists($callable)
+ {
+ foreach ($this as $k => $v) {
+ if ($callable($k, $v) === true) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Sets all key/value pairs in the map.
+ *
+ * @param array $kvMap
+ *
+ * @return void
+ */
+ public function setAll(array $kvMap)
+ {
+ $this->elements = array_merge($this->elements, $kvMap);
+ }
+
+ public function addMap(MapInterface $map)
+ {
+ foreach ($map as $k => $v) {
+ $this->elements[$k] = $v;
+ }
+ }
+
+ public function get($key)
+ {
+ if (isset($this->elements[$key])) {
+ return new Some($this->elements[$key]);
+ }
+
+ return None::create();
+ }
+
+ public function all()
+ {
+ return $this->elements;
+ }
+
+ public function remove($key)
+ {
+ if ( ! isset($this->elements[$key])) {
+ throw new \InvalidArgumentException(sprintf('The map has no key named "%s".', $key));
+ }
+
+ $element = $this->elements[$key];
+ unset($this->elements[$key]);
+
+ return $element;
+ }
+
+ public function clear()
+ {
+ $this->elements = array();
+ }
+
+ public function first()
+ {
+ if (empty($this->elements)) {
+ return None::create();
+ }
+
+ $elem = reset($this->elements);
+
+ return new Some(array(key($this->elements), $elem));
+ }
+
+ public function last()
+ {
+ if (empty($this->elements)) {
+ return None::create();
+ }
+
+ $elem = end($this->elements);
+
+ return new Some(array(key($this->elements), $elem));
+ }
+
+ public function contains($elem)
+ {
+ foreach ($this->elements as $existingElem) {
+ if ($existingElem === $elem) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public function containsKey($key)
+ {
+ return isset($this->elements[$key]);
+ }
+
+ public function isEmpty()
+ {
+ return empty($this->elements);
+ }
+
+ /**
+ * Returns a new filtered map.
+ *
+ * @param callable $callable receives the element and must return true (= keep), or false (= remove).
+ *
+ * @return AbstractMap
+ */
+ public function filter($callable)
+ {
+ return $this->filterInternal($callable, true);
+ }
+
+ /**
+ * Returns a new filtered map.
+ *
+ * @param callable $callable receives the element and must return true (= remove), or false (= keep).
+ *
+ * @return AbstractMap
+ */
+ public function filterNot($callable)
+ {
+ return $this->filterInternal($callable, false);
+ }
+
+ /**
+ * @param callable $callable
+ * @param boolean $booleanKeep
+ */
+ private function filterInternal($callable, $booleanKeep)
+ {
+ $newElements = array();
+ foreach ($this->elements as $k => $element) {
+ if ($booleanKeep !== call_user_func($callable, $element)) {
+ continue;
+ }
+
+ $newElements[$k] = $element;
+ }
+
+ return $this->createNew($newElements);
+ }
+
+ public function foldLeft($initialValue, $callable)
+ {
+ $value = $initialValue;
+ foreach ($this->elements as $elem) {
+ $value = call_user_func($callable, $value, $elem);
+ }
+
+ return $value;
+ }
+
+ public function foldRight($initialValue, $callable)
+ {
+ $value = $initialValue;
+ foreach (array_reverse($this->elements) as $elem) {
+ $value = call_user_func($callable, $elem, $value);
+ }
+
+ return $value;
+ }
+
+ public function dropWhile($callable)
+ {
+ $newElements = array();
+ $stopped = false;
+ foreach ($this->elements as $k => $v) {
+ if ( ! $stopped) {
+ if (call_user_func($callable, $k, $v) === true) {
+ continue;
+ }
+
+ $stopped = true;
+ }
+
+ $newElements[$k] = $v;
+ }
+
+ return $this->createNew($newElements);
+ }
+
+ public function drop($number)
+ {
+ if ($number <= 0) {
+ throw new \InvalidArgumentException(sprintf('The number must be greater than 0, but got %d.', $number));
+ }
+
+ return $this->createNew(array_slice($this->elements, $number, null, true));
+ }
+
+ public function dropRight($number)
+ {
+ if ($number <= 0) {
+ throw new \InvalidArgumentException(sprintf('The number must be greater than 0, but got %d.', $number));
+ }
+
+ return $this->createNew(array_slice($this->elements, 0, -1 * $number, true));
+ }
+
+ public function take($number)
+ {
+ if ($number <= 0) {
+ throw new \InvalidArgumentException(sprintf('The number must be greater than 0, but got %d.', $number));
+ }
+
+ return $this->createNew(array_slice($this->elements, 0, $number, true));
+ }
+
+ public function takeWhile($callable)
+ {
+ $newElements = array();
+ foreach ($this->elements as $k => $v) {
+ if (call_user_func($callable, $k, $v) !== true) {
+ break;
+ }
+
+ $newElements[$k] = $v;
+ }
+
+ return $this->createNew($newElements);
+ }
+
+ public function find($callable)
+ {
+ foreach ($this->elements as $k => $v) {
+ if (call_user_func($callable, $k, $v) === true) {
+ return new Some(array($k, $v));
+ }
+ }
+
+ return None::create();
+ }
+
+ public function keys()
+ {
+ return array_keys($this->elements);
+ }
+
+ public function values()
+ {
+ return array_values($this->elements);
+ }
+
+ public function count()
+ {
+ return count($this->elements);
+ }
+
+ public function getIterator()
+ {
+ return new \ArrayIterator($this->elements);
+ }
+
+ protected function createNew(array $elements)
+ {
+ return new static($elements);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+use PhpOption\Some;
+use PhpOption\None;
+use PhpOption\Option;
+use OutOfBoundsException;
+
+/**
+ * A sequence with numerically indexed elements.
+ *
+ * This is rawly equivalent to an array with only numeric keys.
+ * There are no restrictions on how many same values may occur in the sequence.
+ *
+ * This sequence is mutable.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class AbstractSequence extends AbstractCollection implements \IteratorAggregate, SequenceInterface
+{
+ protected $elements;
+
+ /**
+ * @param array $elements
+ */
+ public function __construct(array $elements = array())
+ {
+ $this->elements = array_values($elements);
+ }
+
+ public function addSequence(SequenceInterface $seq)
+ {
+ $this->addAll($seq->all());
+ }
+
+ public function indexOf($searchedElement)
+ {
+ foreach ($this->elements as $i => $element) {
+ if ($searchedElement === $element) {
+ return $i;
+ }
+ }
+
+ return -1;
+ }
+
+ public function lastIndexOf($searchedElement)
+ {
+ for ($i=count($this->elements)-1; $i>=0; $i--) {
+ if ($this->elements[$i] === $searchedElement) {
+ return $i;
+ }
+ }
+
+ return -1;
+ }
+
+ public function reverse()
+ {
+ return $this->createNew(array_reverse($this->elements));
+ }
+
+ public function isDefinedAt($index)
+ {
+ return isset($this->elements[$index]);
+ }
+
+ /**
+ * Returns a filtered sequence.
+ *
+ * @param callable $callable receives the element and must return true (= keep) or false (= remove).
+ *
+ * @return AbstractSequence
+ */
+ public function filter($callable)
+ {
+ return $this->filterInternal($callable, true);
+ }
+
+ public function map($callable)
+ {
+ $newElements = array();
+ foreach ($this->elements as $i => $element) {
+ $newElements[$i] = $callable($element);
+ }
+
+ return $this->createNew($newElements);
+ }
+
+ /**
+ * Returns a filtered sequence.
+ *
+ * @param callable $callable receives the element and must return true (= remove) or false (= keep).
+ *
+ * @return AbstractSequence
+ */
+ public function filterNot($callable)
+ {
+ return $this->filterInternal($callable, false);
+ }
+
+ private function filterInternal($callable, $booleanKeep)
+ {
+ $newElements = array();
+ foreach ($this->elements as $element) {
+ if ($booleanKeep !== call_user_func($callable, $element)) {
+ continue;
+ }
+
+ $newElements[] = $element;
+ }
+
+ return $this->createNew($newElements);
+ }
+
+ public function foldLeft($initialValue, $callable)
+ {
+ $value = $initialValue;
+ foreach ($this->elements as $elem) {
+ $value = call_user_func($callable, $value, $elem);
+ }
+
+ return $value;
+ }
+
+ public function foldRight($initialValue, $callable)
+ {
+ $value = $initialValue;
+ foreach (array_reverse($this->elements) as $elem) {
+ $value = call_user_func($callable, $elem, $value);
+ }
+
+ return $value;
+ }
+
+ /**
+ * Finds the first index where the given callable returns true.
+ *
+ * @param callable $callable
+ *
+ * @return integer the index, or -1 if the predicate is not true for any element.
+ */
+ public function indexWhere($callable)
+ {
+ foreach ($this->elements as $i => $element) {
+ if (call_user_func($callable, $element) === true) {
+ return $i;
+ }
+ }
+
+ return -1;
+ }
+
+ public function lastIndexWhere($callable)
+ {
+ for ($i=count($this->elements)-1; $i>=0; $i--) {
+ if (call_user_func($callable, $this->elements[$i]) === true) {
+ return $i;
+ }
+ }
+
+ return -1;
+ }
+
+ public function last()
+ {
+ if (empty($this->elements)) {
+ return None::create();
+ }
+
+ return new Some(end($this->elements));
+ }
+
+ public function first()
+ {
+ if (empty($this->elements)) {
+ return None::create();
+ }
+
+ return new Some(reset($this->elements));
+ }
+
+ public function indices()
+ {
+ return array_keys($this->elements);
+ }
+
+ /**
+ * Returns an element based on its index (0-based).
+ *
+ * @param integer $index
+ *
+ * @return T
+ */
+ public function get($index)
+ {
+ if ( ! isset($this->elements[$index])) {
+ throw new OutOfBoundsException(sprintf('The index "%s" does not exist in this sequence.', $index));
+ }
+
+ return $this->elements[$index];
+ }
+
+ /**
+ * Removes the element at the given index, and returns it.
+ *
+ * @param int $index
+ *
+ * @return T
+ *
+ * @throws \OutOfBoundsException If there is no element at the given index.
+ */
+ public function remove($index)
+ {
+ if ( ! isset($this->elements[$index])) {
+ throw new OutOfBoundsException(sprintf('The index "%d" is not in the interval [0, %d).', $index, count($this->elements)));
+ }
+
+ $element = $this->elements[$index];
+ unset($this->elements[$index]);
+ $this->elements = array_values($this->elements);
+
+ return $element;
+ }
+
+ /**
+ * Updates the element at the given index (0-based).
+ *
+ * @param integer $index
+ * @param T $value
+ */
+ public function update($index, $value)
+ {
+ if ( ! isset($this->elements[$index])) {
+ throw new \InvalidArgumentException(sprintf('There is no element at index "%d".', $index));
+ }
+
+ $this->elements[$index] = $value;
+ }
+
+ public function isEmpty()
+ {
+ return empty($this->elements);
+ }
+
+ public function all()
+ {
+ return $this->elements;
+ }
+
+ public function add($newElement)
+ {
+ $this->elements[] = $newElement;
+ }
+
+ public function addAll(array $addedElements)
+ {
+ foreach ($addedElements as $newElement) {
+ $this->elements[] = $newElement;
+ }
+ }
+
+ public function take($number)
+ {
+ if ($number <= 0) {
+ throw new \InvalidArgumentException(sprintf('$number must be greater than 0, but got %d.', $number));
+ }
+
+ return $this->createNew(array_slice($this->elements, 0, $number));
+ }
+
+ /**
+ * Extracts element from the head while the passed callable returns true.
+ *
+ * @param callable $callable receives elements of this sequence as first argument, and returns true/false.
+ *
+ * @return Sequence
+ */
+ public function takeWhile($callable)
+ {
+ $newElements = array();
+
+ for ($i=0,$c=count($this->elements); $i<$c; $i++) {
+ if (call_user_func($callable, $this->elements[$i]) !== true) {
+ break;
+ }
+
+ $newElements[] = $this->elements[$i];
+ }
+
+ return $this->createNew($newElements);
+ }
+
+ public function drop($number)
+ {
+ if ($number <= 0) {
+ throw new \InvalidArgumentException(sprintf('The number must be greater than 0, but got %d.', $number));
+ }
+
+ return $this->createNew(array_slice($this->elements, $number));
+ }
+
+ public function dropRight($number)
+ {
+ if ($number <= 0) {
+ throw new \InvalidArgumentException(sprintf('The number must be greater than 0, but got %d.', $number));
+ }
+
+ return $this->createNew(array_slice($this->elements, 0, -1 * $number));
+ }
+
+ public function dropWhile($callable)
+ {
+ for ($i=0,$c=count($this->elements); $i<$c; $i++) {
+ if (true !== call_user_func($callable, $this->elements[$i])) {
+ break;
+ }
+ }
+
+ return $this->createNew(array_slice($this->elements, $i));
+ }
+
+ public function exists($callable)
+ {
+ foreach ($this as $elem) {
+ if ($callable($elem) === true) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public function count()
+ {
+ return count($this->elements);
+ }
+
+ public function getIterator()
+ {
+ return new \ArrayIterator($this->elements);
+ }
+
+ protected function createNew(array $elements)
+ {
+ return new static($elements);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+/**
+ * Basic interface which adds some behaviors, and a few methods common to all collections.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface CollectionInterface extends \Traversable, \Countable
+{
+ /**
+ * Returns whether this collection contains the passed element.
+ *
+ * @param mixed $elem
+ *
+ * @return boolean
+ */
+ public function contains($elem);
+
+ /**
+ * Returns whether the collection is empty.
+ *
+ * @return boolean
+ */
+ public function isEmpty();
+
+ /**
+ * Returns a filtered collection of the same type.
+ *
+ * Removes all elements for which the provided callable returns false.
+ *
+ * @param callable $callable receives an element of the collection and must return true (= keep) or false (= remove).
+ *
+ * @return CollectionInterface
+ */
+ public function filter($callable);
+
+ /**
+ * Returns a filtered collection of the same type.
+ *
+ * Removes all elements for which the provided callable returns true.
+ *
+ * @param callable $callable receives an element of the collection and must return true (= remove) or false (= keep).
+ *
+ * @return CollectionInterface
+ */
+ public function filterNot($callable);
+
+ /**
+ * Applies the callable to an initial value and each element, going left to right.
+ *
+ * @param mixed $initialValue
+ * @param callable $callable receives the current value (the first time this equals $initialValue) and the element
+ *
+ * @return mixed the last value returned by $callable, or $initialValue if collection is empty.
+ */
+ public function foldLeft($initialValue, $callable);
+
+ /**
+ * Applies the callable to each element, and an initial value, going right to left.
+ *
+ * @param mixed $initialValue
+ * @param callable $callable receives the element, and the current value (the first time this equals $initialValue).
+ * @return mixed the last value returned by $callable, or $initialValue if collection is empty.
+ */
+ public function foldRight($initialValue, $callable);
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpCollection;
+
+/**
+ * Implementation for ObjectBasics for entity-like objects.
+ *
+ * Two objects are considered equal if they refer to the same instance.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+trait EntityLikeObject
+{
+ public function hash()
+ {
+ return spl_object_hash($this);
+ }
+
+ public function equals(ObjectBasics $other)
+ {
+ return $this === $other;
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+class Map extends AbstractMap implements SortableInterface
+{
+ public function sortWith($callable)
+ {
+ uksort($this->elements, $callable);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+use PhpOption\Option;
+
+/**
+ * Basic map interface.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface MapInterface extends CollectionInterface
+{
+ /**
+ * Returns the first element in the collection if available.
+ *
+ * @return Option on array<K,V>
+ */
+ public function first();
+
+ /**
+ * Returns the last element in the collection if available.
+ *
+ * @return Option on array<K,V>
+ */
+ public function last();
+
+ /**
+ * Returns all elements in this collection.
+ *
+ * @return array
+ */
+ public function all();
+
+ /**
+ * Searches the collection for an element.
+ *
+ * @param callable $callable receives the element as first argument, and returns true, or false
+ *
+ * @return Option on array<K,V>
+ */
+ public function find($callable);
+
+ /**
+ * Returns the value associated with the given key.
+ *
+ * @param mixed $key
+ *
+ * @return Option on V
+ */
+ public function get($key);
+
+ /**
+ * Returns whether this map contains a given key.
+ *
+ * @param mixed $key
+ *
+ * @return boolean
+ */
+ public function containsKey($key);
+
+ /**
+ * Puts a new element in the map.
+ *
+ * @param mixed $key
+ * @param mixed $value
+ *
+ * @return void
+ */
+ public function set($key, $value);
+
+ /**
+ * Removes an element from the map.
+ *
+ * @param mixed $key
+ *
+ * @return mixed
+ */
+ public function remove($key);
+
+ /**
+ * Adds all another map to this map, and returns itself.
+ *
+ * @param MapInterface $map
+ *
+ * @return MapInterface
+ */
+ public function addMap(MapInterface $map);
+
+ /**
+ * Returns an array with the keys.
+ *
+ * @return array
+ */
+ public function keys();
+
+ /**
+ * Returns an array with the values.
+ *
+ * @return array
+ */
+ public function values();
+
+ /**
+ * Returns a new sequence by omitting the given number of elements from the beginning.
+ *
+ * If the passed number is greater than the available number of elements, all will be removed.
+ *
+ * @param integer $number
+ *
+ * @return MapInterface
+ */
+ public function drop($number);
+
+ /**
+ * Returns a new sequence by omitting the given number of elements from the end.
+ *
+ * If the passed number is greater than the available number of elements, all will be removed.
+ *
+ * @param integer $number
+ *
+ * @return MapInterface
+ */
+ public function dropRight($number);
+
+ /**
+ * Returns a new sequence by omitting elements from the beginning for as long as the callable returns true.
+ *
+ * @param callable $callable Receives the element to drop as first argument, and returns true (drop), or false (stop).
+ *
+ * @return MapInterface
+ */
+ public function dropWhile($callable);
+
+ /**
+ * Creates a new collection by taking the given number of elements from the beginning
+ * of the current collection.
+ *
+ * If the passed number is greater than the available number of elements, then all elements
+ * will be returned as a new collection.
+ *
+ * @param integer $number
+ *
+ * @return MapInterface
+ */
+ public function take($number);
+
+ /**
+ * Creates a new collection by taking elements from the current collection
+ * for as long as the callable returns true.
+ *
+ * @param callable $callable
+ *
+ * @return MapInterface
+ */
+ public function takeWhile($callable);
+}
--- /dev/null
+<?php
+
+namespace PhpCollection;
+
+/**
+ * Interface that must be implemented by objects that are used as keys, or in sets.
+ *
+ * For entities, you can use the "EntityLikeObject" trait.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface ObjectBasics
+{
+ /**
+ * Produces a hash for the given object.
+ *
+ * If two objects are equal (as per the equals() method), the hash() method must produce
+ * the same hash for them.
+ *
+ * The reverse can, but does not necessarily have to be true. That is, if two objects have the
+ * same hash, they do not necessarily have to be equal, but the equals() method must be called
+ * to be sure.
+ *
+ * When implementing this method try to use a simple and fast algorithm that produces reasonably
+ * different results for non-equal objects, and shift the heavy comparison logic to equals().
+ *
+ * @return string|integer
+ */
+ public function hash();
+
+ /**
+ * Whether two objects are equal.
+ *
+ * This can compare by referential equality (===), or in case of value objects like (\DateTime) compare
+ * the individual properties of the objects; it's up to the implementation.
+ *
+ * @return boolean
+ */
+ public function equals(ObjectBasics $other);
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpCollection;
+
+/**
+ * Interface for external handlers that provide ObjectBasics functionality.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface ObjectBasicsHandler
+{
+ /**
+ * @param object $object This object is guaranteed to be of the type the handler was registered for.
+ * @return string|integer
+ */
+ public function hash($object);
+
+ /**
+ * @param object $firstObject This object is guaranteed to be of the type the handler was registered for.
+ * @param object $secondObject This might be an object of any class.
+ * @return boolean
+ */
+ public function equals($firstObject, $secondObject);
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpCollection\ObjectBasicsHandler;
+
+use PhpCollection\ObjectBasicsHandler;
+
+class DateTimeHandler implements ObjectBasicsHandler
+{
+ public function hash($object)
+ {
+ if ( ! $object instanceof \DateTime) {
+ throw new \LogicException('$object must be an instance of \DateTime.');
+ }
+
+ return $object->getTimestamp();
+ }
+
+ public function equals($thisObject, $otherObject)
+ {
+ if ( ! $thisObject instanceof \DateTime) {
+ throw new \LogicException('$thisObject must be an instance of \DateTime.');
+ }
+ if ( ! $otherObject instanceof \DateTime) {
+ return false;
+ }
+
+ return $thisObject->format(\DateTime::ISO8601) === $otherObject->format(\DateTime::ISO8601);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpCollection\ObjectBasicsHandler;
+
+use PhpCollection\ObjectBasicsHandler;
+
+class IdentityHandler implements ObjectBasicsHandler
+{
+ public function hash($object)
+ {
+ return spl_object_hash($object);
+ }
+
+ public function equals($a, $b)
+ {
+ return $a === $b;
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpCollection;
+use PhpCollection\ObjectBasicsHandler\IdentityHandler;
+
+/**
+ * Registry for handlers that provide ObjectBasics functionality for classes.
+ *
+ * You want to register a handler if you cannot implement the ObjectBasics interface, for example
+ * because a class is provided by a third-party package, or built into PHP.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+abstract class ObjectBasicsHandlerRegistry
+{
+ private static $handlers = array(
+ 'DateTime' => 'PhpCollection\\ObjectBasicsHandler\\DateTimeHandler',
+ );
+ private static $defaultObjectHandler;
+
+ private static $aliases = array();
+
+ /**
+ * Defines an alias.
+ *
+ * $aliasClass must be a sub-type (extend or implement) $handlingClass; otherwise you will run into trouble.
+ *
+ * Aliases can only be one level deep,
+ *
+ * i.e. aliasClass -> handlingClass is supported,
+ * but aliasClass -> anotherAliasClass -> handlingClass is not.
+ *
+ * @param string $handlingClass The class that should be aliased, i.e. MyDateTime
+ * @param string $aliasClass The class that should be used instead, i.e. DateTime
+ */
+ public static function addAliasFor($handlingClass, $aliasClass)
+ {
+ self::$aliases[$handlingClass] = $aliasClass;
+ }
+
+ public static function addHandlerFor($handlingClass, $handlerInstanceOrClassName)
+ {
+ if ( ! $handlerInstanceOrClassName instanceof ObjectBasicsHandler && ! is_string($handlerInstanceOrClassName)) {
+ throw new \LogicException('$handler must be an instance of ObjectBasicsHandler, or a string referring to the handlers class.');
+ }
+
+ self::$handlers[$handlingClass] = $handlerInstanceOrClassName;
+ }
+
+ public static function getHandler($className)
+ {
+ if (isset(self::$aliases[$className])) {
+ $className = self::$aliases[$className];
+ }
+
+ if ( ! isset(self::$handlers[$className])) {
+ if (self::$defaultObjectHandler === null) {
+ self::$defaultObjectHandler = new IdentityHandler();
+ }
+
+ return self::$defaultObjectHandler;
+ }
+
+ if (self::$handlers[$className] instanceof ObjectBasicsHandler) {
+ return self::$handlers[$className];
+ }
+
+ if (is_string(self::$handlers[$className])) {
+ $handlerClass = self::$handlers[$className];
+
+ return self::$handlers[$className] = new $handlerClass();
+ }
+
+ throw new \LogicException(sprintf(
+ 'Unknown handler type ("%s") for class "%s" - should never be reached.',
+ gettype(self::$handlers[$className]),
+ $className
+ ));
+ }
+
+ private final function __construct() { }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+/**
+ * Unsorted sequence implementation.
+ *
+ * Characteristics:
+ *
+ * - Keys: consequentially numbered, without gaps
+ * - Values: anything, duplicates allowed
+ * - Ordering: same as input unless when explicitly sorted
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class Sequence extends AbstractSequence implements SortableInterface
+{
+ public function sortWith($callable)
+ {
+ usort($this->elements, $callable);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+use PhpOption\Option;
+
+/**
+ * Interface for mutable sequences.
+ *
+ * Equality of elements in the sequence is established via a shallow comparison (===).
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface SequenceInterface extends CollectionInterface
+{
+ /**
+ * Returns the first element in the collection if available.
+ *
+ * @return Option
+ */
+ public function first();
+
+ /**
+ * Returns the last element in the collection if available.
+ *
+ * @return Option
+ */
+ public function last();
+
+ /**
+ * Returns all elements in this sequence.
+ *
+ * @return array
+ */
+ public function all();
+
+ /**
+ * Returns a new Sequence with all elements in reverse order.
+ *
+ * @return SequenceInterface
+ */
+ public function reverse();
+
+ /**
+ * Adds the elements of another sequence to this sequence.
+ *
+ * @param SequenceInterface $seq
+ *
+ * @return SequenceInterface
+ */
+ public function addSequence(SequenceInterface $seq);
+
+ /**
+ * Returns the index of the passed element.
+ *
+ * @param mixed $elem
+ *
+ * @return integer the index (0-based), or -1 if not found
+ */
+ public function indexOf($elem);
+
+ /**
+ * Returns the last index of the passed element.
+ *
+ * @param mixed $elem
+ * @return integer the index (0-based), or -1 if not found
+ */
+ public function lastIndexOf($elem);
+
+ /**
+ * Returns whether the given index is defined in the sequence.
+ *
+ * @param integer $index (0-based)
+ * @return boolean
+ */
+ public function isDefinedAt($index);
+
+ /**
+ * Returns the first index where the given callable returns true.
+ *
+ * @param callable $callable receives the element as first argument, and returns true, or false
+ *
+ * @return integer the index (0-based), or -1 if the callable returns false for all elements
+ */
+ public function indexWhere($callable);
+
+ /**
+ * Returns the last index where the given callable returns true.
+ *
+ * @param callable $callable receives the element as first argument, and returns true, or false
+ *
+ * @return integer the index (0-based), or -1 if the callable returns false for all elements
+ */
+ public function lastIndexWhere($callable);
+
+ /**
+ * Returns all indices of this collection.
+ *
+ * @return integer[]
+ */
+ public function indices();
+
+ /**
+ * Returns the element at the given index.
+ *
+ * @param integer $index (0-based)
+ *
+ * @return mixed
+ */
+ public function get($index);
+
+ /**
+ * Adds an element to the sequence.
+ *
+ * @param mixed $elem
+ *
+ * @return void
+ */
+ public function add($elem);
+
+ /**
+ * Removes the element at the given index, and returns it.
+ *
+ * @param integer $index
+ *
+ * @return mixed
+ */
+ public function remove($index);
+
+ /**
+ * Adds all elements to the sequence.
+ *
+ * @param array $elements
+ *
+ * @return void
+ */
+ public function addAll(array $elements);
+
+ /**
+ * Updates the value at the given index.
+ *
+ * @param integer $index
+ * @param mixed $value
+ *
+ * @return void
+ */
+ public function update($index, $value);
+
+ /**
+ * Returns a new sequence by omitting the given number of elements from the beginning.
+ *
+ * If the passed number is greater than the available number of elements, all will be removed.
+ *
+ * @param integer $number
+ *
+ * @return SequenceInterface
+ */
+ public function drop($number);
+
+ /**
+ * Returns a new sequence by omitting the given number of elements from the end.
+ *
+ * If the passed number is greater than the available number of elements, all will be removed.
+ *
+ * @param integer $number
+ *
+ * @return SequenceInterface
+ */
+ public function dropRight($number);
+
+ /**
+ * Returns a new sequence by omitting elements from the beginning for as long as the callable returns true.
+ *
+ * @param callable $callable Receives the element to drop as first argument, and returns true (drop), or false (stop).
+ *
+ * @return SequenceInterface
+ */
+ public function dropWhile($callable);
+
+ /**
+ * Creates a new collection by taking the given number of elements from the beginning
+ * of the current collection.
+ *
+ * If the passed number is greater than the available number of elements, then all elements
+ * will be returned as a new collection.
+ *
+ * @param integer $number
+ *
+ * @return CollectionInterface
+ */
+ public function take($number);
+
+ /**
+ * Creates a new collection by taking elements from the current collection
+ * for as long as the callable returns true.
+ *
+ * @param callable $callable
+ *
+ * @return CollectionInterface
+ */
+ public function takeWhile($callable);
+
+ /**
+ * Creates a new collection by applying the passed callable to all elements
+ * of the current collection.
+ *
+ * @param callable $callable
+ * @return CollectionInterface
+ */
+ public function map($callable);
+}
--- /dev/null
+<?php
+
+namespace PhpCollection;
+
+use PhpOption\None;
+use PhpOption\Some;
+
+/**
+ * Implementation of a Set.
+ *
+ * Each set guarantees that equal elements are only contained once in the Set.
+ *
+ * This implementation constraints Sets to either consist of objects that implement ObjectBasics, or objects that have
+ * an external ObjectBasicsHandler implementation, or simple scalars. These types cannot be mixed within the same Set.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class Set implements SetInterface
+{
+ const ELEM_TYPE_SCALAR = 1;
+ const ELEM_TYPE_OBJECT = 2;
+ const ELEM_TYPE_OBJECT_WITH_HANDLER = 3;
+
+ private $elementType;
+
+ private $elements = array();
+ private $elementCount = 0;
+ private $lookup = array();
+
+ public function __construct(array $elements = array())
+ {
+ $this->addAll($elements);
+ }
+
+ public function first()
+ {
+ if (empty($this->elements)) {
+ return None::create();
+ }
+
+ return new Some(reset($this->elements));
+ }
+
+ public function last()
+ {
+ if (empty($this->elements)) {
+ return None::create();
+ }
+
+ return new Some(end($this->elements));
+ }
+
+ public function getIterator()
+ {
+ return new \ArrayIterator(array_values($this->elements));
+ }
+
+ public function addSet(SetInterface $set)
+ {
+ $this->addAll($set->all());
+ }
+
+ public function take($number)
+ {
+ if ($number <= 0) {
+ throw new \InvalidArgumentException(sprintf('$number must be greater than 0, but got %d.', $number));
+ }
+
+ return $this->createNew(array_slice($this->elements, 0, $number));
+ }
+
+ /**
+ * Extracts element from the head while the passed callable returns true.
+ *
+ * @param callable $callable receives elements of this Set as first argument, and returns true/false.
+ *
+ * @return Set
+ */
+ public function takeWhile($callable)
+ {
+ $newElements = array();
+
+ for ($i=0,$c=count($this->elements); $i<$c; $i++) {
+ if (call_user_func($callable, $this->elements[$i]) !== true) {
+ break;
+ }
+
+ $newElements[] = $this->elements[$i];
+ }
+
+ return $this->createNew($newElements);
+ }
+
+ public function drop($number)
+ {
+ if ($number <= 0) {
+ throw new \InvalidArgumentException(sprintf('The number must be greater than 0, but got %d.', $number));
+ }
+
+ return $this->createNew(array_slice($this->elements, $number));
+ }
+
+ public function dropRight($number)
+ {
+ if ($number <= 0) {
+ throw new \InvalidArgumentException(sprintf('The number must be greater than 0, but got %d.', $number));
+ }
+
+ return $this->createNew(array_slice($this->elements, 0, -1 * $number));
+ }
+
+ public function dropWhile($callable)
+ {
+ for ($i=0,$c=count($this->elements); $i<$c; $i++) {
+ if (true !== call_user_func($callable, $this->elements[$i])) {
+ break;
+ }
+ }
+
+ return $this->createNew(array_slice($this->elements, $i));
+ }
+
+ public function map($callable)
+ {
+ $newElements = array();
+ foreach ($this->elements as $i => $element) {
+ $newElements[$i] = $callable($element);
+ }
+
+ return $this->createNew($newElements);
+ }
+
+ public function reverse()
+ {
+ return $this->createNew(array_reverse($this->elements));
+ }
+
+ public function all()
+ {
+ return array_values($this->elements);
+ }
+
+ public function filterNot($callable)
+ {
+ return $this->filterInternal($callable, false);
+ }
+
+ public function filter($callable)
+ {
+ return $this->filterInternal($callable, true);
+ }
+
+ public function foldLeft($initialValue, $callable)
+ {
+ $value = $initialValue;
+ foreach ($this->elements as $elem) {
+ $value = call_user_func($callable, $value, $elem);
+ }
+
+ return $value;
+ }
+
+ public function foldRight($initialValue, $callable)
+ {
+ $value = $initialValue;
+ foreach (array_reverse($this->elements) as $elem) {
+ $value = call_user_func($callable, $elem, $value);
+ }
+
+ return $value;
+ }
+
+ public function addAll(array $elements)
+ {
+ foreach ($elements as $elem) {
+ $this->add($elem);
+ }
+ }
+
+ public function count()
+ {
+ return count($this->elements);
+ }
+
+ public function contains($elem)
+ {
+ if ($this->elementType === self::ELEM_TYPE_OBJECT) {
+ if ($elem instanceof ObjectBasics) {
+ return $this->containsObject($elem);
+ }
+
+ return false;
+ } elseif ($this->elementType === self::ELEM_TYPE_OBJECT_WITH_HANDLER) {
+ if (is_object($elem)) {
+ return $this->containsObjectWithHandler($elem, ObjectBasicsHandlerRegistry::getHandler(get_class($elem)));
+ }
+
+ return false;
+ } elseif ($this->elementType === self::ELEM_TYPE_SCALAR) {
+ if (is_scalar($elem)) {
+ return $this->containsScalar($elem);
+ }
+
+ return false;
+ }
+
+ return false;
+ }
+
+ public function remove($elem)
+ {
+ if ($this->elementType === self::ELEM_TYPE_OBJECT) {
+ if ($elem instanceof ObjectBasics) {
+ $this->removeObject($elem);
+ }
+ } elseif ($this->elementType === self::ELEM_TYPE_OBJECT_WITH_HANDLER) {
+ if (is_object($elem)) {
+ $this->removeObjectWithHandler($elem, ObjectBasicsHandlerRegistry::getHandler(get_class($elem)));
+ }
+ } elseif ($this->elementType === self::ELEM_TYPE_SCALAR) {
+ if (is_scalar($elem)) {
+ $this->removeScalar($elem);
+ }
+ }
+ }
+
+ public function isEmpty()
+ {
+ return empty($this->elements);
+ }
+
+ public function add($elem)
+ {
+ if ($this->elementType === null) {
+ if ($elem instanceof ObjectBasics) {
+ $this->addObject($elem);
+ } elseif (is_scalar($elem)) {
+ $this->addScalar($elem);
+ } else {
+ if (is_object($elem)) {
+ $this->addObjectWithHandler($elem, ObjectBasicsHandlerRegistry::getHandler(get_class($elem)));
+ } else {
+ throw new \LogicException(sprintf('The type of $elem ("%s") is not supported in sets.', gettype($elem)));
+ }
+ }
+ } elseif ($this->elementType === self::ELEM_TYPE_OBJECT) {
+ if ($elem instanceof ObjectBasics) {
+ $this->addObject($elem);
+
+ return;
+ }
+
+ if (is_object($elem)) {
+ throw new \LogicException(sprintf('This Set already contains object implement ObjectBasics, and cannot be mixed with objects that do not implement this interface like "%s".', get_class($elem)));
+ }
+
+ throw new \LogicException(sprintf('This Set already contains objects, and cannot be mixed with elements of type "%s".', gettype($elem)));
+ } elseif ($this->elementType === self::ELEM_TYPE_OBJECT_WITH_HANDLER) {
+ if (is_object($elem)) {
+ $this->addObjectWithHandler($elem, ObjectBasicsHandlerRegistry::getHandler(get_class($elem)));
+
+ return;
+ }
+
+ throw new \LogicException(sprintf('This Set already contains object with an external handler, and cannot be mixed with elements of type "%s".', gettype($elem)));
+ } elseif ($this->elementType === self::ELEM_TYPE_SCALAR) {
+ if (is_scalar($elem)) {
+ $this->addScalar($elem);
+
+ return;
+ }
+
+ throw new \LogicException(sprintf('This Set already contains scalars, and cannot be mixed with elements of type "%s".', gettype($elem)));
+ } else {
+ throw new \LogicException('Unknown element type in Set - should never be reached.');
+ }
+ }
+
+ protected function createNew(array $elements)
+ {
+ return new static($elements);
+ }
+
+ private function filterInternal($callable, $booleanKeep)
+ {
+ $newElements = array();
+ foreach ($this->elements as $element) {
+ if ($booleanKeep !== call_user_func($callable, $element)) {
+ continue;
+ }
+
+ $newElements[] = $element;
+ }
+
+ return $this->createNew($newElements);
+ }
+
+ private function containsScalar($elem)
+ {
+ if ( ! isset($this->lookup[$elem])) {
+ return false;
+ }
+
+ foreach ($this->lookup[$elem] as $index) {
+ if ($elem === $this->elements[$index]) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private function containsObjectWithHandler($object, ObjectBasicsHandler $handler)
+ {
+ $hash = $handler->hash($object);
+ if ( ! isset($this->lookup[$hash])) {
+ return false;
+ }
+
+ foreach ($this->lookup[$hash] as $index) {
+ if ($handler->equals($object, $this->elements[$index])) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private function containsObject(ObjectBasics $object)
+ {
+ $hash = $object->hash();
+ if ( ! isset($this->lookup[$hash])) {
+ return false;
+ }
+
+ foreach ($this->lookup[$hash] as $index) {
+ if ($object->equals($this->elements[$index])) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ private function removeScalar($elem)
+ {
+ if ( ! isset($this->lookup[$elem])) {
+ return;
+ }
+
+ foreach ($this->lookup[$elem] as $k => $index) {
+ if ($elem === $this->elements[$index]) {
+ $this->removeElement($elem, $k, $index);
+ break;
+ }
+ }
+ }
+
+ private function removeObjectWithHandler($object, ObjectBasicsHandler $handler)
+ {
+ $hash = $handler->hash($object);
+ if ( ! isset($this->lookup[$hash])) {
+ return;
+ }
+
+ foreach ($this->lookup[$hash] as $k => $index) {
+ if ($handler->equals($object, $this->elements[$index])) {
+ $this->removeElement($hash, $k, $index);
+ break;
+ }
+ }
+ }
+
+ private function removeObject(ObjectBasics $object)
+ {
+ $hash = $object->hash();
+ if ( ! isset($this->lookup[$hash])) {
+ return;
+ }
+
+ foreach ($this->lookup[$hash] as $k => $index) {
+ if ($object->equals($this->elements[$index])) {
+ $this->removeElement($hash, $k, $index);
+ break;
+ }
+ }
+ }
+
+ private function removeElement($hash, $lookupIndex, $storageIndex)
+ {
+ unset($this->lookup[$hash][$lookupIndex]);
+ if (empty($this->lookup[$hash])) {
+ unset($this->lookup[$hash]);
+ }
+
+ unset($this->elements[$storageIndex]);
+ }
+
+ private function addScalar($elem)
+ {
+ if (isset($this->lookup[$elem])) {
+ foreach ($this->lookup[$elem] as $index) {
+ if ($this->elements[$index] === $elem) {
+ return; // Already exists.
+ }
+ }
+ }
+
+ $this->insertElement($elem, $elem);
+ $this->elementType = self::ELEM_TYPE_SCALAR;
+ }
+
+ private function addObjectWithHandler($object, ObjectBasicsHandler $handler)
+ {
+ $hash = $handler->hash($object);
+ if (isset($this->lookup[$hash])) {
+ foreach ($this->lookup[$hash] as $index) {
+ if ($handler->equals($object, $this->elements[$index])) {
+ return; // Already exists.
+ }
+ }
+ }
+
+ $this->insertElement($object, $hash);
+ $this->elementType = self::ELEM_TYPE_OBJECT_WITH_HANDLER;
+ }
+
+ private function addObject(ObjectBasics $elem)
+ {
+ $hash = $elem->hash();
+ if (isset($this->lookup[$hash])) {
+ foreach ($this->lookup[$hash] as $index) {
+ if ($elem->equals($this->elements[$index])) {
+ return; // Element already exists.
+ }
+ }
+ }
+
+ $this->insertElement($elem, $hash);
+ $this->elementType = self::ELEM_TYPE_OBJECT;
+ }
+
+ private function insertElement($elem, $hash)
+ {
+ $index = $this->elementCount++;
+ $this->elements[$index] = $elem;
+ $this->lookup[$hash][] = $index;
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpCollection;
+use PhpOption\Option;
+
+/**
+ * Interface for sets.
+ *
+ * Each Set contains equal values only once.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface SetInterface extends CollectionInterface, \IteratorAggregate
+{
+ /**
+ * @param object|scalar $elem
+ * @return void
+ */
+ public function add($elem);
+
+ /**
+ * @param object|scalar $elements
+ * @return void
+ */
+ public function addAll(array $elements);
+
+ /**
+ * @param object|scalar $elem
+ * @return void
+ */
+ public function remove($elem);
+
+ /**
+ * Returns the first element in the collection if available.
+ *
+ * @return Option
+ */
+ public function first();
+
+ /**
+ * Returns the last element in the collection if available.
+ *
+ * @return Option
+ */
+ public function last();
+
+ /**
+ * Returns all elements in this Set.
+ *
+ * @return array
+ */
+ public function all();
+
+ /**
+ * Returns a new Set with all elements in reverse order.
+ *
+ * @return SetInterface
+ */
+ public function reverse();
+
+ /**
+ * Adds the elements of another Set to this Set.
+ *
+ * @param SetInterface $seq
+ *
+ * @return SetInterface
+ */
+ public function addSet(SetInterface $seq);
+
+ /**
+ * Returns a new Set by omitting the given number of elements from the beginning.
+ *
+ * If the passed number is greater than the available number of elements, all will be removed.
+ *
+ * @param integer $number
+ *
+ * @return SetInterface
+ */
+ public function drop($number);
+
+ /**
+ * Returns a new Set by omitting the given number of elements from the end.
+ *
+ * If the passed number is greater than the available number of elements, all will be removed.
+ *
+ * @param integer $number
+ *
+ * @return SetInterface
+ */
+ public function dropRight($number);
+
+ /**
+ * Returns a new Set by omitting elements from the beginning for as long as the callable returns true.
+ *
+ * @param callable $callable Receives the element to drop as first argument, and returns true (drop), or false (stop).
+ *
+ * @return SetInterface
+ */
+ public function dropWhile($callable);
+
+ /**
+ * Creates a new collection by taking the given number of elements from the beginning
+ * of the current collection.
+ *
+ * If the passed number is greater than the available number of elements, then all elements
+ * will be returned as a new collection.
+ *
+ * @param integer $number
+ *
+ * @return CollectionInterface
+ */
+ public function take($number);
+
+ /**
+ * Creates a new collection by taking elements from the current collection
+ * for as long as the callable returns true.
+ *
+ * @param callable $callable
+ *
+ * @return CollectionInterface
+ */
+ public function takeWhile($callable);
+
+ /**
+ * Creates a new collection by applying the passed callable to all elements
+ * of the current collection.
+ *
+ * @param callable $callable
+ * @return CollectionInterface
+ */
+ public function map($callable);
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+/**
+ * Interface for sortable collections.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+interface SortableInterface
+{
+ public function sortWith($callable);
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpCollection;
+
+/**
+ * A sequence with a fixed sort-order.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+class SortedSequence extends AbstractSequence
+{
+ private $sortFunc;
+
+ public function __construct($sortFunc, array $elements = array())
+ {
+ usort($elements, $sortFunc);
+ parent::__construct($elements);
+
+ $this->sortFunc = $sortFunc;
+ }
+
+ public function add($newElement)
+ {
+ $added = false;
+ $newElements = array();
+ foreach ($this->elements as $element) {
+ // We insert the new element before the first element that is greater than itself.
+ if ( ! $added && (integer) call_user_func($this->sortFunc, $newElement, $element) < 0) {
+ $newElements[] = $newElement;
+ $added = true;
+ }
+
+ $newElements[] = $element;
+ }
+
+ if ( ! $added) {
+ $newElements[] = $newElement;
+ }
+ $this->elements = $newElements;
+ }
+
+ public function addAll(array $addedElements)
+ {
+ usort($addedElements, $this->sortFunc);
+
+ $newElements = array();
+ foreach ($this->elements as $element) {
+ if ( ! empty($addedElements)) {
+ foreach ($addedElements as $i => $newElement) {
+ // If the currently looked at $newElement is not smaller than $element, then we can also conclude
+ // that all other new elements are also not smaller than $element as we have ordered them before.
+ if ((integer) call_user_func($this->sortFunc, $newElement, $element) > -1) {
+ break;
+ }
+
+ $newElements[] = $newElement;
+ unset($addedElements[$i]);
+ }
+ }
+
+ $newElements[] = $element;
+ }
+
+ if ( ! empty($addedElements)) {
+ foreach ($addedElements as $newElement) {
+ $newElements[] = $newElement;
+ }
+ }
+
+ $this->elements = $newElements;
+ }
+
+ protected function createNew(array $elements)
+ {
+ return new static($this->sortFunc, $elements);
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpCollection\Tests;
+
+use PhpCollection\Map;
+
+class MapTest extends \PHPUnit_Framework_TestCase
+{
+ /** @var Map */
+ private $map;
+
+ public function testExists()
+ {
+ $this->assertFalse($this->map->exists(function($k) { return $k === 0; }));
+
+ $this->map->set('foo', 'bar');
+ $this->assertTrue($this->map->exists(function($k, $v) { return $k === 'foo' && $v === 'bar'; }));
+ }
+
+ public function testSet()
+ {
+ $this->assertTrue($this->map->get('asdf')->isEmpty());
+ $this->map->set('asdf', 'foo');
+ $this->assertEquals('foo', $this->map->get('asdf')->get());
+
+ $this->assertEquals('bar', $this->map->get('foo')->get());
+ $this->map->set('foo', 'asdf');
+ $this->assertEquals('asdf', $this->map->get('foo')->get());
+ }
+
+ public function testSetSetAll()
+ {
+ $this->map->setAll(array('foo' => 'asdf', 'bar' => array('foo')));
+ $this->assertEquals(array('foo' => 'asdf', 'bar' => array('foo'), 'baz' => 'boo'), iterator_to_array($this->map));
+ }
+
+ public function testAll()
+ {
+ $this->map->setAll(array('foo' => 'asdf', 'bar' => array('foo')));
+ $this->assertEquals(array('foo' => 'asdf', 'bar' => array('foo'), 'baz' => 'boo'), $this->map->all());
+ }
+
+ public function testAddMap()
+ {
+ $map = new Map();
+ $map->set('foo', array('bar'));
+ $this->map->addMap($map);
+
+ $this->assertEquals(array('foo' => array('bar'), 'bar' => 'baz', 'baz' => 'boo'), iterator_to_array($this->map));
+ }
+
+ public function testRemove()
+ {
+ $this->assertTrue($this->map->get('foo')->isDefined());
+ $this->assertEquals('bar', $this->map->remove('foo'));
+ $this->assertFalse($this->map->get('foo')->isDefined());
+ }
+
+ public function testClear()
+ {
+ $this->assertCount(3, $this->map);
+ $this->map->clear();
+ $this->assertCount(0, $this->map);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage The map has no key named "asdfasdf".
+ */
+ public function testRemoveWithUnknownIndex()
+ {
+ $this->map->remove('asdfasdf');
+ }
+
+ public function testFirst()
+ {
+ $this->assertEquals(array('foo', 'bar'), $this->map->first()->get());
+ $this->map->clear();
+ $this->assertTrue($this->map->first()->isEmpty());
+ }
+
+ public function testLast()
+ {
+ $this->assertEquals(array('baz', 'boo'), $this->map->last()->get());
+ $this->map->clear();
+ $this->assertTrue($this->map->last()->isEmpty());
+ }
+
+ public function testContains()
+ {
+ $this->assertTrue($this->map->contains('boo'));
+ $this->assertFalse($this->map->contains('asdf'));
+ }
+
+ public function testContainsKey()
+ {
+ $this->assertTrue($this->map->containsKey('foo'));
+ $this->assertFalse($this->map->containsKey('boo'));
+ }
+
+ public function testIsEmpty()
+ {
+ $this->assertFalse($this->map->isEmpty());
+ $this->map->clear();
+ $this->assertTrue($this->map->isEmpty());
+ }
+
+ public function testFilter()
+ {
+ $map = new Map(array('a' => 'b', 'c' => 'd', 'e' => 'f'));
+ $newMap = $map->filter(function($v) { return $v === 'd'; });
+
+ $this->assertNotSame($newMap, $map);
+ $this->assertCount(3, $map);
+ $this->assertCount(1, $newMap);
+ $this->assertEquals(array('c' => 'd'), iterator_to_array($newMap));
+ }
+
+ public function testFilterNot()
+ {
+ $map = new Map(array('a' => 'b', 'c' => 'd', 'e' => 'f'));
+ $newMap = $map->filterNot(function($v) { return $v === 'd'; });
+
+ $this->assertNotSame($newMap, $map);
+ $this->assertCount(3, $map);
+ $this->assertCount(2, $newMap);
+ $this->assertEquals(array('a' => 'b', 'e' => 'f'), iterator_to_array($newMap));
+ }
+
+ public function testFoldLeftRight()
+ {
+ $map = new Map(array('a' => 'b', 'c' => 'd', 'e' => 'f'));
+ $rsLeft = $map->foldLeft('', function($a, $b) { return $a.$b; });
+ $rsRight = $map->foldRight('', function($a, $b) { return $a.$b; });
+
+ $this->assertEquals('bdf', $rsLeft);
+ $this->assertEquals('bdf', $rsRight);
+ }
+
+ public function testDropWhile()
+ {
+ $newMap = $this->map->dropWhile(function($k, $v) { return 'foo' === $k || 'baz' === $v; });
+ $this->assertEquals(array('baz' => 'boo'), iterator_to_array($newMap));
+ $this->assertCount(3, $this->map);
+ }
+
+ public function testDrop()
+ {
+ $newMap = $this->map->drop(2);
+ $this->assertEquals(array('baz' => 'boo'), iterator_to_array($newMap));
+ $this->assertCount(3, $this->map);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage The number must be greater than 0, but got -4.
+ */
+ public function testDropWithNegativeNumber()
+ {
+ $this->map->drop(-4);
+ }
+
+ public function testDropRight()
+ {
+ $newMap = $this->map->dropRight(2);
+ $this->assertEquals(array('foo' => 'bar'), iterator_to_array($newMap));
+ $this->assertCount(3, $this->map);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage The number must be greater than 0, but got -5.
+ */
+ public function testDropRightWithNegativeNumber()
+ {
+ $this->map->dropRight(-5);
+ }
+
+ public function testTake()
+ {
+ $newMap = $this->map->take(1);
+ $this->assertEquals(array('foo' => 'bar'), iterator_to_array($newMap));
+ $this->assertCount(3, $this->map);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage The number must be greater than 0, but got -5.
+ */
+ public function testTakeWithNegativeNumber()
+ {
+ $this->map->take(-5);
+ }
+
+ public function testTakeWhile()
+ {
+ $newMap = $this->map->takeWhile(function($k, $v) { return 'foo' === $k || 'baz' === $v; });
+ $this->assertEquals(array('foo' => 'bar', 'bar' => 'baz'), iterator_to_array($newMap));
+ $this->assertCount(3, $this->map);
+ }
+
+ public function testFind()
+ {
+ $foundElem = $this->map->find(function($k, $v) { return 'foo' === $k && 'bar' === $v; });
+ $this->assertEquals(array('foo', 'bar'), $foundElem->get());
+
+ $this->assertTrue($this->map->find(function() { return false; })->isEmpty());
+ }
+
+ public function testKeys()
+ {
+ $this->assertEquals(array('foo', 'bar', 'baz'), $this->map->keys());
+ }
+
+ public function testValues()
+ {
+ $this->assertEquals(array('bar', 'baz', 'boo'), $this->map->values());
+ }
+
+ protected function setUp()
+ {
+ $this->map = new Map();
+ $this->map->setAll(array(
+ 'foo' => 'bar',
+ 'bar' => 'baz',
+ 'baz' => 'boo',
+ ));
+ }
+}
--- /dev/null
+<?php
+
+namespace PhpCollection\Tests;
+
+use PhpCollection\Sequence;
+use OutOfBoundsException;
+use stdClass;
+
+class SequenceTest extends \PHPUnit_Framework_TestCase
+{
+ /** @var Sequence */
+ private $seq;
+ private $a;
+ private $b;
+
+ public function testGet()
+ {
+ $this->assertSame(0, $this->seq->get(0));
+ $this->assertSame($this->a, $this->seq->get(1));
+ }
+
+ public function testIndexOf()
+ {
+ $this->assertSame(0, $this->seq->indexOf(0));
+ $this->assertSame(1, $this->seq->indexOf($this->a));
+ $this->assertSame(2, $this->seq->indexOf($this->b));
+ $this->assertSame(-1, $this->seq->indexOf(1));
+ }
+
+ public function testReverse()
+ {
+ $seq = new Sequence(array(1, 2, 3));
+ $this->assertEquals(array(1, 2, 3), $seq->all());
+ $this->assertEquals(array(3, 2, 1), $seq->reverse()->all());
+ }
+
+ public function testLastIndexOf()
+ {
+ $this->assertSame(3, $this->seq->lastIndexOf(0));
+ $this->assertSame(1, $this->seq->lastIndexOf($this->a));
+ $this->assertSame(2, $this->seq->lastIndexOf($this->b));
+ $this->assertSame(-1, $this->seq->lastIndexOf(1));
+ }
+
+ public function testFilter()
+ {
+ $seq = new Sequence(array(1, 2, 3));
+ $newSeq = $seq->filter(function($n) { return $n === 2; });
+
+ $this->assertNotSame($newSeq, $seq);
+ $this->assertCount(3, $seq);
+ $this->assertCount(1, $newSeq);
+ $this->assertSame(2, $newSeq->get(0));
+ }
+
+ public function testFilterNot()
+ {
+ $seq = new Sequence(array(1, 2, 3));
+ $newSeq = $seq->filterNot(function($n) { return $n === 2; });
+
+ $this->assertNotSame($newSeq, $seq);
+ $this->assertCount(3, $seq);
+ $this->assertCount(2, $newSeq);
+ $this->assertSame(1, $newSeq->get(0));
+ $this->assertSame(3, $newSeq->get(1));
+ }
+
+ public function testFoldLeftRight()
+ {
+ $seq = new Sequence(array('a', 'b', 'c'));
+ $rsLeft = $seq->foldLeft('', function($a, $b) { return $a.$b; });
+ $rsRight = $seq->foldRight('', function($a, $b) { return $a.$b; });
+
+ $this->assertEquals('abc', $rsLeft);
+ $this->assertEquals('abc', $rsRight);
+ }
+
+ public function testAddSequence()
+ {
+ $seq = new Sequence();
+ $seq->add(1);
+ $seq->add(0);
+
+ $this->seq->addSequence($seq);
+
+ $this->assertSame(array(
+ 0,
+ $this->a,
+ $this->b,
+ 0,
+ 1,
+ 0,
+ ), $this->seq->all());
+ }
+
+ public function testIsDefinedAt()
+ {
+ $this->assertTrue($this->seq->isDefinedAt(0));
+ $this->assertTrue($this->seq->isDefinedAt(1));
+ $this->assertFalse($this->seq->isDefinedAt(9999999));
+ }
+
+ public function testIndexWhere()
+ {
+ $this->assertSame(-1, $this->seq->indexWhere(function() { return false; }));
+ $this->assertSame(0, $this->seq->indexWhere(function() { return true; }));
+ }
+
+ public function testLastIndexWhere()
+ {
+ $this->assertSame(-1, $this->seq->lastIndexWhere(function() { return false; }));
+ $this->assertSame(3, $this->seq->lastIndexWhere(function() { return true; }));
+ }
+
+ public function testFirst()
+ {
+ $this->assertSame(0, $this->seq->first()->get());
+ $this->assertSame(0, $this->seq->last()->get());
+ }
+
+ public function testIndices()
+ {
+ $this->assertSame(array(0, 1, 2, 3), $this->seq->indices());
+ }
+
+ public function testContains()
+ {
+ $this->assertTrue($this->seq->contains(0));
+ $this->assertTrue($this->seq->contains($this->a));
+ $this->assertFalse($this->seq->contains(9999));
+ $this->assertFalse($this->seq->contains(new stdClass()));
+ }
+
+ public function testExists()
+ {
+ $this->assertTrue($this->seq->exists(function($v) { return $v === 0; }));
+
+ $a = $this->a;
+ $this->assertTrue($this->seq->exists(function($v) use ($a) { return $v === $a; }));
+
+ $this->assertFalse($this->seq->exists(function($v) { return $v === 9999; }));
+ $this->assertFalse($this->seq->exists(function($v) { return $v === new \stdClass; }));
+ }
+
+ public function testFind()
+ {
+ $a = $this->a;
+
+ $this->assertSame($this->a, $this->seq->find(function($x) use ($a) { return $a === $x; })->get());
+ $this->assertFalse($this->seq->find(function() { return false; })->isDefined());
+ }
+
+ public function testIsEmpty()
+ {
+ $this->assertFalse($this->seq->isEmpty());
+ $seq = new Sequence();
+ $this->assertTrue($seq->isEmpty());
+ }
+
+ public function testAdd()
+ {
+ $this->seq->add(1);
+ $this->assertSame(array(0, $this->a, $this->b, 0, 1), $this->seq->all());
+
+ $this->seq->sortWith(function($a, $b) {
+ if (is_integer($a)) {
+ if ( ! is_integer($b)) {
+ return -1;
+ }
+
+ return $a > $b ? 1 : -1;
+ }
+
+ if (is_integer($b)) {
+ return 1;
+ }
+
+ return 1;
+ });
+
+ $this->assertSame(array(0, 0, 1, $this->a, $this->b), $this->seq->all());
+ }
+
+ public function testUpdate()
+ {
+ $this->assertSame(0, $this->seq->get(0));
+ $this->seq->update(0, 5);
+ $this->assertSame(5, $this->seq->get(0));
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage There is no element at index "99999".
+ */
+ public function testUpdateWithNonExistentIndex()
+ {
+ $this->seq->update(99999, 0);
+ }
+
+ public function testAddAll()
+ {
+ $this->seq->addAll(array(2, 1, 3));
+ $this->assertSame(array(0, $this->a, $this->b, 0, 2, 1, 3), $this->seq->all());
+
+ $this->seq->sortWith(function($a, $b) {
+ if (is_integer($a)) {
+ if ( ! is_integer($b)) {
+ return -1;
+ }
+
+ return $a > $b ? 1 : -1;
+ }
+
+ if (is_integer($b)) {
+ return 1;
+ }
+
+ return -1;
+ });
+
+ $this->assertSame(array(0, 0, 1, 2, 3, $this->a, $this->b), $this->seq->all());
+ }
+
+ public function testTake()
+ {
+ $this->assertSame(array(0), $this->seq->take(1)->all());
+ $this->assertSame(array(0, $this->a), $this->seq->take(2)->all());
+ $this->assertSame(array(0, $this->a, $this->b, 0), $this->seq->take(9999)->all());
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage $number must be greater than 0, but got -5.
+ */
+ public function testTakeWithNegativeNumber()
+ {
+ $this->seq->take(-5);
+ }
+
+ public function testTakeWhile()
+ {
+ $this->assertSame(array(0), $this->seq->takeWhile('is_integer')->all());
+ }
+
+ public function testCount()
+ {
+ $this->assertCount(4, $this->seq);
+ }
+
+ public function testTraverse()
+ {
+ $this->assertSame(array(0, $this->a, $this->b, 0), iterator_to_array($this->seq));
+ }
+
+ public function testDrop()
+ {
+ $this->assertSame(array($this->a, $this->b, 0), $this->seq->drop(1)->all());
+ $this->assertSame(array($this->b, 0), $this->seq->drop(2)->all());
+ $this->assertSame(array(), $this->seq->drop(9999)->all());
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage The number must be greater than 0, but got -5.
+ */
+ public function testDropWithNegativeIndex()
+ {
+ $this->seq->drop(-5);
+ }
+
+ public function testDropRight()
+ {
+ $this->assertSame(array(0, $this->a, $this->b), $this->seq->dropRight(1)->all());
+ $this->assertSame(array(0, $this->a), $this->seq->dropRight(2)->all());
+ $this->assertSame(array(), $this->seq->dropRight(9999)->all());
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage The number must be greater than 0, but got -5.
+ */
+ public function testDropRightWithNegativeIndex()
+ {
+ $this->seq->dropRight(-5);
+ }
+
+ public function testDropWhile()
+ {
+ $this->assertSame(array(0, $this->a, $this->b, 0), $this->seq->dropWhile(function() { return false; })->all());
+ $this->assertSame(array(), $this->seq->dropWhile(function() { return true; })->all());
+ }
+
+ public function testRemove()
+ {
+ $this->assertSame(0, $this->seq->remove(0));
+ $this->assertSame($this->a, $this->seq->remove(0));
+ $this->assertSame(0, $this->seq->remove(1));
+ }
+
+ /**
+ * @expectedException OutOfBoundsException
+ * @expectedExceptionMessage The index "9999" is not in the interval [0, 4).
+ */
+ public function testRemoveWithInvalidIndex()
+ {
+ $this->seq->remove(9999);
+ }
+
+ public function testMap()
+ {
+ $seq = new Sequence();
+ $seq->add('a');
+ $seq->add('b');
+
+ $self = $this;
+ $newSeq = $seq->map(function($elem) use ($self) {
+ switch ($elem) {
+ case 'a':
+ return 'c';
+
+ case 'b':
+ return 'd';
+
+ default:
+ $self->fail('Unexpected element: ' . var_export($elem, true));
+ }
+ });
+
+ $this->assertInstanceOf('PhpCollection\Sequence', $newSeq);
+ $this->assertNotSame($newSeq, $seq);
+ $this->assertEquals(array('c', 'd'), $newSeq->all());
+ }
+
+ protected function setUp()
+ {
+ $this->seq = new Sequence();
+ $this->seq->addAll(array(
+ 0,
+ $this->a = new \stdClass(),
+ $this->b = new \stdClass(),
+ 0
+ ));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpCollection\Tests;
+
+use PhpCollection\ObjectBasics;
+use PhpCollection\ObjectBasicsHandlerRegistry;
+use PhpCollection\Set;
+
+class SetTest extends \PHPUnit_Framework_TestCase
+{
+ /** @var Set */
+ private $set;
+
+ public function testContainsScalar()
+ {
+ $this->set->add('a');
+
+ $this->assertFalse($this->set->contains('b'));
+ $this->assertFalse($this->set->contains(new ObjectThatImplementsBasics('foo')));
+ $this->assertFalse($this->set->contains(new \DateTime('today')));
+ }
+
+ public function testContainsObjectWithHandler()
+ {
+ $this->set->add(new \DateTime('today'));
+
+ $this->assertFalse($this->set->contains(new ObjectThatImplementsBasics('foo')));
+ $this->assertFalse($this->set->contains('a'));
+
+ $this->assertTrue($this->set->contains(new \DateTime('today')));
+ }
+
+ public function testContainsObject()
+ {
+ $this->set->add(new ObjectThatImplementsBasics('foo'));
+
+ $this->assertFalse($this->set->contains(new ObjectThatImplementsBasics('bar')));
+ $this->assertFalse($this->set->contains('a'));
+ $this->assertFalse($this->set->contains(new \DateTime()));
+
+ $this->assertTrue($this->set->contains(new ObjectThatImplementsBasics('foo')));
+ }
+
+ public function testReverse()
+ {
+ $this->set->add('a');
+ $this->set->add('b');
+ $this->assertEquals(array('a', 'b'), $this->set->all());
+
+ $reversedSet = $this->set->reverse();
+ $this->assertEquals(array('a', 'b'), $this->set->all());
+ $this->assertEquals(array('b', 'a'), $reversedSet->all());
+ }
+
+ public function testMap()
+ {
+ $this->set->add('a');
+ $this->set->add('b');
+ $this->assertEquals(array('a', 'b'), $this->set->all());
+
+ $newSet = $this->set->map(function($char) {
+ if ($char === 'a') {
+ return 'c';
+ } elseif ($char === 'b') {
+ return 'd';
+ }
+
+ return $char;
+ });
+
+ $this->assertEquals(array('a', 'b'), $this->set->all());
+ $this->assertEquals(array('c', 'd'), $newSet->all());
+ }
+
+ public function testRemoveScalar()
+ {
+ $this->set->add('a');
+ $this->assertCount(1, $this->set);
+
+ $this->set->remove('b');
+ $this->assertCount(1, $this->set);
+
+ $this->set->remove('a');
+ $this->assertCount(0, $this->set);
+ $this->assertTrue($this->set->isEmpty());
+ }
+
+ public function testRemoveObjectWithHandler()
+ {
+ $this->set->add(new \DateTime('today'));
+ $this->assertCount(1, $this->set);
+
+ $this->set->remove(new \DateTime('-2 days'));
+ $this->assertCount(1, $this->set);
+
+ $this->set->remove(new \DateTime('today'));
+ $this->assertCount(0, $this->set);
+ $this->assertTrue($this->set->isEmpty());
+ }
+
+ public function testRemoveObject()
+ {
+ $this->set->add(new ObjectThatImplementsBasics('foo'));
+ $this->assertCount(1, $this->set);
+
+ $this->set->remove(new ObjectThatImplementsBasics('bar'));
+ $this->assertCount(1, $this->set);
+
+ $this->set->remove(new ObjectThatImplementsBasics('foo'));
+ $this->assertCount(0, $this->set);
+ $this->assertTrue($this->set->isEmpty());
+ }
+
+ public function testAddScalar()
+ {
+ $this->set->add('a');
+ $this->set->add('b');
+ $this->set->add('a');
+
+ $this->assertEquals(array('a', 'b'), $this->set->all());
+ }
+
+ public function testAddObject()
+ {
+ $this->set->add(new ObjectThatImplementsBasics('foo'));
+ $this->set->add(new ObjectThatImplementsBasics('bar'));
+ $this->set->add(new ObjectThatImplementsBasics('foo'));
+
+ $this->assertEquals(
+ array(
+ new ObjectThatImplementsBasics('foo'),
+ new ObjectThatImplementsBasics('bar')
+ ),
+ $this->set->all()
+ );
+ }
+
+ public function testAddObjectWithHandler()
+ {
+ $this->set->add((new \DateTime('today'))->setTimezone(new \DateTimeZone('UTC')));
+ $this->set->add((new \DateTime('today'))->setTimezone(new \DateTimeZone('UTC')));
+ $this->set->add((new \DateTime('today'))->setTimezone(new \DateTimeZone('US/Pacific')));
+
+ $this->assertEquals(
+ array(
+ (new \DateTime('today'))->setTimezone(new \DateTimeZone('UTC')),
+ (new \DateTime('today'))->setTimezone(new \DateTimeZone('US/Pacific')),
+ ),
+ $this->set->all()
+ );
+ }
+
+ protected function setUp()
+ {
+ $this->set = new Set();
+ }
+}
+
+class ObjectThatImplementsBasics implements ObjectBasics
+{
+ private $value;
+
+ public function __construct($value)
+ {
+ $this->value = $value;
+ }
+
+ public function hash()
+ {
+ return 'foo'; // This is not recommended in the real-world.
+ }
+
+ public function equals(ObjectBasics $other)
+ {
+ if ($this === $other) {
+ return true;
+ }
+ if ( ! $other instanceof ObjectThatImplementsBasics) {
+ return false;
+ }
+
+ return $this->value === $other->value;
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpCollection\Tests;
+
+use PhpCollection\SortedSequence;
+
+class SortedSequenceTest extends \PHPUnit_Framework_TestCase
+{
+ private $seq;
+ private $a;
+ private $b;
+
+ public function testAdd()
+ {
+ $this->seq->add(1);
+ $this->assertSame(array(0, 0, 1, $this->a, $this->b), $this->seq->all());
+
+ $this->seq->add(2);
+ $this->assertSame(array(0, 0, 1, 2, $this->a, $this->b), $this->seq->all());
+ }
+
+ public function testAddAll()
+ {
+ $this->seq->addAll(array(2, 1, 3));
+ $this->assertSame(array(0, 0, 1, 2, 3, $this->a, $this->b), $this->seq->all());
+
+ $this->seq->addAll(array(2, 3, 1, 2));
+ $this->assertSame(array(0, 0, 1, 1, 2, 2, 2, 3, 3, $this->a, $this->b), $this->seq->all());
+ }
+
+ public function testTake()
+ {
+ $seq = $this->seq->take(2);
+ $this->assertInstanceOf('PhpCollection\SortedSequence', $seq);
+ $this->assertSame(array(0, 0), $seq->all());
+ }
+
+ protected function setUp()
+ {
+ $this->seq = new SortedSequence(function($a, $b) {
+ if (is_integer($a)) {
+ if ( ! is_integer($b)) {
+ return -1;
+ }
+
+ return $a - $b;
+ }
+
+ if (is_integer($b)) {
+ return 1;
+ }
+
+ return -1;
+ });
+ $this->seq->addAll(array(
+ 0,
+ $this->a = new \stdClass,
+ $this->b = new \stdClass,
+ 0,
+ ));
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+if ( ! is_file($autoloadFile = __DIR__.'/../vendor/autoload.php')) {
+ echo 'Could not find "vendor/autoload.php". Did you forget to run "composer install --dev"?'.PHP_EOL;
+ exit(1);
+}
+
+require_once $autoloadFile;
\ No newline at end of file
--- /dev/null
+vendor/
+phpunit.xml
+composer.lock
--- /dev/null
+language: php
+php:
+ - 5.3
+ - 5.4
+ - 5.5
+ - hhvm
+
+before_script:
+ - wget http://getcomposer.org/composer.phar
+ - php composer.phar install --dev
+
+script:
+ - phpunit
+
+matrix:
+ allow_failures:
+ - php: hhvm
--- /dev/null
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
--- /dev/null
+PHP Option Type [](http://travis-ci.org/schmittjoh/php-option) [](https://scrutinizer-ci.com/g/schmittjoh/php-option/)
+===============
+This adds an Option type for PHP.
+
+The Option type is intended for cases where you sometimes might return a value
+(typically an object), and sometimes you might return no value (typically null)
+depending on arguments, or other runtime factors.
+
+Often times, you forget to handle the case where no value is returned. Not intentionally
+of course, but maybe you did not account for all possible states of the system; or maybe you
+indeed covered all cases, then time goes on, code is refactored, some of these your checks
+might become invalid, or incomplete. Suddenly, without noticing, the no value case is not
+handled anymore. As a result, you might sometimes get fatal PHP errors telling you that
+you called a method on a non-object; users might see blank pages, or worse.
+
+On one hand, the Option type forces a developer to consciously think about both cases
+(returning a value, or returning no value). That in itself will already make your code more
+robust. On the other hand, the Option type also allows the API developer to provide
+more concise API methods, and empowers the API user in how he consumes these methods.
+
+Installation
+============
+Installation is super-easy via composer
+
+```
+composer require phpoption/phpoption
+```
+
+or add it to your composer.json file.
+
+
+Usage
+=====
+
+Using the Option Type in your API
+---------------------------------
+```php
+class MyRepository
+{
+ public function findSomeEntity($criteria)
+ {
+ if (null !== $entity = $this->em->find(...)) {
+ return new \PhpOption\Some($entity);
+ }
+
+ // We use a singleton, for the None case.
+ return \PhpOption\None::create();
+ }
+}
+```
+
+If you are consuming an existing library, you can also use a shorter version
+which by default treats ``null`` as ``None``, and everything else as ``Some`` case:
+
+```php
+class MyRepository
+{
+ public function findSomeEntity($criteria)
+ {
+ return \PhpOption\Option::fromValue($this->em->find(...));
+
+ // or, if you want to change the none value to false for example:
+ return \PhpOption\Option::fromValue($this->em->find(...), false);
+ }
+}
+```
+
+Case 1: You always Require an Entity in Calling Code
+----------------------------------------------------
+```php
+$entity = $repo->findSomeEntity(...)->get(); // returns entity, or throws exception
+```
+
+Case 2: Fallback to Default Value If Not Available
+--------------------------------------------------
+```php
+$entity = $repo->findSomeEntity(...)->getOrElse(new Entity());
+
+// Or, if you want to lazily create the entity.
+$entity = $repo->findSomeEntity(...)->getOrCall(function() {
+ return new Entity();
+});
+```
+
+More Examples
+=============
+
+No More Boiler Plate Code
+-------------------------
+```php
+// Before
+if (null === $entity = $this->findSomeEntity()) {
+ throw new NotFoundException();
+}
+echo $entity->name;
+
+// After
+echo $this->findSomeEntity()->get()->name;
+```
+
+No More Control Flow Exceptions
+-------------------------------
+```php
+// Before
+try {
+ $entity = $this->findSomeEntity();
+} catch (NotFoundException $ex) {
+ $entity = new Entity();
+}
+
+// After
+$entity = $this->findSomeEntity()->getOrElse(new Entity());
+```
+
+More Concise Null Handling
+--------------------------
+```php
+// Before
+$entity = $this->findSomeEntity();
+if (null === $entity) {
+ return new Entity();
+}
+
+return $entity;
+
+// After
+return $this->findSomeEntity()->getOrElse(new Entity());
+```
+
+Trying Multiple Alternative Options
+-----------------------------------
+If you'd like to try multiple alternatives, the ``orElse`` method allows you to
+do this very elegantly:
+
+```php
+return $this->findSomeEntity()
+ ->orElse($this->findSomeOtherEntity())
+ ->orElse($this->createEntity());
+```
+The first option which is non-empty will be returned. This is especially useful
+with lazy-evaluated options, see below.
+
+Lazy-Evaluated Options
+----------------------
+The above example has the flaw that we would need to evaluate all options when
+the method is called which creates unnecessary overhead if the first option is
+already non-empty.
+
+Fortunately, we can easily solve this by using the ``LazyOption`` class:
+
+```php
+return $this->findSomeEntity()
+ ->orElse(new LazyOption(array($this, 'findSomeOtherEntity')))
+ ->orElse(new LazyOption(array($this, 'createEntity')));
+```
+
+This way, only the options that are necessary will actually be evaluated.
+
+
+Performance Considerations
+==========================
+Of course, performance is important. Attached is a performance benchmark which
+you can run on a machine of your choosing.
+
+The overhead incurred by the Option type comes down to the time that it takes to
+create one object, our wrapper. Also, we need to perform one additional method call
+to retrieve the value from the wrapper.
+
+* Overhead: Creation of 1 Object, and 1 Method Call
+* Average Overhead per Invocation (some case/value returned): 0.000000761s (that is 761 nano seconds)
+* Average Overhead per Invocation (none case/null returned): 0.000000368s (that is 368 nano seconds)
+
+The benchmark was run under Ubuntu precise with PHP 5.4.6. As you can see the
+overhead is surprisingly low, almost negligible.
+
+So in conclusion, unless you plan to call a method thousands of times during a
+request, there is no reason to stick to the ``object|null`` return value; better give
+your code some options!
--- /dev/null
+{
+ "name": "phpoption/phpoption",
+ "description": "Option Type for PHP",
+ "keywords": ["php","option","language","type"],
+ "type": "library",
+ "license": "Apache2",
+ "authors": [
+ {
+ "name": "Johannes M. Schmitt",
+ "email": "schmittjoh@gmail.com"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "4.7.*"
+ },
+ "autoload": {
+ "psr-0": { "PhpOption\\": "src/" }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "1.3-dev"
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ colors="true"
+ convertErrorsToExceptions="true"
+ convertNoticesToExceptions="true"
+ convertWarningsToExceptions="true"
+ processIsolation="false"
+ stopOnFailure="false"
+ syntaxCheck="false"
+ bootstrap="tests/bootstrap.php"
+>
+ <testsuites>
+ <testsuite name="PhpOption Type Test Suite">
+ <directory>./tests/PhpOption/</directory>
+ </testsuite>
+ </testsuites>
+
+ <groups>
+ <exclude>
+ <group>performance</group>
+ </exclude>
+ </groups>
+</phpunit>
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpOption;
+
+final class LazyOption extends Option
+{
+ /** @var callable */
+ private $callback;
+
+ /** @var array */
+ private $arguments;
+
+ /** @var Option|null */
+ private $option;
+
+ /**
+ * Helper Constructor.
+ *
+ * @param callable $callback
+ * @param array $arguments
+ *
+ * @return LazyOption
+ */
+ public static function create($callback, array $arguments = array())
+ {
+ return new self($callback, $arguments);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param callable $callback
+ * @param array $arguments
+ */
+ public function __construct($callback, array $arguments = array())
+ {
+ if (!is_callable($callback)) {
+ throw new \InvalidArgumentException('Invalid callback given');
+ }
+
+ $this->callback = $callback;
+ $this->arguments = $arguments;
+ }
+
+ public function isDefined()
+ {
+ return $this->option()->isDefined();
+ }
+
+ public function isEmpty()
+ {
+ return $this->option()->isEmpty();
+ }
+
+ public function get()
+ {
+ return $this->option()->get();
+ }
+
+ public function getOrElse($default)
+ {
+ return $this->option()->getOrElse($default);
+ }
+
+ public function getOrCall($callable)
+ {
+ return $this->option()->getOrCall($callable);
+ }
+
+ public function getOrThrow(\Exception $ex)
+ {
+ return $this->option()->getOrThrow($ex);
+ }
+
+ public function orElse(Option $else)
+ {
+ return $this->option()->orElse($else);
+ }
+
+ /**
+ * @deprecated Use forAll() instead.
+ */
+ public function ifDefined($callable)
+ {
+ $this->option()->ifDefined($callable);
+ }
+
+ public function forAll($callable)
+ {
+ return $this->option()->forAll($callable);
+ }
+
+ public function map($callable)
+ {
+ return $this->option()->map($callable);
+ }
+
+ public function flatMap($callable)
+ {
+ return $this->option()->flatMap($callable);
+ }
+
+ public function filter($callable)
+ {
+ return $this->option()->filter($callable);
+ }
+
+ public function filterNot($callable)
+ {
+ return $this->option()->filterNot($callable);
+ }
+
+ public function select($value)
+ {
+ return $this->option()->select($value);
+ }
+
+ public function reject($value)
+ {
+ return $this->option()->reject($value);
+ }
+
+ public function getIterator()
+ {
+ return $this->option()->getIterator();
+ }
+
+ public function foldLeft($initialValue, $callable)
+ {
+ return $this->option()->foldLeft($initialValue, $callable);
+ }
+
+ public function foldRight($initialValue, $callable)
+ {
+ return $this->option()->foldRight($initialValue, $callable);
+ }
+
+ /**
+ * @return Option
+ */
+ private function option()
+ {
+ if (null === $this->option) {
+ $this->option = call_user_func_array($this->callback, $this->arguments);
+ if (!$this->option instanceof Option) {
+ $this->option = null;
+ throw new \RuntimeException('Expected instance of \PhpOption\Option');
+ }
+ }
+
+ return $this->option;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpOption;
+
+use EmptyIterator;
+
+final class None extends Option
+{
+ private static $instance;
+
+ public static function create()
+ {
+ if (null === self::$instance) {
+ self::$instance = new self();
+ }
+
+ return self::$instance;
+ }
+
+ public function get()
+ {
+ throw new \RuntimeException('None has no value.');
+ }
+
+ public function getOrCall($callable)
+ {
+ return call_user_func($callable);
+ }
+
+ public function getOrElse($default)
+ {
+ return $default;
+ }
+
+ public function getOrThrow(\Exception $ex)
+ {
+ throw $ex;
+ }
+
+ public function isEmpty()
+ {
+ return true;
+ }
+
+ public function isDefined()
+ {
+ return false;
+ }
+
+ public function orElse(Option $else)
+ {
+ return $else;
+ }
+
+ /**
+ * @deprecated Use forAll() instead.
+ */
+ public function ifDefined($callable)
+ {
+ // Just do nothing in that case.
+ }
+
+ public function forAll($callable)
+ {
+ return $this;
+ }
+
+ public function map($callable)
+ {
+ return $this;
+ }
+
+ public function flatMap($callable)
+ {
+ return $this;
+ }
+
+ public function filter($callable)
+ {
+ return $this;
+ }
+
+ public function filterNot($callable)
+ {
+ return $this;
+ }
+
+ public function select($value)
+ {
+ return $this;
+ }
+
+ public function reject($value)
+ {
+ return $this;
+ }
+
+ public function getIterator()
+ {
+ return new EmptyIterator();
+ }
+
+ public function foldLeft($initialValue, $callable)
+ {
+ return $initialValue;
+ }
+
+ public function foldRight($initialValue, $callable)
+ {
+ return $initialValue;
+ }
+
+ private function __construct() { }
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpOption;
+
+use IteratorAggregate;
+
+/**
+ * Base Option Class.
+ *
+ * @author Johannes M. Schmitt <schmittjoh@gmail.com>
+ */
+abstract class Option implements IteratorAggregate
+{
+ /**
+ * Creates an option given a return value.
+ *
+ * This is intended for consuming existing APIs and allows you to easily
+ * convert them to an option. By default, we treat ``null`` as the None case,
+ * and everything else as Some.
+ *
+ * @param mixed $value The actual return value.
+ * @param mixed $noneValue The value which should be considered "None"; null
+ * by default.
+ *
+ * @return Option
+ */
+ public static function fromValue($value, $noneValue = null)
+ {
+ if ($value === $noneValue) {
+ return None::create();
+ }
+
+ return new Some($value);
+ }
+
+ /**
+ * Creates an option from an array's value.
+ *
+ * If the key does not exist in the array, the array is not actually an array, or the
+ * array's value at the given key is null, None is returned.
+ *
+ * Otherwise, Some is returned wrapping the value at the given key.
+ *
+ * @param mixed $array a potential array value
+ * @param string $key the key to check
+ *
+ * @return Option
+ */
+ public static function fromArraysValue($array, $key)
+ {
+ if ( ! isset($array[$key])) {
+ return None::create();
+ }
+
+ return new Some($array[$key]);
+ }
+
+ /**
+ * Creates a lazy-option with the given callback.
+ *
+ * This is also a helper constructor for lazy-consuming existing APIs where
+ * the return value is not yet an option. By default, we treat ``null`` as
+ * None case, and everything else as Some.
+ *
+ * @param callable $callback The callback to evaluate.
+ * @param array $arguments
+ * @param mixed $noneValue The value which should be considered "None"; null
+ * by default.
+ *
+ * @return Option
+ */
+ public static function fromReturn($callback, array $arguments = array(), $noneValue = null)
+ {
+ return new LazyOption(function() use ($callback, $arguments, $noneValue) {
+ $return = call_user_func_array($callback, $arguments);
+
+ if ($return === $noneValue) {
+ return None::create();
+ }
+
+ return new Some($return);
+ });
+ }
+
+ /**
+ * Option factory, which creates new option based on passed value.
+ * If value is already an option, it simply returns
+ * If value is a \Closure, LazyOption with passed callback created and returned. If Option returned from callback,
+ * it returns directly (flatMap-like behaviour)
+ * On other case value passed to Option::fromValue() method
+ *
+ * @param Option|\Closure|mixed $value
+ * @param null $noneValue used when $value is mixed or Closure, for None-check
+ *
+ * @return Option
+ */
+ public static function ensure($value, $noneValue = null)
+ {
+ if ($value instanceof Option) {
+ return $value;
+ } elseif ($value instanceof \Closure) {
+ return new LazyOption(function() use ($value, $noneValue) {
+ $return = $value();
+
+ if ($return instanceof Option) {
+ return $return;
+ } else {
+ return Option::fromValue($return, $noneValue);
+ }
+ });
+ } else {
+ return Option::fromValue($value, $noneValue);
+ }
+ }
+
+ /**
+ * Returns the value if available, or throws an exception otherwise.
+ *
+ * @throws \RuntimeException if value is not available
+ *
+ * @return mixed
+ */
+ abstract public function get();
+
+ /**
+ * Returns the value if available, or the default value if not.
+ *
+ * @param mixed $default
+ *
+ * @return mixed
+ */
+ abstract public function getOrElse($default);
+
+ /**
+ * Returns the value if available, or the results of the callable.
+ *
+ * This is preferable over ``getOrElse`` if the computation of the default
+ * value is expensive.
+ *
+ * @param callable $callable
+ *
+ * @return mixed
+ */
+ abstract public function getOrCall($callable);
+
+ /**
+ * Returns the value if available, or throws the passed exception.
+ *
+ * @param \Exception $ex
+ *
+ * @return mixed
+ */
+ abstract public function getOrThrow(\Exception $ex);
+
+ /**
+ * Returns true if no value is available, false otherwise.
+ *
+ * @return boolean
+ */
+ abstract public function isEmpty();
+
+ /**
+ * Returns true if a value is available, false otherwise.
+ *
+ * @return boolean
+ */
+ abstract public function isDefined();
+
+ /**
+ * Returns this option if non-empty, or the passed option otherwise.
+ *
+ * This can be used to try multiple alternatives, and is especially useful
+ * with lazy evaluating options:
+ *
+ * ```php
+ * $repo->findSomething()
+ * ->orElse(new LazyOption(array($repo, 'findSomethingElse')))
+ * ->orElse(new LazyOption(array($repo, 'createSomething')));
+ * ```
+ *
+ * @param Option $else
+ *
+ * @return Option
+ */
+ abstract public function orElse(Option $else);
+
+ /**
+ * This is similar to map() below except that the return value has no meaning;
+ * the passed callable is simply executed if the option is non-empty, and
+ * ignored if the option is empty.
+ *
+ * In all cases, the return value of the callable is discarded.
+ *
+ * ```php
+ * $comment->getMaybeFile()->ifDefined(function($file) {
+ * // Do something with $file here.
+ * });
+ * ```
+ *
+ * If you're looking for something like ``ifEmpty``, you can use ``getOrCall``
+ * and ``getOrElse`` in these cases.
+ *
+ * @deprecated Use forAll() instead.
+ *
+ * @param callable $callable
+ *
+ * @return void
+ */
+ abstract public function ifDefined($callable);
+
+ /**
+ * This is similar to map() except that the return value of the callable has no meaning.
+ *
+ * The passed callable is simply executed if the option is non-empty, and ignored if the
+ * option is empty. This method is preferred for callables with side-effects, while map()
+ * is intended for callables without side-effects.
+ *
+ * @param callable $callable
+ *
+ * @return Option
+ */
+ abstract public function forAll($callable);
+
+ /**
+ * Applies the callable to the value of the option if it is non-empty,
+ * and returns the return value of the callable wrapped in Some().
+ *
+ * If the option is empty, then the callable is not applied.
+ *
+ * ```php
+ * (new Some("foo"))->map('strtoupper')->get(); // "FOO"
+ * ```
+ *
+ * @param callable $callable
+ *
+ * @return Option
+ */
+ abstract public function map($callable);
+
+ /**
+ * Applies the callable to the value of the option if it is non-empty, and
+ * returns the return value of the callable directly.
+ *
+ * In contrast to ``map``, the return value of the callable is expected to
+ * be an Option itself; it is not automatically wrapped in Some().
+ *
+ * @param callable $callable must return an Option
+ *
+ * @return Option
+ */
+ abstract public function flatMap($callable);
+
+ /**
+ * If the option is empty, it is returned immediately without applying the callable.
+ *
+ * If the option is non-empty, the callable is applied, and if it returns true,
+ * the option itself is returned; otherwise, None is returned.
+ *
+ * @param callable $callable
+ *
+ * @return Option
+ */
+ abstract public function filter($callable);
+
+ /**
+ * If the option is empty, it is returned immediately without applying the callable.
+ *
+ * If the option is non-empty, the callable is applied, and if it returns false,
+ * the option itself is returned; otherwise, None is returned.
+ *
+ * @param callable $callable
+ *
+ * @return Option
+ */
+ abstract public function filterNot($callable);
+
+ /**
+ * If the option is empty, it is returned immediately.
+ *
+ * If the option is non-empty, and its value does not equal the passed value
+ * (via a shallow comparison ===), then None is returned. Otherwise, the
+ * Option is returned.
+ *
+ * In other words, this will filter all but the passed value.
+ *
+ * @param mixed $value
+ *
+ * @return Option
+ */
+ abstract public function select($value);
+
+ /**
+ * If the option is empty, it is returned immediately.
+ *
+ * If the option is non-empty, and its value does equal the passed value (via
+ * a shallow comparison ===), then None is returned; otherwise, the Option is
+ * returned.
+ *
+ * In other words, this will let all values through except the passed value.
+ *
+ * @param mixed $value
+ *
+ * @return Option
+ */
+ abstract public function reject($value);
+
+ /**
+ * Binary operator for the initial value and the option's value.
+ *
+ * If empty, the initial value is returned.
+ * If non-empty, the callable receives the initial value and the option's value as arguments
+ *
+ * ```php
+ *
+ * $some = new Some(5);
+ * $none = None::create();
+ * $result = $some->foldLeft(1, function($a, $b) { return $a + $b; }); // int(6)
+ * $result = $none->foldLeft(1, function($a, $b) { return $a + $b; }); // int(1)
+ *
+ * // This can be used instead of something like the following:
+ * $option = Option::fromValue($integerOrNull);
+ * $result = 1;
+ * if ( ! $option->isEmpty()) {
+ * $result += $option->get();
+ * }
+ * ```
+ *
+ * @param mixed $initialValue
+ * @param callable $callable function(initialValue, callable): result
+ *
+ * @return mixed
+ */
+ abstract public function foldLeft($initialValue, $callable);
+
+ /**
+ * foldLeft() but with reversed arguments for the callable.
+ *
+ * @param mixed $initialValue
+ * @param callable $callable function(callable, initialValue): result
+ *
+ * @return mixed
+ */
+ abstract public function foldRight($initialValue, $callable);
+}
--- /dev/null
+<?php
+
+/*
+ * Copyright 2012 Johannes M. Schmitt <schmittjoh@gmail.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace PhpOption;
+
+use ArrayIterator;
+
+final class Some extends Option
+{
+ private $value;
+
+ public function __construct($value)
+ {
+ $this->value = $value;
+ }
+
+ public static function create($value)
+ {
+ return new self($value);
+ }
+
+ public function isDefined()
+ {
+ return true;
+ }
+
+ public function isEmpty()
+ {
+ return false;
+ }
+
+ public function get()
+ {
+ return $this->value;
+ }
+
+ public function getOrElse($default)
+ {
+ return $this->value;
+ }
+
+ public function getOrCall($callable)
+ {
+ return $this->value;
+ }
+
+ public function getOrThrow(\Exception $ex)
+ {
+ return $this->value;
+ }
+
+ public function orElse(Option $else)
+ {
+ return $this;
+ }
+
+ /**
+ * @deprecated Use forAll() instead.
+ */
+ public function ifDefined($callable)
+ {
+ call_user_func($callable, $this->value);
+ }
+
+ public function forAll($callable)
+ {
+ call_user_func($callable, $this->value);
+
+ return $this;
+ }
+
+ public function map($callable)
+ {
+ return new self(call_user_func($callable, $this->value));
+ }
+
+ public function flatMap($callable)
+ {
+ $rs = call_user_func($callable, $this->value);
+ if ( ! $rs instanceof Option) {
+ throw new \RuntimeException('Callables passed to flatMap() must return an Option. Maybe you should use map() instead?');
+ }
+
+ return $rs;
+ }
+
+ public function filter($callable)
+ {
+ if (true === call_user_func($callable, $this->value)) {
+ return $this;
+ }
+
+ return None::create();
+ }
+
+ public function filterNot($callable)
+ {
+ if (false === call_user_func($callable, $this->value)) {
+ return $this;
+ }
+
+ return None::create();
+ }
+
+ public function select($value)
+ {
+ if ($this->value === $value) {
+ return $this;
+ }
+
+ return None::create();
+ }
+
+ public function reject($value)
+ {
+ if ($this->value === $value) {
+ return None::create();
+ }
+
+ return $this;
+ }
+
+ public function getIterator()
+ {
+ return new ArrayIterator(array($this->value));
+ }
+
+ public function foldLeft($initialValue, $callable)
+ {
+ return call_user_func($callable, $initialValue, $this->value);
+ }
+
+ public function foldRight($initialValue, $callable)
+ {
+ return call_user_func($callable, $this->value, $initialValue);
+ }
+}
--- /dev/null
+<?php
+
+namespace PhpOption\Tests;
+
+use PhpOption\None;
+use PhpOption\Option;
+use PhpOption\Some;
+
+/**
+ * Tests for Option::ensure() method
+ *
+ * @covers Option::ensure
+ */
+class EnsureTest extends \PHPUnit_Framework_TestCase
+{
+ protected function ensure($value, $noneValue = null)
+ {
+ $option = Option::ensure($value, $noneValue);
+ $this->assertInstanceOf('PhpOption\Option', $option);
+ return $option;
+ }
+
+ public function testMixedValue()
+ {
+ $option = $this->ensure(1);
+ $this->assertTrue($option->isDefined());
+ $this->assertSame(1, $option->get());
+ $this->assertFalse($this->ensure(null)->isDefined());
+ $this->assertFalse($this->ensure(1,1)->isDefined());
+ }
+
+ public function testReturnValue()
+ {
+ $option = $this->ensure(function() { return 1; });
+ $this->assertTrue($option->isDefined());
+ $this->assertSame(1, $option->get());
+ $this->assertFalse($this->ensure(function() { return null; })->isDefined());
+ $this->assertFalse($this->ensure(function() { return 1; }, 1)->isDefined());
+ }
+
+ public function testOptionReturnsAsSameInstance()
+ {
+ $option = $this->ensure(1);
+ $this->assertSame($option, $this->ensure($option));
+ }
+
+ public function testOptionReturnedFromClosure()
+ {
+ $option = $this->ensure(function() { return Some::create(1); });
+ $this->assertTrue($option->isDefined());
+ $this->assertSame(1, $option->get());
+
+ $option = $this->ensure(function() { return None::create(); });
+ $this->assertFalse($option->isDefined());
+ }
+
+ public function testClosureReturnedFromClosure()
+ {
+ $option = $this->ensure(function() { return function() {}; });
+ $this->assertTrue($option->isDefined());
+ $this->assertInstanceOf('Closure', $option->get());
+ }
+}
--- /dev/null
+<?php
+
+namespace PhpOption\Tests;
+
+use PhpOption\LazyOption;
+
+class LazyOptionTest extends \PHPUnit_Framework_TestCase
+{
+ private $subject;
+
+ public function setUp()
+ {
+ $this->subject = $this
+ ->getMockBuilder('Subject')
+ ->setMethods(array('execute'))
+ ->getMock();
+ }
+
+ public function testGetWithArgumentsAndConstructor()
+ {
+ $some = \PhpOption\LazyOption::create(array($this->subject, 'execute'), array('foo'));
+
+ $this->subject
+ ->expects($this->once())
+ ->method('execute')
+ ->with('foo')
+ ->will($this->returnValue(\PhpOption\Some::create('foo')));
+
+ $this->assertEquals('foo', $some->get());
+ $this->assertEquals('foo', $some->getOrElse(null));
+ $this->assertEquals('foo', $some->getOrCall('does_not_exist'));
+ $this->assertEquals('foo', $some->getOrThrow(new \RuntimeException('does_not_exist')));
+ $this->assertFalse($some->isEmpty());
+ }
+
+ public function testGetWithArgumentsAndCreate()
+ {
+ $some = new \PhpOption\LazyOption(array($this->subject, 'execute'), array('foo'));
+
+ $this->subject
+ ->expects($this->once())
+ ->method('execute')
+ ->with('foo')
+ ->will($this->returnValue(\PhpOption\Some::create('foo')));
+
+ $this->assertEquals('foo', $some->get());
+ $this->assertEquals('foo', $some->getOrElse(null));
+ $this->assertEquals('foo', $some->getOrCall('does_not_exist'));
+ $this->assertEquals('foo', $some->getOrThrow(new \RuntimeException('does_not_exist')));
+ $this->assertFalse($some->isEmpty());
+ }
+
+ public function testGetWithoutArgumentsAndConstructor()
+ {
+ $some = new \PhpOption\LazyOption(array($this->subject, 'execute'));
+
+ $this->subject
+ ->expects($this->once())
+ ->method('execute')
+ ->will($this->returnValue(\PhpOption\Some::create('foo')));
+
+ $this->assertEquals('foo', $some->get());
+ $this->assertEquals('foo', $some->getOrElse(null));
+ $this->assertEquals('foo', $some->getOrCall('does_not_exist'));
+ $this->assertEquals('foo', $some->getOrThrow(new \RuntimeException('does_not_exist')));
+ $this->assertFalse($some->isEmpty());
+ }
+
+ public function testGetWithoutArgumentsAndCreate()
+ {
+ $option = \PhpOption\LazyOption::create(array($this->subject, 'execute'));
+
+ $this->subject
+ ->expects($this->once())
+ ->method('execute')
+ ->will($this->returnValue(\PhpOption\Some::create('foo')));
+
+ $this->assertTrue($option->isDefined());
+ $this->assertFalse($option->isEmpty());
+ $this->assertEquals('foo', $option->get());
+ $this->assertEquals('foo', $option->getOrElse(null));
+ $this->assertEquals('foo', $option->getOrCall('does_not_exist'));
+ $this->assertEquals('foo', $option->getOrThrow(new \RuntimeException('does_not_exist')));
+ }
+
+ /**
+ * @expectedException \RuntimeException
+ * @expectedExceptionMessage None has no value
+ */
+ public function testCallbackReturnsNull()
+ {
+ $option = \PhpOption\LazyOption::create(array($this->subject, 'execute'));
+
+ $this->subject
+ ->expects($this->once())
+ ->method('execute')
+ ->will($this->returnValue(\PhpOption\None::create()));
+
+ $this->assertFalse($option->isDefined());
+ $this->assertTrue($option->isEmpty());
+ $this->assertEquals('alt', $option->getOrElse('alt'));
+ $this->assertEquals('alt', $option->getOrCall(function(){return 'alt';}));
+
+ $option->get();
+ }
+
+ /**
+ * @expectedException \RuntimeException
+ * @expectedExceptionMessage Expected instance of \PhpOption\Option
+ */
+ public function testExceptionIsThrownIfCallbackReturnsNonOption()
+ {
+ $option = \PhpOption\LazyOption::create(array($this->subject, 'execute'));
+
+ $this->subject
+ ->expects($this->once())
+ ->method('execute')
+ ->will($this->returnValue(null));
+
+ $this->assertFalse($option->isDefined());
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage Invalid callback given
+ */
+ public function testInvalidCallbackAndConstructor()
+ {
+ new \PhpOption\LazyOption('invalidCallback');
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage Invalid callback given
+ */
+ public function testInvalidCallbackAndCreate()
+ {
+ \PhpOption\LazyOption::create('invalidCallback');
+ }
+
+ public function testifDefined()
+ {
+ $called = false;
+ $self = $this;
+ $this->assertNull(LazyOption::fromValue('foo')->ifDefined(function($v) use (&$called, $self) {
+ $called = true;
+ $self->assertEquals('foo', $v);
+ }));
+ $this->assertTrue($called);
+ }
+
+ public function testForAll()
+ {
+ $called = false;
+ $self = $this;
+ $this->assertInstanceOf('PhpOption\Some', LazyOption::fromValue('foo')->forAll(function($v) use (&$called, $self) {
+ $called = true;
+ $self->assertEquals('foo', $v);
+ }));
+ $this->assertTrue($called);
+ }
+
+ public function testOrElse()
+ {
+ $some = \PhpOption\Some::create('foo');
+ $lazy = \PhpOption\LazyOption::create(function() use ($some) {return $some;});
+ $this->assertSame($some, $lazy->orElse(\PhpOption\None::create()));
+ $this->assertSame($some, $lazy->orElse(\PhpOption\Some::create('bar')));
+ }
+
+ public function testFoldLeftRight()
+ {
+ $callback = function() { };
+
+ $option = $this->getMockForAbstractClass('PhpOption\Option');
+ $option->expects($this->once())
+ ->method('foldLeft')
+ ->with(5, $callback)
+ ->will($this->returnValue(6));
+ $lazyOption = new LazyOption(function() use ($option) { return $option; });
+ $this->assertSame(6, $lazyOption->foldLeft(5, $callback));
+
+ $option->expects($this->once())
+ ->method('foldRight')
+ ->with(5, $callback)
+ ->will($this->returnValue(6));
+ $lazyOption = new LazyOption(function() use ($option) { return $option; });
+ $this->assertSame(6, $lazyOption->foldRight(5, $callback));
+ }
+}
--- /dev/null
+<?php
+
+namespace PhpOption\Tests;
+
+use PhpOption\None;
+
+class NoneTest extends \PHPUnit_Framework_TestCase
+{
+ private $none;
+
+ /**
+ * @expectedException \RuntimeException
+ */
+ public function testGet()
+ {
+ $none = \PhpOption\None::create();
+ $none->get();
+ }
+
+ public function testGetOrElse()
+ {
+ $none = \PhpOption\None::create();
+ $this->assertEquals('foo', $none->getOrElse('foo'));
+ }
+
+ public function testGetOrCall()
+ {
+ $none = \PhpOption\None::create();
+ $this->assertEquals('foo', $none->getOrCall(function() { return 'foo'; }));
+ }
+
+ /**
+ * @expectedException \RuntimeException
+ * @expectedExceptionMessage Not Found!
+ */
+ public function testGetOrThrow()
+ {
+ None::create()->getOrThrow(new \RuntimeException('Not Found!'));
+ }
+
+ public function testIsEmpty()
+ {
+ $none = \PhpOption\None::create();
+ $this->assertTrue($none->isEmpty());
+ }
+
+ public function testOrElse()
+ {
+ $option = \PhpOption\Some::create('foo');
+ $this->assertSame($option, \PhpOption\None::create()->orElse($option));
+ }
+
+ public function testifDefined()
+ {
+ $this->assertNull($this->none->ifDefined(function() {
+ throw new \LogicException('Should never be called.');
+ }));
+ }
+
+ public function testForAll()
+ {
+ $this->assertSame($this->none, $this->none->forAll(function() {
+ throw new \LogicException('Should never be called.');
+ }));
+ }
+
+ public function testMap()
+ {
+ $this->assertSame($this->none, $this->none->map(function() {
+ throw new \LogicException('Should not be called.');
+ }));
+ }
+
+ public function testFlatMap()
+ {
+ $this->assertSame($this->none, $this->none->flatMap(function() {
+ throw new \LogicException('Should not be called.');
+ }));
+ }
+
+ public function testFilter()
+ {
+ $this->assertSame($this->none, $this->none->filter(function() {
+ throw new \LogicException('Should not be called.');
+ }));
+ }
+
+ public function testFilterNot()
+ {
+ $this->assertSame($this->none, $this->none->filterNot(function() {
+ throw new \LogicException('Should not be called.');
+ }));
+ }
+
+ public function testSelect()
+ {
+ $this->assertSame($this->none, $this->none->select(null));
+ }
+
+ public function testReject()
+ {
+ $this->assertSame($this->none, $this->none->reject(null));
+ }
+
+ public function testForeach()
+ {
+ $none = \PhpOption\None::create();
+
+ $called = 0;
+ foreach ($none as $value) {
+ $called++;
+ }
+
+ $this->assertEquals(0, $called);
+ }
+
+ public function testFoldLeftRight()
+ {
+ $this->assertSame(1, $this->none->foldLeft(1, function() { $this->fail(); }));
+ $this->assertSame(1, $this->none->foldRight(1, function() { $this->fail(); }));
+ }
+
+ protected function setUp()
+ {
+ $this->none = None::create();
+ }
+}
--- /dev/null
+<?php
+
+namespace PhpOption\Tests;
+
+use PhpOption\None;
+use PhpOption\Option;
+use PhpOption\Some;
+
+class OptionTest extends \PHPUnit_Framework_TestCase
+{
+ public function testfromValueWithDefaultNoneValue()
+ {
+ $this->assertInstanceOf('PhpOption\None', \PhpOption\Option::fromValue(null));
+ $this->assertInstanceOf('PhpOption\Some', \PhpOption\Option::fromValue('value'));
+ }
+
+ public function testFromValueWithFalseNoneValue()
+ {
+ $this->assertInstanceOf('PhpOption\None', \PhpOption\Option::fromValue(false, false));
+ $this->assertInstanceOf('PhpOption\Some', \PhpOption\Option::fromValue('value', false));
+ $this->assertInstanceOf('PhpOption\Some', \PhpOption\Option::fromValue(null, false));
+ }
+
+ public function testFromArraysValue()
+ {
+ $this->assertEquals(None::create(), Option::fromArraysValue('foo', 'bar'));
+ $this->assertEquals(None::create(), Option::fromArraysValue(null, 'bar'));
+ $this->assertEquals(None::create(), Option::fromArraysValue(array('foo' => 'bar'), 'baz'));
+ $this->assertEquals(None::create(), Option::fromArraysValue(array('foo' => null), 'foo'));
+ $this->assertEquals(new Some('foo'), Option::fromArraysValue(array('foo' => 'foo'), 'foo'));
+ }
+
+ public function testFromReturn()
+ {
+ $null = function() { return null; };
+ $false = function() { return false; };
+ $some = function() { return 'foo'; };
+
+ $this->assertTrue(\PhpOption\Option::fromReturn($null)->isEmpty());
+ $this->assertFalse(\PhpOption\Option::fromReturn($false)->isEmpty());
+ $this->assertTrue(\PhpOption\Option::fromReturn($false, array(), false)->isEmpty());
+ $this->assertTrue(\PhpOption\Option::fromReturn($some)->isDefined());
+ $this->assertFalse(\PhpOption\Option::fromReturn($some, array(), 'foo')->isDefined());
+ }
+
+ public function testOrElse()
+ {
+ $a = new \PhpOption\Some('a');
+ $b = new \PhpOption\Some('b');
+
+ $this->assertEquals('a', $a->orElse($b)->get());
+ }
+
+ public function testOrElseWithNoneAsFirst()
+ {
+ $a = \PhpOption\None::create();
+ $b = new \PhpOption\Some('b');
+
+ $this->assertEquals('b', $a->orElse($b)->get());
+ }
+
+ public function testOrElseWithLazyOptions()
+ {
+ $throws = function() { throw new \LogicException('Should never be called.'); };
+
+ $a = new \PhpOption\Some('a');
+ $b = new \PhpOption\LazyOption($throws);
+
+ $this->assertEquals('a', $a->orElse($b)->get());
+ }
+
+ public function testOrElseWithMultipleAlternatives()
+ {
+ $throws = new \PhpOption\LazyOption(function() { throw new \LogicException('Should never be called.'); });
+ $returns = new \PhpOption\LazyOption(function() { return new \PhpOption\Some('foo'); });
+
+ $a = \PhpOption\None::create();
+
+ $this->assertEquals('foo', $a->orElse($returns)->orElse($throws)->get());
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpOption\Tests;
+
+/**
+ * @group performance
+ */
+class PerformanceTest extends \PHPUnit_Framework_TestCase
+{
+ private $traditionalRepo;
+ private $phpOptionRepo;
+
+ public function testSomeCase()
+ {
+ $traditionalTime = microtime(true);
+ for ($i=0; $i<10000; $i++) {
+ if (null === $rs = $this->traditionalRepo->findMaybe(true)) {
+ $rs = new \stdClass();
+ }
+ }
+ $traditionalTime = microtime(true) - $traditionalTime;
+
+ $phpOptionTime = microtime(true);
+ for ($i=0; $i<10000; $i++) {
+ $rs = $this->phpOptionRepo->findMaybe(true)->getOrElse(new \stdClass);
+ }
+ $phpOptionTime = microtime(true) - $phpOptionTime;
+
+ $overheadPerInvocation = ($phpOptionTime - $traditionalTime) / 10000;
+ printf("Overhead per invocation (some case): %.9fs\n", $overheadPerInvocation);
+ }
+
+ public function testNoneCase()
+ {
+ $traditionalTime = microtime(true);
+ for ($i=0; $i<10000; $i++) {
+ if (null === $rs = $this->traditionalRepo->findMaybe(false)) {
+ $rs = new \stdClass();
+ }
+ }
+ $traditionalTime = microtime(true) - $traditionalTime;
+
+ $phpOptionTime = microtime(true);
+ for ($i=0; $i<10000; $i++) {
+ $rs = $this->phpOptionRepo->findMaybe(false)->getOrElse(new \stdClass);
+ }
+ $phpOptionTime = microtime(true) - $phpOptionTime;
+
+ $overheadPerInvocation = ($phpOptionTime - $traditionalTime) / 10000;
+ printf("Overhead per invocation (none case): %.9fs\n", $overheadPerInvocation);
+ }
+
+ protected function setUp()
+ {
+ $this->traditionalRepo = new TraditionalRepo();
+ $this->phpOptionRepo = new PhpOptionRepo();
+ }
+}
+
+class TraditionalRepo
+{
+ public function findMaybe($success)
+ {
+ if ($success) {
+ return new \stdClass;
+ }
+
+ return null;
+ }
+}
+
+class PhpOptionRepo
+{
+ public function findMaybe($success)
+ {
+ if ($success) {
+ return new \PhpOption\Some(new \stdClass);
+ }
+
+ return \PhpOption\None::create();
+ }
+}
\ No newline at end of file
--- /dev/null
+<?php
+
+namespace PhpOption\Tests;
+
+use PhpOption\Some;
+
+class SomeTest extends \PHPUnit_Framework_TestCase
+{
+ public function testGet()
+ {
+ $some = new \PhpOption\Some('foo');
+ $this->assertEquals('foo', $some->get());
+ $this->assertEquals('foo', $some->getOrElse(null));
+ $this->assertEquals('foo', $some->getOrCall('does_not_exist'));
+ $this->assertEquals('foo', $some->getOrThrow(new \RuntimeException('Not found')));
+ $this->assertFalse($some->isEmpty());
+ }
+
+ public function testCreate()
+ {
+ $some = \PhpOption\Some::create('foo');
+ $this->assertEquals('foo', $some->get());
+ $this->assertEquals('foo', $some->getOrElse(null));
+ $this->assertEquals('foo', $some->getOrCall('does_not_exist'));
+ $this->assertEquals('foo', $some->getOrThrow(new \RuntimeException('Not found')));
+ $this->assertFalse($some->isEmpty());
+ }
+
+ public function testOrElse()
+ {
+ $some = \PhpOption\Some::create('foo');
+ $this->assertSame($some, $some->orElse(\PhpOption\None::create()));
+ $this->assertSame($some, $some->orElse(\PhpOption\Some::create('bar')));
+ }
+
+ public function testifDefined()
+ {
+ $called = false;
+ $self = $this;
+ $some = new Some('foo');
+ $this->assertNull($some->ifDefined(function($v) use (&$called, $self) {
+ $called = true;
+ $self->assertEquals('foo', $v);
+ }));
+ $this->assertTrue($called);
+ }
+
+ public function testForAll()
+ {
+ $called = false;
+ $self = $this;
+ $some = new Some('foo');
+ $this->assertSame($some, $some->forAll(function($v) use (&$called, $self) {
+ $called = true;
+ $self->assertEquals('foo', $v);
+ }));
+ $this->assertTrue($called);
+ }
+
+ public function testMap()
+ {
+ $some = new Some('foo');
+ $this->assertEquals('o', $some->map(function($v) { return substr($v, 1, 1); })->get());
+ }
+
+ public function testFlatMap()
+ {
+ $repo = new Repository(array('foo'));
+
+ $this->assertEquals(array('name' => 'foo'), $repo->getLastRegisteredUsername()
+ ->flatMap(array($repo, 'getUser'))
+ ->getOrCall(array($repo, 'getDefaultUser')));
+ }
+
+ public function testFilter()
+ {
+ $some = new Some('foo');
+
+ $this->assertInstanceOf('PhpOption\None', $some->filter(function($v) { return 0 === strlen($v); }));
+ $this->assertSame($some, $some->filter(function($v) { return strlen($v) > 0; }));
+ }
+
+ public function testFilterNot()
+ {
+ $some = new Some('foo');
+
+ $this->assertInstanceOf('PhpOption\None', $some->filterNot(function($v) { return strlen($v) > 0; }));
+ $this->assertSame($some, $some->filterNot(function($v) { return strlen($v) === 0; }));
+ }
+
+ public function testSelect()
+ {
+ $some = new Some('foo');
+
+ $this->assertSame($some, $some->select('foo'));
+ $this->assertInstanceOf('PhpOption\None', $some->select('bar'));
+ $this->assertInstanceOf('PhpOption\None', $some->select(true));
+ }
+
+ public function testReject()
+ {
+ $some = new Some('foo');
+
+ $this->assertSame($some, $some->reject(null));
+ $this->assertSame($some, $some->reject(true));
+ $this->assertInstanceOf('PhpOption\None', $some->reject('foo'));
+ }
+
+ public function testFoldLeftRight()
+ {
+ $some = new Some(5);
+
+ $this->assertSame(6, $some->foldLeft(1, function($a, $b) {
+ $this->assertEquals(1, $a);
+ $this->assertEquals(5, $b);
+
+ return $a + $b;
+ }));
+
+ $this->assertSame(6, $some->foldRight(1, function($a, $b) {
+ $this->assertEquals(1, $b);
+ $this->assertEquals(5, $a);
+
+ return $a + $b;
+ }));
+ }
+
+ public function testForeach()
+ {
+ $some = new Some('foo');
+
+ $called = 0;
+ $extractedValue = null;
+ foreach ($some as $value) {
+ $extractedValue = $value;
+ $called++;
+ }
+
+ $this->assertEquals('foo', $extractedValue);
+ $this->assertEquals(1, $called);
+ }
+}
+
+// For the interested reader of these tests, we have gone some great lengths
+// to come up with a non-contrived example that might also be used in the
+// real-world, and not only for testing purposes :)
+class Repository
+{
+ private $users;
+
+ public function __construct(array $users = array())
+ {
+ $this->users = $users;
+ }
+
+ // A fast ID lookup, probably cached, sometimes we might not need the entire user.
+ public function getLastRegisteredUsername()
+ {
+ if (empty($this->users)) {
+ return \PhpOption\None::create();
+ }
+
+ return new Some(end($this->users));
+ }
+
+ // Returns a user object (we will live with an array here).
+ public function getUser($name)
+ {
+ if (in_array($name, $this->users, true)) {
+ return new Some(array('name' => $name));
+ }
+
+ return \PhpOption\None::create();
+ }
+
+ public function getDefaultUser()
+ {
+ return array('name' => 'muhuhu');
+ }
+}
--- /dev/null
+<?php
+
+if ( ! is_file($autoloadFile = __DIR__.'/../vendor/autoload.php')) {
+ echo 'Could not find "vendor/autoload.php". Did you forget to run "composer install --dev"?'.PHP_EOL;
+ exit(1);
+}
+
+require_once $autoloadFile;
\ No newline at end of file
--- /dev/null
+vendor/
+composer.lock
+phpunit.xml
--- /dev/null
+CHANGELOG
+=========
+
+3.4.0
+-----
+
+ * added support for parsing YAML files using the `Yaml::parseFile()` or `Parser::parseFile()` method
+
+ * the `Dumper`, `Parser`, and `Yaml` classes are marked as final
+
+ * Deprecated the `!php/object:` tag which will be replaced by the
+ `!php/object` tag (without the colon) in 4.0.
+
+ * Deprecated the `!php/const:` tag which will be replaced by the
+ `!php/const` tag (without the colon) in 4.0.
+
+ * Support for the `!str` tag is deprecated, use the `!!str` tag instead.
+
+ * Deprecated using the non-specific tag `!` as its behavior will change in 4.0.
+ It will force non-evaluating your values in 4.0. Use plain integers or `!!float` instead.
+
+3.3.0
+-----
+
+ * Starting an unquoted string with a question mark followed by a space is
+ deprecated and will throw a `ParseException` in Symfony 4.0.
+
+ * Deprecated support for implicitly parsing non-string mapping keys as strings.
+ Mapping keys that are no strings will lead to a `ParseException` in Symfony
+ 4.0. Use quotes to opt-in for keys to be parsed as strings.
+
+ Before:
+
+ ```php
+ $yaml = <<<YAML
+ null: null key
+ true: boolean true
+ 2.0: float key
+ YAML;
+
+ Yaml::parse($yaml);
+ ```
+
+ After:
+
+ ```php
+
+ $yaml = <<<YAML
+ "null": null key
+ "true": boolean true
+ "2.0": float key
+ YAML;
+
+ Yaml::parse($yaml);
+ ```
+
+ * Omitted mapping values will be parsed as `null`.
+
+ * Omitting the key of a mapping is deprecated and will throw a `ParseException` in Symfony 4.0.
+
+ * Added support for dumping empty PHP arrays as YAML sequences:
+
+ ```php
+ Yaml::dump([], 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
+ ```
+
+3.2.0
+-----
+
+ * Mappings with a colon (`:`) that is not followed by a whitespace are deprecated
+ when the mapping key is not quoted and will lead to a `ParseException` in
+ Symfony 4.0 (e.g. `foo:bar` must be `foo: bar`).
+
+ * Added support for parsing PHP constants:
+
+ ```php
+ Yaml::parse('!php/const:PHP_INT_MAX', Yaml::PARSE_CONSTANT);
+ ```
+
+ * Support for silently ignoring duplicate mapping keys in YAML has been
+ deprecated and will lead to a `ParseException` in Symfony 4.0.
+
+3.1.0
+-----
+
+ * Added support to dump `stdClass` and `ArrayAccess` objects as YAML mappings
+ through the `Yaml::DUMP_OBJECT_AS_MAP` flag.
+
+ * Strings that are not UTF-8 encoded will be dumped as base64 encoded binary
+ data.
+
+ * Added support for dumping multi line strings as literal blocks.
+
+ * Added support for parsing base64 encoded binary data when they are tagged
+ with the `!!binary` tag.
+
+ * Added support for parsing timestamps as `\DateTime` objects:
+
+ ```php
+ Yaml::parse('2001-12-15 21:59:43.10 -5', Yaml::PARSE_DATETIME);
+ ```
+
+ * `\DateTime` and `\DateTimeImmutable` objects are dumped as YAML timestamps.
+
+ * Deprecated usage of `%` at the beginning of an unquoted string.
+
+ * Added support for customizing the YAML parser behavior through an optional bit field:
+
+ ```php
+ Yaml::parse('{ "foo": "bar", "fiz": "cat" }', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE | Yaml::PARSE_OBJECT | Yaml::PARSE_OBJECT_FOR_MAP);
+ ```
+
+ * Added support for customizing the dumped YAML string through an optional bit field:
+
+ ```php
+ Yaml::dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE | Yaml::DUMP_OBJECT);
+ ```
+
+3.0.0
+-----
+
+ * Yaml::parse() now throws an exception when a blackslash is not escaped
+ in double-quoted strings
+
+2.8.0
+-----
+
+ * Deprecated usage of a colon in an unquoted mapping value
+ * Deprecated usage of @, \`, | and > at the beginning of an unquoted string
+ * When surrounding strings with double-quotes, you must now escape `\` characters. Not
+ escaping those characters (when surrounded by double-quotes) is deprecated.
+
+ Before:
+
+ ```yml
+ class: "Foo\Var"
+ ```
+
+ After:
+
+ ```yml
+ class: "Foo\\Var"
+ ```
+
+2.1.0
+-----
+
+ * Yaml::parse() does not evaluate loaded files as PHP files by default
+ anymore (call Yaml::enablePhpParsing() to get back the old behavior)
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Command;
+
+use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
+use Symfony\Component\Yaml\Exception\ParseException;
+use Symfony\Component\Yaml\Parser;
+use Symfony\Component\Yaml\Yaml;
+
+/**
+ * Validates YAML files syntax and outputs encountered errors.
+ *
+ * @author Grégoire Pineau <lyrixx@lyrixx.info>
+ * @author Robin Chalas <robin.chalas@gmail.com>
+ */
+class LintCommand extends Command
+{
+ protected static $defaultName = 'lint:yaml';
+
+ private $parser;
+ private $format;
+ private $displayCorrectFiles;
+ private $directoryIteratorProvider;
+ private $isReadableProvider;
+
+ public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null)
+ {
+ parent::__construct($name);
+
+ $this->directoryIteratorProvider = $directoryIteratorProvider;
+ $this->isReadableProvider = $isReadableProvider;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ $this
+ ->setDescription('Lints a file and outputs encountered errors')
+ ->addArgument('filename', null, 'A file or a directory or STDIN')
+ ->addOption('format', null, InputOption::VALUE_REQUIRED, 'The output format', 'txt')
+ ->addOption('parse-tags', null, InputOption::VALUE_NONE, 'Parse custom tags')
+ ->setHelp(<<<EOF
+The <info>%command.name%</info> command lints a YAML file and outputs to STDOUT
+the first encountered syntax error.
+
+You can validates YAML contents passed from STDIN:
+
+ <info>cat filename | php %command.full_name%</info>
+
+You can also validate the syntax of a file:
+
+ <info>php %command.full_name% filename</info>
+
+Or of a whole directory:
+
+ <info>php %command.full_name% dirname</info>
+ <info>php %command.full_name% dirname --format=json</info>
+
+EOF
+ )
+ ;
+ }
+
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ $io = new SymfonyStyle($input, $output);
+ $filename = $input->getArgument('filename');
+ $this->format = $input->getOption('format');
+ $this->displayCorrectFiles = $output->isVerbose();
+ $flags = $input->getOption('parse-tags') ? Yaml::PARSE_CUSTOM_TAGS : 0;
+
+ if (!$filename) {
+ if (!$stdin = $this->getStdin()) {
+ throw new \RuntimeException('Please provide a filename or pipe file content to STDIN.');
+ }
+
+ return $this->display($io, array($this->validate($stdin, $flags)));
+ }
+
+ if (!$this->isReadable($filename)) {
+ throw new \RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
+ }
+
+ $filesInfo = array();
+ foreach ($this->getFiles($filename) as $file) {
+ $filesInfo[] = $this->validate(file_get_contents($file), $flags, $file);
+ }
+
+ return $this->display($io, $filesInfo);
+ }
+
+ private function validate($content, $flags, $file = null)
+ {
+ $prevErrorHandler = set_error_handler(function ($level, $message, $file, $line) use (&$prevErrorHandler) {
+ if (E_USER_DEPRECATED === $level) {
+ throw new ParseException($message, $this->getParser()->getRealCurrentLineNb() + 1);
+ }
+
+ return $prevErrorHandler ? $prevErrorHandler($level, $message, $file, $line) : false;
+ });
+
+ try {
+ $this->getParser()->parse($content, Yaml::PARSE_CONSTANT | $flags);
+ } catch (ParseException $e) {
+ return array('file' => $file, 'line' => $e->getParsedLine(), 'valid' => false, 'message' => $e->getMessage());
+ } finally {
+ restore_error_handler();
+ }
+
+ return array('file' => $file, 'valid' => true);
+ }
+
+ private function display(SymfonyStyle $io, array $files)
+ {
+ switch ($this->format) {
+ case 'txt':
+ return $this->displayTxt($io, $files);
+ case 'json':
+ return $this->displayJson($io, $files);
+ default:
+ throw new \InvalidArgumentException(sprintf('The format "%s" is not supported.', $this->format));
+ }
+ }
+
+ private function displayTxt(SymfonyStyle $io, array $filesInfo)
+ {
+ $countFiles = count($filesInfo);
+ $erroredFiles = 0;
+
+ foreach ($filesInfo as $info) {
+ if ($info['valid'] && $this->displayCorrectFiles) {
+ $io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
+ } elseif (!$info['valid']) {
+ ++$erroredFiles;
+ $io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
+ $io->text(sprintf('<error> >> %s</error>', $info['message']));
+ }
+ }
+
+ if (0 === $erroredFiles) {
+ $io->success(sprintf('All %d YAML files contain valid syntax.', $countFiles));
+ } else {
+ $io->warning(sprintf('%d YAML files have valid syntax and %d contain errors.', $countFiles - $erroredFiles, $erroredFiles));
+ }
+
+ return min($erroredFiles, 1);
+ }
+
+ private function displayJson(SymfonyStyle $io, array $filesInfo)
+ {
+ $errors = 0;
+
+ array_walk($filesInfo, function (&$v) use (&$errors) {
+ $v['file'] = (string) $v['file'];
+ if (!$v['valid']) {
+ ++$errors;
+ }
+ });
+
+ $io->writeln(json_encode($filesInfo, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
+
+ return min($errors, 1);
+ }
+
+ private function getFiles($fileOrDirectory)
+ {
+ if (is_file($fileOrDirectory)) {
+ yield new \SplFileInfo($fileOrDirectory);
+
+ return;
+ }
+
+ foreach ($this->getDirectoryIterator($fileOrDirectory) as $file) {
+ if (!in_array($file->getExtension(), array('yml', 'yaml'))) {
+ continue;
+ }
+
+ yield $file;
+ }
+ }
+
+ private function getStdin()
+ {
+ if (0 !== ftell(STDIN)) {
+ return;
+ }
+
+ $inputs = '';
+ while (!feof(STDIN)) {
+ $inputs .= fread(STDIN, 1024);
+ }
+
+ return $inputs;
+ }
+
+ private function getParser()
+ {
+ if (!$this->parser) {
+ $this->parser = new Parser();
+ }
+
+ return $this->parser;
+ }
+
+ private function getDirectoryIterator($directory)
+ {
+ $default = function ($directory) {
+ return new \RecursiveIteratorIterator(
+ new \RecursiveDirectoryIterator($directory, \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS),
+ \RecursiveIteratorIterator::LEAVES_ONLY
+ );
+ };
+
+ if (null !== $this->directoryIteratorProvider) {
+ return call_user_func($this->directoryIteratorProvider, $directory, $default);
+ }
+
+ return $default($directory);
+ }
+
+ private function isReadable($fileOrDirectory)
+ {
+ $default = function ($fileOrDirectory) {
+ return is_readable($fileOrDirectory);
+ };
+
+ if (null !== $this->isReadableProvider) {
+ return call_user_func($this->isReadableProvider, $fileOrDirectory, $default);
+ }
+
+ return $default($fileOrDirectory);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml;
+
+/**
+ * Dumper dumps PHP variables to YAML strings.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @final since version 3.4
+ */
+class Dumper
+{
+ /**
+ * The amount of spaces to use for indentation of nested nodes.
+ *
+ * @var int
+ */
+ protected $indentation;
+
+ /**
+ * @param int $indentation
+ */
+ public function __construct($indentation = 4)
+ {
+ if ($indentation < 1) {
+ throw new \InvalidArgumentException('The indentation must be greater than zero.');
+ }
+
+ $this->indentation = $indentation;
+ }
+
+ /**
+ * Sets the indentation.
+ *
+ * @param int $num The amount of spaces to use for indentation of nested nodes
+ *
+ * @deprecated since version 3.1, to be removed in 4.0. Pass the indentation to the constructor instead.
+ */
+ public function setIndentation($num)
+ {
+ @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 3.1 and will be removed in 4.0. Pass the indentation to the constructor instead.', E_USER_DEPRECATED);
+
+ $this->indentation = (int) $num;
+ }
+
+ /**
+ * Dumps a PHP value to YAML.
+ *
+ * @param mixed $input The PHP value
+ * @param int $inline The level where you switch to inline YAML
+ * @param int $indent The level of indentation (used internally)
+ * @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
+ *
+ * @return string The YAML representation of the PHP value
+ */
+ public function dump($input, $inline = 0, $indent = 0, $flags = 0)
+ {
+ if (is_bool($flags)) {
+ @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
+
+ if ($flags) {
+ $flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE;
+ } else {
+ $flags = 0;
+ }
+ }
+
+ if (func_num_args() >= 5) {
+ @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
+
+ if (func_get_arg(4)) {
+ $flags |= Yaml::DUMP_OBJECT;
+ }
+ }
+
+ $output = '';
+ $prefix = $indent ? str_repeat(' ', $indent) : '';
+ $dumpObjectAsInlineMap = true;
+
+ if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($input instanceof \ArrayObject || $input instanceof \stdClass)) {
+ $dumpObjectAsInlineMap = empty((array) $input);
+ }
+
+ if ($inline <= 0 || (!is_array($input) && $dumpObjectAsInlineMap) || empty($input)) {
+ $output .= $prefix.Inline::dump($input, $flags);
+ } else {
+ $dumpAsMap = Inline::isHash($input);
+
+ foreach ($input as $key => $value) {
+ if ($inline >= 1 && Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && is_string($value) && false !== strpos($value, "\n") && false === strpos($value, "\r\n")) {
+ // If the first line starts with a space character, the spec requires a blockIndicationIndicator
+ // http://www.yaml.org/spec/1.2/spec.html#id2793979
+ $blockIndentationIndicator = (' ' === substr($value, 0, 1)) ? (string) $this->indentation : '';
+ $output .= sprintf("%s%s%s |%s\n", $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator);
+
+ foreach (preg_split('/\n|\r\n/', $value) as $row) {
+ $output .= sprintf("%s%s%s\n", $prefix, str_repeat(' ', $this->indentation), $row);
+ }
+
+ continue;
+ }
+
+ $dumpObjectAsInlineMap = true;
+
+ if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \ArrayObject || $value instanceof \stdClass)) {
+ $dumpObjectAsInlineMap = empty((array) $value);
+ }
+
+ $willBeInlined = $inline - 1 <= 0 || !is_array($value) && $dumpObjectAsInlineMap || empty($value);
+
+ $output .= sprintf('%s%s%s%s',
+ $prefix,
+ $dumpAsMap ? Inline::dump($key, $flags).':' : '-',
+ $willBeInlined ? ' ' : "\n",
+ $this->dump($value, $inline - 1, $willBeInlined ? 0 : $indent + $this->indentation, $flags)
+ ).($willBeInlined ? "\n" : '');
+ }
+ }
+
+ return $output;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml;
+
+/**
+ * Escaper encapsulates escaping rules for single and double-quoted
+ * YAML strings.
+ *
+ * @author Matthew Lewinski <matthew@lewinski.org>
+ *
+ * @internal
+ */
+class Escaper
+{
+ // Characters that would cause a dumped string to require double quoting.
+ const REGEX_CHARACTER_TO_ESCAPE = "[\\x00-\\x1f]|\xc2\x85|\xc2\xa0|\xe2\x80\xa8|\xe2\x80\xa9";
+
+ // Mapping arrays for escaping a double quoted string. The backslash is
+ // first to ensure proper escaping because str_replace operates iteratively
+ // on the input arrays. This ordering of the characters avoids the use of strtr,
+ // which performs more slowly.
+ private static $escapees = array('\\', '\\\\', '\\"', '"',
+ "\x00", "\x01", "\x02", "\x03", "\x04", "\x05", "\x06", "\x07",
+ "\x08", "\x09", "\x0a", "\x0b", "\x0c", "\x0d", "\x0e", "\x0f",
+ "\x10", "\x11", "\x12", "\x13", "\x14", "\x15", "\x16", "\x17",
+ "\x18", "\x19", "\x1a", "\x1b", "\x1c", "\x1d", "\x1e", "\x1f",
+ "\xc2\x85", "\xc2\xa0", "\xe2\x80\xa8", "\xe2\x80\xa9",
+ );
+ private static $escaped = array('\\\\', '\\"', '\\\\', '\\"',
+ '\\0', '\\x01', '\\x02', '\\x03', '\\x04', '\\x05', '\\x06', '\\a',
+ '\\b', '\\t', '\\n', '\\v', '\\f', '\\r', '\\x0e', '\\x0f',
+ '\\x10', '\\x11', '\\x12', '\\x13', '\\x14', '\\x15', '\\x16', '\\x17',
+ '\\x18', '\\x19', '\\x1a', '\\e', '\\x1c', '\\x1d', '\\x1e', '\\x1f',
+ '\\N', '\\_', '\\L', '\\P',
+ );
+
+ /**
+ * Determines if a PHP value would require double quoting in YAML.
+ *
+ * @param string $value A PHP value
+ *
+ * @return bool True if the value would require double quotes
+ */
+ public static function requiresDoubleQuoting($value)
+ {
+ return 0 < preg_match('/'.self::REGEX_CHARACTER_TO_ESCAPE.'/u', $value);
+ }
+
+ /**
+ * Escapes and surrounds a PHP value with double quotes.
+ *
+ * @param string $value A PHP value
+ *
+ * @return string The quoted, escaped string
+ */
+ public static function escapeWithDoubleQuotes($value)
+ {
+ return sprintf('"%s"', str_replace(self::$escapees, self::$escaped, $value));
+ }
+
+ /**
+ * Determines if a PHP value would require single quoting in YAML.
+ *
+ * @param string $value A PHP value
+ *
+ * @return bool True if the value would require single quotes
+ */
+ public static function requiresSingleQuoting($value)
+ {
+ // Determines if a PHP value is entirely composed of a value that would
+ // require single quoting in YAML.
+ if (in_array(strtolower($value), array('null', '~', 'true', 'false', 'y', 'n', 'yes', 'no', 'on', 'off'))) {
+ return true;
+ }
+
+ // Determines if the PHP value contains any single characters that would
+ // cause it to require single quoting in YAML.
+ return 0 < preg_match('/[ \s \' " \: \{ \} \[ \] , & \* \# \?] | \A[ \- ? | < > = ! % @ ` ]/x', $value);
+ }
+
+ /**
+ * Escapes and surrounds a PHP value with single quotes.
+ *
+ * @param string $value A PHP value
+ *
+ * @return string The quoted, escaped string
+ */
+ public static function escapeWithSingleQuotes($value)
+ {
+ return sprintf("'%s'", str_replace('\'', '\'\'', $value));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Exception;
+
+/**
+ * Exception class thrown when an error occurs during dumping.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+class DumpException extends RuntimeException
+{
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Exception;
+
+/**
+ * Exception interface for all exceptions thrown by the component.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+interface ExceptionInterface
+{
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Exception;
+
+/**
+ * Exception class thrown when an error occurs during parsing.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ */
+class ParseException extends RuntimeException
+{
+ private $parsedFile;
+ private $parsedLine;
+ private $snippet;
+ private $rawMessage;
+
+ /**
+ * @param string $message The error message
+ * @param int $parsedLine The line where the error occurred
+ * @param string|null $snippet The snippet of code near the problem
+ * @param string|null $parsedFile The file name where the error occurred
+ * @param \Exception|null $previous The previous exception
+ */
+ public function __construct($message, $parsedLine = -1, $snippet = null, $parsedFile = null, \Exception $previous = null)
+ {
+ $this->parsedFile = $parsedFile;
+ $this->parsedLine = $parsedLine;
+ $this->snippet = $snippet;
+ $this->rawMessage = $message;
+
+ $this->updateRepr();
+
+ parent::__construct($this->message, 0, $previous);
+ }
+
+ /**
+ * Gets the snippet of code near the error.
+ *
+ * @return string The snippet of code
+ */
+ public function getSnippet()
+ {
+ return $this->snippet;
+ }
+
+ /**
+ * Sets the snippet of code near the error.
+ *
+ * @param string $snippet The code snippet
+ */
+ public function setSnippet($snippet)
+ {
+ $this->snippet = $snippet;
+
+ $this->updateRepr();
+ }
+
+ /**
+ * Gets the filename where the error occurred.
+ *
+ * This method returns null if a string is parsed.
+ *
+ * @return string The filename
+ */
+ public function getParsedFile()
+ {
+ return $this->parsedFile;
+ }
+
+ /**
+ * Sets the filename where the error occurred.
+ *
+ * @param string $parsedFile The filename
+ */
+ public function setParsedFile($parsedFile)
+ {
+ $this->parsedFile = $parsedFile;
+
+ $this->updateRepr();
+ }
+
+ /**
+ * Gets the line where the error occurred.
+ *
+ * @return int The file line
+ */
+ public function getParsedLine()
+ {
+ return $this->parsedLine;
+ }
+
+ /**
+ * Sets the line where the error occurred.
+ *
+ * @param int $parsedLine The file line
+ */
+ public function setParsedLine($parsedLine)
+ {
+ $this->parsedLine = $parsedLine;
+
+ $this->updateRepr();
+ }
+
+ private function updateRepr()
+ {
+ $this->message = $this->rawMessage;
+
+ $dot = false;
+ if ('.' === substr($this->message, -1)) {
+ $this->message = substr($this->message, 0, -1);
+ $dot = true;
+ }
+
+ if (null !== $this->parsedFile) {
+ $this->message .= sprintf(' in %s', json_encode($this->parsedFile, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
+ }
+
+ if ($this->parsedLine >= 0) {
+ $this->message .= sprintf(' at line %d', $this->parsedLine);
+ }
+
+ if ($this->snippet) {
+ $this->message .= sprintf(' (near "%s")', $this->snippet);
+ }
+
+ if ($dot) {
+ $this->message .= '.';
+ }
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Exception;
+
+/**
+ * Exception class thrown when an error occurs during parsing.
+ *
+ * @author Romain Neutron <imprec@gmail.com>
+ */
+class RuntimeException extends \RuntimeException implements ExceptionInterface
+{
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml;
+
+use Symfony\Component\Yaml\Exception\ParseException;
+use Symfony\Component\Yaml\Exception\DumpException;
+use Symfony\Component\Yaml\Tag\TaggedValue;
+
+/**
+ * Inline implements a YAML parser/dumper for the YAML inline syntax.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @internal
+ */
+class Inline
+{
+ const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*+(?:\\\\.[^"\\\\]*+)*+)"|\'([^\']*+(?:\'\'[^\']*+)*+)\')';
+
+ public static $parsedLineNumber = -1;
+ public static $parsedFilename;
+
+ private static $exceptionOnInvalidType = false;
+ private static $objectSupport = false;
+ private static $objectForMap = false;
+ private static $constantSupport = false;
+
+ /**
+ * @param int $flags
+ * @param int|null $parsedLineNumber
+ * @param string|null $parsedFilename
+ */
+ public static function initialize($flags, $parsedLineNumber = null, $parsedFilename = null)
+ {
+ self::$exceptionOnInvalidType = (bool) (Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE & $flags);
+ self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
+ self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags);
+ self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags);
+ self::$parsedFilename = $parsedFilename;
+
+ if (null !== $parsedLineNumber) {
+ self::$parsedLineNumber = $parsedLineNumber;
+ }
+ }
+
+ /**
+ * Converts a YAML string to a PHP value.
+ *
+ * @param string $value A YAML string
+ * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
+ * @param array $references Mapping of variable names to values
+ *
+ * @return mixed A PHP value
+ *
+ * @throws ParseException
+ */
+ public static function parse($value, $flags = 0, $references = array())
+ {
+ if (is_bool($flags)) {
+ @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
+
+ if ($flags) {
+ $flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
+ } else {
+ $flags = 0;
+ }
+ }
+
+ if (func_num_args() >= 3 && !is_array($references)) {
+ @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
+
+ if ($references) {
+ $flags |= Yaml::PARSE_OBJECT;
+ }
+
+ if (func_num_args() >= 4) {
+ @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
+
+ if (func_get_arg(3)) {
+ $flags |= Yaml::PARSE_OBJECT_FOR_MAP;
+ }
+ }
+
+ if (func_num_args() >= 5) {
+ $references = func_get_arg(4);
+ } else {
+ $references = array();
+ }
+ }
+
+ self::initialize($flags);
+
+ $value = trim($value);
+
+ if ('' === $value) {
+ return '';
+ }
+
+ if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
+ $mbEncoding = mb_internal_encoding();
+ mb_internal_encoding('ASCII');
+ }
+
+ $i = 0;
+ $tag = self::parseTag($value, $i, $flags);
+ switch ($value[$i]) {
+ case '[':
+ $result = self::parseSequence($value, $flags, $i, $references);
+ ++$i;
+ break;
+ case '{':
+ $result = self::parseMapping($value, $flags, $i, $references);
+ ++$i;
+ break;
+ default:
+ $result = self::parseScalar($value, $flags, null, $i, null === $tag, $references);
+ }
+
+ if (null !== $tag) {
+ return new TaggedValue($tag, $result);
+ }
+
+ // some comments are allowed at the end
+ if (preg_replace('/\s+#.*$/A', '', substr($value, $i))) {
+ throw new ParseException(sprintf('Unexpected characters near "%s".', substr($value, $i)), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
+ }
+
+ if (isset($mbEncoding)) {
+ mb_internal_encoding($mbEncoding);
+ }
+
+ return $result;
+ }
+
+ /**
+ * Dumps a given PHP variable to a YAML string.
+ *
+ * @param mixed $value The PHP variable to convert
+ * @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
+ *
+ * @return string The YAML string representing the PHP value
+ *
+ * @throws DumpException When trying to dump PHP resource
+ */
+ public static function dump($value, $flags = 0)
+ {
+ if (is_bool($flags)) {
+ @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
+
+ if ($flags) {
+ $flags = Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE;
+ } else {
+ $flags = 0;
+ }
+ }
+
+ if (func_num_args() >= 3) {
+ @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
+
+ if (func_get_arg(2)) {
+ $flags |= Yaml::DUMP_OBJECT;
+ }
+ }
+
+ switch (true) {
+ case is_resource($value):
+ if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
+ throw new DumpException(sprintf('Unable to dump PHP resources in a YAML file ("%s").', get_resource_type($value)));
+ }
+
+ return 'null';
+ case $value instanceof \DateTimeInterface:
+ return $value->format('c');
+ case is_object($value):
+ if ($value instanceof TaggedValue) {
+ return '!'.$value->getTag().' '.self::dump($value->getValue(), $flags);
+ }
+
+ if (Yaml::DUMP_OBJECT & $flags) {
+ return '!php/object '.self::dump(serialize($value));
+ }
+
+ if (Yaml::DUMP_OBJECT_AS_MAP & $flags && ($value instanceof \stdClass || $value instanceof \ArrayObject)) {
+ return self::dumpArray($value, $flags & ~Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
+ }
+
+ if (Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE & $flags) {
+ throw new DumpException('Object support when dumping a YAML file has been disabled.');
+ }
+
+ return 'null';
+ case is_array($value):
+ return self::dumpArray($value, $flags);
+ case null === $value:
+ return 'null';
+ case true === $value:
+ return 'true';
+ case false === $value:
+ return 'false';
+ case ctype_digit($value):
+ return is_string($value) ? "'$value'" : (int) $value;
+ case is_numeric($value):
+ $locale = setlocale(LC_NUMERIC, 0);
+ if (false !== $locale) {
+ setlocale(LC_NUMERIC, 'C');
+ }
+ if (is_float($value)) {
+ $repr = (string) $value;
+ if (is_infinite($value)) {
+ $repr = str_ireplace('INF', '.Inf', $repr);
+ } elseif (floor($value) == $value && $repr == $value) {
+ // Preserve float data type since storing a whole number will result in integer value.
+ $repr = '!!float '.$repr;
+ }
+ } else {
+ $repr = is_string($value) ? "'$value'" : (string) $value;
+ }
+ if (false !== $locale) {
+ setlocale(LC_NUMERIC, $locale);
+ }
+
+ return $repr;
+ case '' == $value:
+ return "''";
+ case self::isBinaryString($value):
+ return '!!binary '.base64_encode($value);
+ case Escaper::requiresDoubleQuoting($value):
+ return Escaper::escapeWithDoubleQuotes($value);
+ case Escaper::requiresSingleQuoting($value):
+ case Parser::preg_match('{^[0-9]+[_0-9]*$}', $value):
+ case Parser::preg_match(self::getHexRegex(), $value):
+ case Parser::preg_match(self::getTimestampRegex(), $value):
+ return Escaper::escapeWithSingleQuotes($value);
+ default:
+ return $value;
+ }
+ }
+
+ /**
+ * Check if given array is hash or just normal indexed array.
+ *
+ * @internal
+ *
+ * @param array|\ArrayObject|\stdClass $value The PHP array or array-like object to check
+ *
+ * @return bool true if value is hash array, false otherwise
+ */
+ public static function isHash($value)
+ {
+ if ($value instanceof \stdClass || $value instanceof \ArrayObject) {
+ return true;
+ }
+
+ $expectedKey = 0;
+
+ foreach ($value as $key => $val) {
+ if ($key !== $expectedKey++) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Dumps a PHP array to a YAML string.
+ *
+ * @param array $value The PHP array to dump
+ * @param int $flags A bit field of Yaml::DUMP_* constants to customize the dumped YAML string
+ *
+ * @return string The YAML string representing the PHP array
+ */
+ private static function dumpArray($value, $flags)
+ {
+ // array
+ if (($value || Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE & $flags) && !self::isHash($value)) {
+ $output = array();
+ foreach ($value as $val) {
+ $output[] = self::dump($val, $flags);
+ }
+
+ return sprintf('[%s]', implode(', ', $output));
+ }
+
+ // hash
+ $output = array();
+ foreach ($value as $key => $val) {
+ $output[] = sprintf('%s: %s', self::dump($key, $flags), self::dump($val, $flags));
+ }
+
+ return sprintf('{ %s }', implode(', ', $output));
+ }
+
+ /**
+ * Parses a YAML scalar.
+ *
+ * @param string $scalar
+ * @param int $flags
+ * @param string[] $delimiters
+ * @param int &$i
+ * @param bool $evaluate
+ * @param array $references
+ *
+ * @return string
+ *
+ * @throws ParseException When malformed inline YAML string is parsed
+ *
+ * @internal
+ */
+ public static function parseScalar($scalar, $flags = 0, $delimiters = null, &$i = 0, $evaluate = true, $references = array(), $legacyOmittedKeySupport = false)
+ {
+ if (in_array($scalar[$i], array('"', "'"))) {
+ // quoted scalar
+ $output = self::parseQuotedScalar($scalar, $i);
+
+ if (null !== $delimiters) {
+ $tmp = ltrim(substr($scalar, $i), ' ');
+ if (!in_array($tmp[0], $delimiters)) {
+ throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+ }
+ } else {
+ // "normal" string
+ if (!$delimiters) {
+ $output = substr($scalar, $i);
+ $i += strlen($output);
+
+ // remove comments
+ if (Parser::preg_match('/[ \t]+#/', $output, $match, PREG_OFFSET_CAPTURE)) {
+ $output = substr($output, 0, $match[0][1]);
+ }
+ } elseif (Parser::preg_match('/^(.'.($legacyOmittedKeySupport ? '+' : '*').'?)('.implode('|', $delimiters).')/', substr($scalar, $i), $match)) {
+ $output = $match[1];
+ $i += strlen($output);
+ } else {
+ throw new ParseException(sprintf('Malformed inline YAML string: %s.', $scalar), self::$parsedLineNumber + 1, null, self::$parsedFilename);
+ }
+
+ // a non-quoted string cannot start with @ or ` (reserved) nor with a scalar indicator (| or >)
+ if ($output && ('@' === $output[0] || '`' === $output[0] || '|' === $output[0] || '>' === $output[0])) {
+ throw new ParseException(sprintf('The reserved indicator "%s" cannot start a plain scalar; you need to quote the scalar.', $output[0]), self::$parsedLineNumber + 1, $output, self::$parsedFilename);
+ }
+
+ if ($output && '%' === $output[0]) {
+ @trigger_error(self::getDeprecationMessage(sprintf('Not quoting the scalar "%s" starting with the "%%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0.', $output)), E_USER_DEPRECATED);
+ }
+
+ if ($evaluate) {
+ $output = self::evaluateScalar($output, $flags, $references);
+ }
+ }
+
+ return $output;
+ }
+
+ /**
+ * Parses a YAML quoted scalar.
+ *
+ * @param string $scalar
+ * @param int &$i
+ *
+ * @return string
+ *
+ * @throws ParseException When malformed inline YAML string is parsed
+ */
+ private static function parseQuotedScalar($scalar, &$i)
+ {
+ if (!Parser::preg_match('/'.self::REGEX_QUOTED_STRING.'/Au', substr($scalar, $i), $match)) {
+ throw new ParseException(sprintf('Malformed inline YAML string: %s.', substr($scalar, $i)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+
+ $output = substr($match[0], 1, strlen($match[0]) - 2);
+
+ $unescaper = new Unescaper();
+ if ('"' == $scalar[$i]) {
+ $output = $unescaper->unescapeDoubleQuotedString($output);
+ } else {
+ $output = $unescaper->unescapeSingleQuotedString($output);
+ }
+
+ $i += strlen($match[0]);
+
+ return $output;
+ }
+
+ /**
+ * Parses a YAML sequence.
+ *
+ * @param string $sequence
+ * @param int $flags
+ * @param int &$i
+ * @param array $references
+ *
+ * @return array
+ *
+ * @throws ParseException When malformed inline YAML string is parsed
+ */
+ private static function parseSequence($sequence, $flags, &$i = 0, $references = array())
+ {
+ $output = array();
+ $len = strlen($sequence);
+ ++$i;
+
+ // [foo, bar, ...]
+ while ($i < $len) {
+ if (']' === $sequence[$i]) {
+ return $output;
+ }
+ if (',' === $sequence[$i] || ' ' === $sequence[$i]) {
+ ++$i;
+
+ continue;
+ }
+
+ $tag = self::parseTag($sequence, $i, $flags);
+ switch ($sequence[$i]) {
+ case '[':
+ // nested sequence
+ $value = self::parseSequence($sequence, $flags, $i, $references);
+ break;
+ case '{':
+ // nested mapping
+ $value = self::parseMapping($sequence, $flags, $i, $references);
+ break;
+ default:
+ $isQuoted = in_array($sequence[$i], array('"', "'"));
+ $value = self::parseScalar($sequence, $flags, array(',', ']'), $i, null === $tag, $references);
+
+ // the value can be an array if a reference has been resolved to an array var
+ if (is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
+ // embedded mapping?
+ try {
+ $pos = 0;
+ $value = self::parseMapping('{'.$value.'}', $flags, $pos, $references);
+ } catch (\InvalidArgumentException $e) {
+ // no, it's not
+ }
+ }
+
+ --$i;
+ }
+
+ if (null !== $tag) {
+ $value = new TaggedValue($tag, $value);
+ }
+
+ $output[] = $value;
+
+ ++$i;
+ }
+
+ throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
+ }
+
+ /**
+ * Parses a YAML mapping.
+ *
+ * @param string $mapping
+ * @param int $flags
+ * @param int &$i
+ * @param array $references
+ *
+ * @return array|\stdClass
+ *
+ * @throws ParseException When malformed inline YAML string is parsed
+ */
+ private static function parseMapping($mapping, $flags, &$i = 0, $references = array())
+ {
+ $output = array();
+ $len = strlen($mapping);
+ ++$i;
+ $allowOverwrite = false;
+
+ // {foo: bar, bar:foo, ...}
+ while ($i < $len) {
+ switch ($mapping[$i]) {
+ case ' ':
+ case ',':
+ ++$i;
+ continue 2;
+ case '}':
+ if (self::$objectForMap) {
+ return (object) $output;
+ }
+
+ return $output;
+ }
+
+ // key
+ $isKeyQuoted = in_array($mapping[$i], array('"', "'"), true);
+ $key = self::parseScalar($mapping, $flags, array(':', ' '), $i, false, array(), true);
+
+ if (':' !== $key && false === $i = strpos($mapping, ':', $i)) {
+ break;
+ }
+
+ if (':' === $key) {
+ @trigger_error(self::getDeprecationMessage('Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0.'), E_USER_DEPRECATED);
+ }
+
+ if (!$isKeyQuoted) {
+ $evaluatedKey = self::evaluateScalar($key, $flags, $references);
+
+ if ('' !== $key && $evaluatedKey !== $key && !is_string($evaluatedKey) && !is_int($evaluatedKey)) {
+ @trigger_error(self::getDeprecationMessage('Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.'), E_USER_DEPRECATED);
+ }
+ }
+
+ if (':' !== $key && !$isKeyQuoted && (!isset($mapping[$i + 1]) || !in_array($mapping[$i + 1], array(' ', ',', '[', ']', '{', '}'), true))) {
+ @trigger_error(self::getDeprecationMessage('Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since Symfony 3.2 and will throw a ParseException in 4.0.'), E_USER_DEPRECATED);
+ }
+
+ if ('<<' === $key) {
+ $allowOverwrite = true;
+ }
+
+ while ($i < $len) {
+ if (':' === $mapping[$i] || ' ' === $mapping[$i]) {
+ ++$i;
+
+ continue;
+ }
+
+ $tag = self::parseTag($mapping, $i, $flags);
+ switch ($mapping[$i]) {
+ case '[':
+ // nested sequence
+ $value = self::parseSequence($mapping, $flags, $i, $references);
+ // Spec: Keys MUST be unique; first one wins.
+ // Parser cannot abort this mapping earlier, since lines
+ // are processed sequentially.
+ // But overwriting is allowed when a merge node is used in current block.
+ if ('<<' === $key) {
+ foreach ($value as $parsedValue) {
+ $output += $parsedValue;
+ }
+ } elseif ($allowOverwrite || !isset($output[$key])) {
+ if (null !== $tag) {
+ $output[$key] = new TaggedValue($tag, $value);
+ } else {
+ $output[$key] = $value;
+ }
+ } elseif (isset($output[$key])) {
+ @trigger_error(self::getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
+ }
+ break;
+ case '{':
+ // nested mapping
+ $value = self::parseMapping($mapping, $flags, $i, $references);
+ // Spec: Keys MUST be unique; first one wins.
+ // Parser cannot abort this mapping earlier, since lines
+ // are processed sequentially.
+ // But overwriting is allowed when a merge node is used in current block.
+ if ('<<' === $key) {
+ $output += $value;
+ } elseif ($allowOverwrite || !isset($output[$key])) {
+ if (null !== $tag) {
+ $output[$key] = new TaggedValue($tag, $value);
+ } else {
+ $output[$key] = $value;
+ }
+ } elseif (isset($output[$key])) {
+ @trigger_error(self::getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
+ }
+ break;
+ default:
+ $value = self::parseScalar($mapping, $flags, array(',', '}'), $i, null === $tag, $references);
+ // Spec: Keys MUST be unique; first one wins.
+ // Parser cannot abort this mapping earlier, since lines
+ // are processed sequentially.
+ // But overwriting is allowed when a merge node is used in current block.
+ if ('<<' === $key) {
+ $output += $value;
+ } elseif ($allowOverwrite || !isset($output[$key])) {
+ if (null !== $tag) {
+ $output[$key] = new TaggedValue($tag, $value);
+ } else {
+ $output[$key] = $value;
+ }
+ } elseif (isset($output[$key])) {
+ @trigger_error(self::getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
+ }
+ --$i;
+ }
+ ++$i;
+
+ continue 2;
+ }
+ }
+
+ throw new ParseException(sprintf('Malformed inline YAML string: %s.', $mapping), self::$parsedLineNumber + 1, null, self::$parsedFilename);
+ }
+
+ /**
+ * Evaluates scalars and replaces magic values.
+ *
+ * @param string $scalar
+ * @param int $flags
+ * @param array $references
+ *
+ * @return mixed The evaluated YAML string
+ *
+ * @throws ParseException when object parsing support was disabled and the parser detected a PHP object or when a reference could not be resolved
+ */
+ private static function evaluateScalar($scalar, $flags, $references = array())
+ {
+ $scalar = trim($scalar);
+ $scalarLower = strtolower($scalar);
+
+ if (0 === strpos($scalar, '*')) {
+ if (false !== $pos = strpos($scalar, '#')) {
+ $value = substr($scalar, 1, $pos - 2);
+ } else {
+ $value = substr($scalar, 1);
+ }
+
+ // an unquoted *
+ if (false === $value || '' === $value) {
+ throw new ParseException('A reference must contain at least one character.', self::$parsedLineNumber + 1, $value, self::$parsedFilename);
+ }
+
+ if (!array_key_exists($value, $references)) {
+ throw new ParseException(sprintf('Reference "%s" does not exist.', $value), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
+ }
+
+ return $references[$value];
+ }
+
+ switch (true) {
+ case 'null' === $scalarLower:
+ case '' === $scalar:
+ case '~' === $scalar:
+ return;
+ case 'true' === $scalarLower:
+ return true;
+ case 'false' === $scalarLower:
+ return false;
+ case '!' === $scalar[0]:
+ switch (true) {
+ case 0 === strpos($scalar, '!str'):
+ @trigger_error(self::getDeprecationMessage('Support for the !str tag is deprecated since Symfony 3.4. Use the !!str tag instead.'), E_USER_DEPRECATED);
+
+ return (string) substr($scalar, 5);
+ case 0 === strpos($scalar, '!!str '):
+ return (string) substr($scalar, 6);
+ case 0 === strpos($scalar, '! '):
+ @trigger_error(self::getDeprecationMessage('Using the non-specific tag "!" is deprecated since Symfony 3.4 as its behavior will change in 4.0. It will force non-evaluating your values in 4.0. Use plain integers or !!float instead.'), E_USER_DEPRECATED);
+
+ return (int) self::parseScalar(substr($scalar, 2), $flags);
+ case 0 === strpos($scalar, '!php/object:'):
+ if (self::$objectSupport) {
+ @trigger_error(self::getDeprecationMessage('The !php/object: tag to indicate dumped PHP objects is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.'), E_USER_DEPRECATED);
+
+ return unserialize(substr($scalar, 12));
+ }
+
+ if (self::$exceptionOnInvalidType) {
+ throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+
+ return;
+ case 0 === strpos($scalar, '!!php/object:'):
+ if (self::$objectSupport) {
+ @trigger_error(self::getDeprecationMessage('The !!php/object: tag to indicate dumped PHP objects is deprecated since Symfony 3.1 and will be removed in 4.0. Use the !php/object (without the colon) tag instead.'), E_USER_DEPRECATED);
+
+ return unserialize(substr($scalar, 13));
+ }
+
+ if (self::$exceptionOnInvalidType) {
+ throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+
+ return;
+ case 0 === strpos($scalar, '!php/object'):
+ if (self::$objectSupport) {
+ return unserialize(self::parseScalar(substr($scalar, 12)));
+ }
+
+ if (self::$exceptionOnInvalidType) {
+ throw new ParseException('Object support when parsing a YAML file has been disabled.', self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+
+ return;
+ case 0 === strpos($scalar, '!php/const:'):
+ if (self::$constantSupport) {
+ @trigger_error(self::getDeprecationMessage('The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead.'), E_USER_DEPRECATED);
+
+ if (defined($const = substr($scalar, 11))) {
+ return constant($const);
+ }
+
+ throw new ParseException(sprintf('The constant "%s" is not defined.', $const), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+ if (self::$exceptionOnInvalidType) {
+ throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+
+ return;
+ case 0 === strpos($scalar, '!php/const'):
+ if (self::$constantSupport) {
+ $i = 0;
+ if (defined($const = self::parseScalar(substr($scalar, 11), 0, null, $i, false))) {
+ return constant($const);
+ }
+
+ throw new ParseException(sprintf('The constant "%s" is not defined.', $const), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+ if (self::$exceptionOnInvalidType) {
+ throw new ParseException(sprintf('The string "%s" could not be parsed as a constant. Have you forgotten to pass the "Yaml::PARSE_CONSTANT" flag to the parser?', $scalar), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+
+ return;
+ case 0 === strpos($scalar, '!!float '):
+ return (float) substr($scalar, 8);
+ case 0 === strpos($scalar, '!!binary '):
+ return self::evaluateBinaryScalar(substr($scalar, 9));
+ default:
+ @trigger_error(self::getDeprecationMessage(sprintf('Using the unquoted scalar value "%s" is deprecated since Symfony 3.3 and will be considered as a tagged value in 4.0. You must quote it.', $scalar)), E_USER_DEPRECATED);
+ }
+
+ // Optimize for returning strings.
+ // no break
+ case '+' === $scalar[0] || '-' === $scalar[0] || '.' === $scalar[0] || is_numeric($scalar[0]):
+ switch (true) {
+ case Parser::preg_match('{^[+-]?[0-9][0-9_]*$}', $scalar):
+ $scalar = str_replace('_', '', (string) $scalar);
+ // omitting the break / return as integers are handled in the next case
+ // no break
+ case ctype_digit($scalar):
+ $raw = $scalar;
+ $cast = (int) $scalar;
+
+ return '0' == $scalar[0] ? octdec($scalar) : (((string) $raw == (string) $cast) ? $cast : $raw);
+ case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
+ $raw = $scalar;
+ $cast = (int) $scalar;
+
+ return '0' == $scalar[1] ? octdec($scalar) : (((string) $raw === (string) $cast) ? $cast : $raw);
+ case is_numeric($scalar):
+ case Parser::preg_match(self::getHexRegex(), $scalar):
+ $scalar = str_replace('_', '', $scalar);
+
+ return '0x' === $scalar[0].$scalar[1] ? hexdec($scalar) : (float) $scalar;
+ case '.inf' === $scalarLower:
+ case '.nan' === $scalarLower:
+ return -log(0);
+ case '-.inf' === $scalarLower:
+ return log(0);
+ case Parser::preg_match('/^(-|\+)?[0-9][0-9,]*(\.[0-9_]+)?$/', $scalar):
+ case Parser::preg_match('/^(-|\+)?[0-9][0-9_]*(\.[0-9_]+)?$/', $scalar):
+ if (false !== strpos($scalar, ',')) {
+ @trigger_error(self::getDeprecationMessage('Using the comma as a group separator for floats is deprecated since Symfony 3.2 and will be removed in 4.0.'), E_USER_DEPRECATED);
+ }
+
+ return (float) str_replace(array(',', '_'), '', $scalar);
+ case Parser::preg_match(self::getTimestampRegex(), $scalar):
+ if (Yaml::PARSE_DATETIME & $flags) {
+ // When no timezone is provided in the parsed date, YAML spec says we must assume UTC.
+ return new \DateTime($scalar, new \DateTimeZone('UTC'));
+ }
+
+ $timeZone = date_default_timezone_get();
+ date_default_timezone_set('UTC');
+ $time = strtotime($scalar);
+ date_default_timezone_set($timeZone);
+
+ return $time;
+ }
+ }
+
+ return (string) $scalar;
+ }
+
+ /**
+ * @param string $value
+ * @param int &$i
+ * @param int $flags
+ *
+ * @return null|string
+ */
+ private static function parseTag($value, &$i, $flags)
+ {
+ if ('!' !== $value[$i]) {
+ return;
+ }
+
+ $tagLength = strcspn($value, " \t\n", $i + 1);
+ $tag = substr($value, $i + 1, $tagLength);
+
+ $nextOffset = $i + $tagLength + 1;
+ $nextOffset += strspn($value, ' ', $nextOffset);
+
+ // Is followed by a scalar
+ if ((!isset($value[$nextOffset]) || !in_array($value[$nextOffset], array('[', '{'), true)) && 'tagged' !== $tag) {
+ // Manage non-whitelisted scalars in {@link self::evaluateScalar()}
+ return;
+ }
+
+ // Built-in tags
+ if ($tag && '!' === $tag[0]) {
+ throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
+ }
+
+ if (Yaml::PARSE_CUSTOM_TAGS & $flags) {
+ $i = $nextOffset;
+
+ return $tag;
+ }
+
+ throw new ParseException(sprintf('Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
+ }
+
+ /**
+ * @param string $scalar
+ *
+ * @return string
+ *
+ * @internal
+ */
+ public static function evaluateBinaryScalar($scalar)
+ {
+ $parsedBinaryData = self::parseScalar(preg_replace('/\s/', '', $scalar));
+
+ if (0 !== (strlen($parsedBinaryData) % 4)) {
+ throw new ParseException(sprintf('The normalized base64 encoded data (data without whitespace characters) length must be a multiple of four (%d bytes given).', strlen($parsedBinaryData)), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+
+ if (!Parser::preg_match('#^[A-Z0-9+/]+={0,2}$#i', $parsedBinaryData)) {
+ throw new ParseException(sprintf('The base64 encoded data (%s) contains invalid characters.', $parsedBinaryData), self::$parsedLineNumber + 1, $scalar, self::$parsedFilename);
+ }
+
+ return base64_decode($parsedBinaryData, true);
+ }
+
+ private static function isBinaryString($value)
+ {
+ return !preg_match('//u', $value) || preg_match('/[^\x00\x07-\x0d\x1B\x20-\xff]/', $value);
+ }
+
+ /**
+ * Gets a regex that matches a YAML date.
+ *
+ * @return string The regular expression
+ *
+ * @see http://www.yaml.org/spec/1.2/spec.html#id2761573
+ */
+ private static function getTimestampRegex()
+ {
+ return <<<EOF
+ ~^
+ (?P<year>[0-9][0-9][0-9][0-9])
+ -(?P<month>[0-9][0-9]?)
+ -(?P<day>[0-9][0-9]?)
+ (?:(?:[Tt]|[ \t]+)
+ (?P<hour>[0-9][0-9]?)
+ :(?P<minute>[0-9][0-9])
+ :(?P<second>[0-9][0-9])
+ (?:\.(?P<fraction>[0-9]*))?
+ (?:[ \t]*(?P<tz>Z|(?P<tz_sign>[-+])(?P<tz_hour>[0-9][0-9]?)
+ (?::(?P<tz_minute>[0-9][0-9]))?))?)?
+ $~x
+EOF;
+ }
+
+ /**
+ * Gets a regex that matches a YAML number in hexadecimal notation.
+ *
+ * @return string
+ */
+ private static function getHexRegex()
+ {
+ return '~^0x[0-9a-f_]++$~i';
+ }
+
+ private static function getDeprecationMessage($message)
+ {
+ $message = rtrim($message, '.');
+
+ if (null !== self::$parsedFilename) {
+ $message .= ' in '.self::$parsedFilename;
+ }
+
+ if (-1 !== self::$parsedLineNumber) {
+ $message .= ' on line '.(self::$parsedLineNumber + 1);
+ }
+
+ return $message.'.';
+ }
+}
--- /dev/null
+Copyright (c) 2004-2018 Fabien Potencier
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is furnished
+to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml;
+
+use Symfony\Component\Yaml\Exception\ParseException;
+use Symfony\Component\Yaml\Tag\TaggedValue;
+
+/**
+ * Parser parses YAML strings to convert them to PHP arrays.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @final since version 3.4
+ */
+class Parser
+{
+ const TAG_PATTERN = '(?P<tag>![\w!.\/:-]+)';
+ const BLOCK_SCALAR_HEADER_PATTERN = '(?P<separator>\||>)(?P<modifiers>\+|\-|\d+|\+\d+|\-\d+|\d+\+|\d+\-)?(?P<comments> +#.*)?';
+
+ private $filename;
+ private $offset = 0;
+ private $totalNumberOfLines;
+ private $lines = array();
+ private $currentLineNb = -1;
+ private $currentLine = '';
+ private $refs = array();
+ private $skippedLineNumbers = array();
+ private $locallySkippedLineNumbers = array();
+
+ public function __construct()
+ {
+ if (func_num_args() > 0) {
+ @trigger_error(sprintf('The constructor arguments $offset, $totalNumberOfLines, $skippedLineNumbers of %s are deprecated and will be removed in 4.0', self::class), E_USER_DEPRECATED);
+
+ $this->offset = func_get_arg(0);
+ if (func_num_args() > 1) {
+ $this->totalNumberOfLines = func_get_arg(1);
+ }
+ if (func_num_args() > 2) {
+ $this->skippedLineNumbers = func_get_arg(2);
+ }
+ }
+ }
+
+ /**
+ * Parses a YAML file into a PHP value.
+ *
+ * @param string $filename The path to the YAML file to be parsed
+ * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
+ *
+ * @return mixed The YAML converted to a PHP value
+ *
+ * @throws ParseException If the file could not be read or the YAML is not valid
+ */
+ public function parseFile($filename, $flags = 0)
+ {
+ if (!is_file($filename)) {
+ throw new ParseException(sprintf('File "%s" does not exist.', $filename));
+ }
+
+ if (!is_readable($filename)) {
+ throw new ParseException(sprintf('File "%s" cannot be read.', $filename));
+ }
+
+ $this->filename = $filename;
+
+ try {
+ return $this->parse(file_get_contents($filename), $flags);
+ } finally {
+ $this->filename = null;
+ }
+ }
+
+ /**
+ * Parses a YAML string to a PHP value.
+ *
+ * @param string $value A YAML string
+ * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
+ *
+ * @return mixed A PHP value
+ *
+ * @throws ParseException If the YAML is not valid
+ */
+ public function parse($value, $flags = 0)
+ {
+ if (is_bool($flags)) {
+ @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
+
+ if ($flags) {
+ $flags = Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE;
+ } else {
+ $flags = 0;
+ }
+ }
+
+ if (func_num_args() >= 3) {
+ @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
+
+ if (func_get_arg(2)) {
+ $flags |= Yaml::PARSE_OBJECT;
+ }
+ }
+
+ if (func_num_args() >= 4) {
+ @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
+
+ if (func_get_arg(3)) {
+ $flags |= Yaml::PARSE_OBJECT_FOR_MAP;
+ }
+ }
+
+ if (Yaml::PARSE_KEYS_AS_STRINGS & $flags) {
+ @trigger_error('Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.', E_USER_DEPRECATED);
+ }
+
+ if (false === preg_match('//u', $value)) {
+ throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename);
+ }
+
+ $this->refs = array();
+
+ $mbEncoding = null;
+ $e = null;
+ $data = null;
+
+ if (2 /* MB_OVERLOAD_STRING */ & (int) ini_get('mbstring.func_overload')) {
+ $mbEncoding = mb_internal_encoding();
+ mb_internal_encoding('UTF-8');
+ }
+
+ try {
+ $data = $this->doParse($value, $flags);
+ } catch (\Exception $e) {
+ } catch (\Throwable $e) {
+ }
+
+ if (null !== $mbEncoding) {
+ mb_internal_encoding($mbEncoding);
+ }
+
+ $this->lines = array();
+ $this->currentLine = '';
+ $this->refs = array();
+ $this->skippedLineNumbers = array();
+ $this->locallySkippedLineNumbers = array();
+
+ if (null !== $e) {
+ throw $e;
+ }
+
+ return $data;
+ }
+
+ private function doParse($value, $flags)
+ {
+ $this->currentLineNb = -1;
+ $this->currentLine = '';
+ $value = $this->cleanup($value);
+ $this->lines = explode("\n", $value);
+ $this->locallySkippedLineNumbers = array();
+
+ if (null === $this->totalNumberOfLines) {
+ $this->totalNumberOfLines = count($this->lines);
+ }
+
+ if (!$this->moveToNextLine()) {
+ return null;
+ }
+
+ $data = array();
+ $context = null;
+ $allowOverwrite = false;
+
+ while ($this->isCurrentLineEmpty()) {
+ if (!$this->moveToNextLine()) {
+ return null;
+ }
+ }
+
+ // Resolves the tag and returns if end of the document
+ if (null !== ($tag = $this->getLineTag($this->currentLine, $flags, false)) && !$this->moveToNextLine()) {
+ return new TaggedValue($tag, '');
+ }
+
+ do {
+ if ($this->isCurrentLineEmpty()) {
+ continue;
+ }
+
+ // tab?
+ if ("\t" === $this->currentLine[0]) {
+ throw new ParseException('A YAML file cannot contain tabs as indentation.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
+ }
+
+ Inline::initialize($flags, $this->getRealCurrentLineNb(), $this->filename);
+
+ $isRef = $mergeNode = false;
+ if (self::preg_match('#^\-((?P<leadspaces>\s+)(?P<value>.+))?$#u', rtrim($this->currentLine), $values)) {
+ if ($context && 'mapping' == $context) {
+ throw new ParseException('You cannot define a sequence item when in a mapping', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
+ }
+ $context = 'sequence';
+
+ if (isset($values['value']) && self::preg_match('#^&(?P<ref>[^ ]+) *(?P<value>.*)#u', $values['value'], $matches)) {
+ $isRef = $matches['ref'];
+ $values['value'] = $matches['value'];
+ }
+
+ if (isset($values['value'][1]) && '?' === $values['value'][0] && ' ' === $values['value'][1]) {
+ @trigger_error($this->getDeprecationMessage('Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.'), E_USER_DEPRECATED);
+ }
+
+ // array
+ if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
+ $data[] = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true), $flags);
+ } elseif (null !== $subTag = $this->getLineTag(ltrim($values['value'], ' '), $flags)) {
+ $data[] = new TaggedValue(
+ $subTag,
+ $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true), $flags)
+ );
+ } else {
+ if (isset($values['leadspaces'])
+ && self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->trimTag($values['value']), $matches)
+ ) {
+ // this is a compact notation element, add to next block and parse
+ $block = $values['value'];
+ if ($this->isNextLineIndented()) {
+ $block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + strlen($values['leadspaces']) + 1);
+ }
+
+ $data[] = $this->parseBlock($this->getRealCurrentLineNb(), $block, $flags);
+ } else {
+ $data[] = $this->parseValue($values['value'], $flags, $context);
+ }
+ }
+ if ($isRef) {
+ $this->refs[$isRef] = end($data);
+ }
+ } elseif (
+ self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(\s++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
+ && (false === strpos($values['key'], ' #') || in_array($values['key'][0], array('"', "'")))
+ ) {
+ if ($context && 'sequence' == $context) {
+ throw new ParseException('You cannot define a mapping item when in a sequence', $this->currentLineNb + 1, $this->currentLine, $this->filename);
+ }
+ $context = 'mapping';
+
+ try {
+ $i = 0;
+ $evaluateKey = !(Yaml::PARSE_KEYS_AS_STRINGS & $flags);
+
+ // constants in key will be evaluated anyway
+ if (isset($values['key'][0]) && '!' === $values['key'][0] && Yaml::PARSE_CONSTANT & $flags) {
+ $evaluateKey = true;
+ }
+
+ $key = Inline::parseScalar($values['key'], 0, null, $i, $evaluateKey);
+ } catch (ParseException $e) {
+ $e->setParsedLine($this->getRealCurrentLineNb() + 1);
+ $e->setSnippet($this->currentLine);
+
+ throw $e;
+ }
+
+ if (!is_string($key) && !is_int($key)) {
+ $keyType = is_numeric($key) ? 'numeric key' : 'non-string key';
+ @trigger_error($this->getDeprecationMessage(sprintf('Implicit casting of %s to string is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead.', $keyType)), E_USER_DEPRECATED);
+ }
+
+ // Convert float keys to strings, to avoid being converted to integers by PHP
+ if (is_float($key)) {
+ $key = (string) $key;
+ }
+
+ if ('<<' === $key && (!isset($values['value']) || !self::preg_match('#^&(?P<ref>[^ ]+)#u', $values['value'], $refMatches))) {
+ $mergeNode = true;
+ $allowOverwrite = true;
+ if (isset($values['value'][0]) && '*' === $values['value'][0]) {
+ $refName = substr(rtrim($values['value']), 1);
+ if (!array_key_exists($refName, $this->refs)) {
+ throw new ParseException(sprintf('Reference "%s" does not exist.', $refName), $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
+ }
+
+ $refValue = $this->refs[$refName];
+
+ if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $refValue instanceof \stdClass) {
+ $refValue = (array) $refValue;
+ }
+
+ if (!is_array($refValue)) {
+ throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
+ }
+
+ $data += $refValue; // array union
+ } else {
+ if (isset($values['value']) && '' !== $values['value']) {
+ $value = $values['value'];
+ } else {
+ $value = $this->getNextEmbedBlock();
+ }
+ $parsed = $this->parseBlock($this->getRealCurrentLineNb() + 1, $value, $flags);
+
+ if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $parsed instanceof \stdClass) {
+ $parsed = (array) $parsed;
+ }
+
+ if (!is_array($parsed)) {
+ throw new ParseException('YAML merge keys used with a scalar value instead of an array.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
+ }
+
+ if (isset($parsed[0])) {
+ // If the value associated with the merge key is a sequence, then this sequence is expected to contain mapping nodes
+ // and each of these nodes is merged in turn according to its order in the sequence. Keys in mapping nodes earlier
+ // in the sequence override keys specified in later mapping nodes.
+ foreach ($parsed as $parsedItem) {
+ if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $parsedItem instanceof \stdClass) {
+ $parsedItem = (array) $parsedItem;
+ }
+
+ if (!is_array($parsedItem)) {
+ throw new ParseException('Merge items must be arrays.', $this->getRealCurrentLineNb() + 1, $parsedItem, $this->filename);
+ }
+
+ $data += $parsedItem; // array union
+ }
+ } else {
+ // If the value associated with the key is a single mapping node, each of its key/value pairs is inserted into the
+ // current mapping, unless the key already exists in it.
+ $data += $parsed; // array union
+ }
+ }
+ } elseif ('<<' !== $key && isset($values['value']) && self::preg_match('#^&(?P<ref>[^ ]++) *+(?P<value>.*)#u', $values['value'], $matches)) {
+ $isRef = $matches['ref'];
+ $values['value'] = $matches['value'];
+ }
+
+ $subTag = null;
+ if ($mergeNode) {
+ // Merge keys
+ } elseif (!isset($values['value']) || '' === $values['value'] || 0 === strpos($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) {
+ // hash
+ // if next line is less indented or equal, then it means that the current value is null
+ if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
+ // Spec: Keys MUST be unique; first one wins.
+ // But overwriting is allowed when a merge node is used in current block.
+ if ($allowOverwrite || !isset($data[$key])) {
+ if (null !== $subTag) {
+ $data[$key] = new TaggedValue($subTag, '');
+ } else {
+ $data[$key] = null;
+ }
+ } else {
+ @trigger_error($this->getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
+ }
+ } else {
+ $value = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(), $flags);
+ if ('<<' === $key) {
+ $this->refs[$refMatches['ref']] = $value;
+
+ if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $value instanceof \stdClass) {
+ $value = (array) $value;
+ }
+
+ $data += $value;
+ } elseif ($allowOverwrite || !isset($data[$key])) {
+ // Spec: Keys MUST be unique; first one wins.
+ // But overwriting is allowed when a merge node is used in current block.
+ if (null !== $subTag) {
+ $data[$key] = new TaggedValue($subTag, $value);
+ } else {
+ $data[$key] = $value;
+ }
+ } else {
+ @trigger_error($this->getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
+ }
+ }
+ } else {
+ $value = $this->parseValue(rtrim($values['value']), $flags, $context);
+ // Spec: Keys MUST be unique; first one wins.
+ // But overwriting is allowed when a merge node is used in current block.
+ if ($allowOverwrite || !isset($data[$key])) {
+ $data[$key] = $value;
+ } else {
+ @trigger_error($this->getDeprecationMessage(sprintf('Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated since Symfony 3.2 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.', $key)), E_USER_DEPRECATED);
+ }
+ }
+ if ($isRef) {
+ $this->refs[$isRef] = $data[$key];
+ }
+ } else {
+ // multiple documents are not supported
+ if ('---' === $this->currentLine) {
+ throw new ParseException('Multiple documents are not supported.', $this->currentLineNb + 1, $this->currentLine, $this->filename);
+ }
+
+ if (isset($this->currentLine[1]) && '?' === $this->currentLine[0] && ' ' === $this->currentLine[1]) {
+ @trigger_error($this->getDeprecationMessage('Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0.'), E_USER_DEPRECATED);
+ }
+
+ // 1-liner optionally followed by newline(s)
+ if (is_string($value) && $this->lines[0] === trim($value)) {
+ try {
+ $value = Inline::parse($this->lines[0], $flags, $this->refs);
+ } catch (ParseException $e) {
+ $e->setParsedLine($this->getRealCurrentLineNb() + 1);
+ $e->setSnippet($this->currentLine);
+
+ throw $e;
+ }
+
+ return $value;
+ }
+
+ // try to parse the value as a multi-line string as a last resort
+ if (0 === $this->currentLineNb) {
+ $previousLineWasNewline = false;
+ $previousLineWasTerminatedWithBackslash = false;
+ $value = '';
+
+ foreach ($this->lines as $line) {
+ if ('' === trim($line)) {
+ $value .= "\n";
+ } elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {
+ $value .= ' ';
+ }
+
+ if ('' !== trim($line) && '\\' === substr($line, -1)) {
+ $value .= ltrim(substr($line, 0, -1));
+ } elseif ('' !== trim($line)) {
+ $value .= trim($line);
+ }
+
+ if ('' === trim($line)) {
+ $previousLineWasNewline = true;
+ $previousLineWasTerminatedWithBackslash = false;
+ } elseif ('\\' === substr($line, -1)) {
+ $previousLineWasNewline = false;
+ $previousLineWasTerminatedWithBackslash = true;
+ } else {
+ $previousLineWasNewline = false;
+ $previousLineWasTerminatedWithBackslash = false;
+ }
+ }
+
+ try {
+ return Inline::parse(trim($value));
+ } catch (ParseException $e) {
+ // fall-through to the ParseException thrown below
+ }
+ }
+
+ throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
+ }
+ } while ($this->moveToNextLine());
+
+ if (null !== $tag) {
+ $data = new TaggedValue($tag, $data);
+ }
+
+ if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && !is_object($data) && 'mapping' === $context) {
+ $object = new \stdClass();
+
+ foreach ($data as $key => $value) {
+ $object->$key = $value;
+ }
+
+ $data = $object;
+ }
+
+ return empty($data) ? null : $data;
+ }
+
+ private function parseBlock($offset, $yaml, $flags)
+ {
+ $skippedLineNumbers = $this->skippedLineNumbers;
+
+ foreach ($this->locallySkippedLineNumbers as $lineNumber) {
+ if ($lineNumber < $offset) {
+ continue;
+ }
+
+ $skippedLineNumbers[] = $lineNumber;
+ }
+
+ $parser = new self();
+ $parser->offset = $offset;
+ $parser->totalNumberOfLines = $this->totalNumberOfLines;
+ $parser->skippedLineNumbers = $skippedLineNumbers;
+ $parser->refs = &$this->refs;
+
+ return $parser->doParse($yaml, $flags);
+ }
+
+ /**
+ * Returns the current line number (takes the offset into account).
+ *
+ * @internal
+ *
+ * @return int The current line number
+ */
+ public function getRealCurrentLineNb()
+ {
+ $realCurrentLineNumber = $this->currentLineNb + $this->offset;
+
+ foreach ($this->skippedLineNumbers as $skippedLineNumber) {
+ if ($skippedLineNumber > $realCurrentLineNumber) {
+ break;
+ }
+
+ ++$realCurrentLineNumber;
+ }
+
+ return $realCurrentLineNumber;
+ }
+
+ /**
+ * Returns the current line indentation.
+ *
+ * @return int The current line indentation
+ */
+ private function getCurrentLineIndentation()
+ {
+ return strlen($this->currentLine) - strlen(ltrim($this->currentLine, ' '));
+ }
+
+ /**
+ * Returns the next embed block of YAML.
+ *
+ * @param int $indentation The indent level at which the block is to be read, or null for default
+ * @param bool $inSequence True if the enclosing data structure is a sequence
+ *
+ * @return string A YAML string
+ *
+ * @throws ParseException When indentation problem are detected
+ */
+ private function getNextEmbedBlock($indentation = null, $inSequence = false)
+ {
+ $oldLineIndentation = $this->getCurrentLineIndentation();
+ $blockScalarIndentations = array();
+
+ if ($this->isBlockScalarHeader()) {
+ $blockScalarIndentations[] = $oldLineIndentation;
+ }
+
+ if (!$this->moveToNextLine()) {
+ return;
+ }
+
+ if (null === $indentation) {
+ $newIndent = null;
+ $movements = 0;
+
+ do {
+ $EOF = false;
+
+ // empty and comment-like lines do not influence the indentation depth
+ if ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
+ $EOF = !$this->moveToNextLine();
+
+ if (!$EOF) {
+ ++$movements;
+ }
+ } else {
+ $newIndent = $this->getCurrentLineIndentation();
+ }
+ } while (!$EOF && null === $newIndent);
+
+ for ($i = 0; $i < $movements; ++$i) {
+ $this->moveToPreviousLine();
+ }
+
+ $unindentedEmbedBlock = $this->isStringUnIndentedCollectionItem();
+
+ if (!$this->isCurrentLineEmpty() && 0 === $newIndent && !$unindentedEmbedBlock) {
+ throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
+ }
+ } else {
+ $newIndent = $indentation;
+ }
+
+ $data = array();
+ if ($this->getCurrentLineIndentation() >= $newIndent) {
+ $data[] = substr($this->currentLine, $newIndent);
+ } elseif ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()) {
+ $data[] = $this->currentLine;
+ } else {
+ $this->moveToPreviousLine();
+
+ return;
+ }
+
+ if ($inSequence && $oldLineIndentation === $newIndent && isset($data[0][0]) && '-' === $data[0][0]) {
+ // the previous line contained a dash but no item content, this line is a sequence item with the same indentation
+ // and therefore no nested list or mapping
+ $this->moveToPreviousLine();
+
+ return;
+ }
+
+ $isItUnindentedCollection = $this->isStringUnIndentedCollectionItem();
+
+ if (empty($blockScalarIndentations) && $this->isBlockScalarHeader()) {
+ $blockScalarIndentations[] = $this->getCurrentLineIndentation();
+ }
+
+ $previousLineIndentation = $this->getCurrentLineIndentation();
+
+ while ($this->moveToNextLine()) {
+ $indent = $this->getCurrentLineIndentation();
+
+ // terminate all block scalars that are more indented than the current line
+ if (!empty($blockScalarIndentations) && $indent < $previousLineIndentation && '' !== trim($this->currentLine)) {
+ foreach ($blockScalarIndentations as $key => $blockScalarIndentation) {
+ if ($blockScalarIndentation >= $indent) {
+ unset($blockScalarIndentations[$key]);
+ }
+ }
+ }
+
+ if (empty($blockScalarIndentations) && !$this->isCurrentLineComment() && $this->isBlockScalarHeader()) {
+ $blockScalarIndentations[] = $indent;
+ }
+
+ $previousLineIndentation = $indent;
+
+ if ($isItUnindentedCollection && !$this->isCurrentLineEmpty() && !$this->isStringUnIndentedCollectionItem() && $newIndent === $indent) {
+ $this->moveToPreviousLine();
+ break;
+ }
+
+ if ($this->isCurrentLineBlank()) {
+ $data[] = substr($this->currentLine, $newIndent);
+ continue;
+ }
+
+ if ($indent >= $newIndent) {
+ $data[] = substr($this->currentLine, $newIndent);
+ } elseif ($this->isCurrentLineComment()) {
+ $data[] = $this->currentLine;
+ } elseif (0 == $indent) {
+ $this->moveToPreviousLine();
+
+ break;
+ } else {
+ throw new ParseException('Indentation problem.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
+ }
+ }
+
+ return implode("\n", $data);
+ }
+
+ /**
+ * Moves the parser to the next line.
+ *
+ * @return bool
+ */
+ private function moveToNextLine()
+ {
+ if ($this->currentLineNb >= count($this->lines) - 1) {
+ return false;
+ }
+
+ $this->currentLine = $this->lines[++$this->currentLineNb];
+
+ return true;
+ }
+
+ /**
+ * Moves the parser to the previous line.
+ *
+ * @return bool
+ */
+ private function moveToPreviousLine()
+ {
+ if ($this->currentLineNb < 1) {
+ return false;
+ }
+
+ $this->currentLine = $this->lines[--$this->currentLineNb];
+
+ return true;
+ }
+
+ /**
+ * Parses a YAML value.
+ *
+ * @param string $value A YAML value
+ * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
+ * @param string $context The parser context (either sequence or mapping)
+ *
+ * @return mixed A PHP value
+ *
+ * @throws ParseException When reference does not exist
+ */
+ private function parseValue($value, $flags, $context)
+ {
+ if (0 === strpos($value, '*')) {
+ if (false !== $pos = strpos($value, '#')) {
+ $value = substr($value, 1, $pos - 2);
+ } else {
+ $value = substr($value, 1);
+ }
+
+ if (!array_key_exists($value, $this->refs)) {
+ throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLineNb + 1, $this->currentLine, $this->filename);
+ }
+
+ return $this->refs[$value];
+ }
+
+ if (self::preg_match('/^(?:'.self::TAG_PATTERN.' +)?'.self::BLOCK_SCALAR_HEADER_PATTERN.'$/', $value, $matches)) {
+ $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
+
+ $data = $this->parseBlockScalar($matches['separator'], preg_replace('#\d+#', '', $modifiers), (int) abs($modifiers));
+
+ if ('' !== $matches['tag']) {
+ if ('!!binary' === $matches['tag']) {
+ return Inline::evaluateBinaryScalar($data);
+ } elseif ('tagged' === $matches['tag']) {
+ return new TaggedValue(substr($matches['tag'], 1), $data);
+ } elseif ('!' !== $matches['tag']) {
+ @trigger_error($this->getDeprecationMessage(sprintf('Using the custom tag "%s" for the value "%s" is deprecated since Symfony 3.3. It will be replaced by an instance of %s in 4.0.', $matches['tag'], $data, TaggedValue::class)), E_USER_DEPRECATED);
+ }
+ }
+
+ return $data;
+ }
+
+ try {
+ $quotation = '' !== $value && ('"' === $value[0] || "'" === $value[0]) ? $value[0] : null;
+
+ // do not take following lines into account when the current line is a quoted single line value
+ if (null !== $quotation && self::preg_match('/^'.$quotation.'.*'.$quotation.'(\s*#.*)?$/', $value)) {
+ return Inline::parse($value, $flags, $this->refs);
+ }
+
+ $lines = array();
+
+ while ($this->moveToNextLine()) {
+ // unquoted strings end before the first unindented line
+ if (null === $quotation && 0 === $this->getCurrentLineIndentation()) {
+ $this->moveToPreviousLine();
+
+ break;
+ }
+
+ $lines[] = trim($this->currentLine);
+
+ // quoted string values end with a line that is terminated with the quotation character
+ if ('' !== $this->currentLine && substr($this->currentLine, -1) === $quotation) {
+ break;
+ }
+ }
+
+ for ($i = 0, $linesCount = count($lines), $previousLineBlank = false; $i < $linesCount; ++$i) {
+ if ('' === $lines[$i]) {
+ $value .= "\n";
+ $previousLineBlank = true;
+ } elseif ($previousLineBlank) {
+ $value .= $lines[$i];
+ $previousLineBlank = false;
+ } else {
+ $value .= ' '.$lines[$i];
+ $previousLineBlank = false;
+ }
+ }
+
+ Inline::$parsedLineNumber = $this->getRealCurrentLineNb();
+
+ $parsedValue = Inline::parse($value, $flags, $this->refs);
+
+ if ('mapping' === $context && is_string($parsedValue) && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) {
+ throw new ParseException('A colon cannot be used in an unquoted mapping value.', $this->getRealCurrentLineNb() + 1, $value, $this->filename);
+ }
+
+ return $parsedValue;
+ } catch (ParseException $e) {
+ $e->setParsedLine($this->getRealCurrentLineNb() + 1);
+ $e->setSnippet($this->currentLine);
+
+ throw $e;
+ }
+ }
+
+ /**
+ * Parses a block scalar.
+ *
+ * @param string $style The style indicator that was used to begin this block scalar (| or >)
+ * @param string $chomping The chomping indicator that was used to begin this block scalar (+ or -)
+ * @param int $indentation The indentation indicator that was used to begin this block scalar
+ *
+ * @return string The text value
+ */
+ private function parseBlockScalar($style, $chomping = '', $indentation = 0)
+ {
+ $notEOF = $this->moveToNextLine();
+ if (!$notEOF) {
+ return '';
+ }
+
+ $isCurrentLineBlank = $this->isCurrentLineBlank();
+ $blockLines = array();
+
+ // leading blank lines are consumed before determining indentation
+ while ($notEOF && $isCurrentLineBlank) {
+ // newline only if not EOF
+ if ($notEOF = $this->moveToNextLine()) {
+ $blockLines[] = '';
+ $isCurrentLineBlank = $this->isCurrentLineBlank();
+ }
+ }
+
+ // determine indentation if not specified
+ if (0 === $indentation) {
+ if (self::preg_match('/^ +/', $this->currentLine, $matches)) {
+ $indentation = strlen($matches[0]);
+ }
+ }
+
+ if ($indentation > 0) {
+ $pattern = sprintf('/^ {%d}(.*)$/', $indentation);
+
+ while (
+ $notEOF && (
+ $isCurrentLineBlank ||
+ self::preg_match($pattern, $this->currentLine, $matches)
+ )
+ ) {
+ if ($isCurrentLineBlank && strlen($this->currentLine) > $indentation) {
+ $blockLines[] = substr($this->currentLine, $indentation);
+ } elseif ($isCurrentLineBlank) {
+ $blockLines[] = '';
+ } else {
+ $blockLines[] = $matches[1];
+ }
+
+ // newline only if not EOF
+ if ($notEOF = $this->moveToNextLine()) {
+ $isCurrentLineBlank = $this->isCurrentLineBlank();
+ }
+ }
+ } elseif ($notEOF) {
+ $blockLines[] = '';
+ }
+
+ if ($notEOF) {
+ $blockLines[] = '';
+ $this->moveToPreviousLine();
+ } elseif (!$notEOF && !$this->isCurrentLineLastLineInDocument()) {
+ $blockLines[] = '';
+ }
+
+ // folded style
+ if ('>' === $style) {
+ $text = '';
+ $previousLineIndented = false;
+ $previousLineBlank = false;
+
+ for ($i = 0, $blockLinesCount = count($blockLines); $i < $blockLinesCount; ++$i) {
+ if ('' === $blockLines[$i]) {
+ $text .= "\n";
+ $previousLineIndented = false;
+ $previousLineBlank = true;
+ } elseif (' ' === $blockLines[$i][0]) {
+ $text .= "\n".$blockLines[$i];
+ $previousLineIndented = true;
+ $previousLineBlank = false;
+ } elseif ($previousLineIndented) {
+ $text .= "\n".$blockLines[$i];
+ $previousLineIndented = false;
+ $previousLineBlank = false;
+ } elseif ($previousLineBlank || 0 === $i) {
+ $text .= $blockLines[$i];
+ $previousLineIndented = false;
+ $previousLineBlank = false;
+ } else {
+ $text .= ' '.$blockLines[$i];
+ $previousLineIndented = false;
+ $previousLineBlank = false;
+ }
+ }
+ } else {
+ $text = implode("\n", $blockLines);
+ }
+
+ // deal with trailing newlines
+ if ('' === $chomping) {
+ $text = preg_replace('/\n+$/', "\n", $text);
+ } elseif ('-' === $chomping) {
+ $text = preg_replace('/\n+$/', '', $text);
+ }
+
+ return $text;
+ }
+
+ /**
+ * Returns true if the next line is indented.
+ *
+ * @return bool Returns true if the next line is indented, false otherwise
+ */
+ private function isNextLineIndented()
+ {
+ $currentIndentation = $this->getCurrentLineIndentation();
+ $movements = 0;
+
+ do {
+ $EOF = !$this->moveToNextLine();
+
+ if (!$EOF) {
+ ++$movements;
+ }
+ } while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));
+
+ if ($EOF) {
+ return false;
+ }
+
+ $ret = $this->getCurrentLineIndentation() > $currentIndentation;
+
+ for ($i = 0; $i < $movements; ++$i) {
+ $this->moveToPreviousLine();
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Returns true if the current line is blank or if it is a comment line.
+ *
+ * @return bool Returns true if the current line is empty or if it is a comment line, false otherwise
+ */
+ private function isCurrentLineEmpty()
+ {
+ return $this->isCurrentLineBlank() || $this->isCurrentLineComment();
+ }
+
+ /**
+ * Returns true if the current line is blank.
+ *
+ * @return bool Returns true if the current line is blank, false otherwise
+ */
+ private function isCurrentLineBlank()
+ {
+ return '' == trim($this->currentLine, ' ');
+ }
+
+ /**
+ * Returns true if the current line is a comment line.
+ *
+ * @return bool Returns true if the current line is a comment line, false otherwise
+ */
+ private function isCurrentLineComment()
+ {
+ //checking explicitly the first char of the trim is faster than loops or strpos
+ $ltrimmedLine = ltrim($this->currentLine, ' ');
+
+ return '' !== $ltrimmedLine && '#' === $ltrimmedLine[0];
+ }
+
+ private function isCurrentLineLastLineInDocument()
+ {
+ return ($this->offset + $this->currentLineNb) >= ($this->totalNumberOfLines - 1);
+ }
+
+ /**
+ * Cleanups a YAML string to be parsed.
+ *
+ * @param string $value The input YAML string
+ *
+ * @return string A cleaned up YAML string
+ */
+ private function cleanup($value)
+ {
+ $value = str_replace(array("\r\n", "\r"), "\n", $value);
+
+ // strip YAML header
+ $count = 0;
+ $value = preg_replace('#^\%YAML[: ][\d\.]+.*\n#u', '', $value, -1, $count);
+ $this->offset += $count;
+
+ // remove leading comments
+ $trimmedValue = preg_replace('#^(\#.*?\n)+#s', '', $value, -1, $count);
+ if (1 === $count) {
+ // items have been removed, update the offset
+ $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n");
+ $value = $trimmedValue;
+ }
+
+ // remove start of the document marker (---)
+ $trimmedValue = preg_replace('#^\-\-\-.*?\n#s', '', $value, -1, $count);
+ if (1 === $count) {
+ // items have been removed, update the offset
+ $this->offset += substr_count($value, "\n") - substr_count($trimmedValue, "\n");
+ $value = $trimmedValue;
+
+ // remove end of the document marker (...)
+ $value = preg_replace('#\.\.\.\s*$#', '', $value);
+ }
+
+ return $value;
+ }
+
+ /**
+ * Returns true if the next line starts unindented collection.
+ *
+ * @return bool Returns true if the next line starts unindented collection, false otherwise
+ */
+ private function isNextLineUnIndentedCollection()
+ {
+ $currentIndentation = $this->getCurrentLineIndentation();
+ $movements = 0;
+
+ do {
+ $EOF = !$this->moveToNextLine();
+
+ if (!$EOF) {
+ ++$movements;
+ }
+ } while (!$EOF && ($this->isCurrentLineEmpty() || $this->isCurrentLineComment()));
+
+ if ($EOF) {
+ return false;
+ }
+
+ $ret = $this->getCurrentLineIndentation() === $currentIndentation && $this->isStringUnIndentedCollectionItem();
+
+ for ($i = 0; $i < $movements; ++$i) {
+ $this->moveToPreviousLine();
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Returns true if the string is un-indented collection item.
+ *
+ * @return bool Returns true if the string is un-indented collection item, false otherwise
+ */
+ private function isStringUnIndentedCollectionItem()
+ {
+ return '-' === rtrim($this->currentLine) || 0 === strpos($this->currentLine, '- ');
+ }
+
+ /**
+ * Tests whether or not the current line is the header of a block scalar.
+ *
+ * @return bool
+ */
+ private function isBlockScalarHeader()
+ {
+ return (bool) self::preg_match('~'.self::BLOCK_SCALAR_HEADER_PATTERN.'$~', $this->currentLine);
+ }
+
+ /**
+ * A local wrapper for `preg_match` which will throw a ParseException if there
+ * is an internal error in the PCRE engine.
+ *
+ * This avoids us needing to check for "false" every time PCRE is used
+ * in the YAML engine
+ *
+ * @throws ParseException on a PCRE internal error
+ *
+ * @see preg_last_error()
+ *
+ * @internal
+ */
+ public static function preg_match($pattern, $subject, &$matches = null, $flags = 0, $offset = 0)
+ {
+ if (false === $ret = preg_match($pattern, $subject, $matches, $flags, $offset)) {
+ switch (preg_last_error()) {
+ case PREG_INTERNAL_ERROR:
+ $error = 'Internal PCRE error.';
+ break;
+ case PREG_BACKTRACK_LIMIT_ERROR:
+ $error = 'pcre.backtrack_limit reached.';
+ break;
+ case PREG_RECURSION_LIMIT_ERROR:
+ $error = 'pcre.recursion_limit reached.';
+ break;
+ case PREG_BAD_UTF8_ERROR:
+ $error = 'Malformed UTF-8 data.';
+ break;
+ case PREG_BAD_UTF8_OFFSET_ERROR:
+ $error = 'Offset doesn\'t correspond to the begin of a valid UTF-8 code point.';
+ break;
+ default:
+ $error = 'Error.';
+ }
+
+ throw new ParseException($error);
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Trim the tag on top of the value.
+ *
+ * Prevent values such as `!foo {quz: bar}` to be considered as
+ * a mapping block.
+ */
+ private function trimTag($value)
+ {
+ if ('!' === $value[0]) {
+ return ltrim(substr($value, 1, strcspn($value, " \r\n", 1)), ' ');
+ }
+
+ return $value;
+ }
+
+ private function getLineTag($value, $flags, $nextLineCheck = true)
+ {
+ if ('' === $value || '!' !== $value[0] || 1 !== self::preg_match('/^'.self::TAG_PATTERN.' *( +#.*)?$/', $value, $matches)) {
+ return;
+ }
+
+ if ($nextLineCheck && !$this->isNextLineIndented()) {
+ return;
+ }
+
+ $tag = substr($matches['tag'], 1);
+
+ // Built-in tags
+ if ($tag && '!' === $tag[0]) {
+ throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
+ }
+
+ if (Yaml::PARSE_CUSTOM_TAGS & $flags) {
+ return $tag;
+ }
+
+ throw new ParseException(sprintf('Tags support is not enabled. You must use the flag `Yaml::PARSE_CUSTOM_TAGS` to use "%s".', $matches['tag']), $this->getRealCurrentLineNb() + 1, $value, $this->filename);
+ }
+
+ private function getDeprecationMessage($message)
+ {
+ $message = rtrim($message, '.');
+
+ if (null !== $this->filename) {
+ $message .= ' in '.$this->filename;
+ }
+
+ $message .= ' on line '.($this->getRealCurrentLineNb() + 1);
+
+ return $message.'.';
+ }
+}
--- /dev/null
+Yaml Component
+==============
+
+The Yaml component loads and dumps YAML files.
+
+Resources
+---------
+
+ * [Documentation](https://symfony.com/doc/current/components/yaml/index.html)
+ * [Contributing](https://symfony.com/doc/current/contributing/index.html)
+ * [Report issues](https://github.com/symfony/symfony/issues) and
+ [send Pull Requests](https://github.com/symfony/symfony/pulls)
+ in the [main Symfony repository](https://github.com/symfony/symfony)
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Tag;
+
+/**
+ * @author Nicolas Grekas <p@tchwork.com>
+ * @author Guilhem N. <egetick@gmail.com>
+ */
+final class TaggedValue
+{
+ private $tag;
+ private $value;
+
+ /**
+ * @param string $tag
+ * @param mixed $value
+ */
+ public function __construct($tag, $value)
+ {
+ $this->tag = $tag;
+ $this->value = $value;
+ }
+
+ /**
+ * @return string
+ */
+ public function getTag()
+ {
+ return $this->tag;
+ }
+
+ /**
+ * @return mixed
+ */
+ public function getValue()
+ {
+ return $this->value;
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Tests\Command;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Yaml\Command\LintCommand;
+use Symfony\Component\Console\Application;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Tester\CommandTester;
+
+/**
+ * Tests the YamlLintCommand.
+ *
+ * @author Robin Chalas <robin.chalas@gmail.com>
+ */
+class LintCommandTest extends TestCase
+{
+ private $files;
+
+ public function testLintCorrectFile()
+ {
+ $tester = $this->createCommandTester();
+ $filename = $this->createFile('foo: bar');
+
+ $ret = $tester->execute(array('filename' => $filename), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
+
+ $this->assertEquals(0, $ret, 'Returns 0 in case of success');
+ $this->assertRegExp('/^\/\/ OK in /', trim($tester->getDisplay()));
+ }
+
+ public function testLintIncorrectFile()
+ {
+ $incorrectContent = '
+foo:
+bar';
+ $tester = $this->createCommandTester();
+ $filename = $this->createFile($incorrectContent);
+
+ $ret = $tester->execute(array('filename' => $filename), array('decorated' => false));
+
+ $this->assertEquals(1, $ret, 'Returns 1 in case of error');
+ $this->assertContains('Unable to parse at line 3 (near "bar").', trim($tester->getDisplay()));
+ }
+
+ public function testConstantAsKey()
+ {
+ $yaml = <<<YAML
+!php/const 'Symfony\Component\Yaml\Tests\Command\Foo::TEST': bar
+YAML;
+ $ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
+ $this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
+ }
+
+ public function testCustomTags()
+ {
+ $yaml = <<<YAML
+foo: !my_tag {foo: bar}
+YAML;
+ $ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml), '--parse-tags' => true), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
+ $this->assertSame(0, $ret, 'lint:yaml exits with code 0 in case of success');
+ }
+
+ public function testCustomTagsError()
+ {
+ $yaml = <<<YAML
+foo: !my_tag {foo: bar}
+YAML;
+ $ret = $this->createCommandTester()->execute(array('filename' => $this->createFile($yaml)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false));
+ $this->assertSame(1, $ret, 'lint:yaml exits with code 1 in case of error');
+ }
+
+ /**
+ * @expectedException \RuntimeException
+ */
+ public function testLintFileNotReadable()
+ {
+ $tester = $this->createCommandTester();
+ $filename = $this->createFile('');
+ unlink($filename);
+
+ $ret = $tester->execute(array('filename' => $filename), array('decorated' => false));
+ }
+
+ /**
+ * @return string Path to the new file
+ */
+ private function createFile($content)
+ {
+ $filename = tempnam(sys_get_temp_dir().'/framework-yml-lint-test', 'sf-');
+ file_put_contents($filename, $content);
+
+ $this->files[] = $filename;
+
+ return $filename;
+ }
+
+ /**
+ * @return CommandTester
+ */
+ protected function createCommandTester()
+ {
+ $application = new Application();
+ $application->add(new LintCommand());
+ $command = $application->find('lint:yaml');
+
+ return new CommandTester($command);
+ }
+
+ protected function setUp()
+ {
+ $this->files = array();
+ @mkdir(sys_get_temp_dir().'/framework-yml-lint-test');
+ }
+
+ protected function tearDown()
+ {
+ foreach ($this->files as $file) {
+ if (file_exists($file)) {
+ unlink($file);
+ }
+ }
+
+ rmdir(sys_get_temp_dir().'/framework-yml-lint-test');
+ }
+}
+
+class Foo
+{
+ const TEST = 'foo';
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Tests;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Yaml\Parser;
+use Symfony\Component\Yaml\Dumper;
+use Symfony\Component\Yaml\Yaml;
+
+class DumperTest extends TestCase
+{
+ protected $parser;
+ protected $dumper;
+ protected $path;
+
+ protected $array = array(
+ '' => 'bar',
+ 'foo' => '#bar',
+ 'foo\'bar' => array(),
+ 'bar' => array(1, 'foo'),
+ 'foobar' => array(
+ 'foo' => 'bar',
+ 'bar' => array(1, 'foo'),
+ 'foobar' => array(
+ 'foo' => 'bar',
+ 'bar' => array(1, 'foo'),
+ ),
+ ),
+ );
+
+ protected function setUp()
+ {
+ $this->parser = new Parser();
+ $this->dumper = new Dumper();
+ $this->path = __DIR__.'/Fixtures';
+ }
+
+ protected function tearDown()
+ {
+ $this->parser = null;
+ $this->dumper = null;
+ $this->path = null;
+ $this->array = null;
+ }
+
+ public function testIndentationInConstructor()
+ {
+ $dumper = new Dumper(7);
+ $expected = <<<'EOF'
+'': bar
+foo: '#bar'
+'foo''bar': { }
+bar:
+ - 1
+ - foo
+foobar:
+ foo: bar
+ bar:
+ - 1
+ - foo
+ foobar:
+ foo: bar
+ bar:
+ - 1
+ - foo
+
+EOF;
+ $this->assertEquals($expected, $dumper->dump($this->array, 4, 0));
+ }
+
+ /**
+ * @group legacy
+ */
+ public function testSetIndentation()
+ {
+ $this->dumper->setIndentation(7);
+
+ $expected = <<<'EOF'
+'': bar
+foo: '#bar'
+'foo''bar': { }
+bar:
+ - 1
+ - foo
+foobar:
+ foo: bar
+ bar:
+ - 1
+ - foo
+ foobar:
+ foo: bar
+ bar:
+ - 1
+ - foo
+
+EOF;
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 4, 0));
+ }
+
+ public function testSpecifications()
+ {
+ $files = $this->parser->parse(file_get_contents($this->path.'/index.yml'));
+ foreach ($files as $file) {
+ $yamls = file_get_contents($this->path.'/'.$file.'.yml');
+
+ // split YAMLs documents
+ foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
+ if (!$yaml) {
+ continue;
+ }
+
+ $test = $this->parser->parse($yaml);
+ if (isset($test['dump_skip']) && $test['dump_skip']) {
+ continue;
+ } elseif (isset($test['todo']) && $test['todo']) {
+ // TODO
+ } else {
+ eval('$expected = '.trim($test['php']).';');
+ $this->assertSame($expected, $this->parser->parse($this->dumper->dump($expected, 10)), $test['test']);
+ }
+ }
+ }
+ }
+
+ public function testInlineLevel()
+ {
+ $expected = <<<'EOF'
+{ '': bar, foo: '#bar', 'foo''bar': { }, bar: [1, foo], foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } } }
+EOF;
+ $this->assertEquals($expected, $this->dumper->dump($this->array, -10), '->dump() takes an inline level argument');
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 0), '->dump() takes an inline level argument');
+
+ $expected = <<<'EOF'
+'': bar
+foo: '#bar'
+'foo''bar': { }
+bar: [1, foo]
+foobar: { foo: bar, bar: [1, foo], foobar: { foo: bar, bar: [1, foo] } }
+
+EOF;
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 1), '->dump() takes an inline level argument');
+
+ $expected = <<<'EOF'
+'': bar
+foo: '#bar'
+'foo''bar': { }
+bar:
+ - 1
+ - foo
+foobar:
+ foo: bar
+ bar: [1, foo]
+ foobar: { foo: bar, bar: [1, foo] }
+
+EOF;
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 2), '->dump() takes an inline level argument');
+
+ $expected = <<<'EOF'
+'': bar
+foo: '#bar'
+'foo''bar': { }
+bar:
+ - 1
+ - foo
+foobar:
+ foo: bar
+ bar:
+ - 1
+ - foo
+ foobar:
+ foo: bar
+ bar: [1, foo]
+
+EOF;
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 3), '->dump() takes an inline level argument');
+
+ $expected = <<<'EOF'
+'': bar
+foo: '#bar'
+'foo''bar': { }
+bar:
+ - 1
+ - foo
+foobar:
+ foo: bar
+ bar:
+ - 1
+ - foo
+ foobar:
+ foo: bar
+ bar:
+ - 1
+ - foo
+
+EOF;
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 4), '->dump() takes an inline level argument');
+ $this->assertEquals($expected, $this->dumper->dump($this->array, 10), '->dump() takes an inline level argument');
+ }
+
+ public function testObjectSupportEnabled()
+ {
+ $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_OBJECT);
+
+ $this->assertEquals('{ foo: !php/object \'O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}\', bar: 1 }', $dump, '->dump() is able to dump objects');
+ }
+
+ /**
+ * @group legacy
+ */
+ public function testObjectSupportEnabledPassingTrue()
+ {
+ $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, false, true);
+
+ $this->assertEquals('{ foo: !php/object \'O:30:"Symfony\Component\Yaml\Tests\A":1:{s:1:"a";s:3:"foo";}\', bar: 1 }', $dump, '->dump() is able to dump objects');
+ }
+
+ public function testObjectSupportDisabledButNoExceptions()
+ {
+ $dump = $this->dumper->dump(array('foo' => new A(), 'bar' => 1));
+
+ $this->assertEquals('{ foo: null, bar: 1 }', $dump, '->dump() does not dump objects when disabled');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\DumpException
+ */
+ public function testObjectSupportDisabledWithExceptions()
+ {
+ $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE);
+ }
+
+ /**
+ * @group legacy
+ * @expectedException \Symfony\Component\Yaml\Exception\DumpException
+ */
+ public function testObjectSupportDisabledWithExceptionsPassingTrue()
+ {
+ $this->dumper->dump(array('foo' => new A(), 'bar' => 1), 0, 0, true);
+ }
+
+ public function testEmptyArray()
+ {
+ $dump = $this->dumper->dump(array());
+ $this->assertEquals('{ }', $dump);
+
+ $dump = $this->dumper->dump(array(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
+ $this->assertEquals('[]', $dump);
+
+ $dump = $this->dumper->dump(array(), 9, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE);
+ $this->assertEquals('[]', $dump);
+
+ $dump = $this->dumper->dump(new \ArrayObject(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP);
+ $this->assertEquals('{ }', $dump);
+
+ $dump = $this->dumper->dump(new \stdClass(), 0, 0, Yaml::DUMP_EMPTY_ARRAY_AS_SEQUENCE | Yaml::DUMP_OBJECT_AS_MAP);
+ $this->assertEquals('{ }', $dump);
+ }
+
+ /**
+ * @dataProvider getEscapeSequences
+ */
+ public function testEscapedEscapeSequencesInQuotedScalar($input, $expected)
+ {
+ $this->assertEquals($expected, $this->dumper->dump($input));
+ }
+
+ public function getEscapeSequences()
+ {
+ return array(
+ 'empty string' => array('', "''"),
+ 'null' => array("\x0", '"\\0"'),
+ 'bell' => array("\x7", '"\\a"'),
+ 'backspace' => array("\x8", '"\\b"'),
+ 'horizontal-tab' => array("\t", '"\\t"'),
+ 'line-feed' => array("\n", '"\\n"'),
+ 'vertical-tab' => array("\v", '"\\v"'),
+ 'form-feed' => array("\xC", '"\\f"'),
+ 'carriage-return' => array("\r", '"\\r"'),
+ 'escape' => array("\x1B", '"\\e"'),
+ 'space' => array(' ', "' '"),
+ 'double-quote' => array('"', "'\"'"),
+ 'slash' => array('/', '/'),
+ 'backslash' => array('\\', '\\'),
+ 'next-line' => array("\xC2\x85", '"\\N"'),
+ 'non-breaking-space' => array("\xc2\xa0", '"\\_"'),
+ 'line-separator' => array("\xE2\x80\xA8", '"\\L"'),
+ 'paragraph-separator' => array("\xE2\x80\xA9", '"\\P"'),
+ 'colon' => array(':', "':'"),
+ );
+ }
+
+ public function testBinaryDataIsDumpedBase64Encoded()
+ {
+ $binaryData = file_get_contents(__DIR__.'/Fixtures/arrow.gif');
+ $expected = '{ data: !!binary '.base64_encode($binaryData).' }';
+
+ $this->assertSame($expected, $this->dumper->dump(array('data' => $binaryData)));
+ }
+
+ public function testNonUtf8DataIsDumpedBase64Encoded()
+ {
+ // "für" (ISO-8859-1 encoded)
+ $this->assertSame('!!binary ZsM/cg==', $this->dumper->dump("f\xc3\x3fr"));
+ }
+
+ /**
+ * @dataProvider objectAsMapProvider
+ */
+ public function testDumpObjectAsMap($object, $expected)
+ {
+ $yaml = $this->dumper->dump($object, 0, 0, Yaml::DUMP_OBJECT_AS_MAP);
+
+ $this->assertEquals($expected, Yaml::parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
+ }
+
+ public function objectAsMapProvider()
+ {
+ $tests = array();
+
+ $bar = new \stdClass();
+ $bar->class = 'classBar';
+ $bar->args = array('bar');
+ $zar = new \stdClass();
+ $foo = new \stdClass();
+ $foo->bar = $bar;
+ $foo->zar = $zar;
+ $object = new \stdClass();
+ $object->foo = $foo;
+ $tests['stdClass'] = array($object, $object);
+
+ $arrayObject = new \ArrayObject();
+ $arrayObject['foo'] = 'bar';
+ $arrayObject['baz'] = 'foobar';
+ $parsedArrayObject = new \stdClass();
+ $parsedArrayObject->foo = 'bar';
+ $parsedArrayObject->baz = 'foobar';
+ $tests['ArrayObject'] = array($arrayObject, $parsedArrayObject);
+
+ $a = new A();
+ $tests['arbitrary-object'] = array($a, null);
+
+ return $tests;
+ }
+
+ public function testDumpingArrayObjectInstancesRespectsInlineLevel()
+ {
+ $deep = new \ArrayObject(array('deep1' => 'd', 'deep2' => 'e'));
+ $inner = new \ArrayObject(array('inner1' => 'b', 'inner2' => 'c', 'inner3' => $deep));
+ $outer = new \ArrayObject(array('outer1' => 'a', 'outer2' => $inner));
+
+ $yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP);
+
+ $expected = <<<YAML
+outer1: a
+outer2:
+ inner1: b
+ inner2: c
+ inner3: { deep1: d, deep2: e }
+
+YAML;
+ $this->assertSame($expected, $yaml);
+ }
+
+ public function testDumpingArrayObjectInstancesWithNumericKeysInlined()
+ {
+ $deep = new \ArrayObject(array('d', 'e'));
+ $inner = new \ArrayObject(array('b', 'c', $deep));
+ $outer = new \ArrayObject(array('a', $inner));
+
+ $yaml = $this->dumper->dump($outer, 0, 0, Yaml::DUMP_OBJECT_AS_MAP);
+ $expected = <<<YAML
+{ 0: a, 1: { 0: b, 1: c, 2: { 0: d, 1: e } } }
+YAML;
+ $this->assertSame($expected, $yaml);
+ }
+
+ public function testDumpingArrayObjectInstancesWithNumericKeysRespectsInlineLevel()
+ {
+ $deep = new \ArrayObject(array('d', 'e'));
+ $inner = new \ArrayObject(array('b', 'c', $deep));
+ $outer = new \ArrayObject(array('a', $inner));
+ $yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP);
+ $expected = <<<YAML
+0: a
+1:
+ 0: b
+ 1: c
+ 2: { 0: d, 1: e }
+
+YAML;
+ $this->assertEquals($expected, $yaml);
+ }
+
+ public function testDumpEmptyArrayObjectInstanceAsMap()
+ {
+ $this->assertSame('{ }', $this->dumper->dump(new \ArrayObject(), 2, 0, Yaml::DUMP_OBJECT_AS_MAP));
+ }
+
+ public function testDumpEmptyStdClassInstanceAsMap()
+ {
+ $this->assertSame('{ }', $this->dumper->dump(new \stdClass(), 2, 0, Yaml::DUMP_OBJECT_AS_MAP));
+ }
+
+ public function testDumpingStdClassInstancesRespectsInlineLevel()
+ {
+ $deep = new \stdClass();
+ $deep->deep1 = 'd';
+ $deep->deep2 = 'e';
+
+ $inner = new \stdClass();
+ $inner->inner1 = 'b';
+ $inner->inner2 = 'c';
+ $inner->inner3 = $deep;
+
+ $outer = new \stdClass();
+ $outer->outer1 = 'a';
+ $outer->outer2 = $inner;
+
+ $yaml = $this->dumper->dump($outer, 2, 0, Yaml::DUMP_OBJECT_AS_MAP);
+
+ $expected = <<<YAML
+outer1: a
+outer2:
+ inner1: b
+ inner2: c
+ inner3: { deep1: d, deep2: e }
+
+YAML;
+ $this->assertSame($expected, $yaml);
+ }
+
+ public function testDumpMultiLineStringAsScalarBlock()
+ {
+ $data = array(
+ 'data' => array(
+ 'single_line' => 'foo bar baz',
+ 'multi_line' => "foo\nline with trailing spaces:\n \nbar\ninteger like line:\n123456789\nempty line:\n\nbaz",
+ 'multi_line_with_carriage_return' => "foo\nbar\r\nbaz",
+ 'nested_inlined_multi_line_string' => array(
+ 'inlined_multi_line' => "foo\nbar\r\nempty line:\n\nbaz",
+ ),
+ ),
+ );
+
+ $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
+ }
+
+ public function testDumpMultiLineStringAsScalarBlockWhenFirstLineHasLeadingSpace()
+ {
+ $data = array(
+ 'data' => array(
+ 'multi_line' => " the first line has leading spaces\nThe second line does not.",
+ ),
+ );
+
+ $this->assertSame(file_get_contents(__DIR__.'/Fixtures/multiple_lines_as_literal_block_leading_space_in_first_line.yml'), $this->dumper->dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
+ }
+
+ public function testCarriageReturnIsMaintainedWhenDumpingAsMultiLineLiteralBlock()
+ {
+ $this->assertSame("- \"a\\r\\nb\\nc\"\n", $this->dumper->dump(array("a\r\nb\nc"), 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK));
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage The indentation must be greater than zero
+ */
+ public function testZeroIndentationThrowsException()
+ {
+ new Dumper(0);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage The indentation must be greater than zero
+ */
+ public function testNegativeIndentationThrowsException()
+ {
+ new Dumper(-4);
+ }
+}
+
+class A
+{
+ public $a = 'foo';
+}
--- /dev/null
+--- %YAML:1.0
+test: Simple Alias Example
+brief: >
+ If you need to refer to the same item of data twice,
+ you can give that item an alias. The alias is a plain
+ string, starting with an ampersand. The item may then
+ be referred to by the alias throughout your document
+ by using an asterisk before the name of the alias.
+ This is called an anchor.
+yaml: |
+ - &showell Steve
+ - Clark
+ - Brian
+ - Oren
+ - *showell
+php: |
+ array('Steve', 'Clark', 'Brian', 'Oren', 'Steve')
+
+---
+test: Alias of a Mapping
+brief: >
+ An alias can be used on any item of data, including
+ sequences, mappings, and other complex data types.
+yaml: |
+ - &hello
+ Meat: pork
+ Starch: potato
+ - banana
+ - *hello
+php: |
+ array(array('Meat'=>'pork', 'Starch'=>'potato'), 'banana', array('Meat'=>'pork', 'Starch'=>'potato'))
--- /dev/null
+--- %YAML:1.0
+test: Simple Sequence
+brief: |
+ You can specify a list in YAML by placing each
+ member of the list on a new line with an opening
+ dash. These lists are called sequences.
+yaml: |
+ - apple
+ - banana
+ - carrot
+php: |
+ array('apple', 'banana', 'carrot')
+---
+test: Sequence With Item Being Null In The Middle
+brief: |
+ You can specify a list in YAML by placing each
+ member of the list on a new line with an opening
+ dash. These lists are called sequences.
+yaml: |
+ - apple
+ -
+ - carrot
+php: |
+ array('apple', null, 'carrot')
+---
+test: Sequence With Last Item Being Null
+brief: |
+ You can specify a list in YAML by placing each
+ member of the list on a new line with an opening
+ dash. These lists are called sequences.
+yaml: |
+ - apple
+ - banana
+ -
+php: |
+ array('apple', 'banana', null)
+---
+test: Nested Sequences
+brief: |
+ You can include a sequence within another
+ sequence by giving the sequence an empty
+ dash, followed by an indented list.
+yaml: |
+ -
+ - foo
+ - bar
+ - baz
+php: |
+ array(array('foo', 'bar', 'baz'))
+---
+test: Mixed Sequences
+brief: |
+ Sequences can contain any YAML data,
+ including strings and other sequences.
+yaml: |
+ - apple
+ -
+ - foo
+ - bar
+ - x123
+ - banana
+ - carrot
+php: |
+ array('apple', array('foo', 'bar', 'x123'), 'banana', 'carrot')
+---
+test: Deeply Nested Sequences
+brief: |
+ Sequences can be nested even deeper, with each
+ level of indentation representing a level of
+ depth.
+yaml: |
+ -
+ -
+ - uno
+ - dos
+php: |
+ array(array(array('uno', 'dos')))
+---
+test: Simple Mapping
+brief: |
+ You can add a keyed list (also known as a dictionary or
+ hash) to your document by placing each member of the
+ list on a new line, with a colon separating the key
+ from its value. In YAML, this type of list is called
+ a mapping.
+yaml: |
+ foo: whatever
+ bar: stuff
+php: |
+ array('foo' => 'whatever', 'bar' => 'stuff')
+---
+test: Sequence in a Mapping
+brief: |
+ A value in a mapping can be a sequence.
+yaml: |
+ foo: whatever
+ bar:
+ - uno
+ - dos
+php: |
+ array('foo' => 'whatever', 'bar' => array('uno', 'dos'))
+---
+test: Nested Mappings
+brief: |
+ A value in a mapping can be another mapping.
+yaml: |
+ foo: whatever
+ bar:
+ fruit: apple
+ name: steve
+ sport: baseball
+php: |
+ array(
+ 'foo' => 'whatever',
+ 'bar' => array(
+ 'fruit' => 'apple',
+ 'name' => 'steve',
+ 'sport' => 'baseball'
+ )
+ )
+---
+test: Mixed Mapping
+brief: |
+ A mapping can contain any assortment
+ of mappings and sequences as values.
+yaml: |
+ foo: whatever
+ bar:
+ -
+ fruit: apple
+ name: steve
+ sport: baseball
+ - more
+ -
+ python: rocks
+ perl: papers
+ ruby: scissorses
+php: |
+ array(
+ 'foo' => 'whatever',
+ 'bar' => array(
+ array(
+ 'fruit' => 'apple',
+ 'name' => 'steve',
+ 'sport' => 'baseball'
+ ),
+ 'more',
+ array(
+ 'python' => 'rocks',
+ 'perl' => 'papers',
+ 'ruby' => 'scissorses'
+ )
+ )
+ )
+---
+test: Mapping-in-Sequence Shortcut
+todo: true
+brief: |
+ If you are adding a mapping to a sequence, you
+ can place the mapping on the same line as the
+ dash as a shortcut.
+yaml: |
+ - work on YAML.py:
+ - work on Store
+php: |
+ array(array('work on YAML.py' => array('work on Store')))
+---
+test: Sequence-in-Mapping Shortcut
+todo: true
+brief: |
+ The dash in a sequence counts as indentation, so
+ you can add a sequence inside of a mapping without
+ needing spaces as indentation.
+yaml: |
+ allow:
+ - 'localhost'
+ - '%.sourceforge.net'
+ - '%.freepan.org'
+php: |
+ array('allow' => array('localhost', '%.sourceforge.net', '%.freepan.org'))
+---
+todo: true
+test: Merge key
+brief: |
+ A merge key ('<<') can be used in a mapping to insert other mappings. If
+ the value associated with the merge key is a mapping, each of its key/value
+ pairs is inserted into the current mapping.
+yaml: |
+ mapping:
+ name: Joe
+ job: Accountant
+ <<:
+ age: 38
+php: |
+ array(
+ 'mapping' =>
+ array(
+ 'name' => 'Joe',
+ 'job' => 'Accountant',
+ 'age' => 38
+ )
+ )
--- /dev/null
+---
+test: One Element Mapping
+brief: |
+ A mapping with one key/value pair
+yaml: |
+ foo: bar
+php: |
+ array('foo' => 'bar')
+---
+test: Multi Element Mapping
+brief: |
+ More than one key/value pair
+yaml: |
+ red: baron
+ white: walls
+ blue: berries
+php: |
+ array(
+ 'red' => 'baron',
+ 'white' => 'walls',
+ 'blue' => 'berries',
+ )
+---
+test: Values aligned
+brief: |
+ Often times human editors of documents will align the values even
+ though YAML emitters generally don't.
+yaml: |
+ red: baron
+ white: walls
+ blue: berries
+php: |
+ array(
+ 'red' => 'baron',
+ 'white' => 'walls',
+ 'blue' => 'berries',
+ )
+---
+test: Colons aligned
+brief: |
+ Spaces can come before the ': ' key/value separator.
+yaml: |
+ red : baron
+ white : walls
+ blue : berries
+php: |
+ array(
+ 'red' => 'baron',
+ 'white' => 'walls',
+ 'blue' => 'berries',
+ )
--- /dev/null
+--- %YAML:1.0
+test: Trailing Document Separator
+todo: true
+brief: >
+ You can separate YAML documents
+ with a string of three dashes.
+yaml: |
+ - foo: 1
+ bar: 2
+ ---
+ more: stuff
+python: |
+ [
+ [ { 'foo': 1, 'bar': 2 } ],
+ { 'more': 'stuff' }
+ ]
+ruby: |
+ [ { 'foo' => 1, 'bar' => 2 } ]
+
+---
+test: Leading Document Separator
+todo: true
+brief: >
+ You can explicitly give an opening
+ document separator to your YAML stream.
+yaml: |
+ ---
+ - foo: 1
+ bar: 2
+ ---
+ more: stuff
+python: |
+ [
+ [ {'foo': 1, 'bar': 2}],
+ {'more': 'stuff'}
+ ]
+ruby: |
+ [ { 'foo' => 1, 'bar' => 2 } ]
+
+---
+test: YAML Header
+todo: true
+brief: >
+ The opening separator can contain directives
+ to the YAML parser, such as the version
+ number.
+yaml: |
+ --- %YAML:1.0
+ foo: 1
+ bar: 2
+php: |
+ array('foo' => 1, 'bar' => 2)
+documents: 1
+
+---
+test: Red Herring Document Separator
+brief: >
+ Separators included in blocks or strings
+ are treated as blocks or strings, as the
+ document separator should have no indentation
+ preceding it.
+yaml: |
+ foo: |
+ ---
+php: |
+ array('foo' => "---\n")
+
+---
+test: Multiple Document Separators in Block
+brief: >
+ This technique allows you to embed other YAML
+ documents within literal blocks.
+yaml: |
+ foo: |
+ ---
+ foo: bar
+ ---
+ yo: baz
+ bar: |
+ fooness
+php: |
+ array(
+ 'foo' => "---\nfoo: bar\n---\nyo: baz\n",
+ 'bar' => "fooness\n"
+ )
--- /dev/null
+---
+test: Missing value for hash item
+todo: true
+brief: |
+ Third item in this hash doesn't have a value
+yaml: |
+ okay: value
+ also okay: ~
+ causes error because no value specified
+ last key: value okay here too
+python-error: causes error because no value specified
+
+---
+test: Not indenting enough
+brief: |
+ There was a bug in PyYaml where it was off by one
+ in the indentation check. It was allowing the YAML
+ below.
+# This is actually valid YAML now. Someone should tell showell.
+yaml: |
+ foo:
+ firstline: 1
+ secondline: 2
+php: |
+ array('foo' => null, 'firstline' => 1, 'secondline' => 2)
--- /dev/null
+---
+test: Simple Inline Array
+brief: >
+ Sequences can be contained on a
+ single line, using the inline syntax.
+ Separate each entry with commas and
+ enclose in square brackets.
+yaml: |
+ seq: [ a, b, c ]
+php: |
+ array('seq' => array('a', 'b', 'c'))
+---
+test: Simple Inline Hash
+brief: >
+ Mapping can also be contained on
+ a single line, using the inline
+ syntax. Each key-value pair is
+ separated by a colon, with a comma
+ between each entry in the mapping.
+ Enclose with curly braces.
+yaml: |
+ hash: { name: Steve, foo: bar }
+php: |
+ array('hash' => array('name' => 'Steve', 'foo' => 'bar'))
+---
+test: Multi-line Inline Collections
+todo: true
+brief: >
+ Both inline sequences and inline mappings
+ can span multiple lines, provided that you
+ indent the additional lines.
+yaml: |
+ languages: [ Ruby,
+ Perl,
+ Python ]
+ websites: { YAML: yaml.org,
+ Ruby: ruby-lang.org,
+ Python: python.org,
+ Perl: use.perl.org }
+php: |
+ array(
+ 'languages' => array('Ruby', 'Perl', 'Python'),
+ 'websites' => array(
+ 'YAML' => 'yaml.org',
+ 'Ruby' => 'ruby-lang.org',
+ 'Python' => 'python.org',
+ 'Perl' => 'use.perl.org'
+ )
+ )
+---
+test: Commas in Values (not in the spec!)
+todo: true
+brief: >
+ List items in collections are delimited by commas, but
+ there must be a space after each comma. This allows you
+ to add numbers without quoting.
+yaml: |
+ attendances: [ 45,123, 70,000, 17,222 ]
+php: |
+ array('attendances' => array(45123, 70000, 17222))
--- /dev/null
+--- %YAML:1.0
+test: Single ending newline
+brief: >
+ A pipe character, followed by an indented
+ block of text is treated as a literal
+ block, in which newlines are preserved
+ throughout the block, including the final
+ newline.
+yaml: |
+ ---
+ this: |
+ Foo
+ Bar
+php: |
+ array('this' => "Foo\nBar\n")
+---
+test: The '+' indicator
+brief: >
+ The '+' indicator says to keep newlines at the end of text
+ blocks.
+yaml: |
+ normal: |
+ extra new lines not kept
+
+ preserving: |+
+ extra new lines are kept
+
+
+ dummy: value
+php: |
+ array(
+ 'normal' => "extra new lines not kept\n",
+ 'preserving' => "extra new lines are kept\n\n\n",
+ 'dummy' => 'value'
+ )
+---
+test: Three trailing newlines in literals
+brief: >
+ To give you more control over how space
+ is preserved in text blocks, YAML has
+ the keep '+' and chomp '-' indicators.
+ The keep indicator will preserve all
+ ending newlines, while the chomp indicator
+ will strip all ending newlines.
+yaml: |
+ clipped: |
+ This has one newline.
+
+
+
+ same as "clipped" above: "This has one newline.\n"
+
+ stripped: |-
+ This has no newline.
+
+
+
+ same as "stripped" above: "This has no newline."
+
+ kept: |+
+ This has four newlines.
+
+
+
+ same as "kept" above: "This has four newlines.\n\n\n\n"
+php: |
+ array(
+ 'clipped' => "This has one newline.\n",
+ 'same as "clipped" above' => "This has one newline.\n",
+ 'stripped' => 'This has no newline.',
+ 'same as "stripped" above' => 'This has no newline.',
+ 'kept' => "This has four newlines.\n\n\n\n",
+ 'same as "kept" above' => "This has four newlines.\n\n\n\n"
+ )
+---
+test: Extra trailing newlines with spaces
+todo: true
+brief: >
+ Normally, only a single newline is kept
+ from the end of a literal block, unless the
+ keep '+' character is used in combination
+ with the pipe. The following example
+ will preserve all ending whitespace
+ since the last line of both literal blocks
+ contains spaces which extend past the indentation
+ level.
+yaml: |
+ ---
+ this: |
+ Foo
+
+
+ kept: |+
+ Foo
+
+
+php: |
+ array('this' => "Foo\n\n \n",
+ 'kept' => "Foo\n\n \n" )
+
+---
+test: Folded Block in a Sequence
+brief: >
+ A greater-then character, followed by an indented
+ block of text is treated as a folded block, in
+ which lines of text separated by a single newline
+ are concatenated as a single line.
+yaml: |
+ ---
+ - apple
+ - banana
+ - >
+ can't you see
+ the beauty of yaml?
+ hmm
+ - dog
+php: |
+ array(
+ 'apple',
+ 'banana',
+ "can't you see the beauty of yaml? hmm\n",
+ 'dog'
+ )
+---
+test: Folded Block as a Mapping Value
+brief: >
+ Both literal and folded blocks can be
+ used in collections, as values in a
+ sequence or a mapping.
+yaml: |
+ ---
+ quote: >
+ Mark McGwire's
+ year was crippled
+ by a knee injury.
+ source: espn
+php: |
+ array(
+ 'quote' => "Mark McGwire's year was crippled by a knee injury.\n",
+ 'source' => 'espn'
+ )
+---
+test: Three trailing newlines in folded blocks
+brief: >
+ The keep and chomp indicators can also
+ be applied to folded blocks.
+yaml: |
+ clipped: >
+ This has one newline.
+
+
+
+ same as "clipped" above: "This has one newline.\n"
+
+ stripped: >-
+ This has no newline.
+
+
+
+ same as "stripped" above: "This has no newline."
+
+ kept: >+
+ This has four newlines.
+
+
+
+ same as "kept" above: "This has four newlines.\n\n\n\n"
+php: |
+ array(
+ 'clipped' => "This has one newline.\n",
+ 'same as "clipped" above' => "This has one newline.\n",
+ 'stripped' => 'This has no newline.',
+ 'same as "stripped" above' => 'This has no newline.',
+ 'kept' => "This has four newlines.\n\n\n\n",
+ 'same as "kept" above' => "This has four newlines.\n\n\n\n"
+ )
--- /dev/null
+--- %YAML:1.0
+test: Empty Sequence
+brief: >
+ You can represent the empty sequence
+ with an empty inline sequence.
+yaml: |
+ empty: []
+php: |
+ array('empty' => array())
+---
+test: Empty Mapping
+brief: >
+ You can represent the empty mapping
+ with an empty inline mapping.
+yaml: |
+ empty: {}
+php: |
+ array('empty' => array())
+---
+test: Empty Sequence as Entire Document
+yaml: |
+ []
+php: |
+ array()
+---
+test: Empty Mapping as Entire Document
+yaml: |
+ {}
+php: |
+ array()
+---
+test: Null as Document
+yaml: |
+ ~
+php: |
+ null
+---
+test: Empty String
+brief: >
+ You can represent an empty string
+ with a pair of quotes.
+yaml: |
+ ''
+php: |
+ ''
--- /dev/null
+--- %YAML:1.0
+test: Sequence of scalars
+spec: 2.1
+yaml: |
+ - Mark McGwire
+ - Sammy Sosa
+ - Ken Griffey
+php: |
+ array('Mark McGwire', 'Sammy Sosa', 'Ken Griffey')
+---
+test: Mapping of scalars to scalars
+spec: 2.2
+yaml: |
+ hr: 65
+ avg: 0.278
+ rbi: 147
+php: |
+ array('hr' => 65, 'avg' => 0.278, 'rbi' => 147)
+---
+test: Mapping of scalars to sequences
+spec: 2.3
+yaml: |
+ american:
+ - Boston Red Sox
+ - Detroit Tigers
+ - New York Yankees
+ national:
+ - New York Mets
+ - Chicago Cubs
+ - Atlanta Braves
+php: |
+ array('american' =>
+ array( 'Boston Red Sox', 'Detroit Tigers',
+ 'New York Yankees' ),
+ 'national' =>
+ array( 'New York Mets', 'Chicago Cubs',
+ 'Atlanta Braves' )
+ )
+---
+test: Sequence of mappings
+spec: 2.4
+yaml: |
+ -
+ name: Mark McGwire
+ hr: 65
+ avg: 0.278
+ -
+ name: Sammy Sosa
+ hr: 63
+ avg: 0.288
+php: |
+ array(
+ array('name' => 'Mark McGwire', 'hr' => 65, 'avg' => 0.278),
+ array('name' => 'Sammy Sosa', 'hr' => 63, 'avg' => 0.288)
+ )
+---
+test: Legacy A5
+todo: true
+spec: legacy_A5
+yaml: |
+ ?
+ - New York Yankees
+ - Atlanta Braves
+ :
+ - 2001-07-02
+ - 2001-08-12
+ - 2001-08-14
+ ?
+ - Detroit Tigers
+ - Chicago Cubs
+ :
+ - 2001-07-23
+perl-busted: >
+ YAML.pm will be able to emulate this behavior soon. In this regard
+ it may be somewhat more correct than Python's native behaviour which
+ can only use tuples as mapping keys. PyYAML will also need to figure
+ out some clever way to roundtrip structured keys.
+python: |
+ [
+ {
+ ('New York Yankees', 'Atlanta Braves'):
+ [yaml.timestamp('2001-07-02'),
+ yaml.timestamp('2001-08-12'),
+ yaml.timestamp('2001-08-14')],
+ ('Detroit Tigers', 'Chicago Cubs'):
+ [yaml.timestamp('2001-07-23')]
+ }
+ ]
+ruby: |
+ {
+ [ 'New York Yankees', 'Atlanta Braves' ] =>
+ [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ],
+ [ 'Detroit Tigers', 'Chicago Cubs' ] =>
+ [ Date.new( 2001, 7, 23 ) ]
+ }
+syck: |
+ struct test_node seq1[] = {
+ { T_STR, 0, "New York Yankees" },
+ { T_STR, 0, "Atlanta Braves" },
+ end_node
+ };
+ struct test_node seq2[] = {
+ { T_STR, 0, "2001-07-02" },
+ { T_STR, 0, "2001-08-12" },
+ { T_STR, 0, "2001-08-14" },
+ end_node
+ };
+ struct test_node seq3[] = {
+ { T_STR, 0, "Detroit Tigers" },
+ { T_STR, 0, "Chicago Cubs" },
+ end_node
+ };
+ struct test_node seq4[] = {
+ { T_STR, 0, "2001-07-23" },
+ end_node
+ };
+ struct test_node map[] = {
+ { T_SEQ, 0, 0, seq1 },
+ { T_SEQ, 0, 0, seq2 },
+ { T_SEQ, 0, 0, seq3 },
+ { T_SEQ, 0, 0, seq4 },
+ end_node
+ };
+ struct test_node stream[] = {
+ { T_MAP, 0, 0, map },
+ end_node
+ };
+
+---
+test: Sequence of sequences
+spec: 2.5
+yaml: |
+ - [ name , hr , avg ]
+ - [ Mark McGwire , 65 , 0.278 ]
+ - [ Sammy Sosa , 63 , 0.288 ]
+php: |
+ array(
+ array( 'name', 'hr', 'avg' ),
+ array( 'Mark McGwire', 65, 0.278 ),
+ array( 'Sammy Sosa', 63, 0.288 )
+ )
+---
+test: Mapping of mappings
+todo: true
+spec: 2.6
+yaml: |
+ Mark McGwire: {hr: 65, avg: 0.278}
+ Sammy Sosa: {
+ hr: 63,
+ avg: 0.288
+ }
+php: |
+ array(
+ 'Mark McGwire' =>
+ array( 'hr' => 65, 'avg' => 0.278 ),
+ 'Sammy Sosa' =>
+ array( 'hr' => 63, 'avg' => 0.288 )
+ )
+---
+test: Two documents in a stream each with a leading comment
+todo: true
+spec: 2.7
+yaml: |
+ # Ranking of 1998 home runs
+ ---
+ - Mark McGwire
+ - Sammy Sosa
+ - Ken Griffey
+
+ # Team ranking
+ ---
+ - Chicago Cubs
+ - St Louis Cardinals
+ruby: |
+ y = YAML::Stream.new
+ y.add( [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ] )
+ y.add( [ 'Chicago Cubs', 'St Louis Cardinals' ] )
+documents: 2
+
+---
+test: Play by play feed from a game
+todo: true
+spec: 2.8
+yaml: |
+ ---
+ time: 20:03:20
+ player: Sammy Sosa
+ action: strike (miss)
+ ...
+ ---
+ time: 20:03:47
+ player: Sammy Sosa
+ action: grand slam
+ ...
+perl: |
+ [ 'Mark McGwire', 'Sammy Sosa', 'Ken Griffey' ]
+documents: 2
+
+---
+test: Single document with two comments
+spec: 2.9
+yaml: |
+ hr: # 1998 hr ranking
+ - Mark McGwire
+ - Sammy Sosa
+ rbi:
+ # 1998 rbi ranking
+ - Sammy Sosa
+ - Ken Griffey
+php: |
+ array(
+ 'hr' => array( 'Mark McGwire', 'Sammy Sosa' ),
+ 'rbi' => array( 'Sammy Sosa', 'Ken Griffey' )
+ )
+---
+test: Node for Sammy Sosa appears twice in this document
+spec: 2.10
+yaml: |
+ ---
+ hr:
+ - Mark McGwire
+ # Following node labeled SS
+ - &SS Sammy Sosa
+ rbi:
+ - *SS # Subsequent occurrence
+ - Ken Griffey
+php: |
+ array(
+ 'hr' =>
+ array('Mark McGwire', 'Sammy Sosa'),
+ 'rbi' =>
+ array('Sammy Sosa', 'Ken Griffey')
+ )
+---
+test: Mapping between sequences
+todo: true
+spec: 2.11
+yaml: |
+ ? # PLAY SCHEDULE
+ - Detroit Tigers
+ - Chicago Cubs
+ :
+ - 2001-07-23
+
+ ? [ New York Yankees,
+ Atlanta Braves ]
+ : [ 2001-07-02, 2001-08-12,
+ 2001-08-14 ]
+ruby: |
+ {
+ [ 'Detroit Tigers', 'Chicago Cubs' ] => [ Date.new( 2001, 7, 23 ) ],
+ [ 'New York Yankees', 'Atlanta Braves' ] => [ Date.new( 2001, 7, 2 ), Date.new( 2001, 8, 12 ), Date.new( 2001, 8, 14 ) ]
+ }
+syck: |
+ struct test_node seq1[] = {
+ { T_STR, 0, "New York Yankees" },
+ { T_STR, 0, "Atlanta Braves" },
+ end_node
+ };
+ struct test_node seq2[] = {
+ { T_STR, 0, "2001-07-02" },
+ { T_STR, 0, "2001-08-12" },
+ { T_STR, 0, "2001-08-14" },
+ end_node
+ };
+ struct test_node seq3[] = {
+ { T_STR, 0, "Detroit Tigers" },
+ { T_STR, 0, "Chicago Cubs" },
+ end_node
+ };
+ struct test_node seq4[] = {
+ { T_STR, 0, "2001-07-23" },
+ end_node
+ };
+ struct test_node map[] = {
+ { T_SEQ, 0, 0, seq3 },
+ { T_SEQ, 0, 0, seq4 },
+ { T_SEQ, 0, 0, seq1 },
+ { T_SEQ, 0, 0, seq2 },
+ end_node
+ };
+ struct test_node stream[] = {
+ { T_MAP, 0, 0, map },
+ end_node
+ };
+
+---
+test: Sequence key shortcut
+spec: 2.12
+yaml: |
+ ---
+ # products purchased
+ - item : Super Hoop
+ quantity: 1
+ - item : Basketball
+ quantity: 4
+ - item : Big Shoes
+ quantity: 1
+php: |
+ array (
+ array (
+ 'item' => 'Super Hoop',
+ 'quantity' => 1,
+ ),
+ array (
+ 'item' => 'Basketball',
+ 'quantity' => 4,
+ ),
+ array (
+ 'item' => 'Big Shoes',
+ 'quantity' => 1,
+ )
+ )
+perl: |
+ [
+ { item => 'Super Hoop', quantity => 1 },
+ { item => 'Basketball', quantity => 4 },
+ { item => 'Big Shoes', quantity => 1 }
+ ]
+
+ruby: |
+ [
+ { 'item' => 'Super Hoop', 'quantity' => 1 },
+ { 'item' => 'Basketball', 'quantity' => 4 },
+ { 'item' => 'Big Shoes', 'quantity' => 1 }
+ ]
+python: |
+ [
+ { 'item': 'Super Hoop', 'quantity': 1 },
+ { 'item': 'Basketball', 'quantity': 4 },
+ { 'item': 'Big Shoes', 'quantity': 1 }
+ ]
+syck: |
+ struct test_node map1[] = {
+ { T_STR, 0, "item" },
+ { T_STR, 0, "Super Hoop" },
+ { T_STR, 0, "quantity" },
+ { T_STR, 0, "1" },
+ end_node
+ };
+ struct test_node map2[] = {
+ { T_STR, 0, "item" },
+ { T_STR, 0, "Basketball" },
+ { T_STR, 0, "quantity" },
+ { T_STR, 0, "4" },
+ end_node
+ };
+ struct test_node map3[] = {
+ { T_STR, 0, "item" },
+ { T_STR, 0, "Big Shoes" },
+ { T_STR, 0, "quantity" },
+ { T_STR, 0, "1" },
+ end_node
+ };
+ struct test_node seq[] = {
+ { T_MAP, 0, 0, map1 },
+ { T_MAP, 0, 0, map2 },
+ { T_MAP, 0, 0, map3 },
+ end_node
+ };
+ struct test_node stream[] = {
+ { T_SEQ, 0, 0, seq },
+ end_node
+ };
+
+
+---
+test: Literal perserves newlines
+todo: true
+spec: 2.13
+yaml: |
+ # ASCII Art
+ --- |
+ \//||\/||
+ // || ||_
+perl: |
+ "\\//||\\/||\n// || ||_\n"
+ruby: |
+ "\\//||\\/||\n// || ||_\n"
+python: |
+ [
+ flushLeft(
+ """
+ \//||\/||
+ // || ||_
+ """
+ )
+ ]
+syck: |
+ struct test_node stream[] = {
+ { T_STR, 0, "\\//||\\/||\n// || ||_\n" },
+ end_node
+ };
+
+---
+test: Folded treats newlines as a space
+todo: true
+spec: 2.14
+yaml: |
+ ---
+ Mark McGwire's
+ year was crippled
+ by a knee injury.
+perl: |
+ "Mark McGwire's year was crippled by a knee injury."
+ruby: |
+ "Mark McGwire's year was crippled by a knee injury."
+python: |
+ [ "Mark McGwire's year was crippled by a knee injury." ]
+syck: |
+ struct test_node stream[] = {
+ { T_STR, 0, "Mark McGwire's year was crippled by a knee injury." },
+ end_node
+ };
+
+---
+test: Newlines preserved for indented and blank lines
+todo: true
+spec: 2.15
+yaml: |
+ --- >
+ Sammy Sosa completed another
+ fine season with great stats.
+
+ 63 Home Runs
+ 0.288 Batting Average
+
+ What a year!
+perl: |
+ "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n"
+ruby: |
+ "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n"
+python: |
+ [
+ flushLeft(
+ """
+ Sammy Sosa completed another fine season with great stats.
+
+ 63 Home Runs
+ 0.288 Batting Average
+
+ What a year!
+ """
+ )
+ ]
+syck: |
+ struct test_node stream[] = {
+ { T_STR, 0, "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n" },
+ end_node
+ };
+
+
+---
+test: Indentation determines scope
+spec: 2.16
+yaml: |
+ name: Mark McGwire
+ accomplishment: >
+ Mark set a major league
+ home run record in 1998.
+ stats: |
+ 65 Home Runs
+ 0.278 Batting Average
+php: |
+ array(
+ 'name' => 'Mark McGwire',
+ 'accomplishment' => "Mark set a major league home run record in 1998.\n",
+ 'stats' => "65 Home Runs\n0.278 Batting Average\n"
+ )
+---
+test: Quoted scalars
+todo: true
+spec: 2.17
+yaml: |
+ unicode: "Sosa did fine.\u263A"
+ control: "\b1998\t1999\t2000\n"
+ hexesc: "\x0D\x0A is \r\n"
+
+ single: '"Howdy!" he cried.'
+ quoted: ' # not a ''comment''.'
+ tie-fighter: '|\-*-/|'
+ruby: |
+ {
+ "tie-fighter" => "|\\-*-/|",
+ "control"=>"\0101998\t1999\t2000\n",
+ "unicode"=>"Sosa did fine." + ["263A".hex ].pack('U*'),
+ "quoted"=>" # not a 'comment'.",
+ "single"=>"\"Howdy!\" he cried.",
+ "hexesc"=>"\r\n is \r\n"
+ }
+---
+test: Multiline flow scalars
+todo: true
+spec: 2.18
+yaml: |
+ plain:
+ This unquoted scalar
+ spans many lines.
+
+ quoted: "So does this
+ quoted scalar.\n"
+ruby: |
+ {
+ 'plain' => 'This unquoted scalar spans many lines.',
+ 'quoted' => "So does this quoted scalar.\n"
+ }
+---
+test: Integers
+spec: 2.19
+yaml: |
+ canonical: 12345
+ octal: 014
+ hexadecimal: 0xC
+php: |
+ array(
+ 'canonical' => 12345,
+ 'octal' => 014,
+ 'hexadecimal' => 0xC
+ )
+---
+test: Decimal Integer
+deprecated: true
+spec: 2.19
+yaml: |
+ decimal: +12,345
+php: |
+ array(
+ 'decimal' => 12345.0,
+ )
+---
+# FIX: spec shows parens around -inf and NaN
+test: Floating point
+spec: 2.20
+yaml: |
+ canonical: 1.23015e+3
+ exponential: 12.3015e+02
+ negative infinity: -.inf
+ not a number: .NaN
+ float as whole number: !!float 1
+php: |
+ array(
+ 'canonical' => 1230.15,
+ 'exponential' => 1230.15,
+ 'negative infinity' => log(0),
+ 'not a number' => -log(0),
+ 'float as whole number' => (float) 1
+ )
+---
+test: Fixed Floating point
+deprecated: true
+spec: 2.20
+yaml: |
+ fixed: 1,230.15
+php: |
+ array(
+ 'fixed' => 1230.15,
+ )
+---
+test: Timestamps
+todo: true
+spec: 2.22
+yaml: |
+ canonical: 2001-12-15T02:59:43.1Z
+ iso8601: 2001-12-14t21:59:43.10-05:00
+ spaced: 2001-12-14 21:59:43.10 -05:00
+ date: 2002-12-14 # Time is noon UTC
+php: |
+ array(
+ 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
+ 'iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
+ 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
+ 'date' => Date.new( 2002, 12, 14 )
+ )
+---
+test: legacy Timestamps test
+todo: true
+spec: legacy D4
+yaml: |
+ canonical: 2001-12-15T02:59:43.00Z
+ iso8601: 2001-02-28t21:59:43.00-05:00
+ spaced: 2001-12-14 21:59:43.00 -05:00
+ date: 2002-12-14
+php: |
+ array(
+ 'canonical' => Time::utc( 2001, 12, 15, 2, 59, 43, 0 ),
+ 'iso8601' => YAML::mktime( 2001, 2, 28, 21, 59, 43, 0, "-05:00" ),
+ 'spaced' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0, "-05:00" ),
+ 'date' => Date.new( 2002, 12, 14 )
+ )
+---
+test: Various explicit families
+todo: true
+spec: 2.23
+yaml: |
+ not-date: !!str 2002-04-28
+ picture: !binary |
+ R0lGODlhDAAMAIQAAP//9/X
+ 17unp5WZmZgAAAOfn515eXv
+ Pz7Y6OjuDg4J+fn5OTk6enp
+ 56enmleECcgggoBADs=
+
+ application specific tag: !!something |
+ The semantics of the tag
+ above may be different for
+ different documents.
+
+ruby-setup: |
+ YAML.add_private_type( "something" ) do |type, val|
+ "SOMETHING: #{val}"
+ end
+ruby: |
+ {
+ 'not-date' => '2002-04-28',
+ 'picture' => "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236i^\020' \202\n\001\000;",
+ 'application specific tag' => "SOMETHING: The semantics of the tag\nabove may be different for\ndifferent documents.\n"
+ }
+---
+test: Application specific family
+todo: true
+spec: 2.24
+yaml: |
+ # Establish a tag prefix
+ --- !clarkevans.com,2002/graph/^shape
+ # Use the prefix: shorthand for
+ # !clarkevans.com,2002/graph/circle
+ - !^circle
+ center: &ORIGIN {x: 73, 'y': 129}
+ radius: 7
+ - !^line # !clarkevans.com,2002/graph/line
+ start: *ORIGIN
+ finish: { x: 89, 'y': 102 }
+ - !^label
+ start: *ORIGIN
+ color: 0xFFEEBB
+ value: Pretty vector drawing.
+ruby-setup: |
+ YAML.add_domain_type( "clarkevans.com,2002", 'graph/shape' ) { |type, val|
+ if Array === val
+ val << "Shape Container"
+ val
+ else
+ raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
+ end
+ }
+ one_shape_proc = Proc.new { |type, val|
+ scheme, domain, type = type.split( /:/, 3 )
+ if val.is_a? ::Hash
+ val['TYPE'] = "Shape: #{type}"
+ val
+ else
+ raise YAML::Error, "Invalid graph of class #{ val.class }: " + val.inspect
+ end
+ }
+ YAML.add_domain_type( "clarkevans.com,2002", 'graph/circle', &one_shape_proc )
+ YAML.add_domain_type( "clarkevans.com,2002", 'graph/line', &one_shape_proc )
+ YAML.add_domain_type( "clarkevans.com,2002", 'graph/label', &one_shape_proc )
+ruby: |
+ [
+ {
+ "radius" => 7,
+ "center"=>
+ {
+ "x" => 73,
+ "y" => 129
+ },
+ "TYPE" => "Shape: graph/circle"
+ }, {
+ "finish" =>
+ {
+ "x" => 89,
+ "y" => 102
+ },
+ "TYPE" => "Shape: graph/line",
+ "start" =>
+ {
+ "x" => 73,
+ "y" => 129
+ }
+ }, {
+ "TYPE" => "Shape: graph/label",
+ "value" => "Pretty vector drawing.",
+ "start" =>
+ {
+ "x" => 73,
+ "y" => 129
+ },
+ "color" => 16772795
+ },
+ "Shape Container"
+ ]
+# ---
+# test: Unordered set
+# spec: 2.25
+# yaml: |
+# # sets are represented as a
+# # mapping where each key is
+# # associated with the empty string
+# --- !set
+# ? Mark McGwire
+# ? Sammy Sosa
+# ? Ken Griff
+---
+test: Ordered mappings
+todo: true
+spec: 2.26
+yaml: |
+ # ordered maps are represented as
+ # a sequence of mappings, with
+ # each mapping having one key
+ --- !omap
+ - Mark McGwire: 65
+ - Sammy Sosa: 63
+ - Ken Griffy: 58
+ruby: |
+ YAML::Omap[
+ 'Mark McGwire', 65,
+ 'Sammy Sosa', 63,
+ 'Ken Griffy', 58
+ ]
+---
+test: Invoice
+dump_skip: true
+spec: 2.27
+yaml: |
+ --- !clarkevans.com,2002/^invoice
+ invoice: 34843
+ date : 2001-01-23
+ bill-to: &id001
+ given : Chris
+ family : Dumars
+ address:
+ lines: |
+ 458 Walkman Dr.
+ Suite #292
+ city : Royal Oak
+ state : MI
+ postal : 48046
+ ship-to: *id001
+ product:
+ -
+ sku : BL394D
+ quantity : 4
+ description : Basketball
+ price : 450.00
+ -
+ sku : BL4438H
+ quantity : 1
+ description : Super Hoop
+ price : 2392.00
+ tax : 251.42
+ total: 4443.52
+ comments: >
+ Late afternoon is best.
+ Backup contact is Nancy
+ Billsmer @ 338-4338.
+php: |
+ array(
+ 'invoice' => 34843, 'date' => gmmktime(0, 0, 0, 1, 23, 2001),
+ 'bill-to' =>
+ array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
+ , 'ship-to' =>
+ array( 'given' => 'Chris', 'family' => 'Dumars', 'address' => array( 'lines' => "458 Walkman Dr.\nSuite #292\n", 'city' => 'Royal Oak', 'state' => 'MI', 'postal' => 48046 ) )
+ , 'product' =>
+ array(
+ array( 'sku' => 'BL394D', 'quantity' => 4, 'description' => 'Basketball', 'price' => 450.00 ),
+ array( 'sku' => 'BL4438H', 'quantity' => 1, 'description' => 'Super Hoop', 'price' => 2392.00 )
+ ),
+ 'tax' => 251.42, 'total' => 4443.52,
+ 'comments' => "Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.\n"
+ )
+---
+test: Log file
+todo: true
+spec: 2.28
+yaml: |
+ ---
+ Time: 2001-11-23 15:01:42 -05:00
+ User: ed
+ Warning: >
+ This is an error message
+ for the log file
+ ---
+ Time: 2001-11-23 15:02:31 -05:00
+ User: ed
+ Warning: >
+ A slightly different error
+ message.
+ ---
+ Date: 2001-11-23 15:03:17 -05:00
+ User: ed
+ Fatal: >
+ Unknown variable "bar"
+ Stack:
+ - file: TopClass.py
+ line: 23
+ code: |
+ x = MoreObject("345\n")
+ - file: MoreClass.py
+ line: 58
+ code: |-
+ foo = bar
+ruby: |
+ y = YAML::Stream.new
+ y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 01, 42, 00, "-05:00" ),
+ 'User' => 'ed', 'Warning' => "This is an error message for the log file\n" } )
+ y.add( { 'Time' => YAML::mktime( 2001, 11, 23, 15, 02, 31, 00, "-05:00" ),
+ 'User' => 'ed', 'Warning' => "A slightly different error message.\n" } )
+ y.add( { 'Date' => YAML::mktime( 2001, 11, 23, 15, 03, 17, 00, "-05:00" ),
+ 'User' => 'ed', 'Fatal' => "Unknown variable \"bar\"\n",
+ 'Stack' => [
+ { 'file' => 'TopClass.py', 'line' => 23, 'code' => "x = MoreObject(\"345\\n\")\n" },
+ { 'file' => 'MoreClass.py', 'line' => 58, 'code' => "foo = bar" } ] } )
+documents: 3
+
+---
+test: Throwaway comments
+yaml: |
+ ### These are four throwaway comment ###
+
+ ### lines (the second line is empty). ###
+ this: | # Comments may trail lines.
+ contains three lines of text.
+ The third one starts with a
+ # character. This isn't a comment.
+
+ # These are three throwaway comment
+ # lines (the first line is empty).
+php: |
+ array(
+ 'this' => "contains three lines of text.\nThe third one starts with a\n# character. This isn't a comment.\n"
+ )
+---
+test: Document with a single value
+todo: true
+yaml: |
+ --- >
+ This YAML stream contains a single text value.
+ The next stream is a log file - a sequence of
+ log entries. Adding an entry to the log is a
+ simple matter of appending it at the end.
+ruby: |
+ "This YAML stream contains a single text value. The next stream is a log file - a sequence of log entries. Adding an entry to the log is a simple matter of appending it at the end.\n"
+---
+test: Document stream
+todo: true
+yaml: |
+ ---
+ at: 2001-08-12 09:25:00.00 Z
+ type: GET
+ HTTP: '1.0'
+ url: '/index.html'
+ ---
+ at: 2001-08-12 09:25:10.00 Z
+ type: GET
+ HTTP: '1.0'
+ url: '/toc.html'
+ruby: |
+ y = YAML::Stream.new
+ y.add( {
+ 'at' => Time::utc( 2001, 8, 12, 9, 25, 00 ),
+ 'type' => 'GET',
+ 'HTTP' => '1.0',
+ 'url' => '/index.html'
+ } )
+ y.add( {
+ 'at' => Time::utc( 2001, 8, 12, 9, 25, 10 ),
+ 'type' => 'GET',
+ 'HTTP' => '1.0',
+ 'url' => '/toc.html'
+ } )
+documents: 2
+
+---
+test: Top level mapping
+yaml: |
+ # This stream is an example of a top-level mapping.
+ invoice : 34843
+ date : 2001-01-23
+ total : 4443.52
+php: |
+ array(
+ 'invoice' => 34843,
+ 'date' => gmmktime(0, 0, 0, 1, 23, 2001),
+ 'total' => 4443.52
+ )
+---
+test: Single-line documents
+todo: true
+yaml: |
+ # The following is a sequence of three documents.
+ # The first contains an empty mapping, the second
+ # an empty sequence, and the last an empty string.
+ --- {}
+ --- [ ]
+ --- ''
+ruby: |
+ y = YAML::Stream.new
+ y.add( {} )
+ y.add( [] )
+ y.add( '' )
+documents: 3
+
+---
+test: Document with pause
+todo: true
+yaml: |
+ # A communication channel based on a YAML stream.
+ ---
+ sent at: 2002-06-06 11:46:25.10 Z
+ payload: Whatever
+ # Receiver can process this as soon as the following is sent:
+ ...
+ # Even if the next message is sent long after:
+ ---
+ sent at: 2002-06-06 12:05:53.47 Z
+ payload: Whatever
+ ...
+ruby: |
+ y = YAML::Stream.new
+ y.add(
+ { 'sent at' => YAML::mktime( 2002, 6, 6, 11, 46, 25, 0.10 ),
+ 'payload' => 'Whatever' }
+ )
+ y.add(
+ { "payload" => "Whatever", "sent at" => YAML::mktime( 2002, 6, 6, 12, 5, 53, 0.47 ) }
+ )
+documents: 2
+
+---
+test: Explicit typing
+deprecated: Using the non-specific tag "!" is deprecated since Symfony 3.4 as its behavior will change in 4.0.
+yaml: |
+ integer: 12
+ also int: ! "12"
+ string: !!str 12
+php: |
+ array( 'integer' => 12, 'also int' => 12, 'string' => '12' )
+---
+test: Private types
+todo: true
+yaml: |
+ # Both examples below make use of the 'x-private:ball'
+ # type family URI, but with different semantics.
+ ---
+ pool: !!ball
+ number: 8
+ color: black
+ ---
+ bearing: !!ball
+ material: steel
+ruby: |
+ y = YAML::Stream.new
+ y.add( { 'pool' =>
+ YAML::PrivateType.new( 'ball',
+ { 'number' => 8, 'color' => 'black' } ) }
+ )
+ y.add( { 'bearing' =>
+ YAML::PrivateType.new( 'ball',
+ { 'material' => 'steel' } ) }
+ )
+documents: 2
+
+---
+test: Type family under yaml.org
+yaml: |
+ # The URI is 'tag:yaml.org,2002:str'
+ - !!str a Unicode string
+php: |
+ array( 'a Unicode string' )
+---
+test: Type family under perl.yaml.org
+todo: true
+yaml: |
+ # The URI is 'tag:perl.yaml.org,2002:Text::Tabs'
+ - !perl/Text::Tabs {}
+ruby: |
+ [ YAML::DomainType.new( 'perl.yaml.org,2002', 'Text::Tabs', {} ) ]
+---
+test: Type family under clarkevans.com
+todo: true
+yaml: |
+ # The URI is 'tag:clarkevans.com,2003-02:timesheet'
+ - !clarkevans.com,2003-02/timesheet {}
+ruby: |
+ [ YAML::DomainType.new( 'clarkevans.com,2003-02', 'timesheet', {} ) ]
+---
+test: URI Escaping
+todo: true
+yaml: |
+ same:
+ - !domain.tld,2002/type\x30 value
+ - !domain.tld,2002/type0 value
+ different: # As far as the YAML parser is concerned
+ - !domain.tld,2002/type%30 value
+ - !domain.tld,2002/type0 value
+ruby-setup: |
+ YAML.add_domain_type( "domain.tld,2002", "type0" ) { |type, val|
+ "ONE: #{val}"
+ }
+ YAML.add_domain_type( "domain.tld,2002", "type%30" ) { |type, val|
+ "TWO: #{val}"
+ }
+ruby: |
+ { 'same' => [ 'ONE: value', 'ONE: value' ], 'different' => [ 'TWO: value', 'ONE: value' ] }
+---
+test: URI Prefixing
+todo: true
+yaml: |
+ # 'tag:domain.tld,2002:invoice' is some type family.
+ invoice: !domain.tld,2002/^invoice
+ # 'seq' is shorthand for 'tag:yaml.org,2002:seq'.
+ # This does not effect '^customer' below
+ # because it is does not specify a prefix.
+ customers: !seq
+ # '^customer' is shorthand for the full
+ # notation 'tag:domain.tld,2002:customer'.
+ - !^customer
+ given : Chris
+ family : Dumars
+ruby-setup: |
+ YAML.add_domain_type( "domain.tld,2002", /(invoice|customer)/ ) { |type, val|
+ if val.is_a? ::Hash
+ scheme, domain, type = type.split( /:/, 3 )
+ val['type'] = "domain #{type}"
+ val
+ else
+ raise YAML::Error, "Not a Hash in domain.tld/invoice: " + val.inspect
+ end
+ }
+ruby: |
+ { "invoice"=> { "customers"=> [ { "given"=>"Chris", "type"=>"domain customer", "family"=>"Dumars" } ], "type"=>"domain invoice" } }
+
+---
+test: Overriding anchors
+yaml: |
+ anchor : &A001 This scalar has an anchor.
+ override : &A001 >
+ The alias node below is a
+ repeated use of this value.
+ alias : *A001
+php: |
+ array( 'anchor' => 'This scalar has an anchor.',
+ 'override' => "The alias node below is a repeated use of this value.\n",
+ 'alias' => "The alias node below is a repeated use of this value.\n" )
+---
+test: Flow and block formatting
+todo: true
+yaml: |
+ empty: []
+ flow: [ one, two, three # May span lines,
+ , four, # indentation is
+ five ] # mostly ignored.
+ block:
+ - First item in top sequence
+ -
+ - Subordinate sequence entry
+ - >
+ A folded sequence entry
+ - Sixth item in top sequence
+ruby: |
+ { 'empty' => [], 'flow' => [ 'one', 'two', 'three', 'four', 'five' ],
+ 'block' => [ 'First item in top sequence', [ 'Subordinate sequence entry' ],
+ "A folded sequence entry\n", 'Sixth item in top sequence' ] }
+---
+test: Complete mapping test
+todo: true
+yaml: |
+ empty: {}
+ flow: { one: 1, two: 2 }
+ spanning: { one: 1,
+ two: 2 }
+ block:
+ first : First entry
+ second:
+ key: Subordinate mapping
+ third:
+ - Subordinate sequence
+ - { }
+ - Previous mapping is empty.
+ - A key: value pair in a sequence.
+ A second: key:value pair.
+ - The previous entry is equal to the following one.
+ -
+ A key: value pair in a sequence.
+ A second: key:value pair.
+ !float 12 : This key is a float.
+ ? >
+ ?
+ : This key had to be protected.
+ "\a" : This key had to be escaped.
+ ? >
+ This is a
+ multi-line
+ folded key
+ : Whose value is
+ also multi-line.
+ ? this also works as a key
+ : with a value at the next line.
+ ?
+ - This key
+ - is a sequence
+ :
+ - With a sequence value.
+ ?
+ This: key
+ is a: mapping
+ :
+ with a: mapping value.
+ruby: |
+ { 'empty' => {}, 'flow' => { 'one' => 1, 'two' => 2 },
+ 'spanning' => { 'one' => 1, 'two' => 2 },
+ 'block' => { 'first' => 'First entry', 'second' =>
+ { 'key' => 'Subordinate mapping' }, 'third' =>
+ [ 'Subordinate sequence', {}, 'Previous mapping is empty.',
+ { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' },
+ 'The previous entry is equal to the following one.',
+ { 'A key' => 'value pair in a sequence.', 'A second' => 'key:value pair.' } ],
+ 12.0 => 'This key is a float.', "?\n" => 'This key had to be protected.',
+ "\a" => 'This key had to be escaped.',
+ "This is a multi-line folded key\n" => "Whose value is also multi-line.",
+ 'this also works as a key' => 'with a value at the next line.',
+ [ 'This key', 'is a sequence' ] => [ 'With a sequence value.' ] } }
+ # Couldn't recreate map exactly, so we'll do a detailed check to be sure it's entact
+ obj_y['block'].keys.each { |k|
+ if Hash === k
+ v = obj_y['block'][k]
+ if k['This'] == 'key' and k['is a'] == 'mapping' and v['with a'] == 'mapping value.'
+ obj_r['block'][k] = v
+ end
+ end
+ }
+---
+test: Literal explicit indentation
+yaml: |
+ # Explicit indentation must
+ # be given in all the three
+ # following cases.
+ leading spaces: |2
+ This value starts with four spaces.
+
+ leading line break: |2
+
+ This value starts with a line break.
+
+ leading comment indicator: |2
+ # first line starts with a
+ # character.
+
+ # Explicit indentation may
+ # also be given when it is
+ # not required.
+ redundant: |2
+ This value is indented 2 spaces.
+php: |
+ array(
+ 'leading spaces' => " This value starts with four spaces.\n",
+ 'leading line break' => "\nThis value starts with a line break.\n",
+ 'leading comment indicator' => "# first line starts with a\n# character.\n",
+ 'redundant' => "This value is indented 2 spaces.\n"
+ )
+---
+test: Chomping and keep modifiers
+yaml: |
+ clipped: |
+ This has one newline.
+
+ same as "clipped" above: "This has one newline.\n"
+
+ stripped: |-
+ This has no newline.
+
+ same as "stripped" above: "This has no newline."
+
+ kept: |+
+ This has two newlines.
+
+ same as "kept" above: "This has two newlines.\n\n"
+php: |
+ array(
+ 'clipped' => "This has one newline.\n",
+ 'same as "clipped" above' => "This has one newline.\n",
+ 'stripped' => 'This has no newline.',
+ 'same as "stripped" above' => 'This has no newline.',
+ 'kept' => "This has two newlines.\n\n",
+ 'same as "kept" above' => "This has two newlines.\n\n"
+ )
+---
+test: Literal combinations
+todo: true
+yaml: |
+ empty: |
+
+ literal: |
+ The \ ' " characters may be
+ freely used. Leading white
+ space is significant.
+
+ Line breaks are significant.
+ Thus this value contains one
+ empty line and ends with a
+ single line break, but does
+ not start with one.
+
+ is equal to: "The \\ ' \" characters may \
+ be\nfreely used. Leading white\n space \
+ is significant.\n\nLine breaks are \
+ significant.\nThus this value contains \
+ one\nempty line and ends with a\nsingle \
+ line break, but does\nnot start with one.\n"
+
+ # Comments may follow a block
+ # scalar value. They must be
+ # less indented.
+
+ # Modifiers may be combined in any order.
+ indented and chomped: |2-
+ This has no newline.
+
+ also written as: |-2
+ This has no newline.
+
+ both are equal to: " This has no newline."
+php: |
+ array(
+ 'empty' => '',
+ 'literal' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
+ "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
+ "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
+ 'is equal to' => "The \\ ' \" characters may be\nfreely used. Leading white\n space " +
+ "is significant.\n\nLine breaks are significant.\nThus this value contains one\n" +
+ "empty line and ends with a\nsingle line break, but does\nnot start with one.\n",
+ 'indented and chomped' => ' This has no newline.',
+ 'also written as' => ' This has no newline.',
+ 'both are equal to' => ' This has no newline.'
+ )
+---
+test: Folded combinations
+todo: true
+yaml: |
+ empty: >
+
+ one paragraph: >
+ Line feeds are converted
+ to spaces, so this value
+ contains no line breaks
+ except for the final one.
+
+ multiple paragraphs: >2
+
+ An empty line, either
+ at the start or in
+ the value:
+
+ Is interpreted as a
+ line break. Thus this
+ value contains three
+ line breaks.
+
+ indented text: >
+ This is a folded
+ paragraph followed
+ by a list:
+ * first entry
+ * second entry
+ Followed by another
+ folded paragraph,
+ another list:
+
+ * first entry
+
+ * second entry
+
+ And a final folded
+ paragraph.
+
+ above is equal to: |
+ This is a folded paragraph followed by a list:
+ * first entry
+ * second entry
+ Followed by another folded paragraph, another list:
+
+ * first entry
+
+ * second entry
+
+ And a final folded paragraph.
+
+ # Explicit comments may follow
+ # but must be less indented.
+php: |
+ array(
+ 'empty' => '',
+ 'one paragraph' => 'Line feeds are converted to spaces, so this value'.
+ " contains no line breaks except for the final one.\n",
+ 'multiple paragraphs' => "\nAn empty line, either at the start or in the value:\n".
+ "Is interpreted as a line break. Thus this value contains three line breaks.\n",
+ 'indented text' => "This is a folded paragraph followed by a list:\n".
+ " * first entry\n * second entry\nFollowed by another folded paragraph, ".
+ "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n",
+ 'above is equal to' => "This is a folded paragraph followed by a list:\n".
+ " * first entry\n * second entry\nFollowed by another folded paragraph, ".
+ "another list:\n\n * first entry\n\n * second entry\n\nAnd a final folded paragraph.\n"
+ )
+---
+test: Single quotes
+todo: true
+yaml: |
+ empty: ''
+ second: '! : \ etc. can be used freely.'
+ third: 'a single quote '' must be escaped.'
+ span: 'this contains
+ six spaces
+
+ and one
+ line break'
+ is same as: "this contains six spaces\nand one line break"
+php: |
+ array(
+ 'empty' => '',
+ 'second' => '! : \\ etc. can be used freely.',
+ 'third' => "a single quote ' must be escaped.",
+ 'span' => "this contains six spaces\nand one line break",
+ 'is same as' => "this contains six spaces\nand one line break"
+ )
+---
+test: Double quotes
+todo: true
+yaml: |
+ empty: ""
+ second: "! : etc. can be used freely."
+ third: "a \" or a \\ must be escaped."
+ fourth: "this value ends with an LF.\n"
+ span: "this contains
+ four \
+ spaces"
+ is equal to: "this contains four spaces"
+php: |
+ array(
+ 'empty' => '',
+ 'second' => '! : etc. can be used freely.',
+ 'third' => 'a " or a \\ must be escaped.',
+ 'fourth' => "this value ends with an LF.\n",
+ 'span' => "this contains four spaces",
+ 'is equal to' => "this contains four spaces"
+ )
+---
+test: Unquoted strings
+todo: true
+yaml: |
+ first: There is no unquoted empty string.
+
+ second: 12 ## This is an integer.
+
+ third: !!str 12 ## This is a string.
+
+ span: this contains
+ six spaces
+
+ and one
+ line break
+
+ indicators: this has no comments.
+ #:foo and bar# are
+ both text.
+
+ flow: [ can span
+ lines, # comment
+ like
+ this ]
+
+ note: { one-line keys: but multi-line values }
+
+php: |
+ array(
+ 'first' => 'There is no unquoted empty string.',
+ 'second' => 12,
+ 'third' => '12',
+ 'span' => "this contains six spaces\nand one line break",
+ 'indicators' => "this has no comments. #:foo and bar# are both text.",
+ 'flow' => [ 'can span lines', 'like this' ],
+ 'note' => { 'one-line keys' => 'but multi-line values' }
+ )
+---
+test: Spanning sequences
+todo: true
+yaml: |
+ # The following are equal seqs
+ # with different identities.
+ flow: [ one, two ]
+ spanning: [ one,
+ two ]
+ block:
+ - one
+ - two
+php: |
+ array(
+ 'flow' => [ 'one', 'two' ],
+ 'spanning' => [ 'one', 'two' ],
+ 'block' => [ 'one', 'two' ]
+ )
+---
+test: Flow mappings
+yaml: |
+ # The following are equal maps
+ # with different identities.
+ flow: { one: 1, two: 2 }
+ block:
+ one: 1
+ two: 2
+php: |
+ array(
+ 'flow' => array( 'one' => 1, 'two' => 2 ),
+ 'block' => array( 'one' => 1, 'two' => 2 )
+ )
+---
+test: Representations of 12
+todo: true
+yaml: |
+ - 12 # An integer
+ # The following scalars
+ # are loaded to the
+ # string value '1' '2'.
+ - !!str 12
+ - '12'
+ - "12"
+ - "\
+ 1\
+ 2\
+ "
+ # Strings containing paths and regexps can be unquoted:
+ - /foo/bar
+ - d:/foo/bar
+ - foo/bar
+ - /a.*b/
+php: |
+ array( 12, '12', '12', '12', '12', '/foo/bar', 'd:/foo/bar', 'foo/bar', '/a.*b/' )
+---
+test: "Null"
+todo: true
+yaml: |
+ canonical: ~
+
+ english: null
+
+ # This sequence has five
+ # entries, two with values.
+ sparse:
+ - ~
+ - 2nd entry
+ - Null
+ - 4th entry
+ -
+
+ four: This mapping has five keys,
+ only two with values.
+
+php: |
+ array (
+ 'canonical' => null,
+ 'english' => null,
+ 'sparse' => array( null, '2nd entry', null, '4th entry', null ]),
+ 'four' => 'This mapping has five keys, only two with values.'
+ )
+---
+test: Omap
+todo: true
+yaml: |
+ # Explicitly typed dictionary.
+ Bestiary: !omap
+ - aardvark: African pig-like ant eater. Ugly.
+ - anteater: South-American ant eater. Two species.
+ - anaconda: South-American constrictor snake. Scary.
+ # Etc.
+ruby: |
+ {
+ 'Bestiary' => YAML::Omap[
+ 'aardvark', 'African pig-like ant eater. Ugly.',
+ 'anteater', 'South-American ant eater. Two species.',
+ 'anaconda', 'South-American constrictor snake. Scary.'
+ ]
+ }
+
+---
+test: Pairs
+todo: true
+yaml: |
+ # Explicitly typed pairs.
+ tasks: !pairs
+ - meeting: with team.
+ - meeting: with boss.
+ - break: lunch.
+ - meeting: with client.
+ruby: |
+ {
+ 'tasks' => YAML::Pairs[
+ 'meeting', 'with team.',
+ 'meeting', 'with boss.',
+ 'break', 'lunch.',
+ 'meeting', 'with client.'
+ ]
+ }
+
+---
+test: Set
+todo: true
+yaml: |
+ # Explicitly typed set.
+ baseball players: !set
+ Mark McGwire:
+ Sammy Sosa:
+ Ken Griffey:
+ruby: |
+ {
+ 'baseball players' => YAML::Set[
+ 'Mark McGwire', nil,
+ 'Sammy Sosa', nil,
+ 'Ken Griffey', nil
+ ]
+ }
+
+---
+test: Integer
+yaml: |
+ canonical: 12345
+ octal: 014
+ hexadecimal: 0xC
+php: |
+ array(
+ 'canonical' => 12345,
+ 'octal' => 12,
+ 'hexadecimal' => 12
+ )
+---
+test: Decimal
+deprecated: true
+yaml: |
+ decimal: +12,345
+php: |
+ array(
+ 'decimal' => 12345.0,
+ )
+---
+test: Fixed Float
+deprecated: true
+yaml: |
+ fixed: 1,230.15
+php: |
+ array(
+ 'fixed' => 1230.15,
+ )
+---
+test: Float
+yaml: |
+ canonical: 1.23015e+3
+ exponential: 12.3015e+02
+ negative infinity: -.inf
+ not a number: .NaN
+php: |
+ array(
+ 'canonical' => 1230.15,
+ 'exponential' => 1230.15,
+ 'negative infinity' => log(0),
+ 'not a number' => -log(0)
+ )
+---
+test: Timestamp
+todo: true
+yaml: |
+ canonical: 2001-12-15T02:59:43.1Z
+ valid iso8601: 2001-12-14t21:59:43.10-05:00
+ space separated: 2001-12-14 21:59:43.10 -05:00
+ date (noon UTC): 2002-12-14
+ruby: |
+ array(
+ 'canonical' => YAML::mktime( 2001, 12, 15, 2, 59, 43, 0.10 ),
+ 'valid iso8601' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
+ 'space separated' => YAML::mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
+ 'date (noon UTC)' => Date.new( 2002, 12, 14 )
+ )
+---
+test: Binary
+todo: true
+yaml: |
+ canonical: !binary "\
+ R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5\
+ OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+\
+ +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC\
+ AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs="
+ base64: !binary |
+ R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5
+ OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+
+ +f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC
+ AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=
+ description: >
+ The binary value above is a tiny arrow
+ encoded as a gif image.
+ruby-setup: |
+ arrow_gif = "GIF89a\f\000\f\000\204\000\000\377\377\367\365\365\356\351\351\345fff\000\000\000\347\347\347^^^\363\363\355\216\216\216\340\340\340\237\237\237\223\223\223\247\247\247\236\236\236iiiccc\243\243\243\204\204\204\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371\377\376\371!\376\016Made with GIMP\000,\000\000\000\000\f\000\f\000\000\005, \216\2010\236\343@\024\350i\020\304\321\212\010\034\317\200M$z\357\3770\205p\270\2601f\r\e\316\001\303\001\036\020' \202\n\001\000;"
+ruby: |
+ {
+ 'canonical' => arrow_gif,
+ 'base64' => arrow_gif,
+ 'description' => "The binary value above is a tiny arrow encoded as a gif image.\n"
+ }
+
+---
+test: Merge key
+todo: true
+yaml: |
+ ---
+ - &CENTER { x: 1, y: 2 }
+ - &LEFT { x: 0, y: 2 }
+ - &BIG { r: 10 }
+ - &SMALL { r: 1 }
+
+ # All the following maps are equal:
+
+ - # Explicit keys
+ x: 1
+ y: 2
+ r: 10
+ label: center/big
+
+ - # Merge one map
+ << : *CENTER
+ r: 10
+ label: center/big
+
+ - # Merge multiple maps
+ << : [ *CENTER, *BIG ]
+ label: center/big
+
+ - # Override
+ << : [ *BIG, *LEFT, *SMALL ]
+ x: 1
+ label: center/big
+
+ruby-setup: |
+ center = { 'x' => 1, 'y' => 2 }
+ left = { 'x' => 0, 'y' => 2 }
+ big = { 'r' => 10 }
+ small = { 'r' => 1 }
+ node1 = { 'x' => 1, 'y' => 2, 'r' => 10, 'label' => 'center/big' }
+ node2 = center.dup
+ node2.update( { 'r' => 10, 'label' => 'center/big' } )
+ node3 = big.dup
+ node3.update( center )
+ node3.update( { 'label' => 'center/big' } )
+ node4 = small.dup
+ node4.update( left )
+ node4.update( big )
+ node4.update( { 'x' => 1, 'label' => 'center/big' } )
+
+ruby: |
+ [
+ center, left, big, small, node1, node2, node3, node4
+ ]
+
+---
+test: Default key
+todo: true
+yaml: |
+ --- # Old schema
+ link with:
+ - library1.dll
+ - library2.dll
+ --- # New schema
+ link with:
+ - = : library1.dll
+ version: 1.2
+ - = : library2.dll
+ version: 2.3
+ruby: |
+ y = YAML::Stream.new
+ y.add( { 'link with' => [ 'library1.dll', 'library2.dll' ] } )
+ obj_h = Hash[ 'version' => 1.2 ]
+ obj_h.default = 'library1.dll'
+ obj_h2 = Hash[ 'version' => 2.3 ]
+ obj_h2.default = 'library2.dll'
+ y.add( { 'link with' => [ obj_h, obj_h2 ] } )
+documents: 2
+
+---
+test: Special keys
+todo: true
+yaml: |
+ "!": These three keys
+ "&": had to be quoted
+ "=": and are normal strings.
+ # NOTE: the following node should NOT be serialized this way.
+ encoded node :
+ !special '!' : '!type'
+ !special|canonical '&' : 12
+ = : value
+ # The proper way to serialize the above node is as follows:
+ node : !!type &12 value
+ruby: |
+ { '!' => 'These three keys', '&' => 'had to be quoted',
+ '=' => 'and are normal strings.',
+ 'encoded node' => YAML::PrivateType.new( 'type', 'value' ),
+ 'node' => YAML::PrivateType.new( 'type', 'value' ) }
--- /dev/null
+--- %YAML:1.0
+test: Strings
+brief: >
+ Any group of characters beginning with an
+ alphabetic or numeric character is a string,
+ unless it belongs to one of the groups below
+ (such as an Integer or Time).
+yaml: |
+ String
+php: |
+ 'String'
+---
+test: String characters
+brief: >
+ A string can contain any alphabetic or
+ numeric character, along with many
+ punctuation characters, including the
+ period, dash, space, quotes, exclamation, and
+ question mark.
+yaml: |
+ - What's Yaml?
+ - It's for writing data structures in plain text.
+ - And?
+ - And what? That's not good enough for you?
+ - No, I mean, "And what about Yaml?"
+ - Oh, oh yeah. Uh.. Yaml for Ruby.
+php: |
+ array(
+ "What's Yaml?",
+ "It's for writing data structures in plain text.",
+ "And?",
+ "And what? That's not good enough for you?",
+ "No, I mean, \"And what about Yaml?\"",
+ "Oh, oh yeah. Uh.. Yaml for Ruby."
+ )
+---
+test: Indicators in Strings
+brief: >
+ Be careful using indicators in strings. In particular,
+ the comma, colon, and pound sign must be used carefully.
+yaml: |
+ the colon followed by space is an indicator: but is a string:right here
+ same for the pound sign: here we have it#in a string
+ the comma can, honestly, be used in most cases: [ but not in, inline collections ]
+php: |
+ array(
+ 'the colon followed by space is an indicator' => 'but is a string:right here',
+ 'same for the pound sign' => 'here we have it#in a string',
+ 'the comma can, honestly, be used in most cases' => array('but not in', 'inline collections')
+ )
+---
+test: Forcing Strings
+brief: >
+ Any YAML type can be forced into a string using the
+ explicit !!str method.
+yaml: |
+ date string: !!str 2001-08-01
+ number string: !!str 192
+php: |
+ array(
+ 'date string' => '2001-08-01',
+ 'number string' => '192'
+ )
+---
+test: Single-quoted Strings
+brief: >
+ You can also enclose your strings within single quotes,
+ which allows use of slashes, colons, and other indicators
+ freely. Inside single quotes, you can represent a single
+ quote in your string by using two single quotes next to
+ each other.
+yaml: |
+ all my favorite symbols: '#:!/%.)'
+ a few i hate: '&(*'
+ why do i hate them?: 'it''s very hard to explain'
+ entities: '£ me'
+php: |
+ array(
+ 'all my favorite symbols' => '#:!/%.)',
+ 'a few i hate' => '&(*',
+ 'why do i hate them?' => 'it\'s very hard to explain',
+ 'entities' => '£ me'
+ )
+---
+test: Double-quoted Strings
+brief: >
+ Enclosing strings in double quotes allows you
+ to use escapings to represent ASCII and
+ Unicode characters.
+yaml: |
+ i know where i want my line breaks: "one here\nand another here\n"
+php: |
+ array(
+ 'i know where i want my line breaks' => "one here\nand another here\n"
+ )
+---
+test: Multi-line Quoted Strings
+todo: true
+brief: >
+ Both single- and double-quoted strings may be
+ carried on to new lines in your YAML document.
+ They must be indented a step and indentation
+ is interpreted as a single space.
+yaml: |
+ i want a long string: "so i'm going to
+ let it go on and on to other lines
+ until i end it with a quote."
+php: |
+ array('i want a long string' => "so i'm going to ".
+ "let it go on and on to other lines ".
+ "until i end it with a quote."
+ )
+
+---
+test: Plain scalars
+todo: true
+brief: >
+ Unquoted strings may also span multiple lines, if they
+ are free of YAML space indicators and indented.
+yaml: |
+ - My little toe is broken in two places;
+ - I'm crazy to have skied this way;
+ - I'm not the craziest he's seen, since there was always the German guy
+ who skied for 3 hours on a broken shin bone (just below the kneecap);
+ - Nevertheless, second place is respectable, and he doesn't
+ recommend going for the record;
+ - He's going to put my foot in plaster for a month;
+ - This would impair my skiing ability somewhat for the
+ duration, as can be imagined.
+php: |
+ array(
+ "My little toe is broken in two places;",
+ "I'm crazy to have skied this way;",
+ "I'm not the craziest he's seen, since there was always ".
+ "the German guy who skied for 3 hours on a broken shin ".
+ "bone (just below the kneecap);",
+ "Nevertheless, second place is respectable, and he doesn't ".
+ "recommend going for the record;",
+ "He's going to put my foot in plaster for a month;",
+ "This would impair my skiing ability somewhat for the duration, ".
+ "as can be imagined."
+ )
+---
+test: 'Null'
+brief: >
+ You can use the tilde '~' character for a null value.
+yaml: |
+ name: Mr. Show
+ hosted by: Bob and David
+ date of next season: ~
+php: |
+ array(
+ 'name' => 'Mr. Show',
+ 'hosted by' => 'Bob and David',
+ 'date of next season' => null
+ )
+---
+test: Boolean
+brief: >
+ You can use 'true' and 'false' for Boolean values.
+yaml: |
+ Is Gus a Liar?: true
+ Do I rely on Gus for Sustenance?: false
+php: |
+ array(
+ 'Is Gus a Liar?' => true,
+ 'Do I rely on Gus for Sustenance?' => false
+ )
+---
+test: Integers
+dump_skip: true
+brief: >
+ An integer is a series of numbers, optionally
+ starting with a positive or negative sign. Integers
+ may also contain commas for readability.
+yaml: |
+ zero: 0
+ simple: 12
+php: |
+ array(
+ 'zero' => 0,
+ 'simple' => 12,
+ )
+---
+test: Positive Big Integer
+deprecated: true
+dump_skip: true
+brief: >
+ An integer is a series of numbers, optionally
+ starting with a positive or negative sign. Integers
+ may also contain commas for readability.
+yaml: |
+ one-thousand: 1,000
+php: |
+ array(
+ 'one-thousand' => 1000.0,
+ )
+---
+test: Negative Big Integer
+deprecated: true
+dump_skip: true
+brief: >
+ An integer is a series of numbers, optionally
+ starting with a positive or negative sign. Integers
+ may also contain commas for readability.
+yaml: |
+ negative one-thousand: -1,000
+php: |
+ array(
+ 'negative one-thousand' => -1000.0
+ )
+---
+test: Floats
+dump_skip: true
+brief: >
+ Floats are represented by numbers with decimals,
+ allowing for scientific notation, as well as
+ positive and negative infinity and "not a number."
+yaml: |
+ a simple float: 2.00
+ scientific notation: 1.00009e+3
+php: |
+ array(
+ 'a simple float' => 2.0,
+ 'scientific notation' => 1000.09
+ )
+---
+test: Larger Float
+dump_skip: true
+deprecated: true
+brief: >
+ Floats are represented by numbers with decimals,
+ allowing for scientific notation, as well as
+ positive and negative infinity and "not a number."
+yaml: |
+ larger float: 1,000.09
+php: |
+ array(
+ 'larger float' => 1000.09,
+ )
+---
+test: Time
+todo: true
+brief: >
+ You can represent timestamps by using
+ ISO8601 format, or a variation which
+ allows spaces between the date, time and
+ time zone.
+yaml: |
+ iso8601: 2001-12-14t21:59:43.10-05:00
+ space separated: 2001-12-14 21:59:43.10 -05:00
+php: |
+ array(
+ 'iso8601' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" ),
+ 'space separated' => mktime( 2001, 12, 14, 21, 59, 43, 0.10, "-05:00" )
+ )
+---
+test: Date
+todo: true
+brief: >
+ A date can be represented by its year,
+ month and day in ISO8601 order.
+yaml: |
+ 1976-07-31
+php: |
+ date( 1976, 7, 31 )
--- /dev/null
+--- %YAML:1.0
+test: Miscellaneous
+spec: 2.21
+yaml: |
+ true: true
+ false: false
+php: |
+ array(
+ 'true' => true,
+ 'false' => false,
+ )
--- /dev/null
+value: <?php echo 1 + 2 + 3 ?>
--- /dev/null
+test: outside double quotes
+yaml: |
+ \0 \ \a \b \n
+php: |
+ "\\0 \\ \\a \\b \\n"
+---
+test: null
+yaml: |
+ "\0"
+php: |
+ "\x00"
+---
+test: bell
+yaml: |
+ "\a"
+php: |
+ "\x07"
+---
+test: backspace
+yaml: |
+ "\b"
+php: |
+ "\x08"
+---
+test: horizontal tab (1)
+yaml: |
+ "\t"
+php: |
+ "\x09"
+---
+test: horizontal tab (2)
+yaml: |
+ "\ "
+php: |
+ "\x09"
+---
+test: line feed
+yaml: |
+ "\n"
+php: |
+ "\x0a"
+---
+test: vertical tab
+yaml: |
+ "\v"
+php: |
+ "\x0b"
+---
+test: form feed
+yaml: |
+ "\f"
+php: |
+ "\x0c"
+---
+test: carriage return
+yaml: |
+ "\r"
+php: |
+ "\x0d"
+---
+test: escape
+yaml: |
+ "\e"
+php: |
+ "\x1b"
+---
+test: space
+yaml: |
+ "\ "
+php: |
+ "\x20"
+---
+test: slash
+yaml: |
+ "\/"
+php: |
+ "\x2f"
+---
+test: backslash
+yaml: |
+ "\\"
+php: |
+ "\\"
+---
+test: Unicode next line
+yaml: |
+ "\N"
+php: |
+ "\xc2\x85"
+---
+test: Unicode non-breaking space
+yaml: |
+ "\_"
+php: |
+ "\xc2\xa0"
+---
+test: Unicode line separator
+yaml: |
+ "\L"
+php: |
+ "\xe2\x80\xa8"
+---
+test: Unicode paragraph separator
+yaml: |
+ "\P"
+php: |
+ "\xe2\x80\xa9"
+---
+test: Escaped 8-bit Unicode
+yaml: |
+ "\x42"
+php: |
+ "B"
+---
+test: Escaped 16-bit Unicode
+yaml: |
+ "\u20ac"
+php: |
+ "\xe2\x82\xac"
+---
+test: Escaped 32-bit Unicode
+yaml: |
+ "\U00000043"
+php: |
+ "C"
+---
+test: Example 5.13 Escaped Characters
+note: |
+ Currently throws an error parsing first line. Maybe Symfony Yaml doesn't support
+ continuation of string across multiple lines? Keeping test here but disabled.
+todo: true
+yaml: |
+ "Fun with \\
+ \" \a \b \e \f \
+ \n \r \t \v \0 \
+ \ \_ \N \L \P \
+ \x41 \u0041 \U00000041"
+php: |
+ "Fun with \x5C\n\x22 \x07 \x08 \x1B \x0C\n\x0A \x0D \x09 \x0B \x00\n\x20 \xA0 \x85 \xe2\x80\xa8 \xe2\x80\xa9\nA A A"
+---
+test: Double quotes with a line feed
+yaml: |
+ { double: "some value\n \"some quoted string\" and 'some single quotes one'" }
+php: |
+ array(
+ 'double' => "some value\n \"some quoted string\" and 'some single quotes one'"
+ )
+---
+test: Backslashes
+yaml: |
+ { single: 'foo\Var', no-quotes: foo\Var, double: "foo\\Var" }
+php: |
+ array(
+ 'single' => 'foo\Var', 'no-quotes' => 'foo\Var', 'double' => 'foo\Var'
+ )
--- /dev/null
+- escapedCharacters
+- sfComments
+- sfCompact
+- sfTests
+- sfObjects
+- sfMergeKey
+- sfQuotes
+- YtsAnchorAlias
+- YtsBasicTests
+- YtsBlockMapping
+- YtsDocumentSeparator
+- YtsErrorTests
+- YtsFlowCollections
+- YtsFoldedScalars
+- YtsNullsAndEmpties
+- YtsSpecificationExamples
+- YtsTypeTransfers
+- unindentedCollections
--- /dev/null
+--- %YAML:1.0
+test: Miscellaneous
+spec: 2.21
+yaml: |
+ true: true
+ false: false
+php: |
+ array(
+ 1 => true,
+ 0 => false,
+ )
+---
+test: Boolean
+yaml: |
+ false: used as key
+ logical: true
+ answer: false
+php: |
+ array(
+ false => 'used as key',
+ 'logical' => true,
+ 'answer' => false
+ )
--- /dev/null
+- legacyBooleanMappingKeys
+- legacyNullMappingKey
--- /dev/null
+--- %YAML:1.0
+test: Miscellaneous
+spec: 2.21
+yaml: |
+ null: ~
+php: |
+ array(
+ '' => null,
+ )
--- /dev/null
+data:
+ single_line: 'foo bar baz'
+ multi_line: |
+ foo
+ line with trailing spaces:
+
+ bar
+ integer like line:
+ 123456789
+ empty line:
+
+ baz
+ multi_line_with_carriage_return: "foo\nbar\r\nbaz"
+ nested_inlined_multi_line_string: { inlined_multi_line: "foo\nbar\r\nempty line:\n\nbaz" }
--- /dev/null
+data:
+ multi_line: |4
+ the first line has leading spaces
+ The second line does not.
--- /dev/null
+- booleanMappingKeys
+- numericMappingKeys
+- nullMappingKey
--- /dev/null
+- escapedCharacters
+- sfComments
+- sfCompact
+- sfTests
+- sfObjects
+- sfMergeKey
+- sfQuotes
+- YtsAnchorAlias
+- YtsBasicTests
+- YtsBlockMapping
+- YtsDocumentSeparator
+- YtsErrorTests
+- YtsFlowCollections
+- YtsFoldedScalars
+- YtsNullsAndEmpties
+- YtsSpecificationExamples
+- YtsTypeTransfers
+- unindentedCollections
--- /dev/null
+--- %YAML:1.0
+test: Miscellaneous
+spec: 2.21
+yaml: |
+ null: ~
+php: |
+ array(
+ 'null' => null,
+ )
--- /dev/null
+--- %YAML:1.0
+test: A sequence with an unordered array
+brief: >
+ A sequence with an unordered array
+yaml: |
+ 1: foo
+ 0: bar
+php: |
+ array(1 => 'foo', 0 => 'bar')
+---
+test: Integers as Map Keys
+brief: >
+ An integer can be used as dictionary key.
+yaml: |
+ 1: one
+ 2: two
+ 3: three
+php: |
+ array(
+ 1 => 'one',
+ 2 => 'two',
+ 3 => 'three'
+ )
--- /dev/null
+--- %YAML:1.0
+test: Comments at the end of a line
+brief: >
+ Comments at the end of a line
+yaml: |
+ ex1: "foo # bar"
+ ex2: "foo # bar" # comment
+ ex3: 'foo # bar' # comment
+ ex4: foo # comment
+ ex5: foo # comment with tab before
+ ex6: foo#foo # comment here
+ ex7: foo # ignore me # and me
+php: |
+ array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo', 'ex5' => 'foo', 'ex6' => 'foo#foo', 'ex7' => 'foo')
+---
+test: Comments in the middle
+brief: >
+ Comments in the middle
+yaml: |
+ foo:
+ # some comment
+ # some comment
+ bar: foo
+ # some comment
+ # some comment
+php: |
+ array('foo' => array('bar' => 'foo'))
+---
+test: Comments on a hash line
+brief: >
+ Comments on a hash line
+yaml: |
+ foo: # a comment
+ foo: bar # a comment
+php: |
+ array('foo' => array('foo' => 'bar'))
+---
+test: 'Value starting with a #'
+brief: >
+ 'Value starting with a #'
+yaml: |
+ foo: '#bar'
+php: |
+ array('foo' => '#bar')
+---
+test: Document starting with a comment and a separator
+brief: >
+ Commenting before document start is allowed
+yaml: |
+ # document comment
+ ---
+ foo: bar # a comment
+php: |
+ array('foo' => 'bar')
+---
+test: Comment containing a colon on a hash line
+brief: >
+ Comment containing a colon on a scalar line
+yaml: 'foo # comment: this is also part of the comment'
+php: |
+ 'foo'
+---
+test: 'Hash key containing a #'
+brief: >
+ 'Hash key containing a #'
+yaml: 'foo#bar: baz'
+php: |
+ array('foo#bar' => 'baz')
+---
+test: 'Hash key ending with a space and a #'
+brief: >
+ 'Hash key ending with a space and a #'
+yaml: |
+ 'foo #': baz
+php: |
+ array('foo #' => 'baz')
--- /dev/null
+--- %YAML:1.0
+test: Compact notation
+brief: |
+ Compact notation for sets of mappings with single element
+yaml: |
+ ---
+ # products purchased
+ - item : Super Hoop
+ - item : Basketball
+ quantity: 1
+ - item:
+ name: Big Shoes
+ nick: Biggies
+ quantity: 1
+php: |
+ array (
+ array (
+ 'item' => 'Super Hoop',
+ ),
+ array (
+ 'item' => 'Basketball',
+ 'quantity' => 1,
+ ),
+ array (
+ 'item' => array(
+ 'name' => 'Big Shoes',
+ 'nick' => 'Biggies'
+ ),
+ 'quantity' => 1
+ )
+ )
+---
+test: Compact notation combined with inline notation
+brief: |
+ Combinations of compact and inline notation are allowed
+yaml: |
+ ---
+ items:
+ - { item: Super Hoop, quantity: 1 }
+ - [ Basketball, Big Shoes ]
+php: |
+ array (
+ 'items' => array (
+ array (
+ 'item' => 'Super Hoop',
+ 'quantity' => 1,
+ ),
+ array (
+ 'Basketball',
+ 'Big Shoes'
+ )
+ )
+ )
+--- %YAML:1.0
+test: Compact notation
+brief: |
+ Compact notation for sets of mappings with single element
+yaml: |
+ ---
+ # products purchased
+ - item : Super Hoop
+ - item : Basketball
+ quantity: 1
+ - item:
+ name: Big Shoes
+ nick: Biggies
+ quantity: 1
+php: |
+ array (
+ array (
+ 'item' => 'Super Hoop',
+ ),
+ array (
+ 'item' => 'Basketball',
+ 'quantity' => 1,
+ ),
+ array (
+ 'item' => array(
+ 'name' => 'Big Shoes',
+ 'nick' => 'Biggies'
+ ),
+ 'quantity' => 1
+ )
+ )
+---
+test: Compact notation combined with inline notation
+brief: |
+ Combinations of compact and inline notation are allowed
+yaml: |
+ ---
+ items:
+ - { item: Super Hoop, quantity: 1 }
+ - [ Basketball, Big Shoes ]
+php: |
+ array (
+ 'items' => array (
+ array (
+ 'item' => 'Super Hoop',
+ 'quantity' => 1,
+ ),
+ array (
+ 'Basketball',
+ 'Big Shoes'
+ )
+ )
+ )
+--- %YAML:1.0
+test: Compact notation
+brief: |
+ Compact notation for sets of mappings with single element
+yaml: |
+ ---
+ # products purchased
+ - item : Super Hoop
+ - item : Basketball
+ quantity: 1
+ - item:
+ name: Big Shoes
+ nick: Biggies
+ quantity: 1
+php: |
+ array (
+ array (
+ 'item' => 'Super Hoop',
+ ),
+ array (
+ 'item' => 'Basketball',
+ 'quantity' => 1,
+ ),
+ array (
+ 'item' => array(
+ 'name' => 'Big Shoes',
+ 'nick' => 'Biggies'
+ ),
+ 'quantity' => 1
+ )
+ )
+---
+test: Compact notation combined with inline notation
+brief: |
+ Combinations of compact and inline notation are allowed
+yaml: |
+ ---
+ items:
+ - { item: Super Hoop, quantity: 1 }
+ - [ Basketball, Big Shoes ]
+php: |
+ array (
+ 'items' => array (
+ array (
+ 'item' => 'Super Hoop',
+ 'quantity' => 1,
+ ),
+ array (
+ 'Basketball',
+ 'Big Shoes'
+ )
+ )
+ )
--- /dev/null
+--- %YAML:1.0
+test: Simple In Place Substitution
+brief: >
+ If you want to reuse an entire alias, only overwriting what is different
+ you can use a << in place substitution. This is not part of the official
+ YAML spec, but a widely implemented extension. See the following URL for
+ details: http://yaml.org/type/merge.html
+yaml: |
+ foo: &foo
+ a: Steve
+ b: Clark
+ c: Brian
+ e: notnull
+ bar:
+ a: before
+ d: other
+ e: ~
+ <<: *foo
+ b: new
+ x: Oren
+ c:
+ foo: bar
+ bar: foo
+ bar_inline: {a: before, d: other, <<: *foo, b: new, x: Oren, c: { foo: bar, bar: foo}}
+ foo2: &foo2
+ a: Ballmer
+ ding: &dong [ fi, fei, fo, fam]
+ check:
+ <<:
+ - *foo
+ - *dong
+ isit: tested
+ head:
+ <<: [ *foo , *dong , *foo2 ]
+ taz: &taz
+ a: Steve
+ w:
+ p: 1234
+ nested:
+ <<: *taz
+ d: Doug
+ w: &nestedref
+ p: 12345
+ z:
+ <<: *nestedref
+ head_inline: &head_inline { <<: [ *foo , *dong , *foo2 ] }
+ recursive_inline: { <<: *head_inline, c: { <<: *foo2 } }
+php: |
+ array(
+ 'foo' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull'),
+ 'bar' => array('a' => 'before', 'd' => 'other', 'e' => null, 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'x' => 'Oren'),
+ 'bar_inline' => array('a' => 'before', 'd' => 'other', 'b' => 'new', 'c' => array('foo' => 'bar', 'bar' => 'foo'), 'e' => 'notnull', 'x' => 'Oren'),
+ 'foo2' => array('a' => 'Ballmer'),
+ 'ding' => array('fi', 'fei', 'fo', 'fam'),
+ 'check' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam', 'isit' => 'tested'),
+ 'head' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
+ 'taz' => array('a' => 'Steve', 'w' => array('p' => 1234)),
+ 'nested' => array('a' => 'Steve', 'w' => array('p' => 12345), 'd' => 'Doug', 'z' => array('p' => 12345)),
+ 'head_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => 'Brian', 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
+ 'recursive_inline' => array('a' => 'Steve', 'b' => 'Clark', 'c' => array('a' => 'Ballmer'), 'e' => 'notnull', 'fi', 'fei', 'fo', 'fam'),
+ )
--- /dev/null
+--- %YAML:1.0
+test: Objects
+brief: >
+ Comments at the end of a line
+yaml: |
+ ex1: "foo # bar"
+ ex2: "foo # bar" # comment
+ ex3: 'foo # bar' # comment
+ ex4: foo # comment
+php: |
+ array('ex1' => 'foo # bar', 'ex2' => 'foo # bar', 'ex3' => 'foo # bar', 'ex4' => 'foo')
--- /dev/null
+--- %YAML:1.0
+test: Some characters at the beginning of a string must be escaped
+brief: >
+ Some characters at the beginning of a string must be escaped
+yaml: |
+ foo: '| bar'
+php: |
+ array('foo' => '| bar')
+---
+test: A key can be a quoted string
+brief: >
+ A key can be a quoted string
+yaml: |
+ "foo1": bar
+ 'foo2': bar
+ "foo \" bar": bar
+ 'foo '' bar': bar
+ 'foo3: ': bar
+ "foo4: ": bar
+ foo5: { "foo \" bar: ": bar, 'foo '' bar: ': bar }
+php: |
+ array(
+ 'foo1' => 'bar',
+ 'foo2' => 'bar',
+ 'foo " bar' => 'bar',
+ 'foo \' bar' => 'bar',
+ 'foo3: ' => 'bar',
+ 'foo4: ' => 'bar',
+ 'foo5' => array(
+ 'foo " bar: ' => 'bar',
+ 'foo \' bar: ' => 'bar',
+ ),
+ )
--- /dev/null
+--- %YAML:1.0
+test: Multiple quoted string on one line
+brief: >
+ Multiple quoted string on one line
+yaml: |
+ stripped_title: { name: "foo bar", help: "bar foo" }
+php: |
+ array('stripped_title' => array('name' => 'foo bar', 'help' => 'bar foo'))
+---
+test: Empty sequence
+yaml: |
+ foo: [ ]
+php: |
+ array('foo' => array())
+---
+test: Empty value
+yaml: |
+ foo:
+php: |
+ array('foo' => null)
+---
+test: Inline string parsing
+brief: >
+ Inline string parsing
+yaml: |
+ test: ['complex: string', 'another [string]']
+php: |
+ array('test' => array('complex: string', 'another [string]'))
+---
+test: Boolean
+brief: >
+ Boolean
+yaml: |
+ - false
+ - true
+ - null
+ - ~
+ - 'false'
+ - 'true'
+ - 'null'
+ - '~'
+php: |
+ array(
+ false,
+ true,
+ null,
+ null,
+ 'false',
+ 'true',
+ 'null',
+ '~',
+ )
+---
+test: Empty lines in literal blocks
+brief: >
+ Empty lines in literal blocks
+yaml: |
+ foo:
+ bar: |
+ foo
+
+
+
+ bar
+php: |
+ array('foo' => array('bar' => "foo\n\n\n \nbar\n"))
+---
+test: Empty lines in folded blocks
+brief: >
+ Empty lines in folded blocks
+yaml: |
+ foo:
+ bar: >
+
+ foo
+
+
+ bar
+php: |
+ array('foo' => array('bar' => "\nfoo\n\nbar\n"))
+---
+test: IP addresses
+brief: >
+ IP addresses
+yaml: |
+ foo: 10.0.0.2
+php: |
+ array('foo' => '10.0.0.2')
+---
+test: A sequence with an embedded mapping
+brief: >
+ A sequence with an embedded mapping
+yaml: |
+ - foo
+ - bar: { bar: foo }
+php: |
+ array('foo', array('bar' => array('bar' => 'foo')))
+---
+test: Octal
+brief: as in spec example 2.19, octal value is converted
+yaml: |
+ foo: 0123
+php: |
+ array('foo' => 83)
+---
+test: Octal strings
+brief: Octal notation in a string must remain a string
+yaml: |
+ foo: "0123"
+php: |
+ array('foo' => '0123')
+---
+test: Octal strings
+brief: Octal notation in a string must remain a string
+yaml: |
+ foo: '0123'
+php: |
+ array('foo' => '0123')
+---
+test: Octal strings
+brief: Octal notation in a string must remain a string
+yaml: |
+ foo: |
+ 0123
+php: |
+ array('foo' => "0123\n")
+---
+test: Document as a simple hash
+brief: Document as a simple hash
+yaml: |
+ { foo: bar }
+php: |
+ array('foo' => 'bar')
+---
+test: Document as a simple array
+brief: Document as a simple array
+yaml: |
+ [ foo, bar ]
+php: |
+ array('foo', 'bar')
--- /dev/null
+--- %YAML:1.0
+test: Unindented collection
+brief: >
+ Unindented collection
+yaml: |
+ collection:
+ - item1
+ - item2
+ - item3
+php: |
+ array('collection' => array('item1', 'item2', 'item3'))
+---
+test: Nested unindented collection (two levels)
+brief: >
+ Nested unindented collection
+yaml: |
+ collection:
+ key:
+ - a
+ - b
+ - c
+php: |
+ array('collection' => array('key' => array('a', 'b', 'c')))
+---
+test: Nested unindented collection (three levels)
+brief: >
+ Nested unindented collection
+yaml: |
+ collection:
+ key:
+ subkey:
+ - one
+ - two
+ - three
+php: |
+ array('collection' => array('key' => array('subkey' => array('one', 'two', 'three'))))
+---
+test: Key/value after unindented collection (1)
+brief: >
+ Key/value after unindented collection (1)
+yaml: |
+ collection:
+ key:
+ - a
+ - b
+ - c
+ foo: bar
+php: |
+ array('collection' => array('key' => array('a', 'b', 'c')), 'foo' => 'bar')
+---
+test: Key/value after unindented collection (at the same level)
+brief: >
+ Key/value after unindented collection
+yaml: |
+ collection:
+ key:
+ - a
+ - b
+ - c
+ foo: bar
+php: |
+ array('collection' => array('key' => array('a', 'b', 'c'), 'foo' => 'bar'))
+---
+test: Shortcut Key after unindented collection
+brief: >
+ Key/value after unindented collection
+yaml: |
+ collection:
+ - key: foo
+ foo: bar
+php: |
+ array('collection' => array(array('key' => 'foo', 'foo' => 'bar')))
+---
+test: Shortcut Key after unindented collection with custom spaces
+brief: >
+ Key/value after unindented collection
+yaml: |
+ collection:
+ - key: foo
+ foo: bar
+php: |
+ array('collection' => array(array('key' => 'foo', 'foo' => 'bar')))
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Tests;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Yaml\Exception\ParseException;
+use Symfony\Component\Yaml\Inline;
+use Symfony\Component\Yaml\Yaml;
+
+class InlineTest extends TestCase
+{
+ protected function setUp()
+ {
+ Inline::initialize(0, 0);
+ }
+
+ /**
+ * @dataProvider getTestsForParse
+ */
+ public function testParse($yaml, $value, $flags = 0)
+ {
+ $this->assertSame($value, Inline::parse($yaml, $flags), sprintf('::parse() converts an inline YAML to a PHP structure (%s)', $yaml));
+ }
+
+ /**
+ * @dataProvider getTestsForParseWithMapObjects
+ */
+ public function testParseWithMapObjects($yaml, $value, $flags = Yaml::PARSE_OBJECT_FOR_MAP)
+ {
+ $actual = Inline::parse($yaml, $flags);
+
+ $this->assertSame(serialize($value), serialize($actual));
+ }
+
+ /**
+ * @dataProvider getTestsForParsePhpConstants
+ */
+ public function testParsePhpConstants($yaml, $value)
+ {
+ $actual = Inline::parse($yaml, Yaml::PARSE_CONSTANT);
+
+ $this->assertSame($value, $actual);
+ }
+
+ public function getTestsForParsePhpConstants()
+ {
+ return array(
+ array('!php/const Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT),
+ array('!php/const PHP_INT_MAX', PHP_INT_MAX),
+ array('[!php/const PHP_INT_MAX]', array(PHP_INT_MAX)),
+ array('{ foo: !php/const PHP_INT_MAX }', array('foo' => PHP_INT_MAX)),
+ array('!php/const NULL', null),
+ );
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage The constant "WRONG_CONSTANT" is not defined
+ */
+ public function testParsePhpConstantThrowsExceptionWhenUndefined()
+ {
+ Inline::parse('!php/const WRONG_CONSTANT', Yaml::PARSE_CONSTANT);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessageRegExp #The string "!php/const PHP_INT_MAX" could not be parsed as a constant.*#
+ */
+ public function testParsePhpConstantThrowsExceptionOnInvalidType()
+ {
+ Inline::parse('!php/const PHP_INT_MAX', Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 1.
+ * @dataProvider getTestsForParseLegacyPhpConstants
+ */
+ public function testDeprecatedConstantTag($yaml, $expectedValue)
+ {
+ $this->assertSame($expectedValue, Inline::parse($yaml, Yaml::PARSE_CONSTANT));
+ }
+
+ public function getTestsForParseLegacyPhpConstants()
+ {
+ return array(
+ array('!php/const:Symfony\Component\Yaml\Yaml::PARSE_CONSTANT', Yaml::PARSE_CONSTANT),
+ array('!php/const:PHP_INT_MAX', PHP_INT_MAX),
+ array('[!php/const:PHP_INT_MAX]', array(PHP_INT_MAX)),
+ array('{ foo: !php/const:PHP_INT_MAX }', array('foo' => PHP_INT_MAX)),
+ array('!php/const:NULL', null),
+ );
+ }
+
+ /**
+ * @group legacy
+ * @dataProvider getTestsForParseWithMapObjects
+ */
+ public function testParseWithMapObjectsPassingTrue($yaml, $value)
+ {
+ $actual = Inline::parse($yaml, false, false, true);
+
+ $this->assertSame(serialize($value), serialize($actual));
+ }
+
+ /**
+ * @dataProvider getTestsForDump
+ */
+ public function testDump($yaml, $value, $parseFlags = 0)
+ {
+ $this->assertEquals($yaml, Inline::dump($value), sprintf('::dump() converts a PHP structure to an inline YAML (%s)', $yaml));
+
+ $this->assertSame($value, Inline::parse(Inline::dump($value), $parseFlags), 'check consistency');
+ }
+
+ public function testDumpNumericValueWithLocale()
+ {
+ $locale = setlocale(LC_NUMERIC, 0);
+ if (false === $locale) {
+ $this->markTestSkipped('Your platform does not support locales.');
+ }
+
+ try {
+ $requiredLocales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252');
+ if (false === setlocale(LC_NUMERIC, $requiredLocales)) {
+ $this->markTestSkipped('Could not set any of required locales: '.implode(', ', $requiredLocales));
+ }
+
+ $this->assertEquals('1.2', Inline::dump(1.2));
+ $this->assertContains('fr', strtolower(setlocale(LC_NUMERIC, 0)));
+ } finally {
+ setlocale(LC_NUMERIC, $locale);
+ }
+ }
+
+ public function testHashStringsResemblingExponentialNumericsShouldNotBeChangedToINF()
+ {
+ $value = '686e444';
+
+ $this->assertSame($value, Inline::parse(Inline::dump($value)));
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage Found unknown escape character "\V".
+ */
+ public function testParseScalarWithNonEscapedBlackslashShouldThrowException()
+ {
+ Inline::parse('"Foo\Var"');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testParseScalarWithNonEscapedBlackslashAtTheEndShouldThrowException()
+ {
+ Inline::parse('"Foo\\"');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testParseScalarWithIncorrectlyQuotedStringShouldThrowException()
+ {
+ $value = "'don't do somthin' like that'";
+ Inline::parse($value);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testParseScalarWithIncorrectlyDoubleQuotedStringShouldThrowException()
+ {
+ $value = '"don"t do somthin" like that"';
+ Inline::parse($value);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testParseInvalidMappingKeyShouldThrowException()
+ {
+ $value = '{ "foo " bar": "bar" }';
+ Inline::parse($value);
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Using a colon after an unquoted mapping key that is not followed by an indication character (i.e. " ", ",", "[", "]", "{", "}") is deprecated since Symfony 3.2 and will throw a ParseException in 4.0 on line 1.
+ * throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
+ */
+ public function testParseMappingKeyWithColonNotFollowedBySpace()
+ {
+ Inline::parse('{1:""}');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testParseInvalidMappingShouldThrowException()
+ {
+ Inline::parse('[foo] bar');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testParseInvalidSequenceShouldThrowException()
+ {
+ Inline::parse('{ foo: bar } bar');
+ }
+
+ public function testParseScalarWithCorrectlyQuotedStringShouldReturnString()
+ {
+ $value = "'don''t do somthin'' like that'";
+ $expect = "don't do somthin' like that";
+
+ $this->assertSame($expect, Inline::parseScalar($value));
+ }
+
+ /**
+ * @dataProvider getDataForParseReferences
+ */
+ public function testParseReferences($yaml, $expected)
+ {
+ $this->assertSame($expected, Inline::parse($yaml, 0, array('var' => 'var-value')));
+ }
+
+ /**
+ * @group legacy
+ * @dataProvider getDataForParseReferences
+ */
+ public function testParseReferencesAsFifthArgument($yaml, $expected)
+ {
+ $this->assertSame($expected, Inline::parse($yaml, false, false, false, array('var' => 'var-value')));
+ }
+
+ public function getDataForParseReferences()
+ {
+ return array(
+ 'scalar' => array('*var', 'var-value'),
+ 'list' => array('[ *var ]', array('var-value')),
+ 'list-in-list' => array('[[ *var ]]', array(array('var-value'))),
+ 'map-in-list' => array('[ { key: *var } ]', array(array('key' => 'var-value'))),
+ 'embedded-mapping-in-list' => array('[ key: *var ]', array(array('key' => 'var-value'))),
+ 'map' => array('{ key: *var }', array('key' => 'var-value')),
+ 'list-in-map' => array('{ key: [*var] }', array('key' => array('var-value'))),
+ 'map-in-map' => array('{ foo: { bar: *var } }', array('foo' => array('bar' => 'var-value'))),
+ );
+ }
+
+ public function testParseMapReferenceInSequence()
+ {
+ $foo = array(
+ 'a' => 'Steve',
+ 'b' => 'Clark',
+ 'c' => 'Brian',
+ );
+ $this->assertSame(array($foo), Inline::parse('[*foo]', 0, array('foo' => $foo)));
+ }
+
+ /**
+ * @group legacy
+ */
+ public function testParseMapReferenceInSequenceAsFifthArgument()
+ {
+ $foo = array(
+ 'a' => 'Steve',
+ 'b' => 'Clark',
+ 'c' => 'Brian',
+ );
+ $this->assertSame(array($foo), Inline::parse('[*foo]', false, false, false, array('foo' => $foo)));
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage A reference must contain at least one character at line 1.
+ */
+ public function testParseUnquotedAsterisk()
+ {
+ Inline::parse('{ foo: * }');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage A reference must contain at least one character at line 1.
+ */
+ public function testParseUnquotedAsteriskFollowedByAComment()
+ {
+ Inline::parse('{ foo: * #foo }');
+ }
+
+ /**
+ * @dataProvider getReservedIndicators
+ */
+ public function testParseUnquotedScalarStartingWithReservedIndicator($indicator)
+ {
+ if (method_exists($this, 'expectExceptionMessage')) {
+ $this->expectException(ParseException::class);
+ $this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
+ } else {
+ $this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
+ }
+
+ Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
+ }
+
+ public function getReservedIndicators()
+ {
+ return array(array('@'), array('`'));
+ }
+
+ /**
+ * @dataProvider getScalarIndicators
+ */
+ public function testParseUnquotedScalarStartingWithScalarIndicator($indicator)
+ {
+ if (method_exists($this, 'expectExceptionMessage')) {
+ $this->expectException(ParseException::class);
+ $this->expectExceptionMessage(sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
+ } else {
+ $this->setExpectedException(ParseException::class, sprintf('cannot start a plain scalar; you need to quote the scalar at line 1 (near "%sfoo ").', $indicator));
+ }
+
+ Inline::parse(sprintf('{ foo: %sfoo }', $indicator));
+ }
+
+ public function getScalarIndicators()
+ {
+ return array(array('|'), array('>'));
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Not quoting the scalar "%bar " starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0 on line 1.
+ * throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
+ */
+ public function testParseUnquotedScalarStartingWithPercentCharacter()
+ {
+ Inline::parse('{ foo: %bar }');
+ }
+
+ /**
+ * @dataProvider getDataForIsHash
+ */
+ public function testIsHash($array, $expected)
+ {
+ $this->assertSame($expected, Inline::isHash($array));
+ }
+
+ public function getDataForIsHash()
+ {
+ return array(
+ array(array(), false),
+ array(array(1, 2, 3), false),
+ array(array(2 => 1, 1 => 2, 0 => 3), true),
+ array(array('foo' => 1, 'bar' => 2), true),
+ );
+ }
+
+ public function getTestsForParse()
+ {
+ return array(
+ array('', ''),
+ array('null', null),
+ array('false', false),
+ array('true', true),
+ array('12', 12),
+ array('-12', -12),
+ array('1_2', 12),
+ array('_12', '_12'),
+ array('12_', 12),
+ array('"quoted string"', 'quoted string'),
+ array("'quoted string'", 'quoted string'),
+ array('12.30e+02', 12.30e+02),
+ array('123.45_67', 123.4567),
+ array('0x4D2', 0x4D2),
+ array('0x_4_D_2_', 0x4D2),
+ array('02333', 02333),
+ array('0_2_3_3_3', 02333),
+ array('.Inf', -log(0)),
+ array('-.Inf', log(0)),
+ array("'686e444'", '686e444'),
+ array('686e444', 646e444),
+ array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
+ array('"foo\r\nbar"', "foo\r\nbar"),
+ array("'foo#bar'", 'foo#bar'),
+ array("'foo # bar'", 'foo # bar'),
+ array("'#cfcfcf'", '#cfcfcf'),
+ array('::form_base.html.twig', '::form_base.html.twig'),
+
+ // Pre-YAML-1.2 booleans
+ array("'y'", 'y'),
+ array("'n'", 'n'),
+ array("'yes'", 'yes'),
+ array("'no'", 'no'),
+ array("'on'", 'on'),
+ array("'off'", 'off'),
+
+ array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
+ array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
+ array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
+ array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
+ array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
+
+ array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
+ array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
+
+ // sequences
+ // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
+ array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
+ array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)),
+ array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
+
+ // mappings
+ array('{foo: bar,bar: foo,"false": false, "null": null,integer: 12}', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
+ array('{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
+ array('{foo: \'bar\', bar: \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
+ array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', array('foo' => 'bar', 'bar' => 'foo: bar')),
+ array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', array('foo\'' => 'bar', 'bar"' => 'foo: bar')),
+ array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', array('foo: ' => 'bar', 'bar: ' => 'foo: bar')),
+ array('{"foo:bar": "baz"}', array('foo:bar' => 'baz')),
+ array('{"foo":"bar"}', array('foo' => 'bar')),
+
+ // nested sequences and mappings
+ array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
+ array('[foo, {bar: foo}]', array('foo', array('bar' => 'foo'))),
+ array('{ foo: {bar: foo} }', array('foo' => array('bar' => 'foo'))),
+ array('{ foo: [bar, foo] }', array('foo' => array('bar', 'foo'))),
+ array('{ foo:{bar: foo} }', array('foo' => array('bar' => 'foo'))),
+ array('{ foo:[bar, foo] }', array('foo' => array('bar', 'foo'))),
+
+ array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))),
+
+ array('[{ foo: {bar: foo} }]', array(array('foo' => array('bar' => 'foo')))),
+
+ array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
+
+ array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
+
+ array('[foo, bar: { foo: bar }]', array('foo', '1' => array('bar' => array('foo' => 'bar')))),
+ array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
+ );
+ }
+
+ public function getTestsForParseWithMapObjects()
+ {
+ return array(
+ array('', ''),
+ array('null', null),
+ array('false', false),
+ array('true', true),
+ array('12', 12),
+ array('-12', -12),
+ array('"quoted string"', 'quoted string'),
+ array("'quoted string'", 'quoted string'),
+ array('12.30e+02', 12.30e+02),
+ array('0x4D2', 0x4D2),
+ array('02333', 02333),
+ array('.Inf', -log(0)),
+ array('-.Inf', log(0)),
+ array("'686e444'", '686e444'),
+ array('686e444', 646e444),
+ array('123456789123456789123456789123456789', '123456789123456789123456789123456789'),
+ array('"foo\r\nbar"', "foo\r\nbar"),
+ array("'foo#bar'", 'foo#bar'),
+ array("'foo # bar'", 'foo # bar'),
+ array("'#cfcfcf'", '#cfcfcf'),
+ array('::form_base.html.twig', '::form_base.html.twig'),
+
+ array('2007-10-30', gmmktime(0, 0, 0, 10, 30, 2007)),
+ array('2007-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 2007)),
+ array('2007-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 2007)),
+ array('1960-10-30 02:59:43 Z', gmmktime(2, 59, 43, 10, 30, 1960)),
+ array('1730-10-30T02:59:43Z', gmmktime(2, 59, 43, 10, 30, 1730)),
+
+ array('"a \\"string\\" with \'quoted strings inside\'"', 'a "string" with \'quoted strings inside\''),
+ array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
+
+ // sequences
+ // urls are no key value mapping. see #3609. Valid yaml "key: value" mappings require a space after the colon
+ array('[foo, http://urls.are/no/mappings, false, null, 12]', array('foo', 'http://urls.are/no/mappings', false, null, 12)),
+ array('[ foo , bar , false , null , 12 ]', array('foo', 'bar', false, null, 12)),
+ array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
+
+ // mappings
+ array('{foo: bar,bar: foo,"false": false,"null": null,integer: 12}', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), Yaml::PARSE_OBJECT_FOR_MAP),
+ array('{ foo : bar, bar : foo, "false" : false, "null" : null, integer : 12 }', (object) array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12), Yaml::PARSE_OBJECT_FOR_MAP),
+ array('{foo: \'bar\', bar: \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
+ array('{\'foo\': \'bar\', "bar": \'foo: bar\'}', (object) array('foo' => 'bar', 'bar' => 'foo: bar')),
+ array('{\'foo\'\'\': \'bar\', "bar\"": \'foo: bar\'}', (object) array('foo\'' => 'bar', 'bar"' => 'foo: bar')),
+ array('{\'foo: \': \'bar\', "bar: ": \'foo: bar\'}', (object) array('foo: ' => 'bar', 'bar: ' => 'foo: bar')),
+ array('{"foo:bar": "baz"}', (object) array('foo:bar' => 'baz')),
+ array('{"foo":"bar"}', (object) array('foo' => 'bar')),
+
+ // nested sequences and mappings
+ array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
+ array('[foo, {bar: foo}]', array('foo', (object) array('bar' => 'foo'))),
+ array('{ foo: {bar: foo} }', (object) array('foo' => (object) array('bar' => 'foo'))),
+ array('{ foo: [bar, foo] }', (object) array('foo' => array('bar', 'foo'))),
+
+ array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))),
+
+ array('[{ foo: {bar: foo} }]', array((object) array('foo' => (object) array('bar' => 'foo')))),
+
+ array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
+
+ array('[foo, {bar: foo, foo: [foo, {bar: foo}]}, [foo, {bar: foo}]]', array('foo', (object) array('bar' => 'foo', 'foo' => array('foo', (object) array('bar' => 'foo'))), array('foo', (object) array('bar' => 'foo')))),
+
+ array('[foo, bar: { foo: bar }]', array('foo', '1' => (object) array('bar' => (object) array('foo' => 'bar')))),
+ array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', (object) array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
+
+ array('{}', new \stdClass()),
+ array('{ foo : bar, bar : {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
+ array('{ foo : [], bar : {} }', (object) array('foo' => array(), 'bar' => new \stdClass())),
+ array('{foo: \'bar\', bar: {} }', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
+ array('{\'foo\': \'bar\', "bar": {}}', (object) array('foo' => 'bar', 'bar' => new \stdClass())),
+ array('{\'foo\': \'bar\', "bar": \'{}\'}', (object) array('foo' => 'bar', 'bar' => '{}')),
+
+ array('[foo, [{}, {}]]', array('foo', array(new \stdClass(), new \stdClass()))),
+ array('[foo, [[], {}]]', array('foo', array(array(), new \stdClass()))),
+ array('[foo, [[{}, {}], {}]]', array('foo', array(array(new \stdClass(), new \stdClass()), new \stdClass()))),
+ array('[foo, {bar: {}}]', array('foo', '1' => (object) array('bar' => new \stdClass()))),
+ );
+ }
+
+ public function getTestsForDump()
+ {
+ return array(
+ array('null', null),
+ array('false', false),
+ array('true', true),
+ array('12', 12),
+ array("'1_2'", '1_2'),
+ array('_12', '_12'),
+ array("'12_'", '12_'),
+ array("'quoted string'", 'quoted string'),
+ array('!!float 1230', 12.30e+02),
+ array('1234', 0x4D2),
+ array('1243', 02333),
+ array("'0x_4_D_2_'", '0x_4_D_2_'),
+ array("'0_2_3_3_3'", '0_2_3_3_3'),
+ array('.Inf', -log(0)),
+ array('-.Inf', log(0)),
+ array("'686e444'", '686e444'),
+ array('"foo\r\nbar"', "foo\r\nbar"),
+ array("'foo#bar'", 'foo#bar'),
+ array("'foo # bar'", 'foo # bar'),
+ array("'#cfcfcf'", '#cfcfcf'),
+
+ array("'a \"string\" with ''quoted strings inside'''", 'a "string" with \'quoted strings inside\''),
+
+ array("'-dash'", '-dash'),
+ array("'-'", '-'),
+
+ // Pre-YAML-1.2 booleans
+ array("'y'", 'y'),
+ array("'n'", 'n'),
+ array("'yes'", 'yes'),
+ array("'no'", 'no'),
+ array("'on'", 'on'),
+ array("'off'", 'off'),
+
+ // sequences
+ array('[foo, bar, false, null, 12]', array('foo', 'bar', false, null, 12)),
+ array('[\'foo,bar\', \'foo bar\']', array('foo,bar', 'foo bar')),
+
+ // mappings
+ array('{ foo: bar, bar: foo, \'false\': false, \'null\': null, integer: 12 }', array('foo' => 'bar', 'bar' => 'foo', 'false' => false, 'null' => null, 'integer' => 12)),
+ array('{ foo: bar, bar: \'foo: bar\' }', array('foo' => 'bar', 'bar' => 'foo: bar')),
+
+ // nested sequences and mappings
+ array('[foo, [bar, foo]]', array('foo', array('bar', 'foo'))),
+
+ array('[foo, [bar, [foo, [bar, foo]], foo]]', array('foo', array('bar', array('foo', array('bar', 'foo')), 'foo'))),
+
+ array('{ foo: { bar: foo } }', array('foo' => array('bar' => 'foo'))),
+
+ array('[foo, { bar: foo }]', array('foo', array('bar' => 'foo'))),
+
+ array('[foo, { bar: foo, foo: [foo, { bar: foo }] }, [foo, { bar: foo }]]', array('foo', array('bar' => 'foo', 'foo' => array('foo', array('bar' => 'foo'))), array('foo', array('bar' => 'foo')))),
+
+ array('[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', array('foo', '@foo.baz', array('%foo%' => 'foo is %foo%', 'bar' => '%foo%'), true, '@service_container')),
+
+ array('{ foo: { bar: { 1: 2, baz: 3 } } }', array('foo' => array('bar' => array(1 => 2, 'baz' => 3)))),
+ );
+ }
+
+ /**
+ * @dataProvider getTimestampTests
+ */
+ public function testParseTimestampAsUnixTimestampByDefault($yaml, $year, $month, $day, $hour, $minute, $second)
+ {
+ $this->assertSame(gmmktime($hour, $minute, $second, $month, $day, $year), Inline::parse($yaml));
+ }
+
+ /**
+ * @dataProvider getTimestampTests
+ */
+ public function testParseTimestampAsDateTimeObject($yaml, $year, $month, $day, $hour, $minute, $second, $timezone)
+ {
+ $expected = new \DateTime($yaml);
+ $expected->setTimeZone(new \DateTimeZone('UTC'));
+ $expected->setDate($year, $month, $day);
+
+ if (\PHP_VERSION_ID >= 70100) {
+ $expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
+ } else {
+ $expected->setTime($hour, $minute, $second);
+ }
+
+ $date = Inline::parse($yaml, Yaml::PARSE_DATETIME);
+ $this->assertEquals($expected, $date);
+ $this->assertSame($timezone, $date->format('O'));
+ }
+
+ public function getTimestampTests()
+ {
+ return array(
+ 'canonical' => array('2001-12-15T02:59:43.1Z', 2001, 12, 15, 2, 59, 43.1, '+0000'),
+ 'ISO-8601' => array('2001-12-15t21:59:43.10-05:00', 2001, 12, 16, 2, 59, 43.1, '-0500'),
+ 'spaced' => array('2001-12-15 21:59:43.10 -5', 2001, 12, 16, 2, 59, 43.1, '-0500'),
+ 'date' => array('2001-12-15', 2001, 12, 15, 0, 0, 0, '+0000'),
+ );
+ }
+
+ /**
+ * @dataProvider getTimestampTests
+ */
+ public function testParseNestedTimestampListAsDateTimeObject($yaml, $year, $month, $day, $hour, $minute, $second)
+ {
+ $expected = new \DateTime($yaml);
+ $expected->setTimeZone(new \DateTimeZone('UTC'));
+ $expected->setDate($year, $month, $day);
+ if (\PHP_VERSION_ID >= 70100) {
+ $expected->setTime($hour, $minute, $second, 1000000 * ($second - (int) $second));
+ } else {
+ $expected->setTime($hour, $minute, $second);
+ }
+
+ $expectedNested = array('nested' => array($expected));
+ $yamlNested = "{nested: [$yaml]}";
+
+ $this->assertEquals($expectedNested, Inline::parse($yamlNested, Yaml::PARSE_DATETIME));
+ }
+
+ /**
+ * @dataProvider getDateTimeDumpTests
+ */
+ public function testDumpDateTime($dateTime, $expected)
+ {
+ $this->assertSame($expected, Inline::dump($dateTime));
+ }
+
+ public function getDateTimeDumpTests()
+ {
+ $tests = array();
+
+ $dateTime = new \DateTime('2001-12-15 21:59:43', new \DateTimeZone('UTC'));
+ $tests['date-time-utc'] = array($dateTime, '2001-12-15T21:59:43+00:00');
+
+ $dateTime = new \DateTimeImmutable('2001-07-15 21:59:43', new \DateTimeZone('Europe/Berlin'));
+ $tests['immutable-date-time-europe-berlin'] = array($dateTime, '2001-07-15T21:59:43+02:00');
+
+ return $tests;
+ }
+
+ /**
+ * @dataProvider getBinaryData
+ */
+ public function testParseBinaryData($data)
+ {
+ $this->assertSame('Hello world', Inline::parse($data));
+ }
+
+ public function getBinaryData()
+ {
+ return array(
+ 'enclosed with double quotes' => array('!!binary "SGVsbG8gd29ybGQ="'),
+ 'enclosed with single quotes' => array("!!binary 'SGVsbG8gd29ybGQ='"),
+ 'containing spaces' => array('!!binary "SGVs bG8gd 29ybGQ="'),
+ );
+ }
+
+ /**
+ * @dataProvider getInvalidBinaryData
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testParseInvalidBinaryData($data, $expectedMessage)
+ {
+ if (method_exists($this, 'expectException')) {
+ $this->expectExceptionMessageRegExp($expectedMessage);
+ } else {
+ $this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
+ }
+
+ Inline::parse($data);
+ }
+
+ public function getInvalidBinaryData()
+ {
+ return array(
+ 'length not a multiple of four' => array('!!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'),
+ 'invalid characters' => array('!!binary "SGVsbG8#d29ybGQ="', '/The base64 encoded data \(.*\) contains invalid characters/'),
+ 'too many equals characters' => array('!!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'),
+ 'misplaced equals character' => array('!!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'),
+ );
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage Malformed inline YAML string: {this, is not, supported} at line 1.
+ */
+ public function testNotSupportedMissingValue()
+ {
+ Inline::parse('{this, is not, supported}');
+ }
+
+ public function testVeryLongQuotedStrings()
+ {
+ $longStringWithQuotes = str_repeat("x\r\n\\\"x\"x", 1000);
+
+ $yamlString = Inline::dump(array('longStringWithQuotes' => $longStringWithQuotes));
+ $arrayFromYaml = Inline::parse($yamlString);
+
+ $this->assertEquals($longStringWithQuotes, $arrayFromYaml['longStringWithQuotes']);
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Omitting the key of a mapping is deprecated and will throw a ParseException in 4.0 on line 1.
+ */
+ public function testOmittedMappingKeyIsParsedAsColon()
+ {
+ $this->assertSame(array(':' => 'foo'), Inline::parse('{: foo}'));
+ }
+
+ /**
+ * @dataProvider getTestsForNullValues
+ */
+ public function testParseMissingMappingValueAsNull($yaml, $expected)
+ {
+ $this->assertSame($expected, Inline::parse($yaml));
+ }
+
+ public function getTestsForNullValues()
+ {
+ return array(
+ 'null before closing curly brace' => array('{foo:}', array('foo' => null)),
+ 'null before comma' => array('{foo:, bar: baz}', array('foo' => null, 'bar' => 'baz')),
+ );
+ }
+
+ public function testTheEmptyStringIsAValidMappingKey()
+ {
+ $this->assertSame(array('' => 'foo'), Inline::parse('{ "": foo }'));
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 1.
+ * @dataProvider getNotPhpCompatibleMappingKeyData
+ */
+ public function testImplicitStringCastingOfMappingKeysIsDeprecated($yaml, $expected)
+ {
+ $this->assertSame($expected, Inline::parse($yaml));
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.
+ * @expectedDeprecation Implicit casting of incompatible mapping keys to strings is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 1.
+ * @dataProvider getNotPhpCompatibleMappingKeyData
+ */
+ public function testExplicitStringCastingOfMappingKeys($yaml, $expected)
+ {
+ $this->assertSame($expected, Yaml::parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS));
+ }
+
+ public function getNotPhpCompatibleMappingKeyData()
+ {
+ return array(
+ 'boolean-true' => array('{true: "foo"}', array('true' => 'foo')),
+ 'boolean-false' => array('{false: "foo"}', array('false' => 'foo')),
+ 'null' => array('{null: "foo"}', array('null' => 'foo')),
+ 'float' => array('{0.25: "foo"}', array('0.25' => 'foo')),
+ );
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Support for the !str tag is deprecated since Symfony 3.4. Use the !!str tag instead on line 1.
+ */
+ public function testDeprecatedStrTag()
+ {
+ $this->assertSame(array('foo' => 'bar'), Inline::parse('{ foo: !str bar }'));
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Tests;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Yaml\Exception\ParseException;
+
+class ParseExceptionTest extends TestCase
+{
+ public function testGetMessage()
+ {
+ $exception = new ParseException('Error message', 42, 'foo: bar', '/var/www/app/config.yml');
+ $message = 'Error message in "/var/www/app/config.yml" at line 42 (near "foo: bar")';
+
+ $this->assertEquals($message, $exception->getMessage());
+ }
+
+ public function testGetMessageWithUnicodeInFilename()
+ {
+ $exception = new ParseException('Error message', 42, 'foo: bar', 'äöü.yml');
+ $message = 'Error message in "äöü.yml" at line 42 (near "foo: bar")';
+
+ $this->assertEquals($message, $exception->getMessage());
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Tests;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Yaml\Exception\ParseException;
+use Symfony\Component\Yaml\Yaml;
+use Symfony\Component\Yaml\Parser;
+use Symfony\Component\Yaml\Tag\TaggedValue;
+
+class ParserTest extends TestCase
+{
+ /** @var Parser */
+ protected $parser;
+
+ protected function setUp()
+ {
+ $this->parser = new Parser();
+ }
+
+ protected function tearDown()
+ {
+ $this->parser = null;
+
+ chmod(__DIR__.'/Fixtures/not_readable.yml', 0644);
+ }
+
+ /**
+ * @dataProvider getDataFormSpecifications
+ */
+ public function testSpecifications($expected, $yaml, $comment, $deprecated)
+ {
+ $deprecations = array();
+
+ if ($deprecated) {
+ set_error_handler(function ($type, $msg) use (&$deprecations) {
+ if (E_USER_DEPRECATED !== $type) {
+ restore_error_handler();
+
+ if (class_exists('PHPUnit_Util_ErrorHandler')) {
+ return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
+ }
+
+ return call_user_func_array('PHPUnit\Util\ErrorHandler::handleError', func_get_args());
+ }
+
+ $deprecations[] = $msg;
+ });
+ }
+
+ $this->assertEquals($expected, var_export($this->parser->parse($yaml), true), $comment);
+
+ if ($deprecated) {
+ restore_error_handler();
+
+ $this->assertCount(1, $deprecations);
+ $this->assertContains(true !== $deprecated ? $deprecated : 'Using the comma as a group separator for floats is deprecated since Symfony 3.2 and will be removed in 4.0 on line 1.', $deprecations[0]);
+ }
+ }
+
+ public function getDataFormSpecifications()
+ {
+ return $this->loadTestsFromFixtureFiles('index.yml');
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecationMessage Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable
+ * @dataProvider getNonStringMappingKeysData
+ */
+ public function testNonStringMappingKeys($expected, $yaml, $comment)
+ {
+ $this->assertSame($expected, var_export($this->parser->parse($yaml, Yaml::PARSE_KEYS_AS_STRINGS), true), $comment);
+ }
+
+ public function getNonStringMappingKeysData()
+ {
+ return $this->loadTestsFromFixtureFiles('nonStringKeys.yml');
+ }
+
+ /**
+ * @group legacy
+ * @dataProvider getLegacyNonStringMappingKeysData
+ */
+ public function testLegacyNonStringMappingKeys($expected, $yaml, $comment)
+ {
+ $this->assertSame($expected, var_export($this->parser->parse($yaml), true), $comment);
+ }
+
+ public function getLegacyNonStringMappingKeysData()
+ {
+ return $this->loadTestsFromFixtureFiles('legacyNonStringKeys.yml');
+ }
+
+ public function testTabsInYaml()
+ {
+ // test tabs in YAML
+ $yamls = array(
+ "foo:\n bar",
+ "foo:\n bar",
+ "foo:\n bar",
+ "foo:\n bar",
+ );
+
+ foreach ($yamls as $yaml) {
+ try {
+ $content = $this->parser->parse($yaml);
+
+ $this->fail('YAML files must not contain tabs');
+ } catch (\Exception $e) {
+ $this->assertInstanceOf('\Exception', $e, 'YAML files must not contain tabs');
+ $this->assertEquals('A YAML file cannot contain tabs as indentation at line 2 (near "'.strpbrk($yaml, "\t").'").', $e->getMessage(), 'YAML files must not contain tabs');
+ }
+ }
+ }
+
+ public function testEndOfTheDocumentMarker()
+ {
+ $yaml = <<<'EOF'
+--- %YAML:1.0
+foo
+...
+EOF;
+
+ $this->assertEquals('foo', $this->parser->parse($yaml));
+ }
+
+ public function getBlockChompingTests()
+ {
+ $tests = array();
+
+ $yaml = <<<'EOF'
+foo: |-
+ one
+ two
+bar: |-
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo",
+ 'bar' => "one\ntwo",
+ );
+ $tests['Literal block chomping strip with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |-
+ one
+ two
+
+bar: |-
+ one
+ two
+
+
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo",
+ 'bar' => "one\ntwo",
+ );
+ $tests['Literal block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+{}
+
+
+EOF;
+ $expected = array();
+ $tests['Literal block chomping strip with multiple trailing newlines after a 1-liner'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |-
+ one
+ two
+bar: |-
+ one
+ two
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo",
+ 'bar' => "one\ntwo",
+ );
+ $tests['Literal block chomping strip without trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |
+ one
+ two
+bar: |
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo\n",
+ 'bar' => "one\ntwo\n",
+ );
+ $tests['Literal block chomping clip with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |
+ one
+ two
+
+bar: |
+ one
+ two
+
+
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo\n",
+ 'bar' => "one\ntwo\n",
+ );
+ $tests['Literal block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo:
+- bar: |
+ one
+
+ two
+EOF;
+ $expected = array(
+ 'foo' => array(
+ array(
+ 'bar' => "one\n\ntwo",
+ ),
+ ),
+ );
+ $tests['Literal block chomping clip with embedded blank line inside unindented collection'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |
+ one
+ two
+bar: |
+ one
+ two
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo\n",
+ 'bar' => "one\ntwo",
+ );
+ $tests['Literal block chomping clip without trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |+
+ one
+ two
+bar: |+
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo\n",
+ 'bar' => "one\ntwo\n",
+ );
+ $tests['Literal block chomping keep with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |+
+ one
+ two
+
+bar: |+
+ one
+ two
+
+
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo\n\n",
+ 'bar' => "one\ntwo\n\n",
+ );
+ $tests['Literal block chomping keep with multiple trailing newlines'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: |+
+ one
+ two
+bar: |+
+ one
+ two
+EOF;
+ $expected = array(
+ 'foo' => "one\ntwo\n",
+ 'bar' => "one\ntwo",
+ );
+ $tests['Literal block chomping keep without trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >-
+ one
+ two
+bar: >-
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => 'one two',
+ 'bar' => 'one two',
+ );
+ $tests['Folded block chomping strip with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >-
+ one
+ two
+
+bar: >-
+ one
+ two
+
+
+EOF;
+ $expected = array(
+ 'foo' => 'one two',
+ 'bar' => 'one two',
+ );
+ $tests['Folded block chomping strip with multiple trailing newlines'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >-
+ one
+ two
+bar: >-
+ one
+ two
+EOF;
+ $expected = array(
+ 'foo' => 'one two',
+ 'bar' => 'one two',
+ );
+ $tests['Folded block chomping strip without trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >
+ one
+ two
+bar: >
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => "one two\n",
+ 'bar' => "one two\n",
+ );
+ $tests['Folded block chomping clip with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >
+ one
+ two
+
+bar: >
+ one
+ two
+
+
+EOF;
+ $expected = array(
+ 'foo' => "one two\n",
+ 'bar' => "one two\n",
+ );
+ $tests['Folded block chomping clip with multiple trailing newlines'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >
+ one
+ two
+bar: >
+ one
+ two
+EOF;
+ $expected = array(
+ 'foo' => "one two\n",
+ 'bar' => 'one two',
+ );
+ $tests['Folded block chomping clip without trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >+
+ one
+ two
+bar: >+
+ one
+ two
+
+EOF;
+ $expected = array(
+ 'foo' => "one two\n",
+ 'bar' => "one two\n",
+ );
+ $tests['Folded block chomping keep with single trailing newline'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >+
+ one
+ two
+
+bar: >+
+ one
+ two
+
+
+EOF;
+ $expected = array(
+ 'foo' => "one two\n\n",
+ 'bar' => "one two\n\n",
+ );
+ $tests['Folded block chomping keep with multiple trailing newlines'] = array($expected, $yaml);
+
+ $yaml = <<<'EOF'
+foo: >+
+ one
+ two
+bar: >+
+ one
+ two
+EOF;
+ $expected = array(
+ 'foo' => "one two\n",
+ 'bar' => 'one two',
+ );
+ $tests['Folded block chomping keep without trailing newline'] = array($expected, $yaml);
+
+ return $tests;
+ }
+
+ /**
+ * @dataProvider getBlockChompingTests
+ */
+ public function testBlockChomping($expected, $yaml)
+ {
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ /**
+ * Regression test for issue #7989.
+ *
+ * @see https://github.com/symfony/symfony/issues/7989
+ */
+ public function testBlockLiteralWithLeadingNewlines()
+ {
+ $yaml = <<<'EOF'
+foo: |-
+
+
+ bar
+
+EOF;
+ $expected = array(
+ 'foo' => "\n\nbar",
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ public function testObjectSupportEnabled()
+ {
+ $input = <<<'EOF'
+foo: !php/object O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
+bar: 1
+EOF;
+ $this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, Yaml::PARSE_OBJECT), '->parse() is able to parse objects');
+ }
+
+ /**
+ * @group legacy
+ */
+ public function testObjectSupportEnabledPassingTrue()
+ {
+ $input = <<<'EOF'
+foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
+bar: 1
+EOF;
+ $this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($input, false, true), '->parse() is able to parse objects');
+ }
+
+ /**
+ * @group legacy
+ * @dataProvider deprecatedObjectValueProvider
+ */
+ public function testObjectSupportEnabledWithDeprecatedTag($yaml)
+ {
+ $this->assertEquals(array('foo' => new B(), 'bar' => 1), $this->parser->parse($yaml, Yaml::PARSE_OBJECT), '->parse() is able to parse objects');
+ }
+
+ public function deprecatedObjectValueProvider()
+ {
+ return array(
+ array(
+ <<<YAML
+foo: !!php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
+bar: 1
+YAML
+ ),
+ array(
+ <<<YAML
+foo: !php/object:O:30:"Symfony\Component\Yaml\Tests\B":1:{s:1:"b";s:3:"foo";}
+bar: 1
+YAML
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider invalidDumpedObjectProvider
+ */
+ public function testObjectSupportDisabledButNoExceptions($input)
+ {
+ $this->assertEquals(array('foo' => null, 'bar' => 1), $this->parser->parse($input), '->parse() does not parse objects');
+ }
+
+ /**
+ * @dataProvider getObjectForMapTests
+ */
+ public function testObjectForMap($yaml, $expected)
+ {
+ $flags = Yaml::PARSE_OBJECT_FOR_MAP;
+
+ $this->assertEquals($expected, $this->parser->parse($yaml, $flags));
+ }
+
+ /**
+ * @group legacy
+ * @dataProvider getObjectForMapTests
+ */
+ public function testObjectForMapEnabledWithMappingUsingBooleanToggles($yaml, $expected)
+ {
+ $this->assertEquals($expected, $this->parser->parse($yaml, false, false, true));
+ }
+
+ public function getObjectForMapTests()
+ {
+ $tests = array();
+
+ $yaml = <<<'EOF'
+foo:
+ fiz: [cat]
+EOF;
+ $expected = new \stdClass();
+ $expected->foo = new \stdClass();
+ $expected->foo->fiz = array('cat');
+ $tests['mapping'] = array($yaml, $expected);
+
+ $yaml = '{ "foo": "bar", "fiz": "cat" }';
+ $expected = new \stdClass();
+ $expected->foo = 'bar';
+ $expected->fiz = 'cat';
+ $tests['inline-mapping'] = array($yaml, $expected);
+
+ $yaml = "foo: bar\nbaz: foobar";
+ $expected = new \stdClass();
+ $expected->foo = 'bar';
+ $expected->baz = 'foobar';
+ $tests['object-for-map-is-applied-after-parsing'] = array($yaml, $expected);
+
+ $yaml = <<<'EOT'
+array:
+ - key: one
+ - key: two
+EOT;
+ $expected = new \stdClass();
+ $expected->array = array();
+ $expected->array[0] = new \stdClass();
+ $expected->array[0]->key = 'one';
+ $expected->array[1] = new \stdClass();
+ $expected->array[1]->key = 'two';
+ $tests['nest-map-and-sequence'] = array($yaml, $expected);
+
+ $yaml = <<<'YAML'
+map:
+ 1: one
+ 2: two
+YAML;
+ $expected = new \stdClass();
+ $expected->map = new \stdClass();
+ $expected->map->{1} = 'one';
+ $expected->map->{2} = 'two';
+ $tests['numeric-keys'] = array($yaml, $expected);
+
+ $yaml = <<<'YAML'
+map:
+ '0': one
+ '1': two
+YAML;
+ $expected = new \stdClass();
+ $expected->map = new \stdClass();
+ $expected->map->{0} = 'one';
+ $expected->map->{1} = 'two';
+ $tests['zero-indexed-numeric-keys'] = array($yaml, $expected);
+
+ return $tests;
+ }
+
+ /**
+ * @dataProvider invalidDumpedObjectProvider
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testObjectsSupportDisabledWithExceptions($yaml)
+ {
+ $this->parser->parse($yaml, Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
+ }
+
+ public function testCanParseContentWithTrailingSpaces()
+ {
+ $yaml = "items: \n foo: bar";
+
+ $expected = array(
+ 'items' => array('foo' => 'bar'),
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ /**
+ * @group legacy
+ * @dataProvider invalidDumpedObjectProvider
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testObjectsSupportDisabledWithExceptionsUsingBooleanToggles($yaml)
+ {
+ $this->parser->parse($yaml, true);
+ }
+
+ public function invalidDumpedObjectProvider()
+ {
+ $yamlTag = <<<'EOF'
+foo: !!php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
+bar: 1
+EOF;
+ $localTag = <<<'EOF'
+foo: !php/object:O:30:"Symfony\Tests\Component\Yaml\B":1:{s:1:"b";s:3:"foo";}
+bar: 1
+EOF;
+
+ return array(
+ 'yaml-tag' => array($yamlTag),
+ 'local-tag' => array($localTag),
+ );
+ }
+
+ /**
+ * @requires extension iconv
+ */
+ public function testNonUtf8Exception()
+ {
+ $yamls = array(
+ iconv('UTF-8', 'ISO-8859-1', "foo: 'äöüß'"),
+ iconv('UTF-8', 'ISO-8859-15', "euro: '€'"),
+ iconv('UTF-8', 'CP1252', "cp1252: '©ÉÇáñ'"),
+ );
+
+ foreach ($yamls as $yaml) {
+ try {
+ $this->parser->parse($yaml);
+
+ $this->fail('charsets other than UTF-8 are rejected.');
+ } catch (\Exception $e) {
+ $this->assertInstanceOf('Symfony\Component\Yaml\Exception\ParseException', $e, 'charsets other than UTF-8 are rejected.');
+ }
+ }
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testUnindentedCollectionException()
+ {
+ $yaml = <<<'EOF'
+
+collection:
+-item1
+-item2
+-item3
+
+EOF;
+
+ $this->parser->parse($yaml);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testShortcutKeyUnindentedCollectionException()
+ {
+ $yaml = <<<'EOF'
+
+collection:
+- key: foo
+ foo: bar
+
+EOF;
+
+ $this->parser->parse($yaml);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessageRegExp /^Multiple documents are not supported.+/
+ */
+ public function testMultipleDocumentsNotSupportedException()
+ {
+ Yaml::parse(<<<'EOL'
+# Ranking of 1998 home runs
+---
+- Mark McGwire
+- Sammy Sosa
+- Ken Griffey
+
+# Team ranking
+---
+- Chicago Cubs
+- St Louis Cardinals
+EOL
+ );
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testSequenceInAMapping()
+ {
+ Yaml::parse(<<<'EOF'
+yaml:
+ hash: me
+ - array stuff
+EOF
+ );
+ }
+
+ public function testSequenceInMappingStartedBySingleDashLine()
+ {
+ $yaml = <<<'EOT'
+a:
+-
+ b:
+ -
+ bar: baz
+- foo
+d: e
+EOT;
+ $expected = array(
+ 'a' => array(
+ array(
+ 'b' => array(
+ array(
+ 'bar' => 'baz',
+ ),
+ ),
+ ),
+ 'foo',
+ ),
+ 'd' => 'e',
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ public function testSequenceFollowedByCommentEmbeddedInMapping()
+ {
+ $yaml = <<<'EOT'
+a:
+ b:
+ - c
+# comment
+ d: e
+EOT;
+ $expected = array(
+ 'a' => array(
+ 'b' => array('c'),
+ 'd' => 'e',
+ ),
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ public function testNonStringFollowedByCommentEmbeddedInMapping()
+ {
+ $yaml = <<<'EOT'
+a:
+ b:
+ {}
+# comment
+ d:
+ 1.1
+# another comment
+EOT;
+ $expected = array(
+ 'a' => array(
+ 'b' => array(),
+ 'd' => 1.1,
+ ),
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ public function testMultiLineStringLastResortParsing()
+ {
+ $yaml = <<<'EOT'
+test:
+ You can have things that don't look like strings here
+ true
+ yes you can
+EOT;
+ $expected = array(
+ 'test' => 'You can have things that don\'t look like strings here true yes you can',
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testMappingInASequence()
+ {
+ Yaml::parse(<<<'EOF'
+yaml:
+ - array stuff
+ hash: me
+EOF
+ );
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage missing colon
+ */
+ public function testScalarInSequence()
+ {
+ Yaml::parse(<<<'EOF'
+foo:
+ - bar
+"missing colon"
+ foo: bar
+EOF
+ );
+ }
+
+ /**
+ * > It is an error for two equal keys to appear in the same mapping node.
+ * > In such a case the YAML processor may continue, ignoring the second
+ * > `key: value` pair and issuing an appropriate warning. This strategy
+ * > preserves a consistent information model for one-pass and random access
+ * > applications.
+ *
+ * @see http://yaml.org/spec/1.2/spec.html#id2759572
+ * @see http://yaml.org/spec/1.1/#id932806
+ * @group legacy
+ */
+ public function testMappingDuplicateKeyBlock()
+ {
+ $input = <<<'EOD'
+parent:
+ child: first
+ child: duplicate
+parent:
+ child: duplicate
+ child: duplicate
+EOD;
+ $expected = array(
+ 'parent' => array(
+ 'child' => 'first',
+ ),
+ );
+ $this->assertSame($expected, Yaml::parse($input));
+ }
+
+ /**
+ * @group legacy
+ */
+ public function testMappingDuplicateKeyFlow()
+ {
+ $input = <<<'EOD'
+parent: { child: first, child: duplicate }
+parent: { child: duplicate, child: duplicate }
+EOD;
+ $expected = array(
+ 'parent' => array(
+ 'child' => 'first',
+ ),
+ );
+ $this->assertSame($expected, Yaml::parse($input));
+ }
+
+ /**
+ * @group legacy
+ * @dataProvider getParseExceptionOnDuplicateData
+ * @expectedDeprecation Duplicate key "%s" detected whilst parsing YAML. Silent handling of duplicate mapping keys in YAML is deprecated %s and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line %d.
+ * throws \Symfony\Component\Yaml\Exception\ParseException in 4.0
+ */
+ public function testParseExceptionOnDuplicate($input, $duplicateKey, $lineNumber)
+ {
+ Yaml::parse($input);
+ }
+
+ public function getParseExceptionOnDuplicateData()
+ {
+ $tests = array();
+
+ $yaml = <<<EOD
+parent: { child: first, child: duplicate }
+EOD;
+ $tests[] = array($yaml, 'child', 1);
+
+ $yaml = <<<EOD
+parent:
+ child: first,
+ child: duplicate
+EOD;
+ $tests[] = array($yaml, 'child', 3);
+
+ $yaml = <<<EOD
+parent: { child: foo }
+parent: { child: bar }
+EOD;
+ $tests[] = array($yaml, 'parent', 2);
+
+ $yaml = <<<EOD
+parent: { child_mapping: { value: bar}, child_mapping: { value: bar} }
+EOD;
+ $tests[] = array($yaml, 'child_mapping', 1);
+
+ $yaml = <<<EOD
+parent:
+ child_mapping:
+ value: bar
+ child_mapping:
+ value: bar
+EOD;
+ $tests[] = array($yaml, 'child_mapping', 4);
+
+ $yaml = <<<EOD
+parent: { child_sequence: ['key1', 'key2', 'key3'], child_sequence: ['key1', 'key2', 'key3'] }
+EOD;
+ $tests[] = array($yaml, 'child_sequence', 1);
+
+ $yaml = <<<EOD
+parent:
+ child_sequence:
+ - key1
+ - key2
+ - key3
+ child_sequence:
+ - key1
+ - key2
+ - key3
+EOD;
+ $tests[] = array($yaml, 'child_sequence', 6);
+
+ return $tests;
+ }
+
+ public function testEmptyValue()
+ {
+ $input = <<<'EOF'
+hash:
+EOF;
+
+ $this->assertEquals(array('hash' => null), Yaml::parse($input));
+ }
+
+ public function testCommentAtTheRootIndent()
+ {
+ $this->assertEquals(array(
+ 'services' => array(
+ 'app.foo_service' => array(
+ 'class' => 'Foo',
+ ),
+ 'app/bar_service' => array(
+ 'class' => 'Bar',
+ ),
+ ),
+ ), Yaml::parse(<<<'EOF'
+# comment 1
+services:
+# comment 2
+ # comment 3
+ app.foo_service:
+ class: Foo
+# comment 4
+ # comment 5
+ app/bar_service:
+ class: Bar
+EOF
+ ));
+ }
+
+ public function testStringBlockWithComments()
+ {
+ $this->assertEquals(array('content' => <<<'EOT'
+# comment 1
+header
+
+ # comment 2
+ <body>
+ <h1>title</h1>
+ </body>
+
+footer # comment3
+EOT
+ ), Yaml::parse(<<<'EOF'
+content: |
+ # comment 1
+ header
+
+ # comment 2
+ <body>
+ <h1>title</h1>
+ </body>
+
+ footer # comment3
+EOF
+ ));
+ }
+
+ public function testFoldedStringBlockWithComments()
+ {
+ $this->assertEquals(array(array('content' => <<<'EOT'
+# comment 1
+header
+
+ # comment 2
+ <body>
+ <h1>title</h1>
+ </body>
+
+footer # comment3
+EOT
+ )), Yaml::parse(<<<'EOF'
+-
+ content: |
+ # comment 1
+ header
+
+ # comment 2
+ <body>
+ <h1>title</h1>
+ </body>
+
+ footer # comment3
+EOF
+ ));
+ }
+
+ public function testNestedFoldedStringBlockWithComments()
+ {
+ $this->assertEquals(array(array(
+ 'title' => 'some title',
+ 'content' => <<<'EOT'
+# comment 1
+header
+
+ # comment 2
+ <body>
+ <h1>title</h1>
+ </body>
+
+footer # comment3
+EOT
+ )), Yaml::parse(<<<'EOF'
+-
+ title: some title
+ content: |
+ # comment 1
+ header
+
+ # comment 2
+ <body>
+ <h1>title</h1>
+ </body>
+
+ footer # comment3
+EOF
+ ));
+ }
+
+ public function testReferenceResolvingInInlineStrings()
+ {
+ $this->assertEquals(array(
+ 'var' => 'var-value',
+ 'scalar' => 'var-value',
+ 'list' => array('var-value'),
+ 'list_in_list' => array(array('var-value')),
+ 'map_in_list' => array(array('key' => 'var-value')),
+ 'embedded_mapping' => array(array('key' => 'var-value')),
+ 'map' => array('key' => 'var-value'),
+ 'list_in_map' => array('key' => array('var-value')),
+ 'map_in_map' => array('foo' => array('bar' => 'var-value')),
+ ), Yaml::parse(<<<'EOF'
+var: &var var-value
+scalar: *var
+list: [ *var ]
+list_in_list: [[ *var ]]
+map_in_list: [ { key: *var } ]
+embedded_mapping: [ key: *var ]
+map: { key: *var }
+list_in_map: { key: [*var] }
+map_in_map: { foo: { bar: *var } }
+EOF
+ ));
+ }
+
+ public function testYamlDirective()
+ {
+ $yaml = <<<'EOF'
+%YAML 1.2
+---
+foo: 1
+bar: 2
+EOF;
+ $this->assertEquals(array('foo' => 1, 'bar' => 2), $this->parser->parse($yaml));
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Implicit casting of numeric key to string is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 2.
+ */
+ public function testFloatKeys()
+ {
+ $yaml = <<<'EOF'
+foo:
+ 1.2: "bar"
+ 1.3: "baz"
+EOF;
+
+ $expected = array(
+ 'foo' => array(
+ '1.2' => 'bar',
+ '1.3' => 'baz',
+ ),
+ );
+
+ $this->assertEquals($expected, $this->parser->parse($yaml));
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Implicit casting of non-string key to string is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0. Quote your evaluable mapping keys instead on line 1.
+ */
+ public function testBooleanKeys()
+ {
+ $yaml = <<<'EOF'
+true: foo
+false: bar
+EOF;
+
+ $expected = array(
+ 1 => 'foo',
+ 0 => 'bar',
+ );
+
+ $this->assertEquals($expected, $this->parser->parse($yaml));
+ }
+
+ public function testExplicitStringCasting()
+ {
+ $yaml = <<<'EOF'
+'1.2': "bar"
+!!str 1.3: "baz"
+
+'true': foo
+!!str false: bar
+
+!!str null: 'null'
+'~': 'null'
+EOF;
+
+ $expected = array(
+ '1.2' => 'bar',
+ '1.3' => 'baz',
+ 'true' => 'foo',
+ 'false' => 'bar',
+ 'null' => 'null',
+ '~' => 'null',
+ );
+
+ $this->assertEquals($expected, $this->parser->parse($yaml));
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage A colon cannot be used in an unquoted mapping value
+ */
+ public function testColonInMappingValueException()
+ {
+ $yaml = <<<'EOF'
+foo: bar: baz
+EOF;
+
+ $this->parser->parse($yaml);
+ }
+
+ public function testColonInMappingValueExceptionNotTriggeredByColonInComment()
+ {
+ $yaml = <<<'EOT'
+foo:
+ bar: foobar # Note: a comment after a colon
+EOT;
+
+ $this->assertSame(array('foo' => array('bar' => 'foobar')), $this->parser->parse($yaml));
+ }
+
+ /**
+ * @dataProvider getCommentLikeStringInScalarBlockData
+ */
+ public function testCommentLikeStringsAreNotStrippedInBlockScalars($yaml, $expectedParserResult)
+ {
+ $this->assertSame($expectedParserResult, $this->parser->parse($yaml));
+ }
+
+ public function getCommentLikeStringInScalarBlockData()
+ {
+ $tests = array();
+
+ $yaml = <<<'EOT'
+pages:
+ -
+ title: some title
+ content: |
+ # comment 1
+ header
+
+ # comment 2
+ <body>
+ <h1>title</h1>
+ </body>
+
+ footer # comment3
+EOT;
+ $expected = array(
+ 'pages' => array(
+ array(
+ 'title' => 'some title',
+ 'content' => <<<'EOT'
+# comment 1
+header
+
+ # comment 2
+ <body>
+ <h1>title</h1>
+ </body>
+
+footer # comment3
+EOT
+ ,
+ ),
+ ),
+ );
+ $tests[] = array($yaml, $expected);
+
+ $yaml = <<<'EOT'
+test: |
+ foo
+ # bar
+ baz
+collection:
+ - one: |
+ foo
+ # bar
+ baz
+ - two: |
+ foo
+ # bar
+ baz
+EOT;
+ $expected = array(
+ 'test' => <<<'EOT'
+foo
+# bar
+baz
+
+EOT
+ ,
+ 'collection' => array(
+ array(
+ 'one' => <<<'EOT'
+foo
+# bar
+baz
+
+EOT
+ ,
+ ),
+ array(
+ 'two' => <<<'EOT'
+foo
+# bar
+baz
+EOT
+ ,
+ ),
+ ),
+ );
+ $tests[] = array($yaml, $expected);
+
+ $yaml = <<<'EOT'
+foo:
+ bar:
+ scalar-block: >
+ line1
+ line2>
+ baz:
+# comment
+ foobar: ~
+EOT;
+ $expected = array(
+ 'foo' => array(
+ 'bar' => array(
+ 'scalar-block' => "line1 line2>\n",
+ ),
+ 'baz' => array(
+ 'foobar' => null,
+ ),
+ ),
+ );
+ $tests[] = array($yaml, $expected);
+
+ $yaml = <<<'EOT'
+a:
+ b: hello
+# c: |
+# first row
+# second row
+ d: hello
+EOT;
+ $expected = array(
+ 'a' => array(
+ 'b' => 'hello',
+ 'd' => 'hello',
+ ),
+ );
+ $tests[] = array($yaml, $expected);
+
+ return $tests;
+ }
+
+ public function testBlankLinesAreParsedAsNewLinesInFoldedBlocks()
+ {
+ $yaml = <<<'EOT'
+test: >
+ <h2>A heading</h2>
+
+ <ul>
+ <li>a list</li>
+ <li>may be a good example</li>
+ </ul>
+EOT;
+
+ $this->assertSame(
+ array(
+ 'test' => <<<'EOT'
+<h2>A heading</h2>
+<ul> <li>a list</li> <li>may be a good example</li> </ul>
+EOT
+ ,
+ ),
+ $this->parser->parse($yaml)
+ );
+ }
+
+ public function testAdditionallyIndentedLinesAreParsedAsNewLinesInFoldedBlocks()
+ {
+ $yaml = <<<'EOT'
+test: >
+ <h2>A heading</h2>
+
+ <ul>
+ <li>a list</li>
+ <li>may be a good example</li>
+ </ul>
+EOT;
+
+ $this->assertSame(
+ array(
+ 'test' => <<<'EOT'
+<h2>A heading</h2>
+<ul>
+ <li>a list</li>
+ <li>may be a good example</li>
+</ul>
+EOT
+ ,
+ ),
+ $this->parser->parse($yaml)
+ );
+ }
+
+ /**
+ * @dataProvider getBinaryData
+ */
+ public function testParseBinaryData($data)
+ {
+ $this->assertSame(array('data' => 'Hello world'), $this->parser->parse($data));
+ }
+
+ public function getBinaryData()
+ {
+ return array(
+ 'enclosed with double quotes' => array('data: !!binary "SGVsbG8gd29ybGQ="'),
+ 'enclosed with single quotes' => array("data: !!binary 'SGVsbG8gd29ybGQ='"),
+ 'containing spaces' => array('data: !!binary "SGVs bG8gd 29ybGQ="'),
+ 'in block scalar' => array(
+ <<<'EOT'
+data: !!binary |
+ SGVsbG8gd29ybGQ=
+EOT
+ ),
+ 'containing spaces in block scalar' => array(
+ <<<'EOT'
+data: !!binary |
+ SGVs bG8gd 29ybGQ=
+EOT
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider getInvalidBinaryData
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ */
+ public function testParseInvalidBinaryData($data, $expectedMessage)
+ {
+ if (method_exists($this, 'expectException')) {
+ $this->expectExceptionMessageRegExp($expectedMessage);
+ } else {
+ $this->setExpectedExceptionRegExp(ParseException::class, $expectedMessage);
+ }
+
+ $this->parser->parse($data);
+ }
+
+ public function getInvalidBinaryData()
+ {
+ return array(
+ 'length not a multiple of four' => array('data: !!binary "SGVsbG8d29ybGQ="', '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/'),
+ 'invalid characters' => array('!!binary "SGVsbG8#d29ybGQ="', '/The base64 encoded data \(.*\) contains invalid characters/'),
+ 'too many equals characters' => array('data: !!binary "SGVsbG8gd29yb==="', '/The base64 encoded data \(.*\) contains invalid characters/'),
+ 'misplaced equals character' => array('data: !!binary "SGVsbG8gd29ybG=Q"', '/The base64 encoded data \(.*\) contains invalid characters/'),
+ 'length not a multiple of four in block scalar' => array(
+ <<<'EOT'
+data: !!binary |
+ SGVsbG8d29ybGQ=
+EOT
+ ,
+ '/The normalized base64 encoded data \(data without whitespace characters\) length must be a multiple of four \(\d+ bytes given\)/',
+ ),
+ 'invalid characters in block scalar' => array(
+ <<<'EOT'
+data: !!binary |
+ SGVsbG8#d29ybGQ=
+EOT
+ ,
+ '/The base64 encoded data \(.*\) contains invalid characters/',
+ ),
+ 'too many equals characters in block scalar' => array(
+ <<<'EOT'
+data: !!binary |
+ SGVsbG8gd29yb===
+EOT
+ ,
+ '/The base64 encoded data \(.*\) contains invalid characters/',
+ ),
+ 'misplaced equals character in block scalar' => array(
+ <<<'EOT'
+data: !!binary |
+ SGVsbG8gd29ybG=Q
+EOT
+ ,
+ '/The base64 encoded data \(.*\) contains invalid characters/',
+ ),
+ );
+ }
+
+ public function testParseDateAsMappingValue()
+ {
+ $yaml = <<<'EOT'
+date: 2002-12-14
+EOT;
+ $expectedDate = new \DateTime();
+ $expectedDate->setTimeZone(new \DateTimeZone('UTC'));
+ $expectedDate->setDate(2002, 12, 14);
+ $expectedDate->setTime(0, 0, 0);
+
+ $this->assertEquals(array('date' => $expectedDate), $this->parser->parse($yaml, Yaml::PARSE_DATETIME));
+ }
+
+ /**
+ * @param $lineNumber
+ * @param $yaml
+ * @dataProvider parserThrowsExceptionWithCorrectLineNumberProvider
+ */
+ public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
+ {
+ if (method_exists($this, 'expectException')) {
+ $this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
+ } else {
+ $this->setExpectedException('\Symfony\Component\Yaml\Exception\ParseException', sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
+ }
+
+ $this->parser->parse($yaml);
+ }
+
+ public function parserThrowsExceptionWithCorrectLineNumberProvider()
+ {
+ return array(
+ array(
+ 4,
+ <<<'YAML'
+foo:
+ -
+ # bar
+ bar: "123",
+YAML
+ ),
+ array(
+ 5,
+ <<<'YAML'
+foo:
+ -
+ # bar
+ # bar
+ bar: "123",
+YAML
+ ),
+ array(
+ 8,
+ <<<'YAML'
+foo:
+ -
+ # foobar
+ baz: 123
+bar:
+ -
+ # bar
+ bar: "123",
+YAML
+ ),
+ array(
+ 10,
+ <<<'YAML'
+foo:
+ -
+ # foobar
+ # foobar
+ baz: 123
+bar:
+ -
+ # bar
+ # bar
+ bar: "123",
+YAML
+ ),
+ );
+ }
+
+ public function testParseMultiLineQuotedString()
+ {
+ $yaml = <<<EOT
+foo: "bar
+ baz
+ foobar
+foo"
+bar: baz
+EOT;
+
+ $this->assertSame(array('foo' => 'bar baz foobar foo', 'bar' => 'baz'), $this->parser->parse($yaml));
+ }
+
+ public function testMultiLineQuotedStringWithTrailingBackslash()
+ {
+ $yaml = <<<YAML
+foobar:
+ "foo\
+ bar"
+YAML;
+
+ $this->assertSame(array('foobar' => 'foobar'), $this->parser->parse($yaml));
+ }
+
+ public function testCommentCharactersInMultiLineQuotedStrings()
+ {
+ $yaml = <<<YAML
+foo:
+ foobar: 'foo
+ #bar'
+ bar: baz
+YAML;
+ $expected = array(
+ 'foo' => array(
+ 'foobar' => 'foo #bar',
+ 'bar' => 'baz',
+ ),
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ public function testBlankLinesInQuotedMultiLineString()
+ {
+ $yaml = <<<YAML
+foobar: 'foo
+
+ bar'
+YAML;
+ $expected = array(
+ 'foobar' => "foo\nbar",
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ public function testParseMultiLineUnquotedString()
+ {
+ $yaml = <<<EOT
+foo: bar
+ baz
+ foobar
+ foo
+bar: baz
+EOT;
+
+ $this->assertSame(array('foo' => 'bar baz foobar foo', 'bar' => 'baz'), $this->parser->parse($yaml));
+ }
+
+ public function testParseMultiLineString()
+ {
+ $this->assertEquals("foo bar\nbaz", $this->parser->parse("foo\nbar\n\nbaz"));
+ }
+
+ /**
+ * @dataProvider multiLineDataProvider
+ */
+ public function testParseMultiLineMappingValue($yaml, $expected, $parseError)
+ {
+ $this->assertEquals($expected, $this->parser->parse($yaml));
+ }
+
+ public function multiLineDataProvider()
+ {
+ $tests = array();
+
+ $yaml = <<<'EOF'
+foo:
+- bar:
+ one
+
+ two
+ three
+EOF;
+ $expected = array(
+ 'foo' => array(
+ array(
+ 'bar' => "one\ntwo three",
+ ),
+ ),
+ );
+
+ $tests[] = array($yaml, $expected, false);
+
+ $yaml = <<<'EOF'
+bar
+"foo"
+EOF;
+ $expected = 'bar "foo"';
+
+ $tests[] = array($yaml, $expected, false);
+
+ $yaml = <<<'EOF'
+bar
+"foo
+EOF;
+ $expected = 'bar "foo';
+
+ $tests[] = array($yaml, $expected, false);
+
+ $yaml = <<<'EOF'
+bar
+
+'foo'
+EOF;
+ $expected = "bar\n'foo'";
+
+ $tests[] = array($yaml, $expected, false);
+
+ $yaml = <<<'EOF'
+bar
+
+foo'
+EOF;
+ $expected = "bar\nfoo'";
+
+ $tests[] = array($yaml, $expected, false);
+
+ return $tests;
+ }
+
+ public function testTaggedInlineMapping()
+ {
+ $this->assertEquals(new TaggedValue('foo', array('foo' => 'bar')), $this->parser->parse('!foo {foo: bar}', Yaml::PARSE_CUSTOM_TAGS));
+ }
+
+ /**
+ * @dataProvider taggedValuesProvider
+ */
+ public function testCustomTagSupport($expected, $yaml)
+ {
+ $this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_CUSTOM_TAGS));
+ }
+
+ public function taggedValuesProvider()
+ {
+ return array(
+ 'sequences' => array(
+ array(new TaggedValue('foo', array('yaml')), new TaggedValue('quz', array('bar'))),
+ <<<YAML
+- !foo
+ - yaml
+- !quz [bar]
+YAML
+ ),
+ 'mappings' => array(
+ new TaggedValue('foo', array('foo' => new TaggedValue('quz', array('bar')), 'quz' => new TaggedValue('foo', array('quz' => 'bar')))),
+ <<<YAML
+!foo
+foo: !quz [bar]
+quz: !foo
+ quz: bar
+YAML
+ ),
+ 'inline' => array(
+ array(new TaggedValue('foo', array('foo', 'bar')), new TaggedValue('quz', array('foo' => 'bar', 'quz' => new TaggedValue('bar', array('one' => 'bar'))))),
+ <<<YAML
+- !foo [foo, bar]
+- !quz {foo: bar, quz: !bar {one: bar}}
+YAML
+ ),
+ );
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!iterator" at line 1 (near "!iterator [foo]").
+ */
+ public function testCustomTagsDisabled()
+ {
+ $this->parser->parse('!iterator [foo]');
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Using the unquoted scalar value "!iterator foo" is deprecated since Symfony 3.3 and will be considered as a tagged value in 4.0. You must quote it on line 1.
+ */
+ public function testUnsupportedTagWithScalar()
+ {
+ $this->assertEquals('!iterator foo', $this->parser->parse('!iterator foo'));
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage The built-in tag "!!foo" is not implemented at line 1 (near "!!foo").
+ */
+ public function testExceptionWhenUsingUnsuportedBuiltInTags()
+ {
+ $this->parser->parse('!!foo');
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line 1.
+ */
+ public function testComplexMappingThrowsParseException()
+ {
+ $yaml = <<<YAML
+? "1"
+:
+ name: végétalien
+YAML;
+
+ $this->parser->parse($yaml);
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line 2.
+ */
+ public function testComplexMappingNestedInMappingThrowsParseException()
+ {
+ $yaml = <<<YAML
+diet:
+ ? "1"
+ :
+ name: végétalien
+YAML;
+
+ $this->parser->parse($yaml);
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Starting an unquoted string with a question mark followed by a space is deprecated since Symfony 3.3 and will throw \Symfony\Component\Yaml\Exception\ParseException in 4.0 on line 1.
+ */
+ public function testComplexMappingNestedInSequenceThrowsParseException()
+ {
+ $yaml = <<<YAML
+- ? "1"
+ :
+ name: végétalien
+YAML;
+
+ $this->parser->parse($yaml);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage Unable to parse at line 1 (near "[parameters]").
+ */
+ public function testParsingIniThrowsException()
+ {
+ $ini = <<<INI
+[parameters]
+ foo = bar
+ bar = %foo%
+INI;
+
+ $this->parser->parse($ini);
+ }
+
+ private function loadTestsFromFixtureFiles($testsFile)
+ {
+ $parser = new Parser();
+
+ $tests = array();
+ $files = $parser->parseFile(__DIR__.'/Fixtures/'.$testsFile);
+ foreach ($files as $file) {
+ $yamls = file_get_contents(__DIR__.'/Fixtures/'.$file.'.yml');
+
+ // split YAMLs documents
+ foreach (preg_split('/^---( %YAML\:1\.0)?/m', $yamls) as $yaml) {
+ if (!$yaml) {
+ continue;
+ }
+
+ $test = $parser->parse($yaml);
+ if (isset($test['todo']) && $test['todo']) {
+ // TODO
+ } else {
+ eval('$expected = '.trim($test['php']).';');
+
+ $tests[] = array(var_export($expected, true), $test['yaml'], $test['test'], isset($test['deprecated']) ? $test['deprecated'] : false);
+ }
+ }
+ }
+
+ return $tests;
+ }
+
+ public function testCanParseVeryLongValue()
+ {
+ $longStringWithSpaces = str_repeat('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ', 20000);
+ $trickyVal = array('x' => $longStringWithSpaces);
+
+ $yamlString = Yaml::dump($trickyVal);
+ $arrayFromYaml = $this->parser->parse($yamlString);
+
+ $this->assertEquals($trickyVal, $arrayFromYaml);
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage Reference "foo" does not exist at line 2
+ */
+ public function testParserCleansUpReferencesBetweenRuns()
+ {
+ $yaml = <<<YAML
+foo: &foo
+ baz: foobar
+bar:
+ <<: *foo
+YAML;
+ $this->parser->parse($yaml);
+
+ $yaml = <<<YAML
+bar:
+ <<: *foo
+YAML;
+ $this->parser->parse($yaml);
+ }
+
+ public function testPhpConstantTagMappingKey()
+ {
+ $yaml = <<<YAML
+transitions:
+ !php/const 'Symfony\Component\Yaml\Tests\B::FOO':
+ from:
+ - !php/const 'Symfony\Component\Yaml\Tests\B::BAR'
+ to: !php/const 'Symfony\Component\Yaml\Tests\B::BAZ'
+YAML;
+ $expected = array(
+ 'transitions' => array(
+ 'foo' => array(
+ 'from' => array(
+ 'bar',
+ ),
+ 'to' => 'baz',
+ ),
+ ),
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT));
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 2.
+ * @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 4.
+ * @expectedDeprecation The !php/const: tag to indicate dumped PHP constants is deprecated since Symfony 3.4 and will be removed in 4.0. Use the !php/const (without the colon) tag instead on line 5.
+ */
+ public function testDeprecatedPhpConstantTagMappingKey()
+ {
+ $yaml = <<<YAML
+transitions:
+ !php/const:Symfony\Component\Yaml\Tests\B::FOO:
+ from:
+ - !php/const:Symfony\Component\Yaml\Tests\B::BAR
+ to: !php/const:Symfony\Component\Yaml\Tests\B::BAZ
+YAML;
+ $expected = array(
+ 'transitions' => array(
+ 'foo' => array(
+ 'from' => array(
+ 'bar',
+ ),
+ 'to' => 'baz',
+ ),
+ ),
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT));
+ }
+
+ /**
+ * @group legacy
+ * @expectedDeprecation Using the Yaml::PARSE_KEYS_AS_STRINGS flag is deprecated since Symfony 3.4 as it will be removed in 4.0. Quote your keys when they are evaluable instead.
+ */
+ public function testPhpConstantTagMappingKeyWithKeysCastToStrings()
+ {
+ $yaml = <<<YAML
+transitions:
+ !php/const 'Symfony\Component\Yaml\Tests\B::FOO':
+ from:
+ - !php/const 'Symfony\Component\Yaml\Tests\B::BAR'
+ to: !php/const 'Symfony\Component\Yaml\Tests\B::BAZ'
+YAML;
+ $expected = array(
+ 'transitions' => array(
+ 'foo' => array(
+ 'from' => array(
+ 'bar',
+ ),
+ 'to' => 'baz',
+ ),
+ ),
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml, Yaml::PARSE_CONSTANT | Yaml::PARSE_KEYS_AS_STRINGS));
+ }
+
+ public function testMergeKeysWhenMappingsAreParsedAsObjects()
+ {
+ $yaml = <<<YAML
+foo: &FOO
+ bar: 1
+bar: &BAR
+ baz: 2
+ <<: *FOO
+baz:
+ baz_foo: 3
+ <<:
+ baz_bar: 4
+foobar:
+ bar: ~
+ <<: [*FOO, *BAR]
+YAML;
+ $expected = (object) array(
+ 'foo' => (object) array(
+ 'bar' => 1,
+ ),
+ 'bar' => (object) array(
+ 'baz' => 2,
+ 'bar' => 1,
+ ),
+ 'baz' => (object) array(
+ 'baz_foo' => 3,
+ 'baz_bar' => 4,
+ ),
+ 'foobar' => (object) array(
+ 'bar' => null,
+ 'baz' => 2,
+ ),
+ );
+
+ $this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
+ }
+
+ public function testFilenamesAreParsedAsStringsWithoutFlag()
+ {
+ $file = __DIR__.'/Fixtures/index.yml';
+
+ $this->assertSame($file, $this->parser->parse($file));
+ }
+
+ public function testParseFile()
+ {
+ $this->assertInternalType('array', $this->parser->parseFile(__DIR__.'/Fixtures/index.yml'));
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessageRegExp #^File ".+/Fixtures/nonexistent.yml" does not exist\.$#
+ */
+ public function testParsingNonExistentFilesThrowsException()
+ {
+ $this->parser->parseFile(__DIR__.'/Fixtures/nonexistent.yml');
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessageRegExp #^File ".+/Fixtures/not_readable.yml" cannot be read\.$#
+ */
+ public function testParsingNotReadableFilesThrowsException()
+ {
+ if ('\\' === DIRECTORY_SEPARATOR) {
+ $this->markTestSkipped('chmod is not supported on Windows');
+ }
+
+ $file = __DIR__.'/Fixtures/not_readable.yml';
+ chmod($file, 0200);
+
+ $this->parser->parseFile($file);
+ }
+
+ public function testParseReferencesOnMergeKeys()
+ {
+ $yaml = <<<YAML
+mergekeyrefdef:
+ a: foo
+ <<: &quux
+ b: bar
+ c: baz
+mergekeyderef:
+ d: quux
+ <<: *quux
+YAML;
+ $expected = array(
+ 'mergekeyrefdef' => array(
+ 'a' => 'foo',
+ 'b' => 'bar',
+ 'c' => 'baz',
+ ),
+ 'mergekeyderef' => array(
+ 'd' => 'quux',
+ 'b' => 'bar',
+ 'c' => 'baz',
+ ),
+ );
+
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ public function testParseReferencesOnMergeKeysWithMappingsParsedAsObjects()
+ {
+ $yaml = <<<YAML
+mergekeyrefdef:
+ a: foo
+ <<: &quux
+ b: bar
+ c: baz
+mergekeyderef:
+ d: quux
+ <<: *quux
+YAML;
+ $expected = (object) array(
+ 'mergekeyrefdef' => (object) array(
+ 'a' => 'foo',
+ 'b' => 'bar',
+ 'c' => 'baz',
+ ),
+ 'mergekeyderef' => (object) array(
+ 'd' => 'quux',
+ 'b' => 'bar',
+ 'c' => 'baz',
+ ),
+ );
+
+ $this->assertEquals($expected, $this->parser->parse($yaml, Yaml::PARSE_OBJECT_FOR_MAP));
+ }
+
+ /**
+ * @expectedException \Symfony\Component\Yaml\Exception\ParseException
+ * @expectedExceptionMessage Reference "foo" does not exist
+ */
+ public function testEvalRefException()
+ {
+ $yaml = <<<EOE
+foo: { &foo { a: Steve, <<: *foo} }
+EOE;
+ $this->parser->parse($yaml);
+ }
+
+ /**
+ * @dataProvider indentedMappingData
+ */
+ public function testParseIndentedMappings($yaml, $expected)
+ {
+ $this->assertSame($expected, $this->parser->parse($yaml));
+ }
+
+ public function indentedMappingData()
+ {
+ $tests = array();
+
+ $yaml = <<<YAML
+foo:
+ - bar: "foobar"
+ # A comment
+ baz: "foobaz"
+YAML;
+ $expected = array(
+ 'foo' => array(
+ array(
+ 'bar' => 'foobar',
+ 'baz' => 'foobaz',
+ ),
+ ),
+ );
+ $tests['comment line is first line in indented block'] = array($yaml, $expected);
+
+ $yaml = <<<YAML
+foo:
+ - bar:
+ # comment
+ baz: [1, 2, 3]
+YAML;
+ $expected = array(
+ 'foo' => array(
+ array(
+ 'bar' => array(
+ 'baz' => array(1, 2, 3),
+ ),
+ ),
+ ),
+ );
+ $tests['mapping value on new line starting with a comment line'] = array($yaml, $expected);
+
+ $yaml = <<<YAML
+foo:
+ -
+ bar: foobar
+YAML;
+ $expected = array(
+ 'foo' => array(
+ array(
+ 'bar' => 'foobar',
+ ),
+ ),
+ );
+ $tests['mapping in sequence starting on a new line'] = array($yaml, $expected);
+
+ $yaml = <<<YAML
+foo:
+
+ bar: baz
+YAML;
+ $expected = array(
+ 'foo' => array(
+ 'bar' => 'baz',
+ ),
+ );
+ $tests['blank line at the beginning of an indented mapping value'] = array($yaml, $expected);
+
+ return $tests;
+ }
+}
+
+class B
+{
+ public $b = 'foo';
+
+ const FOO = 'foo';
+ const BAR = 'bar';
+ const BAZ = 'baz';
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml\Tests;
+
+use PHPUnit\Framework\TestCase;
+use Symfony\Component\Yaml\Yaml;
+
+class YamlTest extends TestCase
+{
+ public function testParseAndDump()
+ {
+ $data = array('lorem' => 'ipsum', 'dolor' => 'sit');
+ $yml = Yaml::dump($data);
+ $parsed = Yaml::parse($yml);
+ $this->assertEquals($data, $parsed);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage The indentation must be greater than zero
+ */
+ public function testZeroIndentationThrowsException()
+ {
+ Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage The indentation must be greater than zero
+ */
+ public function testNegativeIndentationThrowsException()
+ {
+ Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml;
+
+use Symfony\Component\Yaml\Exception\ParseException;
+
+/**
+ * Unescaper encapsulates unescaping rules for single and double-quoted
+ * YAML strings.
+ *
+ * @author Matthew Lewinski <matthew@lewinski.org>
+ *
+ * @internal
+ */
+class Unescaper
+{
+ /**
+ * Regex fragment that matches an escaped character in a double quoted string.
+ */
+ const REGEX_ESCAPED_CHARACTER = '\\\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8}|.)';
+
+ /**
+ * Unescapes a single quoted string.
+ *
+ * @param string $value A single quoted string
+ *
+ * @return string The unescaped string
+ */
+ public function unescapeSingleQuotedString($value)
+ {
+ return str_replace('\'\'', '\'', $value);
+ }
+
+ /**
+ * Unescapes a double quoted string.
+ *
+ * @param string $value A double quoted string
+ *
+ * @return string The unescaped string
+ */
+ public function unescapeDoubleQuotedString($value)
+ {
+ $callback = function ($match) {
+ return $this->unescapeCharacter($match[0]);
+ };
+
+ // evaluate the string
+ return preg_replace_callback('/'.self::REGEX_ESCAPED_CHARACTER.'/u', $callback, $value);
+ }
+
+ /**
+ * Unescapes a character that was found in a double-quoted string.
+ *
+ * @param string $value An escaped character
+ *
+ * @return string The unescaped character
+ */
+ private function unescapeCharacter($value)
+ {
+ switch ($value[1]) {
+ case '0':
+ return "\x0";
+ case 'a':
+ return "\x7";
+ case 'b':
+ return "\x8";
+ case 't':
+ return "\t";
+ case "\t":
+ return "\t";
+ case 'n':
+ return "\n";
+ case 'v':
+ return "\xB";
+ case 'f':
+ return "\xC";
+ case 'r':
+ return "\r";
+ case 'e':
+ return "\x1B";
+ case ' ':
+ return ' ';
+ case '"':
+ return '"';
+ case '/':
+ return '/';
+ case '\\':
+ return '\\';
+ case 'N':
+ // U+0085 NEXT LINE
+ return "\xC2\x85";
+ case '_':
+ // U+00A0 NO-BREAK SPACE
+ return "\xC2\xA0";
+ case 'L':
+ // U+2028 LINE SEPARATOR
+ return "\xE2\x80\xA8";
+ case 'P':
+ // U+2029 PARAGRAPH SEPARATOR
+ return "\xE2\x80\xA9";
+ case 'x':
+ return self::utf8chr(hexdec(substr($value, 2, 2)));
+ case 'u':
+ return self::utf8chr(hexdec(substr($value, 2, 4)));
+ case 'U':
+ return self::utf8chr(hexdec(substr($value, 2, 8)));
+ default:
+ throw new ParseException(sprintf('Found unknown escape character "%s".', $value));
+ }
+ }
+
+ /**
+ * Get the UTF-8 character for the given code point.
+ *
+ * @param int $c The unicode code point
+ *
+ * @return string The corresponding UTF-8 character
+ */
+ private static function utf8chr($c)
+ {
+ if (0x80 > $c %= 0x200000) {
+ return chr($c);
+ }
+ if (0x800 > $c) {
+ return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
+ }
+ if (0x10000 > $c) {
+ return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
+ }
+
+ return chr(0xF0 | $c >> 18).chr(0x80 | $c >> 12 & 0x3F).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
+ }
+}
--- /dev/null
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Yaml;
+
+use Symfony\Component\Yaml\Exception\ParseException;
+
+/**
+ * Yaml offers convenience methods to load and dump YAML.
+ *
+ * @author Fabien Potencier <fabien@symfony.com>
+ *
+ * @final since version 3.4
+ */
+class Yaml
+{
+ const DUMP_OBJECT = 1;
+ const PARSE_EXCEPTION_ON_INVALID_TYPE = 2;
+ const PARSE_OBJECT = 4;
+ const PARSE_OBJECT_FOR_MAP = 8;
+ const DUMP_EXCEPTION_ON_INVALID_TYPE = 16;
+ const PARSE_DATETIME = 32;
+ const DUMP_OBJECT_AS_MAP = 64;
+ const DUMP_MULTI_LINE_LITERAL_BLOCK = 128;
+ const PARSE_CONSTANT = 256;
+ const PARSE_CUSTOM_TAGS = 512;
+ const DUMP_EMPTY_ARRAY_AS_SEQUENCE = 1024;
+
+ /**
+ * @deprecated since version 3.4, to be removed in 4.0. Quote your evaluable keys instead.
+ */
+ const PARSE_KEYS_AS_STRINGS = 2048;
+
+ /**
+ * Parses a YAML file into a PHP value.
+ *
+ * Usage:
+ * <code>
+ * $array = Yaml::parseFile('config.yml');
+ * print_r($array);
+ * </code>
+ *
+ * @param string $filename The path to the YAML file to be parsed
+ * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
+ *
+ * @return mixed The YAML converted to a PHP value
+ *
+ * @throws ParseException If the file could not be read or the YAML is not valid
+ */
+ public static function parseFile($filename, $flags = 0)
+ {
+ $yaml = new Parser();
+
+ return $yaml->parseFile($filename, $flags);
+ }
+
+ /**
+ * Parses YAML into a PHP value.
+ *
+ * Usage:
+ * <code>
+ * $array = Yaml::parse(file_get_contents('config.yml'));
+ * print_r($array);
+ * </code>
+ *
+ * @param string $input A string containing YAML
+ * @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
+ *
+ * @return mixed The YAML converted to a PHP value
+ *
+ * @throws ParseException If the YAML is not valid
+ */
+ public static function parse($input, $flags = 0)
+ {
+ if (is_bool($flags)) {
+ @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the PARSE_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
+
+ if ($flags) {
+ $flags = self::PARSE_EXCEPTION_ON_INVALID_TYPE;
+ } else {
+ $flags = 0;
+ }
+ }
+
+ if (func_num_args() >= 3) {
+ @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the PARSE_OBJECT flag instead.', E_USER_DEPRECATED);
+
+ if (func_get_arg(2)) {
+ $flags |= self::PARSE_OBJECT;
+ }
+ }
+
+ if (func_num_args() >= 4) {
+ @trigger_error('Passing a boolean flag to toggle object for map support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::PARSE_OBJECT_FOR_MAP flag instead.', E_USER_DEPRECATED);
+
+ if (func_get_arg(3)) {
+ $flags |= self::PARSE_OBJECT_FOR_MAP;
+ }
+ }
+
+ $yaml = new Parser();
+
+ return $yaml->parse($input, $flags);
+ }
+
+ /**
+ * Dumps a PHP value to a YAML string.
+ *
+ * The dump method, when supplied with an array, will do its best
+ * to convert the array into friendly YAML.
+ *
+ * @param mixed $input The PHP value
+ * @param int $inline The level where you switch to inline YAML
+ * @param int $indent The amount of spaces to use for indentation of nested nodes
+ * @param int $flags A bit field of DUMP_* constants to customize the dumped YAML string
+ *
+ * @return string A YAML string representing the original PHP value
+ */
+ public static function dump($input, $inline = 2, $indent = 4, $flags = 0)
+ {
+ if (is_bool($flags)) {
+ @trigger_error('Passing a boolean flag to toggle exception handling is deprecated since Symfony 3.1 and will be removed in 4.0. Use the DUMP_EXCEPTION_ON_INVALID_TYPE flag instead.', E_USER_DEPRECATED);
+
+ if ($flags) {
+ $flags = self::DUMP_EXCEPTION_ON_INVALID_TYPE;
+ } else {
+ $flags = 0;
+ }
+ }
+
+ if (func_num_args() >= 5) {
+ @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
+
+ if (func_get_arg(4)) {
+ $flags |= self::DUMP_OBJECT;
+ }
+ }
+
+ $yaml = new Dumper($indent);
+
+ return $yaml->dump($input, $inline, 0, $flags);
+ }
+}
--- /dev/null
+{
+ "name": "symfony/yaml",
+ "type": "library",
+ "description": "Symfony Yaml Component",
+ "keywords": [],
+ "homepage": "https://symfony.com",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "https://symfony.com/contributors"
+ }
+ ],
+ "require": {
+ "php": "^5.5.9|>=7.0.8"
+ },
+ "require-dev": {
+ "symfony/console": "~3.4|~4.0"
+ },
+ "conflict": {
+ "symfony/console": "<3.4"
+ },
+ "suggest": {
+ "symfony/console": "For validating YAML files using the lint command"
+ },
+ "autoload": {
+ "psr-4": { "Symfony\\Component\\Yaml\\": "" },
+ "exclude-from-classmap": [
+ "/Tests/"
+ ]
+ },
+ "minimum-stability": "dev",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.4-dev"
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
+ backupGlobals="false"
+ colors="true"
+ bootstrap="vendor/autoload.php"
+ failOnRisky="true"
+ failOnWarning="true"
+>
+ <php>
+ <ini name="error_reporting" value="-1" />
+ </php>
+
+ <testsuites>
+ <testsuite name="Symfony Yaml Component Test Suite">
+ <directory>./Tests/</directory>
+ </testsuite>
+ </testsuites>
+
+ <filter>
+ <whitelist>
+ <directory>./</directory>
+ <exclude>
+ <directory>./Tests</directory>
+ <directory>./vendor</directory>
+ </exclude>
+ </whitelist>
+ </filter>
+</phpunit>