diff --git a/_sakura/changelog.json b/_sakura/changelog.json index b234a62..a988fb3 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -52,7 +52,9 @@ "20150825", "20150826", "20150828", - "20150829" + "20150829", + "20150830", + "20150831" ] @@ -2311,6 +2313,36 @@ "user": "Flashwave" } + ], + + "20150830": [ + + { + "type": "ADD", + "change": "Added donation tracker frontend.", + "user": "Flashwave" + } + + ], + + "20150831": [ + + { + "type": "UPD", + "change": "Changed main navigation to font awesome icons.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Fixed bug in settings panel with parent sections.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Updated twig libraries and switched to the unmodified Parsedown branch.", + "user": "Flashwave" + } + ] } diff --git a/_sakura/components/Payments.php b/_sakura/components/Payments.php index 325f442..ec19ea5 100644 --- a/_sakura/components/Payments.php +++ b/_sakura/components/Payments.php @@ -2,7 +2,7 @@ /* * Payment components (only slightly convoluted) */ - + namespace Sakura; use \PayPal\Api\Payer; diff --git a/_sakura/components/Users.php b/_sakura/components/Users.php index 08643e1..bb5bf44 100644 --- a/_sakura/components/Users.php +++ b/_sakura/components/Users.php @@ -1435,4 +1435,42 @@ class Users { } + // Get Premium tracker data + public static function getPremiumTrackerData() { + + // Create data array + $data = []; + + // Get database stuff + $table = Database::fetch('premium_log', true, null, ['id', true]); + + // Add raw table data to data array + $data['table'] = $table; + + // Create balance entry + $data['balance'] = 0.0; + + // Create users entry + $data['users'] = []; + + // Calculate the thing + foreach($table as $row) { + + // Calculate balance + $data['balance'] = $data['balance'] + $row['amount']; + + // Add userdata to table + if(!array_key_exists($row['uid'], $data['users'])) { + + $data['users'][$row['uid']] = new User($row['uid']); + + } + + } + + // Return the data + return $data; + + } + } diff --git a/_sakura/composer.json b/_sakura/composer.json index 8409f37..04c222c 100644 --- a/_sakura/composer.json +++ b/_sakura/composer.json @@ -3,9 +3,9 @@ "php": ">=5.4.0", "ext-curl": "*", "ext-json": "*", - "twig/twig": "~1.18", - "phpmailer/phpmailer": "~5.2", - "flashwave/parsedown": "~1.5", + "twig/twig": "*", + "phpmailer/phpmailer": "*", + "erusev/parsedown": "*", "paypal/rest-api-sdk-php": "*" } } diff --git a/_sakura/composer.lock b/_sakura/composer.lock index 946aa63..965ed6a 100644 --- a/_sakura/composer.lock +++ b/_sakura/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "becd1aabf8b14aea30aa9218aee65fdd", + "hash": "eece9a97b0a0328b534ad22d30aab9bf", "packages": [ { - "name": "flashwave/parsedown", - "version": "1.5.1", + "name": "erusev/parsedown", + "version": "1.5.4", "source": { "type": "git", - "url": "https://github.com/flashii/parsedown.git", - "reference": "9da19c1108c39df9b42adc42e39b8371070652d0" + "url": "https://github.com/erusev/parsedown.git", + "reference": "0e89e3714bda18973184d30646306bb0a482bd96" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/flashii/parsedown/zipball/9da19c1108c39df9b42adc42e39b8371070652d0", - "reference": "9da19c1108c39df9b42adc42e39b8371070652d0", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/0e89e3714bda18973184d30646306bb0a482bd96", + "reference": "0e89e3714bda18973184d30646306bb0a482bd96", "shasum": "" }, "type": "library", @@ -26,7 +26,7 @@ "Parsedown": "" } }, - "notification-url": "http://packagist.org/downloads/", + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -43,20 +43,20 @@ "markdown", "parser" ], - "time": "2015-01-24 13:01:47" + "time": "2015-08-03 09:24:05" }, { "name": "paypal/rest-api-sdk-php", - "version": "v1.5.0", + "version": "v1.5.1", "source": { "type": "git", "url": "https://github.com/paypal/PayPal-PHP-SDK.git", - "reference": "18e4eaaf319b48de2457abb7b2b1807cfe704c0a" + "reference": "70b03c51879fa3d2392d89052b96e92f6e6f6512" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/paypal/PayPal-PHP-SDK/zipball/18e4eaaf319b48de2457abb7b2b1807cfe704c0a", - "reference": "18e4eaaf319b48de2457abb7b2b1807cfe704c0a", + "url": "https://api.github.com/repos/paypal/PayPal-PHP-SDK/zipball/70b03c51879fa3d2392d89052b96e92f6e6f6512", + "reference": "70b03c51879fa3d2392d89052b96e92f6e6f6512", "shasum": "" }, "require": { @@ -91,7 +91,7 @@ "rest", "sdk" ], - "time": "2015-06-25 17:12:03" + "time": "2015-08-17 19:32:59" }, { "name": "phpmailer/phpmailer", @@ -150,25 +150,29 @@ }, { "name": "twig/twig", - "version": "v1.18.2", + "version": "v1.21.1", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "e8e6575abf6102af53ec283f7f14b89e304fa602" + "reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/e8e6575abf6102af53ec283f7f14b89e304fa602", - "reference": "e8e6575abf6102af53ec283f7f14b89e304fa602", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/ca8d3aa90b6a01c82e07909fe815d6b443e75a23", + "reference": "ca8d3aa90b6a01c82e07909fe815d6b443e75a23", "shasum": "" }, "require": { "php": ">=5.2.7" }, + "require-dev": { + "symfony/debug": "~2.7", + "symfony/phpunit-bridge": "~2.7" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.18-dev" + "dev-master": "1.21-dev" } }, "autoload": { @@ -203,7 +207,7 @@ "keywords": [ "templating" ], - "time": "2015-06-06 23:31:24" + "time": "2015-08-26 08:58:31" } ], "packages-dev": [], diff --git a/_sakura/sakura.php b/_sakura/sakura.php index c583d12..d9042da 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20150829'); +define('SAKURA_VERSION', '20150831'); define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_STABLE', false); diff --git a/_sakura/templates/yuuno/global/header.tpl b/_sakura/templates/yuuno/global/header.tpl index 18bbd06..16a3f32 100644 --- a/_sakura/templates/yuuno/global/header.tpl +++ b/_sakura/templates/yuuno/global/header.tpl @@ -160,33 +160,33 @@
This example demonstrate how you could activate the Plan.

Retrieving the Plan object from Create Plan Sample to demonstrate the List

/** @var Plan $createdPlan */ $createdPlan = require 'CreatePlan.php'; -use PayPal\Api\Plan; -use PayPal\Api\PatchRequest; use PayPal\Api\Patch; +use PayPal\Api\PatchRequest; +use PayPal\Api\Plan; use PayPal\Common\PayPalModel; + try { $patch = new Patch(); diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/billing/UpdatePlanPaymentDefinitions.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/billing/UpdatePlanPaymentDefinitions.html index 450f97b..54c5790 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/billing/UpdatePlanPaymentDefinitions.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/billing/UpdatePlanPaymentDefinitions.html @@ -5,9 +5,9 @@ API used: /v1/payments/billing-plans/

This example demonstrate how you could change the plan amount

Retrieving the Plan object from Create Plan Sample to demonstrate the List

/** @var Plan $createdPlan */ $createdPlan = require 'CreatePlan.php'; -use PayPal\Api\Plan; -use PayPal\Api\PatchRequest; use PayPal\Api\Patch; +use PayPal\Api\PatchRequest; +use PayPal\Api\Plan; try { $patch = new Patch(); diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/CancelInvoice.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/CancelInvoice.html index af10410..aa2027e 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/CancelInvoice.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/CancelInvoice.html @@ -3,8 +3,8 @@ an invoice.

/** @var Invoice $invoice */ $invoice = require 'SendInvoice.php'; -use PayPal\Api\Invoice; use PayPal\Api\CancelNotification; +use PayPal\Api\Invoice; try {

Cancel Notification Object

This would send a notification to both merchant as well diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/CreateInvoice.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/CreateInvoice.html index 790abf6..d86432d 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/CreateInvoice.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/CreateInvoice.html @@ -1,16 +1,17 @@ invoice/CreateInvoice

invoice/CreateInvoice.php
<?php

Create Invoice Sample

This sample code demonstrate how you can create an invoice.

require __DIR__ . '/../bootstrap.php'; -use PayPal\Api\Invoice; -use PayPal\Api\MerchantInfo; -use PayPal\Api\BillingInfo; -use PayPal\Api\InvoiceItem; -use PayPal\Api\Phone; use PayPal\Api\Address; +use PayPal\Api\BillingInfo; +use PayPal\Api\Cost; use PayPal\Api\Currency; -use PayPal\Api\PaymentTerm; -use PayPal\Api\ShippingInfo; +use PayPal\Api\Invoice; use PayPal\Api\InvoiceAddress; +use PayPal\Api\InvoiceItem; +use PayPal\Api\MerchantInfo; +use PayPal\Api\PaymentTerm; +use PayPal\Api\Phone; +use PayPal\Api\ShippingInfo; $invoice = new Invoice();

Invoice Info

Fill in all the information that is @@ -65,10 +66,12 @@ detailed breakdown of invoice

5);

Tax Item

You could provide Tax information to each item.

$tax = new \PayPal\Api\Tax(); $tax->setPercent(1)->setName("Local Tax on Sutures"); -$items[0]->setTax($tax);

Second Item

$items[1] = new InvoiceItem(); +$items[0]->setTax($tax);

Second Item

$items[1] = new InvoiceItem();

Lets add some discount to this item.

$item1discount = new Cost(); +$item1discount->setPercent("3"); $items[1] ->setName("Injection") ->setQuantity(5) + ->setDiscount($item1discount) ->setUnitPrice(new Currency()); $items[1]->getUnitPrice() @@ -78,7 +81,10 @@ detailed breakdown of invoice

$tax2->setPercent(3)->setName("Local Tax on Injection"); $items[1]->setTax($tax2); -$invoice->setItems($items); +$invoice->setItems($items);

Final Discount

+

You can add final discount to the invoice as shown below. You could either use "percent" or "value" when providing the discount

$cost = new Cost(); +$cost->setPercent("2"); +$invoice->setDiscount($cost); $invoice->getPaymentTerm() ->setTermType("NET_45");

Shipping Information

$invoice->getShippingInfo() diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/DeleteInvoice.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/DeleteInvoice.html index a5f72d7..7e0d6c2 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/DeleteInvoice.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/DeleteInvoice.html @@ -4,7 +4,6 @@ an invoice.

$invoice = require 'CreateInvoice.php'; use PayPal\Api\Invoice; -use PayPal\Api\CancelNotification; try {

Delete Invoice

Delete invoice object by calling the diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/RetrieveQRCode.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/RetrieveQRCode.html index f1e982b..fb824d7 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/RetrieveQRCode.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/invoice/RetrieveQRCode.html @@ -3,7 +3,6 @@ $invoice = require 'SendInvoice.php'; use PayPal\Api\Invoice; -use PayPal\Api\Notification; try {

Retrieve QR Code of Sent Invoice

Retrieve QR Code of Sent Invoice by calling the diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/lipp/GenerateAccessTokenFromRefreshToken.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/lipp/GenerateAccessTokenFromRefreshToken.html index fc7bba9..a00e32c 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/lipp/GenerateAccessTokenFromRefreshToken.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/lipp/GenerateAccessTokenFromRefreshToken.html @@ -6,11 +6,6 @@ $tokenInfo = new OpenIdTokeninfo(); $tokenInfo = $tokenInfo->createFromRefreshToken(array('refresh_token' => $refreshToken), $apiContext); -} catch (Exception $ex) { - // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printError("Obtained Access Token From Refresh Token", "Access Token", null, null, $ex); +} catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printError("Obtained Access Token From Refresh Token", "Access Token", null, null, $ex); exit(1); -} - -// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printResult("Obtained Access Token From Refresh Token", "Access Token", $tokenInfo->getAccessToken(), null, $tokenInfo);
+}

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Obtained Access Token From Refresh Token", "Access Token", $tokenInfo->getAccessToken(), null, $tokenInfo);
\ No newline at end of file diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/lipp/GetUserInfo.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/lipp/GetUserInfo.html index a7b717a..86b5ba1 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/lipp/GetUserInfo.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/lipp/GetUserInfo.html @@ -1,7 +1,7 @@ lipp/GetUserInfo
lipp/GetUserInfo.php
<?php

Obtain Access Token From Refresh Token

require __DIR__ . '/../bootstrap.php'; -use PayPal\Api\OpenIdUserinfo; -use PayPal\Api\OpenIdTokeninfo;

To obtain User Info, you have to follow three steps in general. +use PayPal\Api\OpenIdTokeninfo; +use PayPal\Api\OpenIdUserinfo;

To obtain User Info, you have to follow three steps in general. First, you need to obtain user's consent to retrieve the information you want. This is explained in the example "ObtainUserConsent.php".

Once you get the user's consent, the end result would be long lived refresh token. This refresh token should be stored in a permanent storage for later use.

Lastly, when you need to retrieve the user information, you need to generate the short lived access token @@ -16,11 +16,6 @@ to retreive the information. The short lived access token can be retrieved using $params = array('access_token' => $tokenInfo->getAccessToken()); $userInfo = OpenIdUserinfo::getUserinfo($params, $apiContext); -} catch (Exception $ex) { - // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printError("User Information", "User Info", null, $params, $ex); +} catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printError("User Information", "User Info", null, $params, $ex); exit(1); -} - -// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printResult("User Information", "User Info", $userInfo->getUserId(), $params, $userInfo);
+}

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("User Information", "User Info", $userInfo->getUserId(), $params, $userInfo);
\ No newline at end of file diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/notifications/SearchWebhookEvents.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/notifications/SearchWebhookEvents.html index 33b2e15..e5d3114 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/notifications/SearchWebhookEvents.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/notifications/SearchWebhookEvents.html @@ -6,7 +6,6 @@ API used: GET /v1/notifications/webhooks-events

Creating webhook is sample purposes only. In real scenario, you dont need to create a new webhook everytime you want to search for a webhook events. This is made in a sample just to make sure there is minimum of one webhook to listen to.

/** @var \PayPal\Api\Webhook $webhook */ $webhook = require __DIR__ . '/../bootstrap.php'; -use PayPal\Api\Authorization; $params = array(

'start_time'=>'2014-12-06T11:00:00Z', 'end_time'=>'2014-12-12T11:00:00Z'

);

Search Webhook events

try { diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/AuthorizationCapture.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/AuthorizationCapture.html index e924b14..e4faace 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/AuthorizationCapture.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/AuthorizationCapture.html @@ -5,8 +5,8 @@ API used: /v1/payments/payment https://developer.paypal.com/webapps/developer/docs/api/#capture-an-authorization

/** @var Authorization $authorization */ $authorization = require 'GetAuthorization.php'; use PayPal\Api\Amount; -use PayPal\Api\Capture; -use PayPal\Api\Authorization;

Capture Payment

+use PayPal\Api\Authorization; +use PayPal\Api\Capture;

Capture Payment

You can capture and process a previously created authorization by invoking the $authorization->capture method with a valid ApiContext (See bootstrap.php for more on ApiContext)

try { diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/AuthorizePayment.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/AuthorizePayment.html index 10f4a43..53e7743 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/AuthorizePayment.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/AuthorizePayment.html @@ -4,12 +4,12 @@ API used: /v1/payments/authorization https://developer.paypal.com/webapps/developer/docs/integration/direct/capture-payment/#authorize-the-payment

require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Address; +use PayPal\Api\Amount; use PayPal\Api\CreditCard; use PayPal\Api\FundingInstrument; use PayPal\Api\Payer; -use PayPal\Api\Amount; -use PayPal\Api\Transaction; -use PayPal\Api\Payment;

The biggest difference between creating a payment, and authorizing a payment is to set the intent of payment +use PayPal\Api\Payment; +use PayPal\Api\Transaction;

The biggest difference between creating a payment, and authorizing a payment is to set the intent of payment to correct setting. In this case, it would be 'authorize'

$addr = new Address(); $addr->setLine1("3909 Witmer Road") ->setLine2("Niagara Falls") diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreateFuturePayment.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreateFuturePayment.html index 14f6101..0fb1e81 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreateFuturePayment.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreateFuturePayment.html @@ -3,10 +3,11 @@ PayPal Account based Payment. API used: /v1/payments/payment

require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Amount; -use PayPal\Api\Payer; use PayPal\Api\FuturePayment; +use PayPal\Api\Payer; use PayPal\Api\RedirectUrls; use PayPal\Api\Transaction; + session_start();

Payer

A resource representing a Payer that funds a payment For paypal account payments, set payment method @@ -33,7 +34,7 @@ the above types and intent set to 'sale'

$payer) ->setRedirectUrls($redirectUrls) ->setTransactions(array($transaction));

Get Refresh Token

-

You need to get a permanent refresh token from the authorization code, retrieved from the mobile sdk.

authorization code from mobile sdk

$authorizationCode = 'EJfRuAqXEE95pdVMmOym_mftTbeJD03RBX-Zjg9pLCAhdLqLeRR6YSKTNsrbQGX7lFoZ3SxwFyxADEZbBOxpn023W9SA0JzSQAy-9eLdON5eDPAyMyKlHyNVS2DqBR2iWVfQGfudbd9MDoRxMEjIZbY';

Client Metadata id from mobile sdk +

You need to get a permanent refresh token from the authorization code, retrieved from the mobile sdk.

authorization code from mobile sdk

$authorizationCode = 'EK7_MAKlB4QxW1dWKnvnr_CEdLKnpH3vnGAf155Eg8yO8e_7VaQonsqIbTK9CR7tUsoIN2eCc5raOfaGbZDCT0j6k_BDE8GkyLgk8ulcQyR_3S-fgBzjMzBwNqpj3AALgCVR03zw1iT8HTsxZXp3s2U';

Client Metadata id from mobile sdk For more information look for PayPal-Client-Metadata-Id in https://developer.paypal.com/docs/api/#authentication--headers

$clientMetadataId = '123123456'; try {

Exchange authorization_code for long living refresh token. You should store @@ -46,7 +47,7 @@ url to which the buyer must be redirected to for payment approval Please note that currently future payments works only with PayPal as a funding instrument.

$payment->create($apiContext, $clientMetadataId); -} catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printError("Future Payment", "Payment", null, $request, $ex); +} catch (Exception $ex) {

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printError("Future Payment", "Payment", null, $payment, $ex); exit(1); }

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Future Payment", "Payment", $payment->getId(), $request, $payment); diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreatePayment.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreatePayment.html index 4fdec3f..7dd7f65 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreatePayment.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreatePayment.html @@ -5,13 +5,13 @@ credit card payment and related features using the REST API is restricted in some countries. API used: /v1/payments/payment

require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Amount; +use PayPal\Api\CreditCard; use PayPal\Api\Details; +use PayPal\Api\FundingInstrument; use PayPal\Api\Item; use PayPal\Api\ItemList; -use PayPal\Api\CreditCard; use PayPal\Api\Payer; use PayPal\Api\Payment; -use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction;

CreditCard

A resource representing a credit card that can be used to fund a payment.

$card = new CreditCard(); diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreatePaymentUsingSavedCard.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreatePaymentUsingSavedCard.html index d04a7f3..c1ffbfe 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreatePaymentUsingSavedCard.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/CreatePaymentUsingSavedCard.html @@ -4,15 +4,15 @@ Payment using a previously stored credit card token. API used: /v1/payments/payment

/** @var CreditCard $card */ $card = require __DIR__ . '/../vault/CreateCreditCard.php'; use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\CreditCardToken; use PayPal\Api\Details; +use PayPal\Api\FundingInstrument; use PayPal\Api\Item; use PayPal\Api\ItemList; -use PayPal\Api\CreditCardToken; use PayPal\Api\Payer; use PayPal\Api\Payment; -use PayPal\Api\FundingInstrument; -use PayPal\Api\Transaction; -use PayPal\Api\CreditCard;

Credit card token

+use PayPal\Api\Transaction;

Credit card token

Saved credit card id from a previous call to CreateCreditCard.php

$creditCardToken = new CreditCardToken(); $creditCardToken->setCreditCardId($card->getId());

FundingInstrument

diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/ExecutePayment.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/ExecutePayment.html index 0a2907f..f1fc85f 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/ExecutePayment.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/ExecutePayment.html @@ -8,9 +8,12 @@ the buyer by logging into paypal site. You can optionally update transaction information by passing in one or more transactions. API used: POST '/v1/payments/payment//execute'.

require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Amount; +use PayPal\Api\Details; use PayPal\Api\ExecutePayment; use PayPal\Api\Payment; -use PayPal\Api\PaymentExecution;

Approval Status

+use PayPal\Api\PaymentExecution; +use PayPal\Api\Transaction;

Approval Status

Determine if the user approved the payment or not

if (isset($_GET['success']) && $_GET['success'] == 'true') {

Get the payment Object by passing paymentId payment id was previously stored in session in CreatePaymentUsingPayPal.php

$paymentId = $_GET['paymentId']; @@ -19,7 +22,22 @@ CreatePaymentUsingPayPal.php

Optional Changes to Amount

+

If you wish to update the amount that you wish to charge the customer, +based on the shipping address or any other reason, you could +do that by passing the transaction object with just amount field in it. +Here is the example on how we changed the shipping to $1 more than before.

$transaction = new Transaction(); + $amount = new Amount(); + $details = new Details(); + + $details->setShipping(2.2) + ->setTax(1.3) + ->setSubtotal(17.50); + + $amount->setCurrency('USD'); + $amount->setTotal(21); + $amount->setDetails($details); + $transaction->setAmount($amount);

Add the above transaction object inside our Execution object.

$execution->addTransaction($transaction); try {

Execute the payment (See bootstrap.php for more on ApiContext)

$result = $payment->execute($execution, $apiContext);

NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printResult("Executed Payment", "Payment", $payment->getId(), $execution, $result); diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/GetAuthorization.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/GetAuthorization.html index 26897fb..f0094d1 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/GetAuthorization.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/GetAuthorization.html @@ -4,8 +4,7 @@ of an authorized payment. API used: /v1/payments/authorization/<$authorizationId>

/** @var Authorization $authorization */ $authorization = require 'AuthorizePayment.php'; $authorizationId = $authorization->getId(); -use PayPal\Api\Authorization; -use PayPal\Api\Payment;

GetAuthorization

+use PayPal\Api\Authorization;

GetAuthorization

You can retrieve info about an Authorization by invoking the Authorization::get method with a valid ApiContext (See bootstrap.php for more on ApiContext) diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/GetCapture.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/GetCapture.html index bdfbc48..8b59257 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/GetCapture.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/GetCapture.html @@ -4,9 +4,7 @@ of a captured payment. API used: /v1/payments/capture/<$captureId>

/** @var Capture $request */ $request = require 'AuthorizationCapture.php'; -use PayPal\Api\Capture; -use PayPal\Api\Amount; -use PayPal\Api\Authorization;

Retrieve Capture details

+use PayPal\Api\Capture;

Retrieve Capture details

You can look up a capture by invoking the Capture::get method with a valid ApiContext (See bootstrap.php for more on ApiContext)

try { $capture = Capture::get($request->getId(), $apiContext); diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderAuthorize.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderAuthorize.html index 2e0fb32..12d08f1 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderAuthorize.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderAuthorize.html @@ -3,7 +3,6 @@ API used: POST /v1/payments/orders//authorize

/** @var \PayPal\Api\Payment $payment */ $payment = require __DIR__ . '/ExecutePayment.php'; -use PayPal\Api\Order; use PayPal\Api\Amount; use PayPal\Api\Authorization;

Approval Status

Determine if the user approved the payment or not

if (isset($_GET['success']) && $_GET['success'] == 'true') {

Retrieve the order

diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderCapture.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderCapture.html index ee92bd0..74e6fed 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderCapture.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderCapture.html @@ -3,8 +3,8 @@ API used: POST /v1/payments/orders//authorize

/** @var \PayPal\Api\Payment $payment */ $payment = require __DIR__ . '/ExecutePayment.php'; -use PayPal\Api\Capture; -use PayPal\Api\Amount;

Approval Status

+use PayPal\Api\Amount; +use PayPal\Api\Capture;

Approval Status

Determine if the user approved the payment or not

if (isset($_GET['success']) && $_GET['success'] == 'true') {

Retrieve the order

OrderId could be retrieved by parsing the object inside related_resources.

$transactions = $payment->getTransactions(); $transaction = $transactions[0]; diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderDoVoid.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderDoVoid.html index 0f131db..bc4f7ec 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderDoVoid.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/OrderDoVoid.html @@ -2,10 +2,7 @@

Use this call to void an existing order. Note: An order cannot be voided if payment has already been partially or fully captured. API used: POST /v1/payments/orders//do-void

/** @var \PayPal\Api\Payment $payment */ -$payment = require __DIR__ . '/ExecutePayment.php'; - -use PayPal\Api\Capture; -use PayPal\Api\Amount;

Approval Status

+$payment = require __DIR__ . '/ExecutePayment.php';

Approval Status

Determine if the user approved the payment or not

if (isset($_GET['success']) && $_GET['success'] == 'true') {

Retrieve the order

OrderId could be retrieved by parsing the object inside related_resources.

$transactions = $payment->getTransactions(); $transaction = $transactions[0]; diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/Reauthorization.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/Reauthorization.html index d865fdc..fe5f347 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/Reauthorization.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/Reauthorization.html @@ -3,8 +3,8 @@ account payment. API used: v1/payments/authorization/{authorization_id}/reauthorize

/** @var Authorization $authorization */ $authorization = require 'AuthorizePayment.php'; -use PayPal\Api\Authorization; -use PayPal\Api\Amount;

Reauthorization

+use PayPal\Api\Amount; +use PayPal\Api\Authorization;

Reauthorization

Reauthorization is available only for PayPal account payments and not for credit card payments.

You can reauthorize a payment only once 4 to 29 days after the 3-day honor period for the original authorization diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/RefundCapture.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/RefundCapture.html index 7f138fa..4d1a157 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/RefundCapture.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/payments/RefundCapture.html @@ -4,10 +4,8 @@ process a refund on a Captured transaction. API used: /v1/payments/capture/{}/refund

/** @var Capture $capture */ $capture = require 'AuthorizationCapture.php'; -use PayPal\Api\Authorization; use PayPal\Api\Capture; -use PayPal\Api\Refund; -use PayPal\Api\Amount;

Refund

+use PayPal\Api\Refund;

Refund

Create a refund object indicating refund amount and call the refund method

$refund = new Refund(); $refund->setAmount($amt); diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/sale/GetSale.html b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/sale/GetSale.html index 4b4616a..bc2a15f 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/sale/GetSale.html +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/doc/sale/GetSale.html @@ -4,8 +4,8 @@ This sample code demonstrates how you can retrieve details of completed Sale Transaction. API used: /v1/payments/sale/{sale-id}

/** @var Payment $payment */ $payment = require __DIR__ . '/../payments/CreatePayment.php'; -use PayPal\Api\Sale; -use PayPal\Api\Payment;

Get Sale From Created Payment

+use PayPal\Api\Payment; +use PayPal\Api\Sale;

Get Sale From Created Payment

You can retrieve the sale Id from Related Resources for each transactions.

$transactions = $payment->getTransactions(); $relatedResources = $transactions[0]->getRelatedResources(); $sale = $relatedResources[0]->getSale(); diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/index.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/index.php index 4035096..d8cb5a7 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/index.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/index.php @@ -426,16 +426,17 @@ if (PHP_SAPI == 'cli') { class="fa fa-file-code-o">
- -
  • -
    Authorize Payment Using PayPal
    +
    +
    Step II: Execute after Success + (required step after user approval)
    +
  • @@ -916,9 +917,9 @@ if (PHP_SAPI == 'cli') {
    Bank Account - Save
    @@ -927,9 +928,9 @@ if (PHP_SAPI == 'cli') {
    Bank Account - Retrieve
    @@ -940,7 +941,7 @@ if (PHP_SAPI == 'cli') {
    diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/CancelInvoice.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/CancelInvoice.php index 366c528..82020a0 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/CancelInvoice.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/CancelInvoice.php @@ -7,8 +7,8 @@ /** @var Invoice $invoice */ $invoice = require 'SendInvoice.php'; -use PayPal\Api\Invoice; use PayPal\Api\CancelNotification; +use PayPal\Api\Invoice; try { diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/CreateInvoice.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/CreateInvoice.php index 3deba88..7e244fb 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/CreateInvoice.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/CreateInvoice.php @@ -5,16 +5,17 @@ // an invoice. require __DIR__ . '/../bootstrap.php'; -use PayPal\Api\Invoice; -use PayPal\Api\MerchantInfo; -use PayPal\Api\BillingInfo; -use PayPal\Api\InvoiceItem; -use PayPal\Api\Phone; use PayPal\Api\Address; +use PayPal\Api\BillingInfo; +use PayPal\Api\Cost; use PayPal\Api\Currency; -use PayPal\Api\PaymentTerm; -use PayPal\Api\ShippingInfo; +use PayPal\Api\Invoice; use PayPal\Api\InvoiceAddress; +use PayPal\Api\InvoiceItem; +use PayPal\Api\MerchantInfo; +use PayPal\Api\PaymentTerm; +use PayPal\Api\Phone; +use PayPal\Api\ShippingInfo; $invoice = new Invoice(); @@ -91,9 +92,13 @@ $items[0]->setTax($tax); // Second Item $items[1] = new InvoiceItem(); +// Lets add some discount to this item. +$item1discount = new Cost(); +$item1discount->setPercent("3"); $items[1] ->setName("Injection") ->setQuantity(5) + ->setDiscount($item1discount) ->setUnitPrice(new Currency()); $items[1]->getUnitPrice() @@ -108,6 +113,12 @@ $items[1]->setTax($tax2); $invoice->setItems($items); +// #### Final Discount +// You can add final discount to the invoice as shown below. You could either use "percent" or "value" when providing the discount +$cost = new Cost(); +$cost->setPercent("2"); +$invoice->setDiscount($cost); + $invoice->getPaymentTerm() ->setTermType("NET_45"); diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/DeleteInvoice.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/DeleteInvoice.php index 6063d64..7657b9d 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/DeleteInvoice.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/DeleteInvoice.php @@ -8,7 +8,6 @@ $invoice = require 'CreateInvoice.php'; use PayPal\Api\Invoice; -use PayPal\Api\CancelNotification; try { diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/RetrieveQRCode.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/RetrieveQRCode.php index d6081f3..e9cbd1d 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/RetrieveQRCode.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/invoice/RetrieveQRCode.php @@ -7,7 +7,6 @@ $invoice = require 'SendInvoice.php'; use PayPal\Api\Invoice; -use PayPal\Api\Notification; try { diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/lipp/GetUserInfo.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/lipp/GetUserInfo.php index 3bdae6c..52b8be7 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/lipp/GetUserInfo.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/lipp/GetUserInfo.php @@ -3,8 +3,8 @@ // ### Obtain Access Token From Refresh Token require __DIR__ . '/../bootstrap.php'; -use PayPal\Api\OpenIdUserinfo; use PayPal\Api\OpenIdTokeninfo; +use PayPal\Api\OpenIdUserinfo; // To obtain User Info, you have to follow three steps in general. // First, you need to obtain user's consent to retrieve the information you want. diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/notifications/SearchWebhookEvents.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/notifications/SearchWebhookEvents.php index 2548abe..cabbc6a 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/notifications/SearchWebhookEvents.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/notifications/SearchWebhookEvents.php @@ -12,7 +12,6 @@ // for a webhook events. This is made in a sample just to make sure there is minimum of one webhook to listen to. /** @var \PayPal\Api\Webhook $webhook */ $webhook = require __DIR__ . '/../bootstrap.php'; -use PayPal\Api\Authorization; $params = array( // 'start_time'=>'2014-12-06T11:00:00Z', diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/AuthorizationCapture.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/AuthorizationCapture.php index 606755a..493e4c5 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/AuthorizationCapture.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/AuthorizationCapture.php @@ -8,8 +8,8 @@ /** @var Authorization $authorization */ $authorization = require 'GetAuthorization.php'; use PayPal\Api\Amount; -use PayPal\Api\Capture; use PayPal\Api\Authorization; +use PayPal\Api\Capture; // ### Capture Payment diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/AuthorizePayment.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/AuthorizePayment.php index 5183624..c32b581 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/AuthorizePayment.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/AuthorizePayment.php @@ -7,12 +7,12 @@ require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Address; +use PayPal\Api\Amount; use PayPal\Api\CreditCard; use PayPal\Api\FundingInstrument; use PayPal\Api\Payer; -use PayPal\Api\Amount; -use PayPal\Api\Transaction; use PayPal\Api\Payment; +use PayPal\Api\Transaction; // The biggest difference between creating a payment, and authorizing a payment is to set the intent of payment // to correct setting. In this case, it would be 'authorize' diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreateFuturePayment.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreateFuturePayment.php index 9a6e579..c3e3f59 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreateFuturePayment.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreateFuturePayment.php @@ -7,10 +7,11 @@ require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Amount; -use PayPal\Api\Payer; use PayPal\Api\FuturePayment; +use PayPal\Api\Payer; use PayPal\Api\RedirectUrls; use PayPal\Api\Transaction; + session_start(); // ### Payer @@ -57,7 +58,7 @@ $payment->setIntent("authorize") // You need to get a permanent refresh token from the authorization code, retrieved from the mobile sdk. // authorization code from mobile sdk -$authorizationCode = 'EJfRuAqXEE95pdVMmOym_mftTbeJD03RBX-Zjg9pLCAhdLqLeRR6YSKTNsrbQGX7lFoZ3SxwFyxADEZbBOxpn023W9SA0JzSQAy-9eLdON5eDPAyMyKlHyNVS2DqBR2iWVfQGfudbd9MDoRxMEjIZbY'; +$authorizationCode = 'EK7_MAKlB4QxW1dWKnvnr_CEdLKnpH3vnGAf155Eg8yO8e_7VaQonsqIbTK9CR7tUsoIN2eCc5raOfaGbZDCT0j6k_BDE8GkyLgk8ulcQyR_3S-fgBzjMzBwNqpj3AALgCVR03zw1iT8HTsxZXp3s2U'; // Client Metadata id from mobile sdk // For more information look for PayPal-Client-Metadata-Id in https://developer.paypal.com/docs/api/#authentication--headers @@ -86,7 +87,7 @@ try { } catch (Exception $ex) { // NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY - ResultPrinter::printError("Future Payment", "Payment", null, $request, $ex); + ResultPrinter::printError("Future Payment", "Payment", null, $payment, $ex); exit(1); } diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreatePayment.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreatePayment.php index d983834..c0317c7 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreatePayment.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreatePayment.php @@ -10,13 +10,13 @@ require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Amount; +use PayPal\Api\CreditCard; use PayPal\Api\Details; +use PayPal\Api\FundingInstrument; use PayPal\Api\Item; use PayPal\Api\ItemList; -use PayPal\Api\CreditCard; use PayPal\Api\Payer; use PayPal\Api\Payment; -use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; // ### CreditCard diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreatePaymentUsingSavedCard.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreatePaymentUsingSavedCard.php index e92d385..96f8512 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreatePaymentUsingSavedCard.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/CreatePaymentUsingSavedCard.php @@ -8,15 +8,15 @@ /** @var CreditCard $card */ $card = require __DIR__ . '/../vault/CreateCreditCard.php'; use PayPal\Api\Amount; +use PayPal\Api\CreditCard; +use PayPal\Api\CreditCardToken; use PayPal\Api\Details; +use PayPal\Api\FundingInstrument; use PayPal\Api\Item; use PayPal\Api\ItemList; -use PayPal\Api\CreditCardToken; use PayPal\Api\Payer; use PayPal\Api\Payment; -use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; -use PayPal\Api\CreditCard; // ### Credit card token // Saved credit card id from a previous call to diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/ExecutePayment.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/ExecutePayment.php index 539becd..c1fb9e5 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/ExecutePayment.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/ExecutePayment.php @@ -11,9 +11,12 @@ // API used: POST '/v1/payments/payment//execute'. require __DIR__ . '/../bootstrap.php'; +use PayPal\Api\Amount; +use PayPal\Api\Details; use PayPal\Api\ExecutePayment; use PayPal\Api\Payment; use PayPal\Api\PaymentExecution; +use PayPal\Api\Transaction; // ### Approval Status // Determine if the user approved the payment or not @@ -33,6 +36,27 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') { $execution = new PaymentExecution(); $execution->setPayerId($_GET['PayerID']); + // ### Optional Changes to Amount + // If you wish to update the amount that you wish to charge the customer, + // based on the shipping address or any other reason, you could + // do that by passing the transaction object with just `amount` field in it. + // Here is the example on how we changed the shipping to $1 more than before. + $transaction = new Transaction(); + $amount = new Amount(); + $details = new Details(); + + $details->setShipping(2.2) + ->setTax(1.3) + ->setSubtotal(17.50); + + $amount->setCurrency('USD'); + $amount->setTotal(21); + $amount->setDetails($details); + $transaction->setAmount($amount); + + // Add the above transaction object inside our Execution object. + $execution->addTransaction($transaction); + try { // Execute the payment // (See bootstrap.php for more on `ApiContext`) diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/GetAuthorization.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/GetAuthorization.php index 426d906..6e423af 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/GetAuthorization.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/GetAuthorization.php @@ -8,7 +8,6 @@ $authorization = require 'AuthorizePayment.php'; $authorizationId = $authorization->getId(); use PayPal\Api\Authorization; -use PayPal\Api\Payment; // ### GetAuthorization // You can retrieve info about an Authorization diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/GetCapture.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/GetCapture.php index fc64b4b..19cea3a 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/GetCapture.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/GetCapture.php @@ -8,8 +8,6 @@ $request = require 'AuthorizationCapture.php'; use PayPal\Api\Capture; -use PayPal\Api\Amount; -use PayPal\Api\Authorization; // ### Retrieve Capture details // You can look up a capture by invoking the Capture::get method diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderAuthorize.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderAuthorize.php index 05deb2e..441dfa9 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderAuthorize.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderAuthorize.php @@ -6,7 +6,6 @@ /** @var \PayPal\Api\Payment $payment */ $payment = require __DIR__ . '/ExecutePayment.php'; -use PayPal\Api\Order; use PayPal\Api\Amount; use PayPal\Api\Authorization; diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderCapture.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderCapture.php index d4a3218..d704081 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderCapture.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderCapture.php @@ -6,8 +6,8 @@ /** @var \PayPal\Api\Payment $payment */ $payment = require __DIR__ . '/ExecutePayment.php'; -use PayPal\Api\Capture; use PayPal\Api\Amount; +use PayPal\Api\Capture; // ### Approval Status // Determine if the user approved the payment or not diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderDoVoid.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderDoVoid.php index f619418..7c0e287 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderDoVoid.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/OrderDoVoid.php @@ -7,9 +7,6 @@ /** @var \PayPal\Api\Payment $payment */ $payment = require __DIR__ . '/ExecutePayment.php'; -use PayPal\Api\Capture; -use PayPal\Api\Amount; - // ### Approval Status // Determine if the user approved the payment or not if (isset($_GET['success']) && $_GET['success'] == 'true') { diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/Reauthorization.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/Reauthorization.php index ab7c55c..dbebdfa 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/Reauthorization.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/Reauthorization.php @@ -5,8 +5,8 @@ // API used: v1/payments/authorization/{authorization_id}/reauthorize /** @var Authorization $authorization */ $authorization = require 'AuthorizePayment.php'; -use PayPal\Api\Authorization; use PayPal\Api\Amount; +use PayPal\Api\Authorization; // ### Reauthorization // Reauthorization is available only for PayPal account payments diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/RefundCapture.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/RefundCapture.php index d368c97..1ebbdaf 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/RefundCapture.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/payments/RefundCapture.php @@ -6,10 +6,8 @@ /** @var Capture $capture */ $capture = require 'AuthorizationCapture.php'; -use PayPal\Api\Authorization; use PayPal\Api\Capture; use PayPal\Api\Refund; -use PayPal\Api\Amount; // ### Refund // Create a refund object indicating diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/sample/sale/GetSale.php b/_sakura/vendor/paypal/rest-api-sdk-php/sample/sale/GetSale.php index 8efb72f..8b91501 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/sample/sale/GetSale.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/sample/sale/GetSale.php @@ -8,8 +8,8 @@ /** @var Payment $payment */ $payment = require __DIR__ . '/../payments/CreatePayment.php'; -use PayPal\Api\Sale; use PayPal\Api\Payment; +use PayPal\Api\Sale; // ### Get Sale From Created Payment // You can retrieve the sale Id from Related Resources for each transactions. diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AddressTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AddressTest.php index 4f675a9..c4ae25d 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AddressTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AddressTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\Address; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementStateDescriptorTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementStateDescriptorTest.php index 68508cb..3099606 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementStateDescriptorTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementStateDescriptorTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\AgreementStateDescriptor; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTest.php index 0b5facb..2da2e72 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTest.php @@ -2,11 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalResourceModel; -use PayPal\Validation\ArgumentValidator; -use PayPal\Api\AgreementTransactions; -use PayPal\Rest\ApiContext; -use PayPal\Transport\PayPalRestCall; use PayPal\Api\Agreement; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionTest.php index 64eeba7..47f02ca 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\AgreementTransaction; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionsTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionsTest.php index df96665..5d513d2 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionsTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AgreementTransactionsTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\AgreementTransactions; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AmountTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AmountTest.php index c8015a7..5efd7d5 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AmountTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AmountTest.php @@ -2,9 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; -use PayPal\Converter\FormatConverter; -use PayPal\Validation\NumericValidator; use PayPal\Api\Amount; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AuthorizationTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AuthorizationTest.php index cee2e8e..ef95265 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AuthorizationTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/AuthorizationTest.php @@ -2,12 +2,8 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalResourceModel; -use PayPal\Validation\ArgumentValidator; -use PayPal\Api\Capture; -use PayPal\Rest\ApiContext; -use PayPal\Transport\PPRestCall; use PayPal\Api\Authorization; +use PayPal\Transport\PPRestCall; /** * Class Authorization diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountTest.php index 1607d99..0ca75a1 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountTest.php @@ -2,10 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalResourceModel; -use PayPal\Validation\ArgumentValidator; -use PayPal\Rest\ApiContext; -use PayPal\Transport\PayPalRestCall; use PayPal\Api\BankAccount; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountsListTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountsListTest.php index 51d80ea..d834f3f 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountsListTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankAccountsListTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\BankAccountsList; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankTokenTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankTokenTest.php index aa3de98..ff1dcb4 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankTokenTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BankTokenTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\BankToken; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BillingInfoTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BillingInfoTest.php index 2d7de85..540b937 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BillingInfoTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/BillingInfoTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\BillingInfo; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CancelNotificationTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CancelNotificationTest.php index d3c0376..6454cc2 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CancelNotificationTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CancelNotificationTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\CancelNotification; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CaptureTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CaptureTest.php index 2b2c74d..97aee4f 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CaptureTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CaptureTest.php @@ -2,12 +2,8 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalResourceModel; -use PayPal\Validation\ArgumentValidator; -use PayPal\Api\Refund; -use PayPal\Rest\ApiContext; -use PayPal\Transport\PPRestCall; use PayPal\Api\Capture; +use PayPal\Transport\PPRestCall; /** * Class Capture diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CarrierAccountTokenTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CarrierAccountTokenTest.php index ec5298b..efc966d 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CarrierAccountTokenTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CarrierAccountTokenTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\CarrierAccountToken; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CartBaseTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CartBaseTest.php index 2105ea6..5d8161c 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CartBaseTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CartBaseTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\CartBase; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/ChargeModelTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/ChargeModelTest.php index ed78c22..46f4d2a 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/ChargeModelTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/ChargeModelTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\ChargeModel; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CostTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CostTest.php index 89f38df..61e3861 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CostTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CostTest.php @@ -2,9 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; -use PayPal\Converter\FormatConverter; -use PayPal\Validation\NumericValidator; use PayPal\Api\Cost; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CreateProfileResponseTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CreateProfileResponseTest.php index 05f3f5e..ec2da48 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CreateProfileResponseTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CreateProfileResponseTest.php @@ -2,7 +2,6 @@ namespace PayPal\Test\Api; -use PayPal\Common\PayPalModel; use PayPal\Api\CreateProfileResponse; /** diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardHistoryTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardHistoryTest.php index d6b8409..14dd6a9 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardHistoryTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Api/CreditCardHistoryTest.php @@ -1,11 +1,8 @@ markTestSkipped('Skipped as the fix is on the way. #PPTIPS-1932'); - $result = $invoice->update($this->apiContext, $this->mockPayPalRestCall); - $this->assertNotNull($result); - $this->assertEquals($invoice->getId(), $result->getId()); - } - /** * @depends testSend * @param $invoice Invoice @@ -134,6 +121,19 @@ class InvoiceFunctionalTest extends \PHPUnit_Framework_TestCase $this->assertEquals($invoice->getId(), $foundObject->getId()); } + + /** + * @depends testSend + * @param $invoice Invoice + * @return Invoice + */ + public function testUpdate($invoice) + { + $result = $invoice->update($this->apiContext, $this->mockPayPalRestCall); + $this->assertNotNull($result); + $this->assertEquals($invoice->getId(), $result->getId()); + } + /** * @depends testSend * @param $invoice Invoice diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PaymentsFunctionalTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PaymentsFunctionalTest.php index b280efc..bee7fb6 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PaymentsFunctionalTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PaymentsFunctionalTest.php @@ -2,20 +2,10 @@ namespace PayPal\Test\Functional\Api; -use PayPal\Api\Amount; -use PayPal\Api\Patch; -use PayPal\Api\PatchRequest; use PayPal\Api\Payment; -use PayPal\Api\PaymentExecution; use PayPal\Api\Refund; use PayPal\Api\Sale; -use PayPal\Common\PayPalModel; -use PayPal\Rest\ApiContext; -use PayPal\Rest\IResource; -use PayPal\Api\CreateProfileResponse; use PayPal\Test\Functional\Setup; -use PayPal\Transport\PayPalRestCall; -use PayPal\Api\WebProfile; /** * Class WebProfile diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php index 5b92897..1c0d640 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/PayoutsFunctionalTest.php @@ -2,17 +2,10 @@ namespace PayPal\Test\Functional\Api; -use PayPal\Api\Patch; use PayPal\Api\Payout; use PayPal\Api\PayoutBatch; use PayPal\Api\PayoutItem; -use PayPal\Common\PayPalModel; -use PayPal\Rest\ApiContext; -use PayPal\Rest\IResource; -use PayPal\Api\CreateProfileResponse; use PayPal\Test\Functional\Setup; -use PayPal\Transport\PayPalRestCall; -use PayPal\Api\WebProfile; /** * Class Payouts diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebProfileFunctionalTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebProfileFunctionalTest.php index 90a2409..a99cb6f 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebProfileFunctionalTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebProfileFunctionalTest.php @@ -2,14 +2,10 @@ namespace PayPal\Test\Functional\Api; -use PayPal\Api\Patch; -use PayPal\Common\PayPalModel; -use PayPal\Rest\ApiContext; -use PayPal\Rest\IResource; use PayPal\Api\CreateProfileResponse; -use PayPal\Test\Functional\Setup; -use PayPal\Transport\PayPalRestCall; +use PayPal\Api\Patch; use PayPal\Api\WebProfile; +use PayPal\Test\Functional\Setup; /** * Class WebProfile diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebhookFunctionalTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebhookFunctionalTest.php index 3f122fe..f7b756b 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebhookFunctionalTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Api/WebhookFunctionalTest.php @@ -2,27 +2,15 @@ namespace PayPal\Test\Functional\Api; -use PayPal\Api\Amount; use PayPal\Api\Patch; use PayPal\Api\PatchRequest; -use PayPal\Api\Payment; -use PayPal\Api\PaymentExecution; -use PayPal\Api\Refund; -use PayPal\Api\Sale; use PayPal\Api\Webhook; use PayPal\Api\WebhookEvent; -use PayPal\Api\WebhookEventList; use PayPal\Api\WebhookEventType; use PayPal\Api\WebhookEventTypeList; use PayPal\Api\WebhookList; -use PayPal\Common\PayPalModel; use PayPal\Exception\PayPalConnectionException; -use PayPal\Rest\ApiContext; -use PayPal\Rest\IResource; -use PayPal\Api\CreateProfileResponse; use PayPal\Test\Functional\Setup; -use PayPal\Transport\PayPalRestCall; -use PayPal\Api\WebProfile; /** * Class WebhookFunctionalTest diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Setup.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Setup.php index 1b67a6b..529ffd0 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Setup.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/Setup.php @@ -3,7 +3,6 @@ namespace PayPal\Test\Functional; use PayPal\Auth\OAuthTokenCredential; -use PayPal\Core\PayPalConfigManager; use PayPal\Core\PayPalCredentialManager; use PayPal\Rest\ApiContext; diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testSend.json b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testSend.json index c321517..08b7981 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testSend.json +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testSend.json @@ -16,7 +16,7 @@ "openIdConnect": {} }, "request": { - "path": "v1/invoicing/invoices/INV2-EHNV-LJ5S-A7DZ-V6NJ/send", + "path": "v1/invoicing/invoices/INV2-RF6D-L66T-D7H2-CRU7/send", "method": "POST", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testUpdate.json b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testUpdate.json index 1c45eb4..77fa2d0 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testUpdate.json +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Functional/resources/InvoiceFunctionalTest/testUpdate.json @@ -16,7 +16,7 @@ "openIdConnect": {} }, "request": { - "path": "v1/invoicing/invoices/INV2-8UZ6-Q3DK-VZXV-SXQB", + "path": "v1/invoicing/invoices/INV2-RF6D-L66T-D7H2-CRU7", "method": "PUT", "headers": { "X-PAYPAL-SECURITY-CONTEXT": "{\"actor\":{\"auth_claims\":[\"CLIENT_ID_SECRET\"],\"auth_state\":\"LOGGEDIN\",\"account_number\":\"1942617323817135416\",\"encrypted_account_number\":\"6QNCBKP95EWWN\",\"party_id\":\"1942617323817135416\"},\"auth_token\":\"A015vRRfXmgj2UscSiBbwz1Elw8RW.ypMlPJsMH77snr6fc\",\"auth_token_type\":\"ACCESS_TOKEN\",\"last_validated\":1405632568,\"scopes\":[\"openid\",\"https://uri.paypal.com/services/invoicing\",\"https://uri.paypal.com/services/subscriptions\",\"https://api.paypal.com/v1/payments/.*\",\"https://api.paypal.com/v1/vault/credit-card/.*\",\"https://api.paypal.com/v1/vault/credit-card\"],\"client_id\":\"AewC1RCK3i4Z7WTbE0cz5buvd_NW17sYbYI4kc29c5qGxeh-0P7sMuXh2chc\",\"claims\":{\"actor_payer_id\":\"6QNCBKP95EWWN\"},\"subjects\":[]}" @@ -80,7 +80,7 @@ "status": "", "headers": {}, "body": { - "id": "INV2-8UZ6-Q3DK-VZXV-SXQB", + "id": "INV2-RF6D-L66T-D7H2-CRU7", "number": "0014", "status": "DRAFT", "merchant_info": { diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Handler/OauthHandlerTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Handler/OauthHandlerTest.php index 546629e..b36d625 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Handler/OauthHandlerTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Handler/OauthHandlerTest.php @@ -2,11 +2,10 @@ namespace PayPal\Test\Handler; -use PayPal\Core\PayPalHttpConfig; -use PayPal\Exception\PayPalConfigurationException; -use PayPal\Rest\ApiContext; use PayPal\Auth\OAuthTokenCredential; +use PayPal\Core\PayPalHttpConfig; use PayPal\Handler\OauthHandler; +use PayPal\Rest\ApiContext; class OauthHandlerTest extends \PHPUnit_Framework_TestCase { diff --git a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Validation/NumericValidatorTest.php b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Validation/NumericValidatorTest.php index 46342cc..360ea04 100644 --- a/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Validation/NumericValidatorTest.php +++ b/_sakura/vendor/paypal/rest-api-sdk-php/tests/PayPal/Test/Validation/NumericValidatorTest.php @@ -1,7 +1,6 @@ > `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi + - if [ "$TWIG_EXT" == "yes" ]; then sh -c "cd ext/twig && phpize && ./configure --enable-twig && make && make install"; fi + - if [ "$TWIG_EXT" == "yes" ]; then echo "extension=twig.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi + - if [ ${TRAVIS_PHP_VERSION:0:3} == "5.2" ]; then sed -i.bak "s|vendor/autoload.php|test/bootstrap.php|" phpunit.xml.dist; fi matrix: - exclude: - - php: hhvm - env: TWIG_EXT=yes - - php: nightly - env: TWIG_EXT=yes + fast_finish: true + exclude: + - php: hhvm + env: TWIG_EXT=yes + allow_failures: + - php: 7.0 + env: TWIG_EXT=yes diff --git a/_sakura/vendor/twig/twig/CHANGELOG b/_sakura/vendor/twig/twig/CHANGELOG index 9493d5d..6e574d4 100644 --- a/_sakura/vendor/twig/twig/CHANGELOG +++ b/_sakura/vendor/twig/twig/CHANGELOG @@ -1,3 +1,31 @@ +* 1.21.1 (2015-08-26) + + * fixed regression when using the deprecated Twig_Test_* classes + +* 1.21.0 (2015-08-24) + + * added deprecation notices for deprecated features + * added a deprecation "framework" for filters/functions/tests and test fixtures + +* 1.20.0 (2015-08-12) + + * forbid access to the Twig environment from templates and internal parts of Twig_Template + * fixed limited RCEs when in sandbox mode + * deprecated Twig_Template::getEnvironment() + * deprecated the _self variable for usage outside of the from and import tags + * added Twig_BaseNodeVisitor to ease the compatibility of node visitors + between 1.x and 2.x + +* 1.19.0 (2015-07-31) + + * fixed wrong error message when including an undefined template in a child template + * added support for variadic filters, functions, and tests + * added support for extra positional arguments in macros + * added ignore_missing flag to the source function + * fixed batch filter with zero items + * deprecated Twig_Environment::clearTemplateCache() + * fixed sandbox disabling when using the include function + * 1.18.2 (2015-06-06) * fixed template/line guessing in exceptions for nested templates diff --git a/_sakura/vendor/twig/twig/composer.json b/_sakura/vendor/twig/twig/composer.json index 20d8ca7..2d3438e 100644 --- a/_sakura/vendor/twig/twig/composer.json +++ b/_sakura/vendor/twig/twig/composer.json @@ -29,6 +29,10 @@ "require": { "php": ">=5.2.7" }, + "require-dev": { + "symfony/phpunit-bridge": "~2.7", + "symfony/debug": "~2.7" + }, "autoload": { "psr-0" : { "Twig_" : "lib/" @@ -36,7 +40,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.18-dev" + "dev-master": "1.21-dev" } } } diff --git a/_sakura/vendor/twig/twig/doc/advanced.rst b/_sakura/vendor/twig/twig/doc/advanced.rst index 0e3be90..a20eab0 100644 --- a/_sakura/vendor/twig/twig/doc/advanced.rst +++ b/_sakura/vendor/twig/twig/doc/advanced.rst @@ -224,6 +224,23 @@ through your filter:: $filter = new Twig_SimpleFilter('somefilter', 'somefilter', array('pre_escape' => 'html', 'is_safe' => array('html'))); +Variadic Filters +~~~~~~~~~~~~~~~~ + +.. versionadded:: 1.19 + Support for variadic filters was added in Twig 1.19. + +When a filter should accept an arbitrary number of arguments, set the +``is_variadic`` option to ``true``; Twig will pass the extra arguments as the +last argument to the filter call as an array:: + + $filter = new Twig_SimpleFilter('thumbnail', function ($file, array $options = array()) { + // ... + }, array('is_variadic' => true)); + +Be warned that named arguments passed to a variadic filter cannot be checked +for validity as they will automatically end up in the option array. + Dynamic Filters ~~~~~~~~~~~~~~~ @@ -250,6 +267,23 @@ arguments, but after the environment and the context. For instance, a call to ``'foo'|a_path_b()`` will result in the following arguments to be passed to the filter: ``('a', 'b', 'foo')``. +Deprecated Filters +~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 1.21 + Support for deprecated filters was added in Twig 1.21. + +You can mark a filter as being deprecated by setting the ``deprecated`` option +to ``true``. You can also give an alternative filter that replaces the +deprecated one when that makes sense:: + + $filter = new Twig_SimpleFilter('obsolete', function () { + // ... + }, array('deprecated' => true, 'alternative' => 'new_one')); + +When a filter is deprecated, Twig emits a deprecation notice when compiling a +template using it. See :ref:`deprecation-notices` for more information. + Functions --------- @@ -331,6 +365,10 @@ The ``node`` sub-node will contain an expression of ``my_value``. Node-based tests also have access to the ``arguments`` node. This node will contain the various other arguments that have been provided to your test. +If you want to pass a variable number of positional or named arguments to the +test, set the ``is_variadic`` option to ``true``. Tests also support dynamic +name feature as filters and functions. + Tags ---- diff --git a/_sakura/vendor/twig/twig/doc/deprecated.rst b/_sakura/vendor/twig/twig/doc/deprecated.rst index bde62ba..1489174 100644 --- a/_sakura/vendor/twig/twig/doc/deprecated.rst +++ b/_sakura/vendor/twig/twig/doc/deprecated.rst @@ -5,6 +5,12 @@ This document lists all deprecated features in Twig. Deprecated features are kept for backward compatibility and removed in the next major release (a feature that was deprecated in Twig 1.x is removed in Twig 2.0). +Deprecation Notices +------------------- + +As of Twig 1.21, Twig generates deprecation notices when a template uses +deprecated features. See :ref:`deprecation-notices` for more information. + Token Parsers ------------- @@ -80,6 +86,12 @@ Tests * The ``sameas`` and ``divisibleby`` tests are deprecated in favor of ``same as`` and ``divisible by`` respectively. +Tags +---- + +* As of Twig 1.x, the ``raw`` tag is deprecated. You should use ``verbatim`` + instead. + Nodes ----- @@ -107,9 +119,30 @@ Loaders * As of Twig 1.x, ``Twig_Loader_String`` is deprecated and will be removed in 2.0. +Node Visitors +------------- + +* Because of the removal of ``Twig_NodeInterface`` in 2.0, you need to extend + ``Twig_BaseNodeVistor`` instead of implementing ``Twig_NodeVisitorInterface`` + directly to make your node visitors compatible with both Twig 1.x and 2.x. + Globals ------- * As of Twig 2.x, the ability to register a global variable after the runtime or the extensions have been initialized is not possible anymore (but changing the value of an already registered global is possible). + +* As of Twig 1.x, the ``_self`` global variable is deprecated except for usage + in the ``from`` and the ``import`` tags. In Twig 2.0, ``_self`` is not + exposed anymore but still usable in the ``from`` and the ``import`` tags. + +Miscellaneous +------------- + +* As of Twig 1.x, ``Twig_Environment::clearTemplateCache()`` is deprecated and + will be removed in 2.0. + +* As of Twig 1.x, ``Twig_Template::getEnvironment()`` and + ``Twig_TemplateInterface::getEnvironment()`` are deprecated and will be + removed in 2.0. diff --git a/_sakura/vendor/twig/twig/doc/filters/batch.rst b/_sakura/vendor/twig/twig/doc/filters/batch.rst index da47eb6..f8b6fa9 100644 --- a/_sakura/vendor/twig/twig/doc/filters/batch.rst +++ b/_sakura/vendor/twig/twig/doc/filters/batch.rst @@ -43,3 +43,9 @@ The above example will be rendered as: No item + +Arguments +--------- + +* ``size``: The size of the batch; fractional numbers will be rounded up +* ``fill``: Used to fill in missing items diff --git a/_sakura/vendor/twig/twig/doc/functions/source.rst b/_sakura/vendor/twig/twig/doc/functions/source.rst index 8ff39c2..3c921b1 100644 --- a/_sakura/vendor/twig/twig/doc/functions/source.rst +++ b/_sakura/vendor/twig/twig/doc/functions/source.rst @@ -4,6 +4,9 @@ .. versionadded:: 1.15 The ``source`` function was added in Twig 1.15. +.. versionadded:: 1.18.3 + The ``ignore_missing`` flag was added in Twig 1.18.3. + The ``source`` function returns the content of a template without rendering it: .. code-block:: jinja @@ -11,6 +14,13 @@ The ``source`` function returns the content of a template without rendering it: {{ source('template.html') }} {{ source(some_var) }} +When you set the ``ignore_missing`` flag, Twig will return an empty string if +the template does not exist: + +.. code-block:: jinja + + {{ source('template.html', ignore_missing = true) }} + The function uses the same template loaders as the ones used to include templates. So, if you are using the filesystem loader, the templates are looked for in the paths defined by it. @@ -19,3 +29,4 @@ Arguments --------- * ``name``: The name of the template to read +* ``ignore_missing``: Whether to ignore missing templates or not diff --git a/_sakura/vendor/twig/twig/doc/internals.rst b/_sakura/vendor/twig/twig/doc/internals.rst index a68796b..ef1174d 100644 --- a/_sakura/vendor/twig/twig/doc/internals.rst +++ b/_sakura/vendor/twig/twig/doc/internals.rst @@ -124,7 +124,7 @@ using):: { // line 1 echo "Hello "; - echo twig_escape_filter($this->env, $this->getContext($context, "name"), "html", null, true); + echo twig_escape_filter($this->env, isset($context["name"]) ? $context["name"] : null), "html", null, true); } // some more code diff --git a/_sakura/vendor/twig/twig/doc/intro.rst b/_sakura/vendor/twig/twig/doc/intro.rst index 773c476..9b38c97 100644 --- a/_sakura/vendor/twig/twig/doc/intro.rst +++ b/_sakura/vendor/twig/twig/doc/intro.rst @@ -21,10 +21,14 @@ The key-features are... * *Flexible*: Twig is powered by a flexible lexer and parser. This allows the developer to define its own custom tags and filters, and create its own DSL. +Twig is used by many Open-Source projects like Symfony, Drupal8, eZPublish, +phpBB, Piwik, OroCRM, and many frameworks have support for it as well like +Slim, Yii, Laravel, Codeigniter, and Kohana, just to name a few. + Prerequisites ------------- -Twig needs at least **PHP 5.2.4** to run. +Twig needs at least **PHP 5.2.7** to run. Installation ------------ diff --git a/_sakura/vendor/twig/twig/doc/recipes.rst b/_sakura/vendor/twig/twig/doc/recipes.rst index 86cede6..b863e10 100644 --- a/_sakura/vendor/twig/twig/doc/recipes.rst +++ b/_sakura/vendor/twig/twig/doc/recipes.rst @@ -1,6 +1,64 @@ Recipes ======= +.. _deprecation-notices: + +Displaying Deprecation Notices +------------------------------ + +.. versionadded:: 1.21 + This works as of Twig 1.21. + +Deprecated features generate deprecation notices (via a call to the +``trigger_error()`` PHP function). By default, they are silenced and never +displayed nor logged. + +To easily remove all deprecated feature usages from your templates, write and +run a script along the lines of the following:: + + require_once __DIR__.'/vendor/autoload.php'; + + $twig = create_your_twig_env(); + + $deprecations = new Twig_Util_DeprecationCollector($twig); + + print_r($deprecations->collectDir(__DIR__.'/templates')); + +The ``collectDir()`` method compiles all templates found in a directory, +catches deprecation notices, and return them. + +.. tip:: + + If your templates are not stored on the filesystem, use the ``collect()`` + method instead which takes an ``Iterator``; the iterator must return + template names as keys and template contents as values (as done by + ``Twig_Util_TemplateDirIterator``). + +However, this code won't find all deprecations (like using deprecated some Twig +classes). To catch all notices, register a custom error handler like the one +below:: + + $deprecations = array(); + set_error_handler(function ($type, $msg) use (&$deprecations) { + if (E_USER_DEPRECATED === $type) { + $deprecations[] = $msg; + } + }); + + // run your application + + print_r($deprecations); + +Note that most deprecation notices are triggered during **compilation**, so +they won't be generated when templates are already cached. + +.. tip:: + + If you want to manage the deprecation notices from your PHPUnit tests, have + a look at the `symfony/phpunit-bridge + `_ package, which eases the + process a lot. + Making a Layout conditional --------------------------- @@ -274,13 +332,14 @@ If you iterate over a set of files, you can pass the filename to the is enforced during template rendering (as Twig needs the context for some checks like allowed methods on objects). -Refreshing modified Templates when APC is enabled and apc.stat = 0 ------------------------------------------------------------------- +Refreshing modified Templates when OPcache or APC is enabled +------------------------------------------------------------ -When using APC with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing -the template cache won't update the APC cache. To get around this, one can -extend ``Twig_Environment`` and force the update of the APC cache when Twig -rewrites the cache:: +When using OPcache with ``opcache.validate_timestamps`` set to ``0`` or APC +with ``apc.stat`` set to ``0`` and Twig cache enabled, clearing the template +cache won't update the cache. To get around this, one can extend +``Twig_Environment`` and force the update of the cache when Twig rewrites the +cache:: class Twig_Environment_APC extends Twig_Environment { @@ -289,7 +348,11 @@ rewrites the cache:: parent::writeCacheFile($file, $content); // Compile cached file into bytecode cache - apc_compile_file($file); + if (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) { + opcache_compile_file($file); + } elseif (extension_loaded('apc') && ini_get('apc.enabled')) { + apc_compile_file($file); + } } } diff --git a/_sakura/vendor/twig/twig/doc/tags/macro.rst b/_sakura/vendor/twig/twig/doc/tags/macro.rst index 11c115a..60a1567 100644 --- a/_sakura/vendor/twig/twig/doc/tags/macro.rst +++ b/_sakura/vendor/twig/twig/doc/tags/macro.rst @@ -20,6 +20,9 @@ Macros differs from native PHP functions in a few ways: * Arguments of a macro are always optional. +* If extra positional arguments are passed to a macro, they end up in the + special ``varargs`` variable as a list of values. + But as with PHP functions, macros don't have access to the current template variables. diff --git a/_sakura/vendor/twig/twig/doc/tags/use.rst b/_sakura/vendor/twig/twig/doc/tags/use.rst index a2f3af0..071b197 100644 --- a/_sakura/vendor/twig/twig/doc/tags/use.rst +++ b/_sakura/vendor/twig/twig/doc/tags/use.rst @@ -74,7 +74,7 @@ is ignored. To avoid name conflicts, you can rename imported blocks: {% extends "base.html" %} - {% use "blocks.html" with sidebar as base_sidebar %} + {% use "blocks.html" with sidebar as base_sidebar, title as base_title %} {% block sidebar %}{% endblock %} {% block title %}{% endblock %} diff --git a/_sakura/vendor/twig/twig/doc/templates.rst b/_sakura/vendor/twig/twig/doc/templates.rst index a60c196..2d59b1a 100644 --- a/_sakura/vendor/twig/twig/doc/templates.rst +++ b/_sakura/vendor/twig/twig/doc/templates.rst @@ -60,6 +60,9 @@ Many IDEs support syntax highlighting and auto-completion for Twig: * *Emacs* via `web-mode.el`_ * *Atom* via the `PHP-twig for atom`_ +Also, `TwigFiddle`_ is an online service that allows you to execute Twig templates +from a browser; it supports all versions of Twig. + Variables --------- @@ -93,7 +96,7 @@ access the variable attribute: don't put the braces around them. If a variable or attribute does not exist, you will receive a ``null`` value -when the ``strict_variables`` option is set to ``false``; alternatively, if ``strict_variables`` +when the ``strict_variables`` option is set to ``false``; alternatively, if ``strict_variables`` is set, Twig will throw an error (see :ref:`environment options`). .. sidebar:: Implementation @@ -124,7 +127,7 @@ Global Variables The following variables are always available in templates: -* ``_self``: references the current template; +* ``_self``: references the current template (deprecated since Twig 1.20); * ``_context``: references the current context; * ``_charset``: references the current charset. @@ -541,6 +544,9 @@ macro call: {% endmacro %} +If extra positional arguments are passed to a macro call, they end up in the +special ``varargs`` variable as a list of values. + .. _twig-expressions: Expressions @@ -879,3 +885,4 @@ Extension` chapter. .. _`web-mode.el`: http://web-mode.org/ .. _`regular expressions`: http://php.net/manual/en/pcre.pattern.php .. _`PHP-twig for atom`: https://github.com/reesef/php-twig +.. _`TwigFiddle`: http://twigfiddle.com/ diff --git a/_sakura/vendor/twig/twig/ext/twig/php_twig.h b/_sakura/vendor/twig/twig/ext/twig/php_twig.h index 168f966..0423b1d 100644 --- a/_sakura/vendor/twig/twig/ext/twig/php_twig.h +++ b/_sakura/vendor/twig/twig/ext/twig/php_twig.h @@ -15,7 +15,7 @@ #ifndef PHP_TWIG_H #define PHP_TWIG_H -#define PHP_TWIG_VERSION "1.18.2" +#define PHP_TWIG_VERSION "1.21.1" #include "php.h" diff --git a/_sakura/vendor/twig/twig/ext/twig/twig.c b/_sakura/vendor/twig/twig/ext/twig/twig.c index 40c03fd..92d1add 100644 --- a/_sakura/vendor/twig/twig/ext/twig/twig.c +++ b/_sakura/vendor/twig/twig/ext/twig/twig.c @@ -55,7 +55,7 @@ ZEND_BEGIN_ARG_INFO_EX(twig_template_get_attribute_args, ZEND_SEND_BY_VAL, ZEND_ ZEND_END_ARG_INFO() #ifndef PHP_FE_END -#define PHP_FE_END { NULL, NULL, NULL, 0, 0 } +#define PHP_FE_END { NULL, NULL, NULL} #endif static const zend_function_entry twig_functions[] = { @@ -609,6 +609,7 @@ static char *TWIG_GET_CLASS_NAME(zval *object TSRMLS_DC) static int twig_add_method_to_class(void *pDest APPLY_TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) { + zend_class_entry *ce; zval *retval; char *item; size_t item_len; @@ -619,12 +620,23 @@ static int twig_add_method_to_class(void *pDest APPLY_TSRMLS_DC, int num_args, v return 0; } + ce = *va_arg(args, zend_class_entry**); retval = va_arg(args, zval*); item_len = strlen(mptr->common.function_name); item = estrndup(mptr->common.function_name, item_len); php_strtolower(item, item_len); + if (strcmp("getenvironment", item) == 0) { + zend_class_entry **twig_template_ce; + if (zend_lookup_class("Twig_Template", strlen("Twig_Template"), &twig_template_ce TSRMLS_CC) == FAILURE) { + return 0; + } + if (instanceof_function(ce, *twig_template_ce TSRMLS_CC)) { + return 0; + } + } + add_assoc_stringl_ex(retval, item, item_len+1, item, item_len, 0); return 0; @@ -670,7 +682,7 @@ static void twig_add_class_to_cache(zval *cache, zval *object, char *class_name array_init(class_methods); array_init(class_properties); // add all methods to self::cache[$class]['methods'] - zend_hash_apply_with_arguments(&class_ce->function_table APPLY_TSRMLS_CC, twig_add_method_to_class, 1, class_methods); + zend_hash_apply_with_arguments(&class_ce->function_table APPLY_TSRMLS_CC, twig_add_method_to_class, 2, &class_ce, class_methods); zend_hash_apply_with_arguments(&class_ce->properties_info APPLY_TSRMLS_CC, twig_add_property_to_class, 2, &class_ce, class_properties); add_assoc_zval(class_info, "methods", class_methods); @@ -898,7 +910,7 @@ PHP_FUNCTION(twig_template_get_attributes) /* // object property - if (Twig_Template::METHOD_CALL !== $type) { + if (Twig_Template::METHOD_CALL !== $type && !$object instanceof Twig_Template) { if (isset($object->$item) || array_key_exists((string) $item, $object)) { if ($isDefinedTest) { return true; @@ -912,7 +924,7 @@ PHP_FUNCTION(twig_template_get_attributes) } } */ - if (strcmp("method", type) != 0) { + if (strcmp("method", type) != 0 && !TWIG_INSTANCE_OF_USERLAND(object, "Twig_Template" TSRMLS_CC)) { zval *tmp_properties, *tmp_item; tmp_properties = TWIG_GET_ARRAY_ELEMENT(tmp_class, "properties", strlen("properties") TSRMLS_CC); @@ -939,7 +951,23 @@ PHP_FUNCTION(twig_template_get_attributes) /* // object method if (!isset(self::$cache[$class]['methods'])) { - self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object))); + if ($object instanceof self) { + $ref = new ReflectionClass($class); + $methods = array(); + + foreach ($ref->getMethods(ReflectionMethod::IS_PUBLIC) as $refMethod) { + $methodName = strtolower($refMethod->name); + + // Accessing the environment from templates is forbidden to prevent untrusted changes to the environment + if ('getenvironment' !== $methodName) { + $methods[$methodName] = true; + } + } + + self::$cache[$class]['methods'] = $methods; + } else { + self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object))); + } } $call = false; diff --git a/_sakura/vendor/twig/twig/lib/Twig/Autoloader.php b/_sakura/vendor/twig/twig/lib/Twig/Autoloader.php index 87f7415..d47583f 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Autoloader.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Autoloader.php @@ -9,10 +9,14 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Autoloader class is deprecated and will be removed in 2.0. Use Composer instead.', E_USER_DEPRECATED); + /** * Autoloads Twig classes. * * @author Fabien Potencier + * + * @deprecated Use Composer instead. Will be removed in Twig 2.0. */ class Twig_Autoloader { @@ -23,6 +27,8 @@ class Twig_Autoloader */ public static function register($prepend = false) { + @trigger_error('Using Twig_Autoloader is deprecated. Use Composer instead.', E_USER_DEPRECATED); + if (PHP_VERSION_ID < 50300) { spl_autoload_register(array(__CLASS__, 'autoload')); } else { diff --git a/_sakura/vendor/twig/twig/lib/Twig/BaseNodeVisitor.php b/_sakura/vendor/twig/twig/lib/Twig/BaseNodeVisitor.php new file mode 100644 index 0000000..3c6ef66 --- /dev/null +++ b/_sakura/vendor/twig/twig/lib/Twig/BaseNodeVisitor.php @@ -0,0 +1,62 @@ + + */ +abstract class Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface +{ + /** + * {@inheritdoc} + */ + final public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) + { + if (!$node instanceof Twig_Node) { + throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.'); + } + + return $this->doEnterNode($node, $env); + } + + /** + * {@inheritdoc} + */ + final public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) + { + if (!$node instanceof Twig_Node) { + throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.'); + } + + return $this->doLeaveNode($node, $env); + } + + /** + * Called before child nodes are visited. + * + * @param Twig_Node $node The node to visit + * @param Twig_Environment $env The Twig environment instance + * + * @return Twig_Node The modified node + */ + abstract protected function doEnterNode(Twig_Node $node, Twig_Environment $env); + + /** + * Called after child nodes are visited. + * + * @param Twig_Node $node The node to visit + * @param Twig_Environment $env The Twig environment instance + * + * @return Twig_Node|false The modified node or false if the node must be removed + */ + abstract protected function doLeaveNode(Twig_Node $node, Twig_Environment $env); +} diff --git a/_sakura/vendor/twig/twig/lib/Twig/Compiler.php b/_sakura/vendor/twig/twig/lib/Twig/Compiler.php index 2514c31..abea3aa 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Compiler.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Compiler.php @@ -21,7 +21,7 @@ class Twig_Compiler implements Twig_CompilerInterface protected $source; protected $indentation; protected $env; - protected $debugInfo; + protected $debugInfo = array(); protected $sourceOffset; protected $sourceLine; protected $filename; @@ -34,7 +34,6 @@ class Twig_Compiler implements Twig_CompilerInterface public function __construct(Twig_Environment $env) { $this->env = $env; - $this->debugInfo = array(); } public function getFilename() diff --git a/_sakura/vendor/twig/twig/lib/Twig/Environment.php b/_sakura/vendor/twig/twig/lib/Twig/Environment.php index f14e5d8..7687d5b 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Environment.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Environment.php @@ -16,7 +16,7 @@ */ class Twig_Environment { - const VERSION = '1.18.2'; + const VERSION = '1.21.1'; protected $charset; protected $loader; @@ -34,15 +34,15 @@ class Twig_Environment protected $tests; protected $functions; protected $globals; - protected $runtimeInitialized; - protected $extensionInitialized; + protected $runtimeInitialized = false; + protected $extensionInitialized = false; protected $loadedTemplates; protected $strictVariables; protected $unaryOperators; protected $binaryOperators; protected $templateClassPrefix = '__TwigTemplate_'; - protected $functionCallbacks; - protected $filterCallbacks; + protected $functionCallbacks = array(); + protected $filterCallbacks = array(); protected $staging; /** @@ -86,33 +86,31 @@ class Twig_Environment { if (null !== $loader) { $this->setLoader($loader); + } else { + @trigger_error('Not passing a Twig_LoaderInterface as the first constructor argument of Twig_Environment is deprecated.', E_USER_DEPRECATED); } $options = array_merge(array( - 'debug' => false, - 'charset' => 'UTF-8', + 'debug' => false, + 'charset' => 'UTF-8', 'base_template_class' => 'Twig_Template', - 'strict_variables' => false, - 'autoescape' => 'html', - 'cache' => false, - 'auto_reload' => null, - 'optimizations' => -1, + 'strict_variables' => false, + 'autoescape' => 'html', + 'cache' => false, + 'auto_reload' => null, + 'optimizations' => -1, ), $options); - $this->debug = (bool) $options['debug']; - $this->charset = strtoupper($options['charset']); - $this->baseTemplateClass = $options['base_template_class']; - $this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload']; - $this->strictVariables = (bool) $options['strict_variables']; - $this->runtimeInitialized = false; + $this->debug = (bool) $options['debug']; + $this->charset = strtoupper($options['charset']); + $this->baseTemplateClass = $options['base_template_class']; + $this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload']; + $this->strictVariables = (bool) $options['strict_variables']; $this->setCache($options['cache']); - $this->functionCallbacks = array(); - $this->filterCallbacks = array(); $this->addExtension(new Twig_Extension_Core()); $this->addExtension(new Twig_Extension_Escaper($options['autoescape'])); $this->addExtension(new Twig_Extension_Optimizer($options['optimizations'])); - $this->extensionInitialized = false; $this->staging = new Twig_Extension_Staging(); } @@ -443,9 +441,13 @@ class Twig_Environment /** * Clears the internal template cache. + * + * @deprecated since 1.18.3 (to be removed in 2.0) */ public function clearTemplateCache() { + @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED); + $this->loadedTemplates = array(); } @@ -709,6 +711,8 @@ class Twig_Environment */ public function removeExtension($name) { + @trigger_error(sprintf('The %s method is deprecated and will be removed in Twig 2.0.', __METHOD__), E_USER_DEPRECATED); + if ($this->extensionInitialized) { throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name)); } @@ -828,6 +832,8 @@ class Twig_Environment if ($name instanceof Twig_SimpleFilter) { $filter = $name; $name = $filter->getName(); + } else { + @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated. Pass an instance of "Twig_SimpleFilter" instead when defining filter "%s".', __METHOD__, $name), E_USER_DEPRECATED); } if ($this->extensionInitialized) { @@ -917,6 +923,8 @@ class Twig_Environment if ($name instanceof Twig_SimpleTest) { $test = $name; $name = $test->getName(); + } else { + @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated. Pass an instance of "Twig_SimpleTest" instead when defining test "%s".', __METHOD__, $name), E_USER_DEPRECATED); } if ($this->extensionInitialized) { @@ -975,6 +983,8 @@ class Twig_Environment if ($name instanceof Twig_SimpleFunction) { $function = $name; $name = $function->getName(); + } else { + @trigger_error(sprintf('Passing a name as a first argument to the %s method is deprecated. Pass an instance of "Twig_SimpleFunction" instead when defining function "%s".', __METHOD__, $name), E_USER_DEPRECATED); } if ($this->extensionInitialized) { @@ -1065,11 +1075,11 @@ class Twig_Environment $this->globals = $this->initGlobals(); } - /* This condition must be uncommented in Twig 2.0 if (!array_key_exists($name, $this->globals)) { - throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name)); + // The deprecation notice must be turned into the following exception in Twig 2.0 + @trigger_error(sprintf('Registering global variable "%s" at runtime or when the extensions have already been initialized is deprecated.', $name), E_USER_DEPRECATED); + //throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name)); } - */ } if ($this->extensionInitialized || $this->runtimeInitialized) { @@ -1184,7 +1194,7 @@ class Twig_Environment } $this->extensionInitialized = true; - $this->parsers = new Twig_TokenParserBroker(); + $this->parsers = new Twig_TokenParserBroker(array(), array(), false); $this->filters = array(); $this->functions = array(); $this->tests = array(); @@ -1202,11 +1212,10 @@ class Twig_Environment { // filters foreach ($extension->getFilters() as $name => $filter) { - if ($name instanceof Twig_SimpleFilter) { - $filter = $name; - $name = $filter->getName(); - } elseif ($filter instanceof Twig_SimpleFilter) { + if ($filter instanceof Twig_SimpleFilter) { $name = $filter->getName(); + } else { + @trigger_error(sprintf('Using an instance of "%s" for filter "%s" is deprecated. Use Twig_SimpleFilter instead.', get_class($filter), $name), E_USER_DEPRECATED); } $this->filters[$name] = $filter; @@ -1214,11 +1223,10 @@ class Twig_Environment // functions foreach ($extension->getFunctions() as $name => $function) { - if ($name instanceof Twig_SimpleFunction) { - $function = $name; - $name = $function->getName(); - } elseif ($function instanceof Twig_SimpleFunction) { + if ($function instanceof Twig_SimpleFunction) { $name = $function->getName(); + } else { + @trigger_error(sprintf('Using an instance of "%s" for function "%s" is deprecated. Use Twig_SimpleFunction instead.', get_class($function), $name), E_USER_DEPRECATED); } $this->functions[$name] = $function; @@ -1226,11 +1234,10 @@ class Twig_Environment // tests foreach ($extension->getTests() as $name => $test) { - if ($name instanceof Twig_SimpleTest) { - $test = $name; - $name = $test->getName(); - } elseif ($test instanceof Twig_SimpleTest) { + if ($test instanceof Twig_SimpleTest) { $name = $test->getName(); + } else { + @trigger_error(sprintf('Using an instance of "%s" for test "%s" is deprecated. Use Twig_SimpleTest instead.', get_class($test), $name), E_USER_DEPRECATED); } $this->tests[$name] = $test; @@ -1241,6 +1248,8 @@ class Twig_Environment if ($parser instanceof Twig_TokenParserInterface) { $this->parsers->addTokenParser($parser); } elseif ($parser instanceof Twig_TokenParserBrokerInterface) { + @trigger_error('Registering a Twig_TokenParserBrokerInterface instance is deprecated.', E_USER_DEPRECATED); + $this->parsers->addTokenParserBroker($parser); } else { throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances'); diff --git a/_sakura/vendor/twig/twig/lib/Twig/ExpressionParser.php b/_sakura/vendor/twig/twig/lib/Twig/ExpressionParser.php index 8fc8346..085588c 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/ExpressionParser.php +++ b/_sakura/vendor/twig/twig/lib/Twig/ExpressionParser.php @@ -387,7 +387,13 @@ class Twig_ExpressionParser throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s")', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename()); } - $node = new Twig_Node_Expression_MethodCall($node, 'get'.$arg->getAttribute('value'), $arguments, $lineno); + $name = $arg->getAttribute('value'); + + if ($this->parser->isReservedMacroName($name)) { + throw new Twig_Error_Syntax(sprintf('"%s" cannot be called as macro as it is a reserved keyword', $name), $token->getLine(), $this->parser->getFilename()); + } + + $node = new Twig_Node_Expression_MethodCall($node, 'get'.$name, $arguments, $lineno); $node->setAttribute('safe', true); return $node; @@ -572,6 +578,16 @@ class Twig_ExpressionParser throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename()); } + if ($function instanceof Twig_SimpleFunction && $function->isDeprecated()) { + $message = sprintf('Twig Function "%s" is deprecated', $function->getName()); + if ($test->getAlternative()) { + $message .= sprintf('. Use "%s" instead', $function->getAlternative()); + } + $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line); + + @trigger_error($message, E_USER_DEPRECATED); + } + if ($function instanceof Twig_SimpleFunction) { return $function->getNodeClass(); } @@ -592,6 +608,16 @@ class Twig_ExpressionParser throw new Twig_Error_Syntax($message, $line, $this->parser->getFilename()); } + if ($filter instanceof Twig_SimpleFilter && $filter->isDeprecated()) { + $message = sprintf('Twig Filter "%s" is deprecated', $filter->getName()); + if ($test->getAlternative()) { + $message .= sprintf('. Use "%s" instead', $filter->getAlternative()); + } + $message .= sprintf(' in %s at line %d.', $this->parser->getFilename(), $line); + + @trigger_error($message, E_USER_DEPRECATED); + } + if ($filter instanceof Twig_SimpleFilter) { return $filter->getNodeClass(); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Extension/Core.php b/_sakura/vendor/twig/twig/lib/Twig/Extension/Core.php index 5ddf21e..cfffa80 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Extension/Core.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Extension/Core.php @@ -233,11 +233,11 @@ class Twig_Extension_Core extends Twig_Extension new Twig_SimpleTest('even', null, array('node_class' => 'Twig_Node_Expression_Test_Even')), new Twig_SimpleTest('odd', null, array('node_class' => 'Twig_Node_Expression_Test_Odd')), new Twig_SimpleTest('defined', null, array('node_class' => 'Twig_Node_Expression_Test_Defined')), - new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')), + new Twig_SimpleTest('sameas', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas', 'deprecated' => true, 'alternative' => 'same as')), new Twig_SimpleTest('same as', null, array('node_class' => 'Twig_Node_Expression_Test_Sameas')), new Twig_SimpleTest('none', null, array('node_class' => 'Twig_Node_Expression_Test_Null')), new Twig_SimpleTest('null', null, array('node_class' => 'Twig_Node_Expression_Test_Null')), - new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')), + new Twig_SimpleTest('divisibleby', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby', 'deprecated' => true, 'alternative' => 'divisible by')), new Twig_SimpleTest('divisible by', null, array('node_class' => 'Twig_Node_Expression_Test_Divisibleby')), new Twig_SimpleTest('constant', null, array('node_class' => 'Twig_Node_Expression_Test_Constant')), new Twig_SimpleTest('empty', 'twig_test_empty'), @@ -255,37 +255,37 @@ class Twig_Extension_Core extends Twig_Extension return array( array( 'not' => array('precedence' => 50, 'class' => 'Twig_Node_Expression_Unary_Not'), - '-' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Neg'), - '+' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Pos'), + '-' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Neg'), + '+' => array('precedence' => 500, 'class' => 'Twig_Node_Expression_Unary_Pos'), ), array( - 'or' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'and' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'b-or' => array('precedence' => 16, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'b-xor' => array('precedence' => 17, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'b-and' => array('precedence' => 18, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '!=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '<' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '>=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '<=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'not in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotIn', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_In', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'matches' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Matches', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'or' => array('precedence' => 10, 'class' => 'Twig_Node_Expression_Binary_Or', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'and' => array('precedence' => 15, 'class' => 'Twig_Node_Expression_Binary_And', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-or' => array('precedence' => 16, 'class' => 'Twig_Node_Expression_Binary_BitwiseOr', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-xor' => array('precedence' => 17, 'class' => 'Twig_Node_Expression_Binary_BitwiseXor', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'b-and' => array('precedence' => 18, 'class' => 'Twig_Node_Expression_Binary_BitwiseAnd', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '==' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Equal', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '!=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '<' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Less', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '>' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Greater', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '>=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_GreaterEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '<=' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_LessEqual', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'not in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_NotIn', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'in' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_In', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'matches' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_Matches', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), 'starts with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_StartsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'ends with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_EndsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '..' => array('precedence' => 25, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '+' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Add', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '-' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Sub', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '~' => array('precedence' => 40, 'class' => 'Twig_Node_Expression_Binary_Concat', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '*' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mul', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '/' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Div', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '//' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_FloorDiv', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '%' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'is' => array('precedence' => 100, 'callable' => array($this, 'parseTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - 'is not' => array('precedence' => 100, 'callable' => array($this, 'parseNotTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), - '**' => array('precedence' => 200, 'class' => 'Twig_Node_Expression_Binary_Power', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT), + 'ends with' => array('precedence' => 20, 'class' => 'Twig_Node_Expression_Binary_EndsWith', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '..' => array('precedence' => 25, 'class' => 'Twig_Node_Expression_Binary_Range', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '+' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Add', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '-' => array('precedence' => 30, 'class' => 'Twig_Node_Expression_Binary_Sub', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '~' => array('precedence' => 40, 'class' => 'Twig_Node_Expression_Binary_Concat', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '*' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mul', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '/' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Div', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '//' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_FloorDiv', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '%' => array('precedence' => 60, 'class' => 'Twig_Node_Expression_Binary_Mod', 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'is' => array('precedence' => 100, 'callable' => array($this, 'parseTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + 'is not' => array('precedence' => 100, 'callable' => array($this, 'parseNotTestExpression'), 'associativity' => Twig_ExpressionParser::OPERATOR_LEFT), + '**' => array('precedence' => 200, 'class' => 'Twig_Node_Expression_Binary_Power', 'associativity' => Twig_ExpressionParser::OPERATOR_RIGHT), ), ); } @@ -298,8 +298,19 @@ class Twig_Extension_Core extends Twig_Extension public function parseTestExpression(Twig_Parser $parser, Twig_NodeInterface $node) { $stream = $parser->getStream(); - $name = $this->getTestName($parser, $node->getLine()); - $class = $this->getTestNodeClass($parser, $name); + list($name, $test) = $this->getTest($parser, $node->getLine()); + + if ($test instanceof Twig_SimpleTest && $test->isDeprecated()) { + $message = sprintf('Twig Test "%s" is deprecated', $name); + if ($test->getAlternative()) { + $message .= sprintf('. Use "%s" instead', $test->getAlternative()); + } + $message .= sprintf(' in %s at line %d.', $stream->getFilename(), $stream->getCurrent()->getLine()); + + @trigger_error($message, E_USER_DEPRECATED); + } + + $class = $this->getTestNodeClass($parser, $test); $arguments = null; if ($stream->test(Twig_Token::PUNCTUATION_TYPE, '(')) { $arguments = $parser->getExpressionParser()->parseArguments(true); @@ -308,46 +319,42 @@ class Twig_Extension_Core extends Twig_Extension return new $class($node, $name, $arguments, $parser->getCurrentToken()->getLine()); } - protected function getTestName(Twig_Parser $parser, $line) + protected function getTest(Twig_Parser $parser, $line) { $stream = $parser->getStream(); $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); $env = $parser->getEnvironment(); - $testMap = $env->getTests(); - if (isset($testMap[$name])) { - return $name; + if ($test = $env->getTest($name)) { + return array($name, $test); } if ($stream->test(Twig_Token::NAME_TYPE)) { // try 2-words tests $name = $name.' '.$parser->getCurrentToken()->getValue(); - if (isset($testMap[$name])) { + if ($test = $env->getTest($name)) { $parser->getStream()->next(); - return $name; + return array($name, $test); } } $message = sprintf('The test "%s" does not exist', $name); - if ($alternatives = $env->computeAlternatives($name, array_keys($testMap))) { + if ($alternatives = $env->computeAlternatives($name, array_keys($env->getTests()))) { $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); } throw new Twig_Error_Syntax($message, $line, $parser->getFilename()); } - protected function getTestNodeClass(Twig_Parser $parser, $name) + protected function getTestNodeClass(Twig_Parser $parser, $test) { - $env = $parser->getEnvironment(); - $testMap = $env->getTests(); - - if ($testMap[$name] instanceof Twig_SimpleTest) { - return $testMap[$name]->getNodeClass(); + if ($test instanceof Twig_SimpleTest) { + return $test->getNodeClass(); } - return $testMap[$name] instanceof Twig_Test_Node ? $testMap[$name]->getClass() : 'Twig_Node_Expression_Test'; + return $test instanceof Twig_Test_Node ? $test->getClass() : 'Twig_Node_Expression_Test'; } /** @@ -382,10 +389,10 @@ function twig_cycle($values, $position) * Returns a random value depending on the supplied parameter type: * - a random item from a Traversable or array * - a random character from a string - * - a random integer between 0 and the integer parameter + * - a random integer between 0 and the integer parameter. * - * @param Twig_Environment $env A Twig_Environment instance - * @param Traversable|array|int|string $values The values to pick a random item from + * @param Twig_Environment $env A Twig_Environment instance + * @param Traversable|array|int|string $values The values to pick a random item from * * @throws Twig_Error_Runtime When $values is an empty array (does not apply to an empty string which is returned as is). * @@ -466,15 +473,15 @@ function twig_date_format_filter(Twig_Environment $env, $date, $format = null, $ } /** - * Returns a new date object modified + * Returns a new date object modified. * *
      *   {{ post.published_at|date_modify("-1day")|date("m/d/Y") }}
      * 
    * - * @param Twig_Environment $env A Twig_Environment instance - * @param DateTime|string $date A date - * @param string $modifier A modifier string + * @param Twig_Environment $env A Twig_Environment instance + * @param DateTime|string $date A date + * @param string $modifier A modifier string * * @return DateTime A new date object */ @@ -545,11 +552,11 @@ function twig_date_converter(Twig_Environment $env, $date = null, $timezone = nu /** * Rounds a number. * - * @param int|float $value The value to round - * @param int|float $precision The rounding precision - * @param string $method The method to use for rounding + * @param int|float $value The value to round + * @param int|float $precision The rounding precision + * @param string $method The method to use for rounding * - * @return int|float The rounded number + * @return int|float The rounded number */ function twig_round($value, $precision = 0, $method = 'common') { @@ -571,11 +578,11 @@ function twig_round($value, $precision = 0, $method = 'common') * be used. Supplying any of the parameters will override the defaults set in the * environment object. * - * @param Twig_Environment $env A Twig_Environment instance - * @param mixed $number A float/int/string of the number to format - * @param int $decimal The number of decimal points to display. - * @param string $decimalPoint The character(s) to use for the decimal point. - * @param string $thousandSep The character(s) to use for the thousands separator. + * @param Twig_Environment $env A Twig_Environment instance + * @param mixed $number A float/int/string of the number to format + * @param int $decimal The number of decimal points to display. + * @param string $decimalPoint The character(s) to use for the decimal point. + * @param string $thousandSep The character(s) to use for the thousands separator. * * @return string The formatted number */ @@ -805,9 +812,9 @@ function twig_join_filter($value, $glue = '') * {# returns [aa, bb, cc] #} * * - * @param string $value A string - * @param string $delimiter The delimiter - * @param int $limit The limit + * @param string $value A string + * @param string $delimiter The delimiter + * @param int $limit The limit * * @return array The split string as an array */ @@ -1190,7 +1197,7 @@ function _twig_escape_html_attr_callback($matches) $chr = $matches[0]; $ord = ord($chr); - /** + /* * The following replaces characters undefined in HTML with the * hex entity for the Unicode replacement character. */ @@ -1198,7 +1205,7 @@ function _twig_escape_html_attr_callback($matches) return '�'; } - /** + /* * Check if the current character to escape has a name entity we should * replace it with while grabbing the hex value of the character. */ @@ -1214,7 +1221,7 @@ function _twig_escape_html_attr_callback($matches) return sprintf('&%s;', $entityMap[$int]); } - /** + /* * Per OWASP recommendations, we'll use hex entities for any other * characters where a named entity does not exist. */ @@ -1369,7 +1376,7 @@ function twig_ensure_traversable($seq) * * @param mixed $value A variable * - * @return bool true if the value is empty, false otherwise + * @return bool true if the value is empty, false otherwise */ function twig_test_empty($value) { @@ -1392,7 +1399,7 @@ function twig_test_empty($value) * * @param mixed $value A variable * - * @return bool true if the value is traversable + * @return bool true if the value is traversable */ function twig_test_iterable($value) { @@ -1427,10 +1434,15 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a } } + $result = null; try { - return $env->resolveTemplate($template)->render($variables); + $result = $env->resolveTemplate($template)->render($variables); } catch (Twig_Error_Loader $e) { if (!$ignoreMissing) { + if ($isSandboxed && !$alreadySandboxed) { + $sandbox->disableSandbox(); + } + throw $e; } } @@ -1438,18 +1450,27 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a if ($isSandboxed && !$alreadySandboxed) { $sandbox->disableSandbox(); } + + return $result; } /** * Returns a template content without rendering it. * - * @param string $name The template name + * @param string $name The template name + * @param bool $ignoreMissing Whether to ignore missing templates or not * * @return string The template source */ -function twig_source(Twig_Environment $env, $name) +function twig_source(Twig_Environment $env, $name, $ignoreMissing = false) { - return $env->getLoader()->getSource($name); + try { + return $env->getLoader()->getSource($name); + } catch (Twig_Error_Loader $e) { + if (!$ignoreMissing) { + throw $e; + } + } } /** @@ -1472,9 +1493,9 @@ function twig_constant($constant, $object = null) /** * Batches item. * - * @param array $items An array of items - * @param int $size The size of the batch - * @param mixed $fill A value used to fill missing items + * @param array $items An array of items + * @param int $size The size of the batch + * @param mixed $fill A value used to fill missing items * * @return array */ @@ -1488,7 +1509,7 @@ function twig_array_batch($items, $size, $fill = null) $result = array_chunk($items, $size, true); - if (null !== $fill) { + if (null !== $fill && !empty($result)) { $last = count($result) - 1; if ($fillCount = $size - count($result[$last])) { $result[$last] = array_merge( diff --git a/_sakura/vendor/twig/twig/lib/Twig/Extension/Debug.php b/_sakura/vendor/twig/twig/lib/Twig/Extension/Debug.php index e3a85bf..86d07c2 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Extension/Debug.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Extension/Debug.php @@ -62,7 +62,7 @@ function twig_var_dump(Twig_Environment $env, $context) var_dump($vars); } else { - for ($i = 2; $i < $count; $i++) { + for ($i = 2; $i < $count; ++$i) { var_dump(func_get_arg($i)); } } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Extension/Escaper.php b/_sakura/vendor/twig/twig/lib/Twig/Extension/Escaper.php index cf2020e..053a895 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Extension/Escaper.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Extension/Escaper.php @@ -12,6 +12,13 @@ class Twig_Extension_Escaper extends Twig_Extension { protected $defaultStrategy; + /** + * Constructor. + * + * @param string|false|callable $defaultStrategy An escaping strategy + * + * @see setDefaultStrategy() + */ public function __construct($defaultStrategy = 'html') { $this->setDefaultStrategy($defaultStrategy); @@ -55,12 +62,14 @@ class Twig_Extension_Escaper extends Twig_Extension * The strategy can be a valid PHP callback that takes the template * "filename" as an argument and returns the strategy to use. * - * @param mixed $defaultStrategy An escaping strategy + * @param string|false|callable $defaultStrategy An escaping strategy */ public function setDefaultStrategy($defaultStrategy) { // for BC if (true === $defaultStrategy) { + @trigger_error('Using "true" as the default strategy is deprecated. Use "html" instead.', E_USER_DEPRECATED); + $defaultStrategy = 'html'; } @@ -76,13 +85,13 @@ class Twig_Extension_Escaper extends Twig_Extension * * @param string $filename The template "filename" * - * @return string The default strategy to use for the template + * @return string|false The default strategy to use for the template */ public function getDefaultStrategy($filename) { // disable string callables to avoid calling a function named html or js, // or any other upcoming escaping strategy - if (!is_string($this->defaultStrategy) && is_callable($this->defaultStrategy)) { + if (!is_string($this->defaultStrategy) && false !== $this->defaultStrategy) { return call_user_func($this->defaultStrategy, $filename); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Extension/Profiler.php b/_sakura/vendor/twig/twig/lib/Twig/Extension/Profiler.php index 35e04a0..e21fdb6 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Extension/Profiler.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Extension/Profiler.php @@ -11,11 +11,11 @@ class Twig_Extension_Profiler extends Twig_Extension { - private $actives; + private $actives = array(); public function __construct(Twig_Profiler_Profile $profile) { - $this->actives = array($profile); + $this->actives[] = $profile; } public function enter(Twig_Profiler_Profile $profile) diff --git a/_sakura/vendor/twig/twig/lib/Twig/Extension/Sandbox.php b/_sakura/vendor/twig/twig/lib/Twig/Extension/Sandbox.php index c58259c..3593e9e 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Extension/Sandbox.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Extension/Sandbox.php @@ -16,7 +16,7 @@ class Twig_Extension_Sandbox extends Twig_Extension public function __construct(Twig_Sandbox_SecurityPolicyInterface $policy, $sandboxed = false) { - $this->policy = $policy; + $this->policy = $policy; $this->sandboxedGlobally = $sandboxed; } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Filter.php b/_sakura/vendor/twig/twig/lib/Twig/Filter.php index 5cfbb66..101d2e7 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Filter.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Filter.php @@ -9,12 +9,15 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Filter class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED); + /** * Represents a template filter. * * Use Twig_SimpleFilter instead. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableInterface @@ -26,10 +29,10 @@ abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableI { $this->options = array_merge(array( 'needs_environment' => false, - 'needs_context' => false, - 'pre_escape' => null, - 'preserves_safety' => null, - 'callable' => null, + 'needs_context' => false, + 'pre_escape' => null, + 'preserves_safety' => null, + 'callable' => null, ), $options); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Filter/Function.php b/_sakura/vendor/twig/twig/lib/Twig/Filter/Function.php index ad374a5..d679cab 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Filter/Function.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Filter/Function.php @@ -9,12 +9,15 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Filter_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED); + /** * Represents a function template filter. * * Use Twig_SimpleFilter instead. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Filter_Function extends Twig_Filter diff --git a/_sakura/vendor/twig/twig/lib/Twig/Filter/Method.php b/_sakura/vendor/twig/twig/lib/Twig/Filter/Method.php index 63c8c3b..655aab4 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Filter/Method.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Filter/Method.php @@ -9,12 +9,15 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Filter_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED); + /** * Represents a method template filter. * * Use Twig_SimpleFilter instead. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Filter_Method extends Twig_Filter diff --git a/_sakura/vendor/twig/twig/lib/Twig/Filter/Node.php b/_sakura/vendor/twig/twig/lib/Twig/Filter/Node.php index 8744c5e..a922f50 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Filter/Node.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Filter/Node.php @@ -9,12 +9,15 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Filter_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFilter instead.', E_USER_DEPRECATED); + /** * Represents a template filter as a node. * * Use Twig_SimpleFilter instead. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Filter_Node extends Twig_Filter diff --git a/_sakura/vendor/twig/twig/lib/Twig/FilterCallableInterface.php b/_sakura/vendor/twig/twig/lib/Twig/FilterCallableInterface.php index 145534d..5679861 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/FilterCallableInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/FilterCallableInterface.php @@ -15,6 +15,7 @@ * Use Twig_SimpleFilter instead. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_FilterCallableInterface diff --git a/_sakura/vendor/twig/twig/lib/Twig/FilterInterface.php b/_sakura/vendor/twig/twig/lib/Twig/FilterInterface.php index 5319ecc..6b0be0e 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/FilterInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/FilterInterface.php @@ -15,6 +15,7 @@ * Use Twig_SimpleFilter instead. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_FilterInterface diff --git a/_sakura/vendor/twig/twig/lib/Twig/Function.php b/_sakura/vendor/twig/twig/lib/Twig/Function.php index b5ffb2b..9fc76a8 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Function.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Function.php @@ -9,12 +9,15 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED); + /** * Represents a template function. * * Use Twig_SimpleFunction instead. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCallableInterface @@ -26,8 +29,8 @@ abstract class Twig_Function implements Twig_FunctionInterface, Twig_FunctionCal { $this->options = array_merge(array( 'needs_environment' => false, - 'needs_context' => false, - 'callable' => null, + 'needs_context' => false, + 'callable' => null, ), $options); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Function/Function.php b/_sakura/vendor/twig/twig/lib/Twig/Function/Function.php index d1e1b96..ae83e15 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Function/Function.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Function/Function.php @@ -10,12 +10,15 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Function_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED); + /** * Represents a function template function. * * Use Twig_SimpleFunction instead. * * @author Arnaud Le Blanc + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Function_Function extends Twig_Function diff --git a/_sakura/vendor/twig/twig/lib/Twig/Function/Method.php b/_sakura/vendor/twig/twig/lib/Twig/Function/Method.php index 67039a9..ba9945e 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Function/Method.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Function/Method.php @@ -10,12 +10,15 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Function_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED); + /** * Represents a method template function. * * Use Twig_SimpleFunction instead. * * @author Arnaud Le Blanc + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Function_Method extends Twig_Function diff --git a/_sakura/vendor/twig/twig/lib/Twig/Function/Node.php b/_sakura/vendor/twig/twig/lib/Twig/Function/Node.php index 06a0d0d..118b0ba 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Function/Node.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Function/Node.php @@ -9,12 +9,15 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Function_Node class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleFunction instead.', E_USER_DEPRECATED); + /** * Represents a template function as a node. * * Use Twig_SimpleFunction instead. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Function_Node extends Twig_Function diff --git a/_sakura/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php b/_sakura/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php index 0aab4f5..87d795e 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/FunctionCallableInterface.php @@ -15,6 +15,7 @@ * Use Twig_SimpleFunction instead. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_FunctionCallableInterface diff --git a/_sakura/vendor/twig/twig/lib/Twig/FunctionInterface.php b/_sakura/vendor/twig/twig/lib/Twig/FunctionInterface.php index 67f4f89..f449234 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/FunctionInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/FunctionInterface.php @@ -16,6 +16,7 @@ * Use Twig_SimpleFunction instead. * * @author Arnaud Le Blanc + * * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_FunctionInterface diff --git a/_sakura/vendor/twig/twig/lib/Twig/Lexer.php b/_sakura/vendor/twig/twig/lib/Twig/Lexer.php index 19380b5..75f763f 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Lexer.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Lexer.php @@ -33,42 +33,42 @@ class Twig_Lexer implements Twig_LexerInterface protected $positions; protected $currentVarBlockLine; - const STATE_DATA = 0; - const STATE_BLOCK = 1; - const STATE_VAR = 2; - const STATE_STRING = 3; - const STATE_INTERPOLATION = 4; + const STATE_DATA = 0; + const STATE_BLOCK = 1; + const STATE_VAR = 2; + const STATE_STRING = 3; + const STATE_INTERPOLATION = 4; - const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A'; - const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A'; - const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As'; + const REGEX_NAME = '/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A'; + const REGEX_NUMBER = '/[0-9]+(?:\.[0-9]+)?/A'; + const REGEX_STRING = '/"([^#"\\\\]*(?:\\\\.[^#"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As'; const REGEX_DQ_STRING_DELIM = '/"/A'; - const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As'; - const PUNCTUATION = '()[]{}?:.,|'; + const REGEX_DQ_STRING_PART = '/[^#"\\\\]*(?:(?:\\\\.|#(?!\{))[^#"\\\\]*)*/As'; + const PUNCTUATION = '()[]{}?:.,|'; public function __construct(Twig_Environment $env, array $options = array()) { $this->env = $env; $this->options = array_merge(array( - 'tag_comment' => array('{#', '#}'), - 'tag_block' => array('{%', '%}'), - 'tag_variable' => array('{{', '}}'), + 'tag_comment' => array('{#', '#}'), + 'tag_block' => array('{%', '%}'), + 'tag_variable' => array('{{', '}}'), 'whitespace_trim' => '-', - 'interpolation' => array('#{', '}'), + 'interpolation' => array('#{', '}'), ), $options); $this->regexes = array( - 'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A', - 'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A', - 'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:end%s)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s', - 'operator' => $this->getOperatorRegex(), - 'lex_comment' => '/(?:'.preg_quote($this->options['whitespace_trim'], '/').preg_quote($this->options['tag_comment'][1], '/').'\s*|'.preg_quote($this->options['tag_comment'][1], '/').')\n?/s', - 'lex_block_raw' => '/\s*(raw|verbatim)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/As', - 'lex_block_line' => '/\s*line\s+(\d+)\s*'.preg_quote($this->options['tag_block'][1], '/').'/As', - 'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s', + 'lex_var' => '/\s*'.preg_quote($this->options['whitespace_trim'].$this->options['tag_variable'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_variable'][1], '/').'/A', + 'lex_block' => '/\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')\n?/A', + 'lex_raw_data' => '/('.preg_quote($this->options['tag_block'][0].$this->options['whitespace_trim'], '/').'|'.preg_quote($this->options['tag_block'][0], '/').')\s*(?:end%s)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/s', + 'operator' => $this->getOperatorRegex(), + 'lex_comment' => '/(?:'.preg_quote($this->options['whitespace_trim'], '/').preg_quote($this->options['tag_comment'][1], '/').'\s*|'.preg_quote($this->options['tag_comment'][1], '/').')\n?/s', + 'lex_block_raw' => '/\s*(raw|verbatim)\s*(?:'.preg_quote($this->options['whitespace_trim'].$this->options['tag_block'][1], '/').'\s*|\s*'.preg_quote($this->options['tag_block'][1], '/').')/As', + 'lex_block_line' => '/\s*line\s+(\d+)\s*'.preg_quote($this->options['tag_block'][1], '/').'/As', + 'lex_tokens_start' => '/('.preg_quote($this->options['tag_variable'][0], '/').'|'.preg_quote($this->options['tag_block'][0], '/').'|'.preg_quote($this->options['tag_comment'][0], '/').')('.preg_quote($this->options['whitespace_trim'], '/').')?/s', 'interpolation_start' => '/'.preg_quote($this->options['interpolation'][0], '/').'\s*/A', - 'interpolation_end' => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A', + 'interpolation_end' => '/\s*'.preg_quote($this->options['interpolation'][1], '/').'/A', ); } @@ -287,6 +287,10 @@ class Twig_Lexer implements Twig_LexerInterface protected function lexRawData($tag) { + if ('raw' === $tag) { + @trigger_error(sprintf('Twig Tag "raw" is deprecated. Use "verbatim" instead in %s at line %d.', $this->filename, $this->lineno), E_USER_DEPRECATED); + } + if (!preg_match(str_replace('%s', $tag, $this->regexes['lex_raw_data']), $this->code, $match, PREG_OFFSET_CAPTURE, $this->cursor)) { throw new Twig_Error_Syntax(sprintf('Unexpected end of file: Unclosed "%s" block', $tag), $this->lineno, $this->filename); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Loader/Array.php b/_sakura/vendor/twig/twig/lib/Twig/Loader/Array.php index 436edd8..90221d5 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Loader/Array.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Loader/Array.php @@ -29,8 +29,6 @@ class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterf * Constructor. * * @param array $templates An array of templates (keys are the names, and values are the source code) - * - * @see Twig_Loader */ public function __construct(array $templates) { diff --git a/_sakura/vendor/twig/twig/lib/Twig/Loader/Filesystem.php b/_sakura/vendor/twig/twig/lib/Twig/Loader/Filesystem.php index 818a461..a68876c 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Loader/Filesystem.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Loader/Filesystem.php @@ -21,6 +21,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI protected $paths = array(); protected $cache = array(); + protected $errorCache = array(); /** * Constructor. @@ -87,7 +88,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI public function addPath($path, $namespace = self::MAIN_NAMESPACE) { // invalidate the cache - $this->cache = array(); + $this->cache = $this->errorCache = array(); if (!is_dir($path)) { throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path)); @@ -107,7 +108,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI public function prependPath($path, $namespace = self::MAIN_NAMESPACE) { // invalidate the cache - $this->cache = array(); + $this->cache = $this->errorCache = array(); if (!is_dir($path)) { throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path)); @@ -150,9 +151,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI } try { - $this->findTemplate($name); - - return true; + return false !== $this->findTemplate($name, false); } catch (Twig_Error_Loader $exception) { return false; } @@ -168,18 +167,33 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI protected function findTemplate($name) { + $throw = func_num_args() > 1 ? func_get_arg(1) : true; $name = $this->normalizeName($name); if (isset($this->cache[$name])) { return $this->cache[$name]; } + if (isset($this->errorCache[$name])) { + if (!$throw) { + return false; + } + + throw new Twig_Error_Loader($this->errorCache[$name]); + } + $this->validateName($name); list($namespace, $shortname) = $this->parseName($name); if (!isset($this->paths[$namespace])) { - throw new Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace)); + $this->errorCache[$name] = sprintf('There are no registered paths for namespace "%s".', $namespace); + + if (!$throw) { + return false; + } + + throw new Twig_Error_Loader($this->errorCache[$name]); } foreach ($this->paths[$namespace] as $path) { @@ -192,7 +206,13 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI } } - throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace]))); + $this->errorCache[$name] = sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths[$namespace])); + + if (!$throw) { + return false; + } + + throw new Twig_Error_Loader($this->errorCache[$name]); } protected function parseName($name, $default = self::MAIN_NAMESPACE) diff --git a/_sakura/vendor/twig/twig/lib/Twig/Loader/String.php b/_sakura/vendor/twig/twig/lib/Twig/Loader/String.php index 63d6890..e7fff3e 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Loader/String.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Loader/String.php @@ -9,6 +9,8 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Loader_String class is deprecated since version 1.18.1 and will be removed in 2.0. Use Twig_Loader_Array instead.', E_USER_DEPRECATED); + /** * Loads a template from a string. * diff --git a/_sakura/vendor/twig/twig/lib/Twig/LoaderInterface.php b/_sakura/vendor/twig/twig/lib/Twig/LoaderInterface.php index 9cd45e2..544ea4e 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/LoaderInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/LoaderInterface.php @@ -41,9 +41,9 @@ interface Twig_LoaderInterface /** * Returns true if the template is still fresh. * - * @param string $name The template name - * @param int $time Timestamp of the last modification time of the - * cached template + * @param string $name The template name + * @param int $time Timestamp of the last modification time of the + * cached template * * @return bool true if the template is fresh, false otherwise * diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node.php b/_sakura/vendor/twig/twig/lib/Twig/Node.php index 1c78e7b..40d67fe 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node.php @@ -74,6 +74,8 @@ class Twig_Node implements Twig_NodeInterface */ public function toXml($asDom = false) { + @trigger_error(sprintf('%s is deprecated.', __METHOD__), E_USER_DEPRECATED); + $dom = new DOMDocument('1.0', 'UTF-8'); $dom->formatOutput = true; $dom->appendChild($xml = $dom->createElement('twig')); diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/CheckSecurity.php b/_sakura/vendor/twig/twig/lib/Twig/Node/CheckSecurity.php index 3040b76..b4a436a 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/CheckSecurity.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/CheckSecurity.php @@ -41,9 +41,9 @@ class Twig_Node_CheckSecurity extends Twig_Node } $compiler - ->write("\$tags = ")->repr(array_filter($tags))->raw(";\n") - ->write("\$filters = ")->repr(array_filter($filters))->raw(";\n") - ->write("\$functions = ")->repr(array_filter($functions))->raw(";\n\n") + ->write('$tags = ')->repr(array_filter($tags))->raw(";\n") + ->write('$filters = ')->repr(array_filter($filters))->raw(";\n") + ->write('$functions = ')->repr(array_filter($functions))->raw(";\n\n") ->write("try {\n") ->indent() ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n") diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Embed.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Embed.php index c54d2cc..a213040 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Embed.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Embed.php @@ -28,7 +28,7 @@ class Twig_Node_Embed extends Twig_Node_Include protected function addGetTemplate(Twig_Compiler $compiler) { $compiler - ->write("\$this->loadTemplate(") + ->write('$this->loadTemplate(') ->string($this->getAttribute('filename')) ->raw(', ') ->repr($compiler->getFilename()) @@ -36,7 +36,7 @@ class Twig_Node_Embed extends Twig_Node_Include ->repr($this->getLine()) ->raw(', ') ->string($this->getAttribute('index')) - ->raw(")") + ->raw(')') ; } } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php index 4ddb2cf..c25aadd 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/BlockReference.php @@ -36,15 +36,15 @@ class Twig_Node_Expression_BlockReference extends Twig_Node_Expression if ($this->getAttribute('output')) { $compiler ->addDebugInfo($this) - ->write("\$this->displayBlock(") + ->write('$this->displayBlock(') ->subcompile($this->getNode('name')) ->raw(", \$context, \$blocks);\n") ; } else { $compiler - ->raw("\$this->renderBlock(") + ->raw('$this->renderBlock(') ->subcompile($this->getNode('name')) - ->raw(", \$context, \$blocks)") + ->raw(', $context, $blocks)') ; } } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Call.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Call.php index 998160b..51e2cac 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Call.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Call.php @@ -106,12 +106,19 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression $parameters[$name] = $node; } - if (!$named) { + $isVariadic = $this->hasAttribute('is_variadic') && $this->getAttribute('is_variadic'); + if (!$named && !$isVariadic) { return $parameters; } if (!$callable) { - throw new LogicException(sprintf('Named arguments are not supported for %s "%s".', $callType, $callName)); + if ($named) { + $message = sprintf('Named arguments are not supported for %s "%s".', $callType, $callName); + } else { + $message = sprintf('Arbitrary positional arguments are not supported for %s "%s".', $callType, $callName); + } + + throw new LogicException($message); } // manage named arguments @@ -141,6 +148,19 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression array_shift($definition); } } + if ($isVariadic) { + $argument = end($definition); + if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && array() === $argument->getDefaultValue()) { + array_pop($definition); + } else { + $callableName = $r->name; + if ($r->getDeclaringClass()) { + $callableName = $r->getDeclaringClass()->name.'::'.$callableName; + } + + throw new LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = array()".', $callableName, $callType, $callName)); + } + } $arguments = array(); $names = array(); @@ -185,6 +205,23 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression } } + if ($isVariadic) { + $arbitraryArguments = new Twig_Node_Expression_Array(array(), -1); + foreach ($parameters as $key => $value) { + if (is_int($key)) { + $arbitraryArguments->addElement($value); + } else { + $arbitraryArguments->addElement($value, new Twig_Node_Expression_Constant($key, -1)); + } + unset($parameters[$key]); + } + + if ($arbitraryArguments->count()) { + $arguments = array_merge($arguments, $optionalArguments); + $arguments[] = $arbitraryArguments; + } + } + if (!empty($parameters)) { $unknownParameter = null; foreach ($parameters as $parameter) { diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php index 207b062..a906232 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Filter.php @@ -30,6 +30,9 @@ class Twig_Node_Expression_Filter extends Twig_Node_Expression_Call if ($filter instanceof Twig_FilterCallableInterface || $filter instanceof Twig_SimpleFilter) { $this->setAttribute('callable', $filter->getCallable()); } + if ($filter instanceof Twig_SimpleFilter) { + $this->setAttribute('is_variadic', $filter->isVariadic()); + } $this->compileCallable($compiler); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Function.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Function.php index 3e1f6b5..7326ede 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Function.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Function.php @@ -29,6 +29,9 @@ class Twig_Node_Expression_Function extends Twig_Node_Expression_Call if ($function instanceof Twig_FunctionCallableInterface || $function instanceof Twig_SimpleFunction) { $this->setAttribute('callable', $function->getCallable()); } + if ($function instanceof Twig_SimpleFunction) { + $this->setAttribute('is_variadic', $function->isVariadic()); + } $this->compileCallable($compiler); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Name.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Name.php index 0bfcdbc..c062a21 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Name.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Name.php @@ -12,7 +12,7 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression { protected $specialVars = array( - '_self' => '$this', + '_self' => '$this', '_context' => '$context', '_charset' => '$this->env->getCharset()', ); @@ -30,11 +30,19 @@ class Twig_Node_Expression_Name extends Twig_Node_Expression if ($this->getAttribute('is_defined_test')) { if ($this->isSpecial()) { + if ('_self' === $name) { + @trigger_error(sprintf('Global variable "_self" is deprecated in %s at line %d', '?', $this->getLine()), E_USER_DEPRECATED); + } + $compiler->repr(true); } else { $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)'); } } elseif ($this->isSpecial()) { + if ('_self' === $name) { + @trigger_error(sprintf('Global variable "_self" is deprecated in %s at line %d', '?', $this->getLine()), E_USER_DEPRECATED); + } + $compiler->raw($this->specialVars[$name]); } elseif ($this->getAttribute('always_defined')) { $compiler diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Parent.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Parent.php index a22ce03..bd5024b 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Parent.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Parent.php @@ -32,15 +32,15 @@ class Twig_Node_Expression_Parent extends Twig_Node_Expression if ($this->getAttribute('output')) { $compiler ->addDebugInfo($this) - ->write("\$this->displayParentBlock(") + ->write('$this->displayParentBlock(') ->string($this->getAttribute('name')) ->raw(", \$context, \$blocks);\n") ; } else { $compiler - ->raw("\$this->renderParentBlock(") + ->raw('$this->renderParentBlock(') ->string($this->getAttribute('name')) - ->raw(", \$context, \$blocks)") + ->raw(', $context, $blocks)') ; } } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Test.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Test.php index 639f501..c0358c8 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Test.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Expression/Test.php @@ -26,6 +26,9 @@ class Twig_Node_Expression_Test extends Twig_Node_Expression_Call if ($test instanceof Twig_TestCallableInterface || $test instanceof Twig_SimpleTest) { $this->setAttribute('callable', $test->getCallable()); } + if ($test instanceof Twig_SimpleTest) { + $this->setAttribute('is_variadic', $test->isVariadic()); + } $this->compileCallable($compiler); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/For.php b/_sakura/vendor/twig/twig/lib/Twig/Node/For.php index c54a23c..36e9de8 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/For.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/For.php @@ -82,7 +82,7 @@ class Twig_Node_For extends Twig_Node $compiler ->write("foreach (\$context['_seq'] as ") ->subcompile($this->getNode('key_target')) - ->raw(" => ") + ->raw(' => ') ->subcompile($this->getNode('value_target')) ->raw(") {\n") ->indent() diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/If.php b/_sakura/vendor/twig/twig/lib/Twig/Node/If.php index 980274e..1b6104d 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/If.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/If.php @@ -34,7 +34,7 @@ class Twig_Node_If extends Twig_Node if ($i > 0) { $compiler ->outdent() - ->write("} elseif (") + ->write('} elseif (') ; } else { $compiler diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Import.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Import.php index 5e4aa11..515ff2a 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Import.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Import.php @@ -36,7 +36,7 @@ class Twig_Node_Import extends Twig_Node ; if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) { - $compiler->raw("\$this"); + $compiler->raw('$this'); } else { $compiler ->raw('$this->loadTemplate(') @@ -45,7 +45,7 @@ class Twig_Node_Import extends Twig_Node ->repr($compiler->getFilename()) ->raw(', ') ->repr($this->getLine()) - ->raw(")") + ->raw(')') ; } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Include.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Include.php index 46b0685..fecaa82 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Include.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Include.php @@ -61,13 +61,13 @@ class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface protected function addGetTemplate(Twig_Compiler $compiler) { $compiler - ->write("\$this->loadTemplate(") + ->write('$this->loadTemplate(') ->subcompile($this->getNode('expr')) ->raw(', ') ->repr($compiler->getFilename()) ->raw(', ') ->repr($this->getLine()) - ->raw(")") + ->raw(')') ; } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Macro.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Macro.php index ab7e8d2..03cf4dd 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Macro.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Macro.php @@ -16,8 +16,16 @@ */ class Twig_Node_Macro extends Twig_Node { + const VARARGS_NAME = 'varargs'; + public function __construct($name, Twig_NodeInterface $body, Twig_NodeInterface $arguments, $lineno, $tag = null) { + foreach ($arguments as $argumentName => $argument) { + if (self::VARARGS_NAME === $argumentName) { + throw new Twig_Error_Syntax(sprintf('The argument "%s" in macro "%s" cannot be defined because the variable "%s" is reserved for arbitrary arguments', self::VARARGS_NAME, $name, self::VARARGS_NAME), $argument->getLine()); + } + } + parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag); } @@ -30,7 +38,7 @@ class Twig_Node_Macro extends Twig_Node { $compiler ->addDebugInfo($this) - ->write(sprintf("public function get%s(", $this->getAttribute('name'))) + ->write(sprintf('public function get%s(', $this->getAttribute('name'))) ; $count = count($this->getNode('arguments')); @@ -46,36 +54,55 @@ class Twig_Node_Macro extends Twig_Node } } + if (PHP_VERSION_ID >= 50600) { + if ($count) { + $compiler->raw(', '); + } + + $compiler->raw('...$__varargs__'); + } + $compiler ->raw(")\n") ->write("{\n") ->indent() ; - if (!count($this->getNode('arguments'))) { - $compiler->write("\$context = \$this->env->getGlobals();\n\n"); - } else { - $compiler - ->write("\$context = \$this->env->mergeGlobals(array(\n") - ->indent() - ; - - foreach ($this->getNode('arguments') as $name => $default) { - $compiler - ->write('') - ->string($name) - ->raw(' => $__'.$name.'__') - ->raw(",\n") - ; - } + $compiler + ->write("\$context = \$this->env->mergeGlobals(array(\n") + ->indent() + ; + foreach ($this->getNode('arguments') as $name => $default) { $compiler - ->outdent() - ->write("));\n\n") + ->addIndentation() + ->string($name) + ->raw(' => $__'.$name.'__') + ->raw(",\n") ; } $compiler + ->addIndentation() + ->string(self::VARARGS_NAME) + ->raw(' => ') + ; + + if (PHP_VERSION_ID >= 50600) { + $compiler->raw("\$__varargs__,\n"); + } else { + $compiler + ->raw('func_num_args() > ') + ->repr($count) + ->raw(' ? array_slice(func_get_args(), ') + ->repr($count) + ->raw(") : array(),\n") + ; + } + + $compiler + ->outdent() + ->write("));\n\n") ->write("\$blocks = array();\n\n") ->write("ob_start();\n") ->write("try {\n") diff --git a/_sakura/vendor/twig/twig/lib/Twig/Node/Module.php b/_sakura/vendor/twig/twig/lib/Twig/Node/Module.php index 7802263..1bc4fea 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Node/Module.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Node/Module.php @@ -107,20 +107,20 @@ class Twig_Node_Module extends Twig_Node ->write("protected function doGetParent(array \$context)\n", "{\n") ->indent() ->addDebugInfo($parent) - ->write("return ") + ->write('return ') ; if ($parent instanceof Twig_Node_Expression_Constant) { $compiler->subcompile($parent); } else { $compiler - ->raw("\$this->loadTemplate(") + ->raw('$this->loadTemplate(') ->subcompile($parent) ->raw(', ') ->repr($compiler->getFilename()) ->raw(', ') ->repr($this->getNode('parent')->getLine()) - ->raw(")") + ->raw(')') ; } @@ -136,7 +136,7 @@ class Twig_Node_Module extends Twig_Node $compiler ->write("\n\n") // if the filename contains */, add a blank to avoid a PHP parse error - ->write("/* ".str_replace('*/', '* /', $this->getAttribute('filename'))." */\n") + ->write('/* '.str_replace('*/', '* /', $this->getAttribute('filename'))." */\n") ->write('class '.$compiler->getEnvironment()->getTemplateClass($this->getAttribute('filename'), $this->getAttribute('index'))) ->raw(sprintf(" extends %s\n", $compiler->getEnvironment()->getBaseTemplateClass())) ->write("{\n") @@ -159,7 +159,7 @@ class Twig_Node_Module extends Twig_Node } elseif ($parent instanceof Twig_Node_Expression_Constant) { $compiler ->addDebugInfo($parent) - ->write("\$this->parent = \$this->loadTemplate(") + ->write('$this->parent = $this->loadTemplate(') ->subcompile($parent) ->raw(', ') ->repr($compiler->getFilename()) @@ -189,23 +189,23 @@ class Twig_Node_Module extends Twig_Node foreach ($trait->getNode('targets') as $key => $value) { $compiler - ->write(sprintf("if (!isset(\$_trait_%s_blocks[", $i)) + ->write(sprintf('if (!isset($_trait_%s_blocks[', $i)) ->string($key) ->raw("])) {\n") ->indent() ->write("throw new Twig_Error_Runtime(sprintf('Block ") ->string($key) - ->raw(" is not defined in trait ") + ->raw(' is not defined in trait ') ->subcompile($trait->getNode('template')) ->raw(".'));\n") ->outdent() ->write("}\n\n") - ->write(sprintf("\$_trait_%s_blocks[", $i)) + ->write(sprintf('$_trait_%s_blocks[', $i)) ->subcompile($value) - ->raw(sprintf("] = \$_trait_%s_blocks[", $i)) + ->raw(sprintf('] = $_trait_%s_blocks[', $i)) ->string($key) - ->raw(sprintf("]; unset(\$_trait_%s_blocks[", $i)) + ->raw(sprintf(']; unset($_trait_%s_blocks[', $i)) ->string($key) ->raw("]);\n\n") ; @@ -218,9 +218,9 @@ class Twig_Node_Module extends Twig_Node ->indent() ; - for ($i = 0; $i < $countTraits; $i++) { + for ($i = 0; $i < $countTraits; ++$i) { $compiler - ->write(sprintf("\$_trait_%s_blocks".($i == $countTraits - 1 ? '' : ',')."\n", $i)) + ->write(sprintf('$_trait_%s_blocks'.($i == $countTraits - 1 ? '' : ',')."\n", $i)) ; } @@ -285,9 +285,9 @@ class Twig_Node_Module extends Twig_Node if (null !== $parent = $this->getNode('parent')) { $compiler->addDebugInfo($parent); if ($parent instanceof Twig_Node_Expression_Constant) { - $compiler->write("\$this->parent"); + $compiler->write('$this->parent'); } else { - $compiler->write("\$this->getParent(\$context)"); + $compiler->write('$this->getParent($context)'); } $compiler->raw("->display(\$context, array_merge(\$this->blocks, \$blocks));\n"); } @@ -393,7 +393,7 @@ class Twig_Node_Module extends Twig_Node { if ($node instanceof Twig_Node_Expression_Constant) { $compiler - ->write(sprintf("%s = \$this->loadTemplate(", $var)) + ->write(sprintf('%s = $this->loadTemplate(', $var)) ->subcompile($node) ->raw(', ') ->repr($compiler->getFilename()) @@ -402,22 +402,7 @@ class Twig_Node_Module extends Twig_Node ->raw(");\n") ; } else { - $compiler - ->write(sprintf("%s = ", $var)) - ->subcompile($node) - ->raw(";\n") - ->write(sprintf("if (!%s", $var)) - ->raw(" instanceof Twig_Template) {\n") - ->indent() - ->write(sprintf("%s = \$this->loadTemplate(%s") - ->raw(', ') - ->repr($compiler->getFilename()) - ->raw(', ') - ->repr($node->getLine()) - ->raw(");\n", $var, $var)) - ->outdent() - ->write("}\n") - ; + throw new LogicException('Trait templates can only be constant nodes'); } } } diff --git a/_sakura/vendor/twig/twig/lib/Twig/NodeTraverser.php b/_sakura/vendor/twig/twig/lib/Twig/NodeTraverser.php index 6024e65..00f7b54 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/NodeTraverser.php +++ b/_sakura/vendor/twig/twig/lib/Twig/NodeTraverser.php @@ -19,7 +19,7 @@ class Twig_NodeTraverser { protected $env; - protected $visitors; + protected $visitors = array(); /** * Constructor. @@ -30,7 +30,6 @@ class Twig_NodeTraverser public function __construct(Twig_Environment $env, array $visitors = array()) { $this->env = $env; - $this->visitors = array(); foreach ($visitors as $visitor) { $this->addVisitor($visitor); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php b/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php index cc4b3d7..5c94977 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php +++ b/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/Escaper.php @@ -14,7 +14,7 @@ * * @author Fabien Potencier */ -class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface +class Twig_NodeVisitor_Escaper extends Twig_BaseNodeVisitor { protected $statusStack = array(); protected $blocks = array(); @@ -29,14 +29,9 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface } /** - * Called before child nodes are visited. - * - * @param Twig_NodeInterface $node The node to visit - * @param Twig_Environment $env The Twig environment instance - * - * @return Twig_NodeInterface The modified node + * {@inheritdoc} */ - public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doEnterNode(Twig_Node $node, Twig_Environment $env) { if ($node instanceof Twig_Node_Module) { if ($env->hasExtension('escaper') && $defaultStrategy = $env->getExtension('escaper')->getDefaultStrategy($node->getAttribute('filename'))) { @@ -55,14 +50,9 @@ class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface } /** - * Called after child nodes are visited. - * - * @param Twig_NodeInterface $node The node to visit - * @param Twig_Environment $env The Twig environment instance - * - * @return Twig_NodeInterface The modified node + * {@inheritdoc} */ - public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) { if ($node instanceof Twig_Node_Module) { $this->defaultStrategy = false; diff --git a/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php b/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php index b206e9a..872b7fe 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php +++ b/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/Optimizer.php @@ -19,13 +19,13 @@ * * @author Fabien Potencier */ -class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface +class Twig_NodeVisitor_Optimizer extends Twig_BaseNodeVisitor { - const OPTIMIZE_ALL = -1; - const OPTIMIZE_NONE = 0; - const OPTIMIZE_FOR = 2; - const OPTIMIZE_RAW_FILTER = 4; - const OPTIMIZE_VAR_ACCESS = 8; + const OPTIMIZE_ALL = -1; + const OPTIMIZE_NONE = 0; + const OPTIMIZE_FOR = 2; + const OPTIMIZE_RAW_FILTER = 4; + const OPTIMIZE_VAR_ACCESS = 8; protected $loops = array(); protected $loopsTargets = array(); @@ -50,7 +50,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface /** * {@inheritdoc} */ - public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doEnterNode(Twig_Node $node, Twig_Environment $env) { if (self::OPTIMIZE_FOR === (self::OPTIMIZE_FOR & $this->optimizers)) { $this->enterOptimizeFor($node, $env); @@ -76,7 +76,7 @@ class Twig_NodeVisitor_Optimizer implements Twig_NodeVisitorInterface /** * {@inheritdoc} */ - public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) { $expression = $node instanceof Twig_Node_Expression; diff --git a/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php b/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php index a5d06de..439f5bf 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php +++ b/_sakura/vendor/twig/twig/lib/Twig/NodeVisitor/SafeAnalysis.php @@ -1,6 +1,15 @@ */ -class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface +class Twig_NodeVisitor_Sandbox extends Twig_BaseNodeVisitor { protected $inAModule = false; protected $tags; @@ -22,14 +22,9 @@ class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface protected $functions; /** - * Called before child nodes are visited. - * - * @param Twig_NodeInterface $node The node to visit - * @param Twig_Environment $env The Twig environment instance - * - * @return Twig_NodeInterface The modified node + * {@inheritdoc} */ - public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doEnterNode(Twig_Node $node, Twig_Environment $env) { if ($node instanceof Twig_Node_Module) { $this->inAModule = true; @@ -64,14 +59,9 @@ class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface } /** - * Called after child nodes are visited. - * - * @param Twig_NodeInterface $node The node to visit - * @param Twig_Environment $env The Twig environment instance - * - * @return Twig_NodeInterface The modified node + * {@inheritdoc} */ - public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) { if ($node instanceof Twig_Node_Module) { $this->inAModule = false; diff --git a/_sakura/vendor/twig/twig/lib/Twig/Parser.php b/_sakura/vendor/twig/twig/lib/Twig/Parser.php index 549ce2b..6f24ee6 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Parser.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Parser.php @@ -64,7 +64,7 @@ class Twig_Parser implements Twig_ParserInterface { // push all variables into the stack to keep the current state of the parser $vars = get_object_vars($this); - unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser']); + unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser'], $vars['reservedMacroNames']); $this->stack[] = $vars; // tag handlers @@ -254,21 +254,30 @@ class Twig_Parser implements Twig_ParserInterface public function setMacro($name, Twig_Node_Macro $node) { - if (null === $this->reservedMacroNames) { - $this->reservedMacroNames = array(); - $r = new ReflectionClass($this->env->getBaseTemplateClass()); - foreach ($r->getMethods() as $method) { - $this->reservedMacroNames[] = $method->getName(); - } - } - - if (in_array($name, $this->reservedMacroNames)) { + if ($this->isReservedMacroName($name)) { throw new Twig_Error_Syntax(sprintf('"%s" cannot be used as a macro name as it is a reserved keyword', $name), $node->getLine(), $this->getFilename()); } $this->macros[$name] = $node; } + public function isReservedMacroName($name) + { + if (null === $this->reservedMacroNames) { + $this->reservedMacroNames = array(); + $r = new ReflectionClass($this->env->getBaseTemplateClass()); + foreach ($r->getMethods() as $method) { + $methodName = strtolower($method->getName()); + + if ('get' === substr($methodName, 0, 3) && isset($methodName[3])) { + $this->reservedMacroNames[] = substr($methodName, 3); + } + } + } + + return in_array(strtolower($name), $this->reservedMacroNames); + } + public function addTrait($trait) { $this->traits[] = $trait; diff --git a/_sakura/vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php b/_sakura/vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php index c898520..f066da7 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Profiler/Dumper/Html.php @@ -14,7 +14,7 @@ */ class Twig_Profiler_Dumper_Html extends Twig_Profiler_Dumper_Text { - static private $colors = array( + private static $colors = array( 'block' => '#dfd', 'macro' => '#ddf', 'template' => '#ffd', diff --git a/_sakura/vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php b/_sakura/vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php index 11c1114..2f97214 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Profiler/Node/EnterProfile.php @@ -27,12 +27,12 @@ class Twig_Profiler_Node_EnterProfile extends Twig_Node public function compile(Twig_Compiler $compiler) { $compiler - ->write(sprintf("\$%s = \$this->env->getExtension(", $this->getAttribute('var_name'))) + ->write(sprintf('$%s = $this->env->getExtension(', $this->getAttribute('var_name'))) ->repr($this->getAttribute('extension_name')) ->raw(");\n") - ->write(sprintf("\$%s->enter(\$%s = new Twig_Profiler_Profile(\$this->getTemplateName(), ", $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof')) + ->write(sprintf('$%s->enter($%s = new Twig_Profiler_Profile($this->getTemplateName(), ', $this->getAttribute('var_name'), $this->getAttribute('var_name').'_prof')) ->repr($this->getAttribute('type')) - ->raw(", ") + ->raw(', ') ->repr($this->getAttribute('name')) ->raw("));\n\n") ; diff --git a/_sakura/vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php b/_sakura/vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php index 58beb0a..4b0baa8 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Profiler/NodeVisitor/Profiler.php @@ -12,7 +12,7 @@ /** * @author Fabien Potencier */ -class Twig_Profiler_NodeVisitor_Profiler implements Twig_NodeVisitorInterface +class Twig_Profiler_NodeVisitor_Profiler extends Twig_BaseNodeVisitor { private $extensionName; @@ -24,7 +24,7 @@ class Twig_Profiler_NodeVisitor_Profiler implements Twig_NodeVisitorInterface /** * {@inheritdoc} */ - public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doEnterNode(Twig_Node $node, Twig_Environment $env) { return $node; } @@ -32,7 +32,7 @@ class Twig_Profiler_NodeVisitor_Profiler implements Twig_NodeVisitorInterface /** * {@inheritdoc} */ - public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) + protected function doLeaveNode(Twig_Node $node, Twig_Environment $env) { if ($node instanceof Twig_Node_Module) { $varName = $this->getVarName(); diff --git a/_sakura/vendor/twig/twig/lib/Twig/Profiler/Profile.php b/_sakura/vendor/twig/twig/lib/Twig/Profiler/Profile.php index fe48a4d..ec9e254 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Profiler/Profile.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Profiler/Profile.php @@ -26,7 +26,7 @@ class Twig_Profiler_Profile implements IteratorAggregate, Serializable private $ends = array(); private $profiles = array(); - public function __construct($template = 'main', $type = Twig_Profiler_Profile::ROOT, $name = 'main') + public function __construct($template = 'main', $type = self::ROOT, $name = 'main') { $this->template = $template; $this->type = $type; diff --git a/_sakura/vendor/twig/twig/lib/Twig/SimpleFilter.php b/_sakura/vendor/twig/twig/lib/Twig/SimpleFilter.php index d35c563..cefc4f5 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/SimpleFilter.php +++ b/_sakura/vendor/twig/twig/lib/Twig/SimpleFilter.php @@ -27,12 +27,15 @@ class Twig_SimpleFilter $this->callable = $callable; $this->options = array_merge(array( 'needs_environment' => false, - 'needs_context' => false, - 'is_safe' => null, - 'is_safe_callback' => null, - 'pre_escape' => null, - 'preserves_safety' => null, - 'node_class' => 'Twig_Node_Expression_Filter', + 'needs_context' => false, + 'is_variadic' => false, + 'is_safe' => null, + 'is_safe_callback' => null, + 'pre_escape' => null, + 'preserves_safety' => null, + 'node_class' => 'Twig_Node_Expression_Filter', + 'deprecated' => false, + 'alternative' => null, ), $options); } @@ -91,4 +94,19 @@ class Twig_SimpleFilter { return $this->options['pre_escape']; } + + public function isVariadic() + { + return $this->options['is_variadic']; + } + + public function isDeprecated() + { + return $this->options['deprecated']; + } + + public function getAlternative() + { + return $this->options['alternative']; + } } diff --git a/_sakura/vendor/twig/twig/lib/Twig/SimpleFunction.php b/_sakura/vendor/twig/twig/lib/Twig/SimpleFunction.php index 8ef6aca..7973540 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/SimpleFunction.php +++ b/_sakura/vendor/twig/twig/lib/Twig/SimpleFunction.php @@ -27,10 +27,13 @@ class Twig_SimpleFunction $this->callable = $callable; $this->options = array_merge(array( 'needs_environment' => false, - 'needs_context' => false, - 'is_safe' => null, - 'is_safe_callback' => null, - 'node_class' => 'Twig_Node_Expression_Function', + 'needs_context' => false, + 'is_variadic' => false, + 'is_safe' => null, + 'is_safe_callback' => null, + 'node_class' => 'Twig_Node_Expression_Function', + 'deprecated' => false, + 'alternative' => null, ), $options); } @@ -81,4 +84,19 @@ class Twig_SimpleFunction return array(); } + + public function isVariadic() + { + return $this->options['is_variadic']; + } + + public function isDeprecated() + { + return $this->options['deprecated']; + } + + public function getAlternative() + { + return $this->options['alternative']; + } } diff --git a/_sakura/vendor/twig/twig/lib/Twig/SimpleTest.php b/_sakura/vendor/twig/twig/lib/Twig/SimpleTest.php index 225459c..8ba2192 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/SimpleTest.php +++ b/_sakura/vendor/twig/twig/lib/Twig/SimpleTest.php @@ -25,7 +25,10 @@ class Twig_SimpleTest $this->name = $name; $this->callable = $callable; $this->options = array_merge(array( + 'is_variadic' => false, 'node_class' => 'Twig_Node_Expression_Test', + 'deprecated' => false, + 'alternative' => null, ), $options); } @@ -43,4 +46,19 @@ class Twig_SimpleTest { return $this->options['node_class']; } + + public function isVariadic() + { + return $this->options['is_variadic']; + } + + public function isDeprecated() + { + return $this->options['deprecated']; + } + + public function getAlternative() + { + return $this->options['alternative']; + } } diff --git a/_sakura/vendor/twig/twig/lib/Twig/Template.php b/_sakura/vendor/twig/twig/lib/Twig/Template.php index 0878d16..e2ab05a 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Template.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Template.php @@ -22,8 +22,8 @@ abstract class Twig_Template implements Twig_TemplateInterface protected $parent; protected $parents = array(); protected $env; - protected $blocks; - protected $traits; + protected $blocks = array(); + protected $traits = array(); /** * Constructor. @@ -33,8 +33,6 @@ abstract class Twig_Template implements Twig_TemplateInterface public function __construct(Twig_Environment $env) { $this->env = $env; - $this->blocks = array(); - $this->traits = array(); } /** @@ -45,10 +43,12 @@ abstract class Twig_Template implements Twig_TemplateInterface abstract public function getTemplateName(); /** - * {@inheritdoc} + * @deprecated since 1.20 (to be removed in 2.0) */ public function getEnvironment() { + @trigger_error('The '.__METHOD__.' method is deprecated since version 1.20 and will be removed in 2.0.', E_USER_DEPRECATED); + return $this->env; } @@ -152,9 +152,25 @@ abstract class Twig_Template implements Twig_TemplateInterface } if (null !== $template) { + // avoid RCEs when sandbox is enabled + if (!$template instanceof self) { + throw new LogicException('A block must be a method on a Twig_Template instance.'); + } + try { $template->$block($context, $blocks); } catch (Twig_Error $e) { + if (!$e->getTemplateFile()) { + $e->setTemplateFile($template->getTemplateName()); + } + + // this is mostly useful for Twig_Error_Loader exceptions + // see Twig_Error_Loader + if (false === $e->getTemplateLine()) { + $e->setTemplateLine(-1); + $e->guess(); + } + throw $e; } catch (Exception $e) { throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the rendering of a template ("%s").', $e->getMessage()), -1, $template->getTemplateName(), $e); @@ -462,7 +478,7 @@ abstract class Twig_Template implements Twig_TemplateInterface } // object property - if (self::METHOD_CALL !== $type) { + if (self::METHOD_CALL !== $type && !$object instanceof self) { // Twig_Template does not have public properties, and we don't want to allow access to internal ones if (isset($object->$item) || array_key_exists((string) $item, $object)) { if ($isDefinedTest) { return true; @@ -480,7 +496,24 @@ abstract class Twig_Template implements Twig_TemplateInterface // object method if (!isset(self::$cache[$class]['methods'])) { - self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object))); + // get_class_methods returns all methods accessible in the scope, but we only want public ones to be accessible in templates + if ($object instanceof self) { + $ref = new ReflectionClass($class); + $methods = array(); + + foreach ($ref->getMethods(ReflectionMethod::IS_PUBLIC) as $refMethod) { + $methodName = strtolower($refMethod->name); + + // Accessing the environment from templates is forbidden to prevent untrusted changes to the environment + if ('getenvironment' !== $methodName) { + $methods[$methodName] = true; + } + } + + self::$cache[$class]['methods'] = $methods; + } else { + self::$cache[$class]['methods'] = array_change_key_case(array_flip(get_class_methods($object))); + } } $call = false; diff --git a/_sakura/vendor/twig/twig/lib/Twig/TemplateInterface.php b/_sakura/vendor/twig/twig/lib/Twig/TemplateInterface.php index d178832..3274640 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TemplateInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TemplateInterface.php @@ -18,8 +18,8 @@ */ interface Twig_TemplateInterface { - const ANY_CALL = 'any'; - const ARRAY_CALL = 'array'; + const ANY_CALL = 'any'; + const ARRAY_CALL = 'array'; const METHOD_CALL = 'method'; /** diff --git a/_sakura/vendor/twig/twig/lib/Twig/Test.php b/_sakura/vendor/twig/twig/lib/Twig/Test.php index 3baff88..3c2d859 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Test.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Test.php @@ -9,10 +9,13 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Test class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED); + /** * Represents a template test. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ abstract class Twig_Test implements Twig_TestInterface, Twig_TestCallableInterface diff --git a/_sakura/vendor/twig/twig/lib/Twig/Test/Function.php b/_sakura/vendor/twig/twig/lib/Twig/Test/Function.php index 4be6b9b..5e76c71 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Test/Function.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Test/Function.php @@ -9,10 +9,13 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Test_Function class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED); + /** * Represents a function template test. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Test_Function extends Twig_Test diff --git a/_sakura/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php b/_sakura/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php index b8bceb8..96892a4 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Test/IntegrationTestCase.php @@ -10,7 +10,7 @@ */ /** - * Integration test helper + * Integration test helper. * * @author Fabien Potencier * @author Karma Dordrak @@ -28,7 +28,16 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase $this->doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs); } - public function getTests() + /** + * @dataProvider getLegacyTests + * @group legacy + */ + public function testLegacyIntegration($file, $message, $condition, $templates, $exception, $outputs) + { + $this->testIntegration($file, $message, $condition, $templates, $exception, $outputs); + } + + public function getTests($name, $legacyTests = false) { $fixturesDir = realpath($this->getFixturesDir()); $tests = array(); @@ -38,10 +47,13 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase continue; } + if ($legacyTests xor false !== strpos($file->getRealpath(), '.legacy.test')) { + continue; + } + $test = file_get_contents($file->getRealpath()); - if (preg_match('/ - --TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) { + if (preg_match('/--TEST--\s*(.*?)\s*(?:--CONDITION--\s*(.*))?\s*((?:--TEMPLATE(?:\(.*?\))?--(?:.*?))+)\s*(?:--DATA--\s*(.*))?\s*--EXCEPTION--\s*(.*)/sx', $test, $match)) { $message = $match[1]; $condition = $match[2]; $templates = $this->parseTemplates($match[3]); @@ -60,9 +72,19 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase $tests[] = array(str_replace($fixturesDir.'/', '', $file), $message, $condition, $templates, $exception, $outputs); } + if (!$tests) { + // add a dummy test to avoid a PHPUnit message + return array(array('not', '-', '', array(), '', array())); + } + return $tests; } + public function getLegacyTests() + { + return $this->getTests('testLegacyIntegration', true); + } + protected function doIntegrationTest($file, $message, $condition, $templates, $exception, $outputs) { if ($condition) { @@ -74,7 +96,7 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase $loader = new Twig_Loader_Array($templates); - foreach ($outputs as $match) { + foreach ($outputs as $i => $match) { $config = array_merge(array( 'cache' => false, 'strict_variables' => true, @@ -85,6 +107,14 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase $twig->addExtension($extension); } + // avoid using the same PHP class name for different cases + // only for PHP 5.2+ + if (PHP_VERSION_ID >= 50300) { + $p = new ReflectionProperty($twig, 'templateClassPrefix'); + $p->setAccessible(true); + $p->setValue($twig, '__TwigTemplate_'.hash('sha256', uniqid(mt_rand(), true), false).'_'); + } + try { $template = $twig->loadTemplate('index.twig'); } catch (Exception $e) { @@ -122,14 +152,14 @@ abstract class Twig_Test_IntegrationTestCase extends PHPUnit_Framework_TestCase } if (false !== $exception) { - list($class, ) = explode(':', $exception); + list($class) = explode(':', $exception); $this->assertThat(null, new PHPUnit_Framework_Constraint_Exception($class)); } $expected = trim($match[3], "\n "); if ($expected != $output) { - echo 'Compiled template that failed:'; + printf("Compiled templates that failed on case %d:\n", $i + 1); foreach (array_keys($templates) as $name) { echo "Template: $name\n"; diff --git a/_sakura/vendor/twig/twig/lib/Twig/Test/Method.php b/_sakura/vendor/twig/twig/lib/Twig/Test/Method.php index 17c6c04..2779986 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Test/Method.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Test/Method.php @@ -9,10 +9,13 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Test_Method class is deprecated since version 1.12 and will be removed in 2.0. Use Twig_SimpleTest instead.', E_USER_DEPRECATED); + /** * Represents a method template test. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Test_Method extends Twig_Test diff --git a/_sakura/vendor/twig/twig/lib/Twig/Test/Node.php b/_sakura/vendor/twig/twig/lib/Twig/Test/Node.php index c832a57..baef49c 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Test/Node.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Test/Node.php @@ -9,10 +9,13 @@ * file that was distributed with this source code. */ +@trigger_error('The Twig_Test_Node class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED); + /** * Represents a template test as a Node. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_Test_Node extends Twig_Test diff --git a/_sakura/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php b/_sakura/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php index bf86521..908ef61 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Test/NodeTestCase.php @@ -35,7 +35,7 @@ abstract class Twig_Test_NodeTestCase extends PHPUnit_Framework_TestCase protected function getEnvironment() { - return new Twig_Environment(); + return new Twig_Environment(new Twig_Loader_Array(array())); } protected function getVariableGetter($name, $line = false) diff --git a/_sakura/vendor/twig/twig/lib/Twig/TestCallableInterface.php b/_sakura/vendor/twig/twig/lib/Twig/TestCallableInterface.php index 0db4368..98d3457 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TestCallableInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TestCallableInterface.php @@ -13,6 +13,7 @@ * Represents a callable template test. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_TestCallableInterface diff --git a/_sakura/vendor/twig/twig/lib/Twig/TestInterface.php b/_sakura/vendor/twig/twig/lib/Twig/TestInterface.php index 30d8a2c..2fa821c 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TestInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TestInterface.php @@ -13,6 +13,7 @@ * Represents a template test. * * @author Fabien Potencier + * * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_TestInterface diff --git a/_sakura/vendor/twig/twig/lib/Twig/Token.php b/_sakura/vendor/twig/twig/lib/Twig/Token.php index 15dd4eb..a0a029b 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/Token.php +++ b/_sakura/vendor/twig/twig/lib/Twig/Token.php @@ -21,19 +21,19 @@ class Twig_Token protected $type; protected $lineno; - const EOF_TYPE = -1; - const TEXT_TYPE = 0; - const BLOCK_START_TYPE = 1; - const VAR_START_TYPE = 2; - const BLOCK_END_TYPE = 3; - const VAR_END_TYPE = 4; - const NAME_TYPE = 5; - const NUMBER_TYPE = 6; - const STRING_TYPE = 7; - const OPERATOR_TYPE = 8; - const PUNCTUATION_TYPE = 9; - const INTERPOLATION_START_TYPE = 10; - const INTERPOLATION_END_TYPE = 11; + const EOF_TYPE = -1; + const TEXT_TYPE = 0; + const BLOCK_START_TYPE = 1; + const VAR_START_TYPE = 2; + const BLOCK_END_TYPE = 3; + const VAR_END_TYPE = 4; + const NAME_TYPE = 5; + const NUMBER_TYPE = 6; + const STRING_TYPE = 7; + const OPERATOR_TYPE = 8; + const PUNCTUATION_TYPE = 9; + const INTERPOLATION_START_TYPE = 10; + const INTERPOLATION_END_TYPE = 11; /** * Constructor. @@ -44,8 +44,8 @@ class Twig_Token */ public function __construct($type, $value, $lineno) { - $this->type = $type; - $this->value = $value; + $this->type = $type; + $this->value = $value; $this->lineno = $lineno; } diff --git a/_sakura/vendor/twig/twig/lib/Twig/TokenParser.php b/_sakura/vendor/twig/twig/lib/Twig/TokenParser.php index 57b1825..fa9b6d8 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TokenParser.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TokenParser.php @@ -22,7 +22,7 @@ abstract class Twig_TokenParser implements Twig_TokenParserInterface protected $parser; /** - * Sets the parser associated with this token parser + * Sets the parser associated with this token parser. * * @param Twig_Parser $parser A Twig_Parser instance */ diff --git a/_sakura/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php b/_sakura/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php index 2756028..a8a3d7a 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TokenParser/AutoEscape.php @@ -57,6 +57,8 @@ class Twig_TokenParser_AutoEscape extends Twig_TokenParser } if ($compat && $stream->test(Twig_Token::NAME_TYPE)) { + @trigger_error('Using the autoescape tag with "true" or "false" before the strategy name is deprecated.', E_USER_DEPRECATED); + if (false === $value) { throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $stream->getCurrent()->getLine(), $stream->getFilename()); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/TokenParser/From.php b/_sakura/vendor/twig/twig/lib/Twig/TokenParser/From.php index dd73f99..5540efa 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TokenParser/From.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TokenParser/From.php @@ -52,6 +52,10 @@ class Twig_TokenParser_From extends Twig_TokenParser $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag()); foreach ($targets as $name => $alias) { + if ($this->parser->isReservedMacroName($name)) { + throw new Twig_Error_Syntax(sprintf('"%s" cannot be an imported macro as it is a reserved keyword', $name), $token->getLine(), $stream->getFilename()); + } + $this->parser->addImportedSymbol('function', $alias, 'get'.$name, $node->getNode('var')); } diff --git a/_sakura/vendor/twig/twig/lib/Twig/TokenParserBroker.php b/_sakura/vendor/twig/twig/lib/Twig/TokenParserBroker.php index ec3fba6..6ca73fb 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TokenParserBroker.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TokenParserBroker.php @@ -14,6 +14,7 @@ * Default implementation of a token parser broker. * * @author Arnaud Le Blanc + * * @deprecated since 1.12 (to be removed in 2.0) */ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface @@ -28,8 +29,12 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances */ - public function __construct($parsers = array(), $brokers = array()) + public function __construct($parsers = array(), $brokers = array(), $triggerDeprecationError = true) { + if ($triggerDeprecationError) { + @trigger_error('The '.__CLASS__.' class is deprecated since version 1.12 and will be removed in 2.0.', E_USER_DEPRECATED); + } + foreach ($parsers as $parser) { if (!$parser instanceof Twig_TokenParserInterface) { throw new LogicException('$parsers must a an array of Twig_TokenParserInterface'); diff --git a/_sakura/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php b/_sakura/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php index 3f006e3..3ec2a88 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TokenParserBrokerInterface.php @@ -16,6 +16,7 @@ * Token parser brokers allows to implement custom logic in the process of resolving a token parser for a given tag name. * * @author Arnaud Le Blanc + * * @deprecated since 1.12 (to be removed in 2.0) */ interface Twig_TokenParserBrokerInterface diff --git a/_sakura/vendor/twig/twig/lib/Twig/TokenParserInterface.php b/_sakura/vendor/twig/twig/lib/Twig/TokenParserInterface.php index 17e394b..12ec396 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TokenParserInterface.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TokenParserInterface.php @@ -17,7 +17,7 @@ interface Twig_TokenParserInterface { /** - * Sets the parser associated with this token parser + * Sets the parser associated with this token parser. * * @param Twig_Parser $parser A Twig_Parser instance */ diff --git a/_sakura/vendor/twig/twig/lib/Twig/TokenStream.php b/_sakura/vendor/twig/twig/lib/Twig/TokenStream.php index 7e95a4f..8d2e220 100644 --- a/_sakura/vendor/twig/twig/lib/Twig/TokenStream.php +++ b/_sakura/vendor/twig/twig/lib/Twig/TokenStream.php @@ -18,7 +18,7 @@ class Twig_TokenStream { protected $tokens; - protected $current; + protected $current = 0; protected $filename; /** @@ -29,9 +29,8 @@ class Twig_TokenStream */ public function __construct(array $tokens, $filename = null) { - $this->tokens = $tokens; - $this->current = 0; - $this->filename = $filename; + $this->tokens = $tokens; + $this->filename = $filename; } /** @@ -115,7 +114,7 @@ class Twig_TokenStream } /** - * Tests the current token + * Tests the current token. * * @return bool */ @@ -125,7 +124,7 @@ class Twig_TokenStream } /** - * Checks if end of stream was reached + * Checks if end of stream was reached. * * @return bool */ @@ -135,7 +134,7 @@ class Twig_TokenStream } /** - * Gets the current token + * Gets the current token. * * @return Twig_Token */ @@ -145,7 +144,7 @@ class Twig_TokenStream } /** - * Gets the filename associated with this stream + * Gets the filename associated with this stream. * * @return string */ diff --git a/_sakura/vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php b/_sakura/vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php new file mode 100644 index 0000000..e406f0a --- /dev/null +++ b/_sakura/vendor/twig/twig/lib/Twig/Util/DeprecationCollector.php @@ -0,0 +1,82 @@ + + */ +class Twig_Util_DeprecationCollector +{ + private $twig; + private $deprecations; + + public function __construct(Twig_Environment $twig) + { + $this->twig = $twig; + } + + /** + * Returns deprecations for templates contained in a directory. + * + * @param string $dir A directory where templates are stored + * @param string $ext Limit the loaded templates by extension + * + * @return array() An array of deprecations + */ + public function collectDir($dir, $ext = '.twig') + { + $iterator = new RegexIterator( + new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY + ), '{'.preg_quote($ext).'$}' + ); + + return $this->collect(new Twig_Util_TemplateDirIterator($iterator)); + } + + /** + * Returns deprecations for passed templates. + * + * @param Iterator $iterator An iterator of templates (where keys are template names and values the contents of the template) + * + * @return array() An array of deprecations + */ + public function collect(Iterator $iterator) + { + $this->deprecations = array(); + + set_error_handler(array($this, 'errorHandler')); + + foreach ($iterator as $name => $contents) { + try { + $this->twig->parse($this->twig->tokenize($contents, $name)); + } catch (Twig_Error_Syntax $e) { + // ignore templates containing syntax errors + } + } + + restore_error_handler(); + + $deprecations = $this->deprecations; + $this->deprecations = array(); + + return $deprecations; + } + + /** + * @internal + */ + public function errorHandler($type, $msg) + { + if (E_USER_DEPRECATED === $type) { + $this->deprecations[] = $msg; + } + } +} diff --git a/_sakura/vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php b/_sakura/vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php new file mode 100644 index 0000000..3fb8932 --- /dev/null +++ b/_sakura/vendor/twig/twig/lib/Twig/Util/TemplateDirIterator.php @@ -0,0 +1,26 @@ + + */ +class Twig_Util_TemplateDirIterator extends IteratorIterator +{ + public function current() + { + return file_get_contents(parent::current()); + } + + public function key() + { + return (string) parent::key(); + } +} diff --git a/_sakura/vendor/twig/twig/phpunit.xml.dist b/_sakura/vendor/twig/twig/phpunit.xml.dist index 6c5046f..6f6d1d2 100644 --- a/_sakura/vendor/twig/twig/phpunit.xml.dist +++ b/_sakura/vendor/twig/twig/phpunit.xml.dist @@ -9,7 +9,7 @@ processIsolation="false" stopOnFailure="false" syntaxCheck="false" - bootstrap="test/bootstrap.php" + bootstrap="vendor/autoload.php" > diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/AutoloaderTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/AutoloaderTest.php index c8b7999..52107c0 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/AutoloaderTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/AutoloaderTest.php @@ -11,6 +11,9 @@ class Twig_Tests_AutoloaderTest extends PHPUnit_Framework_TestCase { + /** + * @group legacy + */ public function testAutoload() { $this->assertFalse(class_exists('FooBarFoo'), '->autoload() does not try to load classes that does not begin with Twig'); diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/CompilerTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/CompilerTest.php index e24b0b5..bc25f11 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/CompilerTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/CompilerTest.php @@ -13,7 +13,7 @@ class Twig_Tests_CompilerTest extends PHPUnit_Framework_TestCase { public function testReprNumericValueWithLocale() { - $compiler = new Twig_Compiler(new Twig_Environment()); + $compiler = new Twig_Compiler(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $locale = setlocale(LC_NUMERIC, 0); if (false === $locale) { @@ -22,7 +22,7 @@ class Twig_Tests_CompilerTest extends PHPUnit_Framework_TestCase $required_locales = array('fr_FR.UTF-8', 'fr_FR.UTF8', 'fr_FR.utf-8', 'fr_FR.utf8', 'French_France.1252'); if (false === setlocale(LC_NUMERIC, $required_locales)) { - $this->markTestSkipped('Could not set any of required locales: '.implode(", ", $required_locales)); + $this->markTestSkipped('Could not set any of required locales: '.implode(', ', $required_locales)); } $this->assertEquals('1.2', $compiler->repr(1.2)->getSource()); diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php index d0ada96..e4bef74 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/EnvironmentTest.php @@ -14,6 +14,7 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase /** * @expectedException LogicException * @expectedExceptionMessage You must set a loader first. + * @group legacy */ public function testRenderNoLoader() { @@ -25,12 +26,12 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase { $loader = new Twig_Loader_Array(array( 'html' => '{{ foo }} {{ foo }}', - 'js' => '{{ bar }} {{ bar }}', + 'js' => '{{ bar }} {{ bar }}', )); $twig = new Twig_Environment($loader, array( - 'debug' => true, - 'cache' => false, + 'debug' => true, + 'cache' => false, 'autoescape' => array($this, 'escapingStrategyCallback'), )); @@ -182,6 +183,9 @@ class Twig_Tests_EnvironmentTest extends PHPUnit_Framework_TestCase $this->assertEquals('Twig_Tests_EnvironmentTest_NodeVisitor', get_class($visitors[2])); } + /** + * @group legacy + */ public function testRemoveExtension() { $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/ErrorTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/ErrorTest.php index 6a78d2b..d58c40b 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/ErrorTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/ErrorTest.php @@ -99,7 +99,7 @@ class Twig_Tests_ErrorTest extends PHPUnit_Framework_TestCase // error occurs in an included template array( array( - 'index' => "{% include 'partial' %}", + 'index' => "{% include 'partial' %}", 'partial' => '{{ foo.bar }}', ), 'partial', 1, diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php index b3b1cb0..a4692c2 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Extension/CoreTest.php @@ -16,9 +16,9 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase */ public function testRandomFunction($value, $expectedInArray) { - $env = new Twig_Environment(); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface')); - for ($i = 0; $i < 100; $i++) { + for ($i = 0; $i < 100; ++$i) { $this->assertTrue(in_array(twig_random($env, $value), $expectedInArray, true)); // assertContains() would not consider the type } } @@ -26,31 +26,31 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase public function getRandomFunctionTestData() { return array( - array( // array + array(// array array('apple', 'orange', 'citrus'), array('apple', 'orange', 'citrus'), ), - array( // Traversable + array(// Traversable new ArrayObject(array('apple', 'orange', 'citrus')), array('apple', 'orange', 'citrus'), ), - array( // unicode string + array(// unicode string 'Ä€é', array('Ä', '€', 'é'), ), - array( // numeric but string + array(// numeric but string '123', array('1', '2', '3'), ), - array( // integer + array(// integer 5, range(0, 5, 1), ), - array( // float + array(// float 5.9, range(0, 5, 1), ), - array( // negative + array(// negative -2, array(0, -1, -2), ), @@ -61,19 +61,19 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase { $max = mt_getrandmax(); - for ($i = 0; $i < 100; $i++) { - $val = twig_random(new Twig_Environment()); + for ($i = 0; $i < 100; ++$i) { + $val = twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $this->assertTrue(is_int($val) && $val >= 0 && $val <= $max); } } public function testRandomFunctionReturnsAsIs() { - $this->assertSame('', twig_random(new Twig_Environment(), '')); - $this->assertSame('', twig_random(new Twig_Environment(null, array('charset' => null)), '')); + $this->assertSame('', twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')), '')); + $this->assertSame('', twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('charset' => null)), '')); $instance = new stdClass(); - $this->assertSame($instance, twig_random(new Twig_Environment(), $instance)); + $this->assertSame($instance, twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $instance)); } /** @@ -81,7 +81,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase */ public function testRandomFunctionOfEmptyArrayThrowsException() { - twig_random(new Twig_Environment(), array()); + twig_random(new Twig_Environment($this->getMock('Twig_LoaderInterface')), array()); } public function testRandomFunctionOnNonUTF8String() @@ -90,11 +90,11 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase $this->markTestSkipped('needs iconv or mbstring'); } - $twig = new Twig_Environment(); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->setCharset('ISO-8859-1'); $text = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8'); - for ($i = 0; $i < 30; $i++) { + for ($i = 0; $i < 30; ++$i) { $rand = twig_random($twig, $text); $this->assertTrue(in_array(twig_convert_encoding($rand, 'UTF-8', 'ISO-8859-1'), array('Ä', 'é'), true)); } @@ -106,7 +106,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase $this->markTestSkipped('needs iconv or mbstring'); } - $twig = new Twig_Environment(); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->setCharset('ISO-8859-1'); $input = twig_convert_encoding('Äé', 'ISO-8859-1', 'UTF-8'); @@ -117,7 +117,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase public function testCustomEscaper() { - $twig = new Twig_Environment(); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $twig->getExtension('core')->setEscaper('foo', 'foo_escaper_for_test'); $this->assertEquals('fooUTF-8', twig_escape_filter($twig, 'foo', 'foo')); @@ -128,12 +128,12 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase */ public function testUnknownCustomEscaper() { - twig_escape_filter(new Twig_Environment(), 'foo', 'bar'); + twig_escape_filter(new Twig_Environment($this->getMock('Twig_LoaderInterface')), 'foo', 'bar'); } public function testTwigFirst() { - $twig = new Twig_Environment(); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $this->assertEquals('a', twig_first($twig, 'abc')); $this->assertEquals(1, twig_first($twig, array(1, 2, 3))); $this->assertSame('', twig_first($twig, null)); @@ -142,7 +142,7 @@ class Twig_Tests_Extension_CoreTest extends PHPUnit_Framework_TestCase public function testTwigLast() { - $twig = new Twig_Environment(); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $this->assertEquals('c', twig_last($twig, 'abc')); $this->assertEquals(3, twig_last($twig, array(1, 2, 3))); $this->assertSame('', twig_last($twig, null)); diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php index fee35a0..d21fb23 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Extension/SandboxTest.php @@ -17,8 +17,8 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase { self::$params = array( 'name' => 'Fabien', - 'obj' => new FooObject(), - 'arr' => array('obj' => new FooObject()), + 'obj' => new FooObject(), + 'arr' => array('obj' => new FooObject()), ); self::$templates = array( @@ -31,9 +31,9 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase '1_basic7' => '{{ cycle(["foo","bar"], 1) }}', '1_basic8' => '{{ obj.getfoobar }}{{ obj.getFooBar }}', '1_basic9' => '{{ obj.foobar }}{{ obj.fooBar }}', - '1_basic' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}', + '1_basic' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}', '1_layout' => '{% block content %}{% endblock %}', - '1_child' => "{% extends \"1_layout\" %}\n{% block content %}\n{{ \"a\"|json_encode }}\n{% endblock %}", + '1_child' => "{% extends \"1_layout\" %}\n{% block content %}\n{{ \"a\"|json_encode }}\n{% endblock %}", ); } @@ -141,7 +141,7 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase public function testSandboxLocallySetForAnInclude() { self::$templates = array( - '2_basic' => '{{ obj.foo }}{% include "2_included" %}{{ obj.foo }}', + '2_basic' => '{{ obj.foo }}{% include "2_included" %}{{ obj.foo }}', '2_included' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}', ); @@ -149,7 +149,7 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase $this->assertEquals('fooFOOfoo', $twig->loadTemplate('2_basic')->render(self::$params), 'Sandbox does nothing if disabled globally and sandboxed not used for the include'); self::$templates = array( - '3_basic' => '{{ obj.foo }}{% sandbox %}{% include "3_included" %}{% endsandbox %}{{ obj.foo }}', + '3_basic' => '{{ obj.foo }}{% sandbox %}{% include "3_included" %}{% endsandbox %}{{ obj.foo }}', '3_included' => '{% if obj.foo %}{{ obj.foo|upper }}{% endif %}', ); @@ -163,7 +163,7 @@ class Twig_Tests_Extension_SandboxTest extends PHPUnit_Framework_TestCase public function testMacrosInASandbox() { - $twig = $this->getEnvironment(true, array('autoescape' => true), array('index' => <<getEnvironment(true, array('autoescape' => 'html'), array('index' => <<{{ text }}

    {% endmacro %} diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_template_in_child_template.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_template_in_child_template.test new file mode 100644 index 0000000..1992510 --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/exceptions/undefined_template_in_child_template.test @@ -0,0 +1,15 @@ +--TEST-- +Exception for an undefined template in a child template +--TEMPLATE-- +{% extends 'base.twig' %} + +{% block sidebar %} + {{ include('include.twig') }} +{% endblock %} +--TEMPLATE(base.twig)-- +{% block sidebar %} +{% endblock %} +--DATA-- +return array() +--EXCEPTION-- +Twig_Error_Loader: Template "include.twig" is not defined in "index.twig" at line 5. diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_keys.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_keys.test new file mode 100644 index 0000000..6015380 --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_keys.test @@ -0,0 +1,10 @@ +--TEST-- +"batch" filter preserves array keys +--TEMPLATE-- +{{ {'foo': 'bar', 'key': 'value'}|batch(4)|first|keys|join(',') }} +{{ {'foo': 'bar', 'key': 'value'}|batch(4, 'fill')|first|keys|join(',') }} +--DATA-- +return array() +--EXPECT-- +foo,key +foo,key,0,1 diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_zero_elements.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_zero_elements.test new file mode 100644 index 0000000..b9c058d --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/filters/batch_with_zero_elements.test @@ -0,0 +1,10 @@ +--TEST-- +"batch" filter with zero elements +--TEMPLATE-- +{{ []|batch(3)|length }} +{{ []|batch(3, 'fill')|length }} +--DATA-- +return array() +--EXPECT-- +0 +0 diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling.test new file mode 100644 index 0000000..8ffc492 --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling.test @@ -0,0 +1,16 @@ +--TEST-- +"include" tag sandboxed +--TEMPLATE-- +{{ include("foo.twig", sandboxed = true) }} +{{ include("bar.twig") }} +--TEMPLATE(foo.twig)-- +foo +--TEMPLATE(bar.twig)-- +{{ foo|e }} +--DATA-- +return array('foo' => 'bar
    ') +--EXPECT-- +foo + + +bar<br /> diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling_ignore_missing.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling_ignore_missing.test new file mode 100644 index 0000000..8bf6e10 --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/functions/include/sandbox_disabling_ignore_missing.test @@ -0,0 +1,13 @@ +--TEST-- +"include" tag sandboxed +--TEMPLATE-- +{{ include("unknown.twig", sandboxed = true, ignore_missing = true) }} +{{ include("bar.twig") }} +--TEMPLATE(bar.twig)-- +{{ foo|e }} +--DATA-- +return array('foo' => 'bar
    ') +--EXPECT-- + + +bar<br /> diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs.test new file mode 100644 index 0000000..412c90f --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs.test @@ -0,0 +1,21 @@ +--TEST-- +macro with arbitrary arguments +--TEMPLATE-- +{% from _self import test1, test2 %} + +{% macro test1(var) %} + {{- var }}: {{ varargs|join(", ") }} +{% endmacro %} + +{% macro test2() %} + {{- varargs|join(", ") }} +{% endmacro %} + +{{ test1("foo", "bar", "foobar") }} +{{ test2("foo", "bar", "foobar") }} +--DATA-- +return array(); +--EXPECT-- +foo: bar, foobar + +foo, bar, foobar diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs_argument.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs_argument.test new file mode 100644 index 0000000..b08c8ec --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/macros/varargs_argument.test @@ -0,0 +1,8 @@ +--TEST-- +macro with varargs argument +--TEMPLATE-- +{% macro test(varargs) %} +{% endmacro %} +--EXCEPTION-- +Twig_Error_Syntax: The argument "varargs" in macro "test" cannot be defined because the variable "varargs" is reserved for arbitrary arguments in "index.twig" at line 2 + diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.legacy.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.legacy.test new file mode 100644 index 0000000..bbf1356 --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.legacy.test @@ -0,0 +1,11 @@ +--TEST-- +"autoescape" tag accepts an escaping strategy +--TEMPLATE-- +{% autoescape true js %}{{ var }}{% endautoescape %} + +{% autoescape true html %}{{ var }}{% endautoescape %} +--DATA-- +return array('var' => '
    "') +--EXPECT-- +\x3Cbr\x20\x2F\x3E\x22 +<br />" diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test index cf8ccee..e496f60 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/autoescape/strategy.test @@ -1,10 +1,6 @@ --TEST-- "autoescape" tag accepts an escaping strategy --TEMPLATE-- -{% autoescape true js %}{{ var }}{% endautoescape %} - -{% autoescape true html %}{{ var }}{% endautoescape %} - {% autoescape 'js' %}{{ var }}{% endautoescape %} {% autoescape 'html' %}{{ var }}{% endautoescape %} @@ -13,5 +9,3 @@ return array('var' => '
    "') --EXPECT-- \x3Cbr\x20\x2F\x3E\x22 <br />" -\x3Cbr\x20\x2F\x3E\x22 -<br />" diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from_with_reserved_name.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from_with_reserved_name.test new file mode 100644 index 0000000..6df4f5d --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/from_with_reserved_name.test @@ -0,0 +1,9 @@ +--TEST-- +"from" tag with reserved name +--TEMPLATE-- +{% from 'forms.twig' import templateName %} +--TEMPLATE(forms.twig)-- +--DATA-- +return array() +--EXCEPTION-- +Twig_Error_Syntax: "templateName" cannot be an imported macro as it is a reserved keyword in "index.twig" at line 2 diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/import_with_reserved_nam.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/import_with_reserved_nam.test new file mode 100644 index 0000000..e5aa749 --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/import_with_reserved_nam.test @@ -0,0 +1,11 @@ +--TEST-- +"from" tag with reserved name +--TEMPLATE-- +{% import 'forms.twig' as macros %} + +{{ macros.parent() }} +--TEMPLATE(forms.twig)-- +--DATA-- +return array() +--EXCEPTION-- +Twig_Error_Syntax: "parent" cannot be called as macro as it is a reserved keyword in "index.twig" at line 4 diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/reserved_name.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/reserved_name.test new file mode 100644 index 0000000..a2dde5a --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/macro/reserved_name.test @@ -0,0 +1,10 @@ +--TEST-- +"macro" tag with reserved name +--TEMPLATE-- +{% macro parent(arg1, arg2) %} + parent +{% endmacro %} +--DATA-- +return array() +--EXCEPTION-- +Twig_Error_Syntax: "parent" cannot be used as a macro name as it is a reserved keyword in "index.twig" at line 2 diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/basic.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/basic.legacy.test similarity index 100% rename from _sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/basic.test rename to _sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/basic.legacy.test diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test similarity index 100% rename from _sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.test rename to _sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/mixed_usage_with_raw.legacy.test diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.test b/_sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.legacy.test similarity index 100% rename from _sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.test rename to _sakura/vendor/twig/twig/test/Twig/Tests/Fixtures/tags/raw/whitespace_control.legacy.test diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/IntegrationTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/IntegrationTest.php index 70f9b80..1908bcd 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/IntegrationTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/IntegrationTest.php @@ -175,7 +175,7 @@ class TwigTestExtension extends Twig_Extension } /** - * nl2br which also escapes, for testing escaper filters + * nl2br which also escapes, for testing escaper filters. */ public function escape_and_nl2br($env, $value, $sep = '
    ') { @@ -183,7 +183,7 @@ class TwigTestExtension extends Twig_Extension } /** - * nl2br only, for testing filters with pre_escape + * nl2br only, for testing filters with pre_escape. */ public function nl2br($value, $sep = '
    ') { diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/test.legacy.test b/_sakura/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/test.legacy.test new file mode 100644 index 0000000..d9c1d50 --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/LegacyFixtures/test.legacy.test @@ -0,0 +1,8 @@ +--TEST-- +Old test classes usage +--TEMPLATE-- +{{ 'foo' is multi word ? 'yes' : 'no' }} +--DATA-- +return array() +--EXPECT-- +no diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php new file mode 100644 index 0000000..02ec3cb --- /dev/null +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/LegacyIntegrationTest.php @@ -0,0 +1,45 @@ + new Twig_Test_Method($this, 'is_multi_word'), + ); + } + + public function is_multi_word($value) + { + return false !== strpos($value, ' '); + } + + public function getName() + { + return 'legacy_integration_test'; + } +} diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/LexerTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/LexerTest.php index 4ef58e5..4945d22 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/LexerTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/LexerTest.php @@ -14,7 +14,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{% § %}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $stream->expect(Twig_Token::BLOCK_START_TYPE); @@ -25,7 +25,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{{ §() }}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $stream->expect(Twig_Token::VAR_START_TYPE); @@ -42,7 +42,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase protected function countToken($template, $type, $value = null) { - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $count = 0; @@ -67,7 +67,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase ."baz\n" ."}}\n"; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); // foo\nbar\n @@ -87,7 +87,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase ."baz\n" ."}}\n"; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); // foo\nbar @@ -102,17 +102,17 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{# '.str_repeat('*', 100000).' #}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $lexer->tokenize($template); // should not throw an exception } - public function testLongRaw() + public function testLongVerbatim() { - $template = '{% raw %}'.str_repeat('*', 100000).'{% endraw %}'; + $template = '{% verbatim %}'.str_repeat('*', 100000).'{% endverbatim %}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $lexer->tokenize($template); // should not throw an exception @@ -122,7 +122,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{{ '.str_repeat('x', 100000).' }}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $lexer->tokenize($template); // should not throw an exception @@ -132,7 +132,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{% '.str_repeat('x', 100000).' %}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $lexer->tokenize($template); // should not throw an exception @@ -142,20 +142,20 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{{ 922337203685477580700 }}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $stream->next(); $node = $stream->next(); - $this->assertEquals("922337203685477580700", $node->getValue()); + $this->assertEquals('922337203685477580700', $node->getValue()); } public function testStringWithEscapedDelimiter() { $tests = array( "{{ 'foo \' bar' }}" => 'foo \' bar', - '{{ "foo \" bar" }}' => "foo \" bar", + '{{ "foo \" bar" }}' => 'foo " bar', ); - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); foreach ($tests as $template => $expected) { $stream = $lexer->tokenize($template); $stream->expect(Twig_Token::VAR_START_TYPE); @@ -167,7 +167,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = 'foo {{ "bar #{ baz + 1 }" }}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $stream->expect(Twig_Token::TEXT_TYPE, 'foo '); $stream->expect(Twig_Token::VAR_START_TYPE); @@ -184,7 +184,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{{ "bar \#{baz+1}" }}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $stream->expect(Twig_Token::VAR_START_TYPE); $stream->expect(Twig_Token::STRING_TYPE, 'bar #{baz+1}'); @@ -195,7 +195,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{{ "bar # baz" }}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $stream->expect(Twig_Token::VAR_START_TYPE); $stream->expect(Twig_Token::STRING_TYPE, 'bar # baz'); @@ -210,7 +210,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{{ "bar #{x" }}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $lexer->tokenize($template); } @@ -218,7 +218,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{{ "bar #{ "foo#{bar}" }" }}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $stream->expect(Twig_Token::VAR_START_TYPE); $stream->expect(Twig_Token::STRING_TYPE, 'bar '); @@ -235,7 +235,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = '{% foo "bar #{ "foo#{bar}" }" %}'; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $stream->expect(Twig_Token::BLOCK_START_TYPE); $stream->expect(Twig_Token::NAME_TYPE, 'foo'); @@ -253,7 +253,7 @@ class Twig_Tests_LexerTest extends PHPUnit_Framework_TestCase { $template = "{{ 1 and\n0}}"; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $stream = $lexer->tokenize($template); $stream->expect(Twig_Token::VAR_START_TYPE); $stream->expect(Twig_Token::NUMBER_TYPE, 1); @@ -275,7 +275,7 @@ bar '; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $lexer->tokenize($template); } @@ -294,7 +294,7 @@ bar '; - $lexer = new Twig_Lexer(new Twig_Environment()); + $lexer = new Twig_Lexer(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $lexer->tokenize($template); } } diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php index 36b6329..942aff9 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/NativeExtensionTest.php @@ -18,8 +18,8 @@ class Twig_Tests_NativeExtensionTest extends PHPUnit_Framework_TestCase } $twig = new Twig_Environment(new Twig_Loader_Array(array('index' => '{{ d1.date }}{{ d2.date }}')), array( - 'debug' => true, - 'cache' => false, + 'debug' => true, + 'cache' => false, 'autoescape' => false, )); diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php index af4e351..43afcd2 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/CallTest.php @@ -73,7 +73,7 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase public function testResolveArgumentsOnlyNecessaryArgumentsForCustomFunction() { - $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'custom_function')); + $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'custom_function')); $this->assertEquals(array('arg1'), $node->getArguments(array($this, 'customFunction'), array('arg1' => 'arg1'))); } @@ -84,6 +84,16 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase $this->assertEquals(array('arg1'), $node->getArguments(__CLASS__.'::customStaticFunction', array('arg1' => 'arg1'))); } + /** + * @expectedException LogicException + * @expectedExceptionMessage The last parameter of "Twig_Tests_Node_Expression_CallTest::customFunctionWithArbitraryArguments" for function "foo" must be an array with default value, eg. "array $arg = array()". + */ + public function testResolveArgumentsWithMissingParameterForArbitraryArguments() + { + $node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'foo', 'is_variadic' => true)); + $node->getArguments(array($this, 'customFunctionWithArbitraryArguments'), array()); + } + public static function customStaticFunction($arg1, $arg2 = 'default', $arg3 = array()) { } @@ -91,6 +101,10 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase public function customFunction($arg1, $arg2 = 'default', $arg3 = array()) { } + + public function customFunctionWithArbitraryArguments() + { + } } class Twig_Tests_Node_Expression_Call extends Twig_Node_Expression_Call diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php index 4aefa7e..d5ffb24 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/FilterTest.php @@ -25,6 +25,10 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase public function getTests() { + $environment = new Twig_Environment($this->getMock('Twig_LoaderInterface')); + $environment->addFilter(new Twig_SimpleFilter('bar', 'bar', array('needs_environment' => true))); + $environment->addFilter(new Twig_SimpleFilter('barbar', 'twig_tests_filter_barbar', array('needs_context' => true, 'is_variadic' => true))); + $tests = array(); $expr = new Twig_Node_Expression_Constant('foo', 1); @@ -41,7 +45,7 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase $date = new Twig_Node_Expression_Constant(0, 1); $node = $this->createFilter($date, 'date', array( 'timezone' => new Twig_Node_Expression_Constant('America/Chicago', 1), - 'format' => new Twig_Node_Expression_Constant('d/m/Y H:i:s P', 1), + 'format' => new Twig_Node_Expression_Constant('d/m/Y H:i:s P', 1), )); $tests[] = array($node, 'twig_date_format_filter($this->env, 0, "d/m/Y H:i:s P", "America/Chicago")'); @@ -69,6 +73,31 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase $tests[] = array($node, 'call_user_func_array($this->env->getFilter(\'anonymous\')->getCallable(), array("foo"))'); } + // needs environment + $node = $this->createFilter($string, 'bar'); + $tests[] = array($node, 'bar($this->env, "abc")', $environment); + + $node = $this->createFilter($string, 'bar', array(new Twig_Node_Expression_Constant('bar', 1))); + $tests[] = array($node, 'bar($this->env, "abc", "bar")', $environment); + + // arbitrary named arguments + $node = $this->createFilter($string, 'barbar'); + $tests[] = array($node, 'twig_tests_filter_barbar($context, "abc")', $environment); + + $node = $this->createFilter($string, 'barbar', array('foo' => new Twig_Node_Expression_Constant('bar', 1))); + $tests[] = array($node, 'twig_tests_filter_barbar($context, "abc", null, null, array("foo" => "bar"))', $environment); + + $node = $this->createFilter($string, 'barbar', array('arg2' => new Twig_Node_Expression_Constant('bar', 1))); + $tests[] = array($node, 'twig_tests_filter_barbar($context, "abc", null, "bar")', $environment); + + $node = $this->createFilter($string, 'barbar', array( + new Twig_Node_Expression_Constant('1', 1), + new Twig_Node_Expression_Constant('2', 1), + new Twig_Node_Expression_Constant('3', 1), + 'foo' => new Twig_Node_Expression_Constant('bar', 1), + )); + $tests[] = array($node, 'twig_tests_filter_barbar($context, "abc", "1", "2", array(0 => "3", "foo" => "bar"))', $environment); + return $tests; } @@ -119,3 +148,7 @@ class Twig_Tests_Node_Expression_FilterTest extends Twig_Test_NodeTestCase return parent::getEnvironment(); } } + +function twig_tests_filter_barbar($context, $string, $arg1 = null, $arg2 = null, array $args = array()) +{ +} diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php index 209b8cf..de2e0f8 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/FunctionTest.php @@ -23,11 +23,12 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase public function getTests() { - $environment = new Twig_Environment(); + $environment = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $environment->addFunction(new Twig_SimpleFunction('foo', 'foo', array())); $environment->addFunction(new Twig_SimpleFunction('bar', 'bar', array('needs_environment' => true))); $environment->addFunction(new Twig_SimpleFunction('foofoo', 'foofoo', array('needs_context' => true))); $environment->addFunction(new Twig_SimpleFunction('foobar', 'foobar', array('needs_environment' => true, 'needs_context' => true))); + $environment->addFunction(new Twig_SimpleFunction('barbar', 'twig_tests_function_barbar', array('is_variadic' => true))); $tests = array(); @@ -58,10 +59,28 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase // named arguments $node = $this->createFunction('date', array( 'timezone' => new Twig_Node_Expression_Constant('America/Chicago', 1), - 'date' => new Twig_Node_Expression_Constant(0, 1), + 'date' => new Twig_Node_Expression_Constant(0, 1), )); $tests[] = array($node, 'twig_date_converter($this->env, 0, "America/Chicago")'); + // arbitrary named arguments + $node = $this->createFunction('barbar'); + $tests[] = array($node, 'twig_tests_function_barbar()', $environment); + + $node = $this->createFunction('barbar', array('foo' => new Twig_Node_Expression_Constant('bar', 1))); + $tests[] = array($node, 'twig_tests_function_barbar(null, null, array("foo" => "bar"))', $environment); + + $node = $this->createFunction('barbar', array('arg2' => new Twig_Node_Expression_Constant('bar', 1))); + $tests[] = array($node, 'twig_tests_function_barbar(null, "bar")', $environment); + + $node = $this->createFunction('barbar', array( + new Twig_Node_Expression_Constant('1', 1), + new Twig_Node_Expression_Constant('2', 1), + new Twig_Node_Expression_Constant('3', 1), + 'foo' => new Twig_Node_Expression_Constant('bar', 1), + )); + $tests[] = array($node, 'twig_tests_function_barbar("1", "2", array(0 => "3", "foo" => "bar"))', $environment); + // function as an anonymous function if (PHP_VERSION_ID >= 50300) { $node = $this->createFunction('anonymous', array(new Twig_Node_Expression_Constant('foo', 1))); @@ -85,3 +104,7 @@ class Twig_Tests_Node_Expression_FunctionTest extends Twig_Test_NodeTestCase return parent::getEnvironment(); } } + +function twig_tests_function_barbar($arg1 = null, $arg2 = null, array $args = array()) +{ +} diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php index 905d8ee..8cbb2f7 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/NameTest.php @@ -21,16 +21,14 @@ class Twig_Tests_Node_Expression_NameTest extends Twig_Test_NodeTestCase public function getTests() { $node = new Twig_Node_Expression_Name('foo', 1); - $self = new Twig_Node_Expression_Name('_self', 1); $context = new Twig_Node_Expression_Name('_context', 1); - $env = new Twig_Environment(null, array('strict_variables' => true)); - $env1 = new Twig_Environment(null, array('strict_variables' => false)); + $env = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true)); + $env1 = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => false)); return array( array($node, "// line 1\n".(PHP_VERSION_ID >= 50400 ? '(isset($context["foo"]) ? $context["foo"] : $this->getContext($context, "foo"))' : '$this->getContext($context, "foo")'), $env), array($node, $this->getVariableGetter('foo', 1), $env1), - array($self, "// line 1\n\$this"), array($context, "// line 1\n\$context"), ); } diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php index 15e3aa9..b5394bc 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FilterInclude.php @@ -1,6 +1,6 @@ addFilter(new Twig_SimpleFilter('anonymous', function () {})); return $env; diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php index d2170ed..e8f68c7 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/FunctionInclude.php @@ -1,6 +1,6 @@ addFunction(new Twig_SimpleFunction('anonymous', function () {})); return $env; diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php index 6366286..9f818bc 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/PHP53/TestInclude.php @@ -1,6 +1,6 @@ addTest(new Twig_SimpleTest('anonymous', function () {})); return $env; diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php index e62a8af..55d3fcb 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/Expression/TestTest.php @@ -25,6 +25,9 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase public function getTests() { + $environment = new Twig_Environment($this->getMock('Twig_LoaderInterface')); + $environment->addTest(new Twig_SimpleTest('barbar', 'twig_tests_test_barbar', array('is_variadic' => true, 'need_context' => true))); + $tests = array(); $expr = new Twig_Node_Expression_Constant('foo', 1); @@ -37,6 +40,25 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase $tests[] = array($node, 'call_user_func_array($this->env->getTest(\'anonymous\')->getCallable(), array("foo", "foo"))'); } + // arbitrary named arguments + $string = new Twig_Node_Expression_Constant('abc', 1); + $node = $this->createTest($string, 'barbar'); + $tests[] = array($node, 'twig_tests_test_barbar("abc")', $environment); + + $node = $this->createTest($string, 'barbar', array('foo' => new Twig_Node_Expression_Constant('bar', 1))); + $tests[] = array($node, 'twig_tests_test_barbar("abc", null, null, array("foo" => "bar"))', $environment); + + $node = $this->createTest($string, 'barbar', array('arg2' => new Twig_Node_Expression_Constant('bar', 1))); + $tests[] = array($node, 'twig_tests_test_barbar("abc", null, "bar")', $environment); + + $node = $this->createTest($string, 'barbar', array( + new Twig_Node_Expression_Constant('1', 1), + new Twig_Node_Expression_Constant('2', 1), + new Twig_Node_Expression_Constant('3', 1), + 'foo' => new Twig_Node_Expression_Constant('bar', 1), + )); + $tests[] = array($node, 'twig_tests_test_barbar("abc", "1", "2", array(0 => "3", "foo" => "bar"))', $environment); + return $tests; } @@ -54,3 +76,7 @@ class Twig_Tests_Node_Expression_TestTest extends Twig_Test_NodeTestCase return parent::getEnvironment(); } } + +function twig_tests_test_barbar($string, $arg1 = null, $arg2 = null, array $args = array()) +{ +} diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php index 52ee8b7..901e57b 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Node/MacroTest.php @@ -31,14 +31,23 @@ class Twig_Tests_Node_MacroTest extends Twig_Test_NodeTestCase ), array(), 1); $node = new Twig_Node_Macro('foo', $body, $arguments, 1); + if (PHP_VERSION_ID >= 50600) { + $declaration = ', ...$__varargs__'; + $varargs = '$__varargs__'; + } else { + $declaration = ''; + $varargs = 'func_num_args() > 2 ? array_slice(func_get_args(), 2) : array()'; + } + return array( array($node, <<env->mergeGlobals(array( "foo" => \$__foo__, "bar" => \$__bar__, + "varargs" => $varargs, )); \$blocks = array(); diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/ParserTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/ParserTest.php index b4a3abb..b29dac3 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/ParserTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/ParserTest.php @@ -16,7 +16,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase public function testSetMacroThrowsExceptionOnReservedMethods() { $parser = $this->getParser(); - $parser->setMacro('display', $this->getMock('Twig_Node_Macro', array(), array(), '', null)); + $parser->setMacro('parent', $this->getMock('Twig_Node_Macro', array(), array(), '', null)); } /** @@ -31,7 +31,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase new Twig_Token(Twig_Token::BLOCK_END_TYPE, '', 1), new Twig_Token(Twig_Token::EOF_TYPE, '', 1), )); - $parser = new Twig_Parser(new Twig_Environment()); + $parser = new Twig_Parser(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $parser->parse($stream); } @@ -94,7 +94,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase public function testParseIsReentrant() { - $twig = new Twig_Environment(null, array( + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array( 'autoescape' => false, 'optimizations' => 0, )); @@ -120,7 +120,7 @@ class Twig_Tests_ParserTest extends PHPUnit_Framework_TestCase // see https://github.com/symfony/symfony/issues/4218 public function testGetVarName() { - $twig = new Twig_Environment(null, array( + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface'), array( 'autoescape' => false, 'optimizations' => 0, )); @@ -137,7 +137,7 @@ EOF protected function getParser() { - $parser = new TestParser(new Twig_Environment()); + $parser = new TestParser(new Twig_Environment($this->getMock('Twig_LoaderInterface'))); $parser->setParent(new Twig_Node()); $parser->stream = $this->getMockBuilder('Twig_TokenStream')->disableOriginalConstructor()->getMock(); diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php index d855664..da97f47 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/Profiler/Dumper/AbstractTest.php @@ -73,11 +73,11 @@ abstract class Twig_Tests_Profiler_Dumper_AbstractTest extends PHPUnit_Framework /** * @param string $name - * @param float $duration - * @param bool $isTemplate + * @param float $duration + * @param bool $isTemplate * @param string $type * @param string $templateName - * @param array $subProfiles + * @param array $subProfiles * * @return Twig_Profiler_Profile */ diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/TemplateTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/TemplateTest.php index cac7926..31a844b 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/TemplateTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/TemplateTest.php @@ -10,6 +10,15 @@ */ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase { + /** + * @expectedException LogicException + */ + public function testDisplayBlocksAcceptTemplateOnlyAsBlocks() + { + $template = $this->getMockForAbstractClass('Twig_Template', array(), '', false); + $template->displayBlock('foo', array(), array('foo' => array(new stdClass(), 'foo'))); + } + /** * @dataProvider getAttributeExceptions */ @@ -27,13 +36,13 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase $template = $env->loadTemplate($name); $context = array( - 'string' => 'foo', - 'null' => null, - 'empty_array' => array(), - 'array' => array('foo' => 'foo'), - 'array_access' => new Twig_TemplateArrayAccessObject(), + 'string' => 'foo', + 'null' => null, + 'empty_array' => array(), + 'array' => array('foo' => 'foo'), + 'array_access' => new Twig_TemplateArrayAccessObject(), 'magic_exception' => new Twig_TemplateMagicPropertyObjectWithException(), - 'object' => new stdClass(), + 'object' => new stdClass(), ); try { @@ -60,7 +69,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase array('{{ array.a }}', 'Key "a" for array with keys "foo" does not exist in "%s" at line 1', false), array('{{ attribute(array, -10) }}', 'Key "-10" for array with keys "foo" does not exist in "%s" at line 1', false), array('{{ array_access.a }}', 'Method "a" for object "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false), - array('{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ _self.foo(array_access) }}', 'Method "missing_method" for object "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false), + array('{% from _self import foo %}{% macro foo(obj) %}{{ obj.missing_method() }}{% endmacro %}{{ foo(array_access) }}', 'Method "missing_method" for object "Twig_TemplateArrayAccessObject" does not exist in "%s" at line 1', false), array('{{ magic_exception.test }}', 'An exception has been thrown during the rendering of a template ("Hey! Don\'t try to isset me!") in "%s" at line 1.', false), array('{{ object["a"] }}', 'Impossible to access a key "a" on an object of class "stdClass" that does not implement ArrayAccess interface in "%s" at line 1', false), ); @@ -80,7 +89,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase */ public function testGetAttributeWithSandbox($object, $item, $allowed, $useExt) { - $twig = new Twig_Environment(); + $twig = new Twig_Environment($this->getMock('Twig_LoaderInterface')); $policy = new Twig_Sandbox_SecurityPolicy(array(), array(), array(/*method*/), array(/*prop*/), array()); $twig->addExtension(new Twig_Extension_Sandbox($policy, !$allowed)); $template = new Twig_TemplateTest($twig, $useExt); @@ -124,8 +133,8 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase */ public function testGetAttributeWithTemplateAsObject($useExt) { - $template = new Twig_TemplateTest(new Twig_Environment(), $useExt); - $template1 = new Twig_TemplateTest(new Twig_Environment(), false); + $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt); + $template1 = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), false); $this->assertInstanceof('Twig_Markup', $template->getAttribute($template1, 'string')); $this->assertEquals('some_string', $template->getAttribute($template1, 'string')); @@ -138,6 +147,11 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase $this->assertNotInstanceof('Twig_Markup', $template->getAttribute($template1, 'empty')); $this->assertSame('', $template->getAttribute($template1, 'empty')); + + $this->assertFalse($template->getAttribute($template1, 'env', array(), Twig_Template::ANY_CALL, true)); + $this->assertFalse($template->getAttribute($template1, 'environment', array(), Twig_Template::ANY_CALL, true)); + $this->assertFalse($template->getAttribute($template1, 'getEnvironment', array(), Twig_Template::METHOD_CALL, true)); + $this->assertFalse($template->getAttribute($template1, 'displayWithErrorHandling', array(), Twig_Template::METHOD_CALL, true)); } public function getGetAttributeWithTemplateAsObject() @@ -159,7 +173,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase public function testGetAttributeOnArrayWithConfusableKey($useExt = false) { $template = new Twig_TemplateTest( - new Twig_Environment(), + new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt ); @@ -198,7 +212,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase */ public function testGetAttribute($defined, $value, $object, $item, $arguments, $type, $useExt = false) { - $template = new Twig_TemplateTest(new Twig_Environment(), $useExt); + $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt); $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type)); } @@ -208,7 +222,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase */ public function testGetAttributeStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false, $exceptionMessage = null) { - $template = new Twig_TemplateTest(new Twig_Environment(null, array('strict_variables' => true)), $useExt); + $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true)), $useExt); if ($defined) { $this->assertEquals($value, $template->getAttribute($object, $item, $arguments, $type)); @@ -230,7 +244,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase */ public function testGetAttributeDefined($defined, $value, $object, $item, $arguments, $type, $useExt = false) { - $template = new Twig_TemplateTest(new Twig_Environment(), $useExt); + $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt); $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true)); } @@ -240,7 +254,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase */ public function testGetAttributeDefinedStrict($defined, $value, $object, $item, $arguments, $type, $useExt = false) { - $template = new Twig_TemplateTest(new Twig_Environment(null, array('strict_variables' => true)), $useExt); + $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface'), array('strict_variables' => true)), $useExt); $this->assertEquals($defined, $template->getAttribute($object, $item, $arguments, $type, true)); } @@ -250,7 +264,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase */ public function testGetAttributeCallExceptions($useExt = false) { - $template = new Twig_TemplateTest(new Twig_Environment(), $useExt); + $template = new Twig_TemplateTest(new Twig_Environment($this->getMock('Twig_LoaderInterface')), $useExt); $object = new Twig_TemplateMagicMethodExceptionObject(); @@ -261,27 +275,27 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase { $array = array( 'defined' => 'defined', - 'zero' => 0, - 'null' => null, - '1' => 1, - 'bar' => true, - '09' => '09', - '+4' => '+4', + 'zero' => 0, + 'null' => null, + '1' => 1, + 'bar' => true, + '09' => '09', + '+4' => '+4', ); - $objectArray = new Twig_TemplateArrayAccessObject(); - $stdObject = (object) $array; + $objectArray = new Twig_TemplateArrayAccessObject(); + $stdObject = (object) $array; $magicPropertyObject = new Twig_TemplateMagicPropertyObject(); - $propertyObject = new Twig_TemplatePropertyObject(); - $propertyObject1 = new Twig_TemplatePropertyObjectAndIterator(); - $propertyObject2 = new Twig_TemplatePropertyObjectAndArrayAccess(); - $propertyObject3 = new Twig_TemplatePropertyObjectDefinedWithUndefinedValue(); - $methodObject = new Twig_TemplateMethodObject(); - $magicMethodObject = new Twig_TemplateMagicMethodObject(); + $propertyObject = new Twig_TemplatePropertyObject(); + $propertyObject1 = new Twig_TemplatePropertyObjectAndIterator(); + $propertyObject2 = new Twig_TemplatePropertyObjectAndArrayAccess(); + $propertyObject3 = new Twig_TemplatePropertyObjectDefinedWithUndefinedValue(); + $methodObject = new Twig_TemplateMethodObject(); + $magicMethodObject = new Twig_TemplateMagicMethodObject(); - $anyType = Twig_Template::ANY_CALL; + $anyType = Twig_Template::ANY_CALL; $methodType = Twig_Template::METHOD_CALL; - $arrayType = Twig_Template::ARRAY_CALL; + $arrayType = Twig_Template::ARRAY_CALL; $basicTests = array( // array(defined, value, property to fetch) @@ -374,7 +388,7 @@ class Twig_Tests_TemplateTest extends PHPUnit_Framework_TestCase // tests when input is not an array or object $tests = array_merge($tests, array( array(false, null, 42, 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a integer variable ("42")'), - array(false, null, "string", 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a string variable ("string")'), + array(false, null, 'string', 'a', array(), $anyType, false, 'Impossible to access an attribute ("a") on a string variable ("string")'), array(false, null, array(), 'a', array(), $anyType, false, 'Key "a" does not exist as the array is empty'), )); @@ -456,12 +470,12 @@ class Twig_TemplateArrayAccessObject implements ArrayAccess public $attributes = array( 'defined' => 'defined', - 'zero' => 0, - 'null' => null, - '1' => 1, - 'bar' => true, - '09' => '09', - '+4' => '+4', + 'zero' => 0, + 'null' => null, + '1' => 1, + 'bar' => true, + '09' => '09', + '+4' => '+4', ); public function offsetExists($name) @@ -488,12 +502,12 @@ class Twig_TemplateMagicPropertyObject public $defined = 'defined'; public $attributes = array( - 'zero' => 0, - 'null' => null, - '1' => 1, - 'bar' => true, - '09' => '09', - '+4' => '+4', + 'zero' => 0, + 'null' => null, + '1' => 1, + 'bar' => true, + '09' => '09', + '+4' => '+4', ); protected $protected = 'protected'; @@ -520,9 +534,9 @@ class Twig_TemplateMagicPropertyObjectWithException class Twig_TemplatePropertyObject { public $defined = 'defined'; - public $zero = 0; - public $null = null; - public $bar = true; + public $zero = 0; + public $null = null; + public $bar = true; protected $protected = 'protected'; } diff --git a/_sakura/vendor/twig/twig/test/Twig/Tests/escapingTest.php b/_sakura/vendor/twig/twig/test/Twig/Tests/escapingTest.php index dfa9d43..7b765ca 100644 --- a/_sakura/vendor/twig/twig/test/Twig/Tests/escapingTest.php +++ b/_sakura/vendor/twig/twig/test/Twig/Tests/escapingTest.php @@ -9,144 +9,144 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase { /** - * All character encodings supported by htmlspecialchars() + * All character encodings supported by htmlspecialchars(). */ protected $htmlSpecialChars = array( - '\'' => ''', - '"' => '"', - '<' => '<', - '>' => '>', - '&' => '&', + '\'' => ''', + '"' => '"', + '<' => '<', + '>' => '>', + '&' => '&', ); protected $htmlAttrSpecialChars = array( - '\'' => ''', + '\'' => ''', /* Characters beyond ASCII value 255 to unicode escape */ - 'Ā' => 'Ā', + 'Ā' => 'Ā', /* Immune chars excluded */ - ',' => ',', - '.' => '.', - '-' => '-', - '_' => '_', + ',' => ',', + '.' => '.', + '-' => '-', + '_' => '_', /* Basic alnums excluded */ - 'a' => 'a', - 'A' => 'A', - 'z' => 'z', - 'Z' => 'Z', - '0' => '0', - '9' => '9', + 'a' => 'a', + 'A' => 'A', + 'z' => 'z', + 'Z' => 'Z', + '0' => '0', + '9' => '9', /* Basic control characters and null */ - "\r" => ' ', - "\n" => ' ', - "\t" => ' ', - "\0" => '�', // should use Unicode replacement char + "\r" => ' ', + "\n" => ' ', + "\t" => ' ', + "\0" => '�', // should use Unicode replacement char /* Encode chars as named entities where possible */ - '<' => '<', - '>' => '>', - '&' => '&', - '"' => '"', + '<' => '<', + '>' => '>', + '&' => '&', + '"' => '"', /* Encode spaces for quoteless attribute protection */ - ' ' => ' ', + ' ' => ' ', ); protected $jsSpecialChars = array( /* HTML special chars - escape without exception to hex */ - '<' => '\\x3C', - '>' => '\\x3E', - '\'' => '\\x27', - '"' => '\\x22', - '&' => '\\x26', + '<' => '\\x3C', + '>' => '\\x3E', + '\'' => '\\x27', + '"' => '\\x22', + '&' => '\\x26', /* Characters beyond ASCII value 255 to unicode escape */ - 'Ā' => '\\u0100', + 'Ā' => '\\u0100', /* Immune chars excluded */ - ',' => ',', - '.' => '.', - '_' => '_', + ',' => ',', + '.' => '.', + '_' => '_', /* Basic alnums excluded */ - 'a' => 'a', - 'A' => 'A', - 'z' => 'z', - 'Z' => 'Z', - '0' => '0', - '9' => '9', + 'a' => 'a', + 'A' => 'A', + 'z' => 'z', + 'Z' => 'Z', + '0' => '0', + '9' => '9', /* Basic control characters and null */ - "\r" => '\\x0D', - "\n" => '\\x0A', - "\t" => '\\x09', - "\0" => '\\x00', + "\r" => '\\x0D', + "\n" => '\\x0A', + "\t" => '\\x09', + "\0" => '\\x00', /* Encode spaces for quoteless attribute protection */ - ' ' => '\\x20', + ' ' => '\\x20', ); protected $urlSpecialChars = array( /* HTML special chars - escape without exception to percent encoding */ - '<' => '%3C', - '>' => '%3E', - '\'' => '%27', - '"' => '%22', - '&' => '%26', + '<' => '%3C', + '>' => '%3E', + '\'' => '%27', + '"' => '%22', + '&' => '%26', /* Characters beyond ASCII value 255 to hex sequence */ - 'Ā' => '%C4%80', + 'Ā' => '%C4%80', /* Punctuation and unreserved check */ - ',' => '%2C', - '.' => '.', - '_' => '_', - '-' => '-', - ':' => '%3A', - ';' => '%3B', - '!' => '%21', + ',' => '%2C', + '.' => '.', + '_' => '_', + '-' => '-', + ':' => '%3A', + ';' => '%3B', + '!' => '%21', /* Basic alnums excluded */ - 'a' => 'a', - 'A' => 'A', - 'z' => 'z', - 'Z' => 'Z', - '0' => '0', - '9' => '9', + 'a' => 'a', + 'A' => 'A', + 'z' => 'z', + 'Z' => 'Z', + '0' => '0', + '9' => '9', /* Basic control characters and null */ - "\r" => '%0D', - "\n" => '%0A', - "\t" => '%09', - "\0" => '%00', + "\r" => '%0D', + "\n" => '%0A', + "\t" => '%09', + "\0" => '%00', /* PHP quirks from the past */ - ' ' => '%20', - '~' => '~', - '+' => '%2B', + ' ' => '%20', + '~' => '~', + '+' => '%2B', ); protected $cssSpecialChars = array( /* HTML special chars - escape without exception to hex */ - '<' => '\\3C ', - '>' => '\\3E ', - '\'' => '\\27 ', - '"' => '\\22 ', - '&' => '\\26 ', + '<' => '\\3C ', + '>' => '\\3E ', + '\'' => '\\27 ', + '"' => '\\22 ', + '&' => '\\26 ', /* Characters beyond ASCII value 255 to unicode escape */ - 'Ā' => '\\100 ', + 'Ā' => '\\100 ', /* Immune chars excluded */ - ',' => '\\2C ', - '.' => '\\2E ', - '_' => '\\5F ', + ',' => '\\2C ', + '.' => '\\2E ', + '_' => '\\5F ', /* Basic alnums excluded */ - 'a' => 'a', - 'A' => 'A', - 'z' => 'z', - 'Z' => 'Z', - '0' => '0', - '9' => '9', + 'a' => 'a', + 'A' => 'A', + 'z' => 'z', + 'Z' => 'Z', + '0' => '0', + '9' => '9', /* Basic control characters and null */ - "\r" => '\\D ', - "\n" => '\\A ', - "\t" => '\\9 ', - "\0" => '\\0 ', + "\r" => '\\D ', + "\n" => '\\A ', + "\t" => '\\9 ', + "\0" => '\\0 ', /* Encode spaces for quoteless attribute protection */ - ' ' => '\\20 ', + ' ' => '\\20 ', ); protected $env; public function setUp() { - $this->env = new Twig_Environment(); + $this->env = new Twig_Environment($this->getMock('Twig_LoaderInterface')); } public function testHtmlEscapingConvertsSpecialChars() @@ -205,16 +205,16 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase } /** - * Range tests to confirm escaped range of characters is within OWASP recommendation + * Range tests to confirm escaped range of characters is within OWASP recommendation. */ /** * Only testing the first few 2 ranges on this prot. function as that's all these - * other range tests require + * other range tests require. */ public function testUnicodeCodepointConversionToUtf8() { - $expected = " ~ޙ"; + $expected = ' ~ޙ'; $codepoints = array(0x20, 0x7e, 0x799); $result = ''; foreach ($codepoints as $value) { @@ -226,7 +226,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase /** * Convert a Unicode Codepoint to a literal UTF-8 character. * - * @param int $codepoint Unicode codepoint in hex notation + * @param int $codepoint Unicode codepoint in hex notation * * @return string UTF-8 literal string */ @@ -256,7 +256,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase public function testJavascriptEscapingEscapesOwaspRecommendedRanges() { $immune = array(',', '.', '_'); // Exceptions to escaping ranges - for ($chr = 0; $chr < 0xFF; $chr++) { + for ($chr = 0; $chr < 0xFF; ++$chr) { if ($chr >= 0x30 && $chr <= 0x39 || $chr >= 0x41 && $chr <= 0x5A || $chr >= 0x61 && $chr <= 0x7A) { @@ -279,7 +279,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase public function testHtmlAttributeEscapingEscapesOwaspRecommendedRanges() { $immune = array(',', '.', '-', '_'); // Exceptions to escaping ranges - for ($chr = 0; $chr < 0xFF; $chr++) { + for ($chr = 0; $chr < 0xFF; ++$chr) { if ($chr >= 0x30 && $chr <= 0x39 || $chr >= 0x41 && $chr <= 0x5A || $chr >= 0x61 && $chr <= 0x7A) { @@ -302,7 +302,7 @@ class Twig_Test_EscapingTest extends PHPUnit_Framework_TestCase public function testCssEscapingEscapesOwaspRecommendedRanges() { // CSS has no exceptions to escaping ranges - for ($chr = 0; $chr < 0xFF; $chr++) { + for ($chr = 0; $chr < 0xFF; ++$chr) { if ($chr >= 0x30 && $chr <= 0x39 || $chr >= 0x41 && $chr <= 0x5A || $chr >= 0x61 && $chr <= 0x7A) { diff --git a/main/content/data/yuuno/css/yuuno.css b/main/content/data/yuuno/css/yuuno.css index 52f324c..3c6fe96 100644 --- a/main/content/data/yuuno/css/yuuno.css +++ b/main/content/data/yuuno/css/yuuno.css @@ -581,18 +581,21 @@ a#gotop.exit { .header .menu .menu-item { margin: 0 8px -2px; display: inline-block; - min-width: 75px; - padding: 5px; border-bottom: 2px solid #8364A1; color: inherit; text-decoration: none; text-align: center; transition: border-color .5s, background .3s; + height: 30px; + width: 30px; + line-height: 30px; + vertical-align: middle; + font-size: 1.6em; + color: #75569B; } .header .menu .menu-item.avatar { - width: auto; - padding-left: 36px; + padding-left: 30px; background: url('/pixel.png') no-repeat scroll left center / contain transparent; background-size: auto 30px; } @@ -1590,6 +1593,46 @@ a#gotop.exit { margin: 0 1px; } +.support table { + width: 100%; + border-spacing: 0; + margin: 3px auto; +} + +.support table td, +.support table th { + padding: 4px 8px; +} + +.support table td { + padding: 4px 8px; + background: #C2AFFE; +} + +.support table th:nth-child(1) { + width: 25%; +} + +.support table th:nth-child(2) { + width: 10%; +} + +.support table td:nth-child(2) { + text-align: center; +} + +.support table th:nth-child(3) { + width: 65%; +} + +.support thead th { + background: linear-gradient(0deg, #C2AFFE, transparent); +} + +.support tfoot th { + background: linear-gradient(180deg, #C2AFFE, transparent); +} + /* * Input box Styling */ diff --git a/main/settings.php b/main/settings.php index 4c3683f..82b414e 100644 --- a/main/settings.php +++ b/main/settings.php @@ -975,7 +975,7 @@ if(Users::checkLogin()) { // Current settings page $category = isset($_GET['cat']) ? (array_key_exists($_GET['cat'], $pages) ? $_GET['cat'] : false) : array_keys($pages)[0]; - $mode = isset($_GET['mode']) && $category ? (array_key_exists($_GET['mode'], $pages[$category]['modes']) ? $_GET['mode'] : false) : array_keys($pages[array_keys($pages)[0]]['modes'])[0]; + $mode = isset($_GET['mode']) && $category ? (array_key_exists($_GET['mode'], $pages[$category]['modes']) ? $_GET['mode'] : false) : array_keys($pages[$category]['modes'])[0]; // Not found if(!$category || empty($category) || !$mode || empty($mode) || !$pages[$category]['modes'][$mode]['access']) { diff --git a/main/support.php b/main/support.php index 658168d..0dde6ef 100644 --- a/main/support.php +++ b/main/support.php @@ -123,6 +123,23 @@ if(isset($_REQUEST['mode']) && Users::checkLogin() && Permissions::check('SITE', } +// Premium tracker +if(isset($_GET['tracker'])) { + + $renderData['page'] = [ + + 'title' => 'Donation Tracker', + 'currentPage' => isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0, + 'premiumData' => ($_PREMIUM = Users::getPremiumTrackerData()), + 'premiumTable' => array_chunk($_PREMIUM['table'], 20, true) + + ]; + + print Templates::render('main/supporttracker.tpl', $renderData); + exit; + +} + // Set default variables $renderData['page'] = [