first commit
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file PaypalPaymentForm.php
|
||||
*
|
||||
* Copyright (c) 2014-2022 Simon Fraser University
|
||||
* Copyright (c) 2003-2022 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class PaypalPaymentForm
|
||||
*
|
||||
* Form for Paypal-based payments.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace APP\plugins\paymethod\paypal;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\core\Request;
|
||||
use APP\template\TemplateManager;
|
||||
use Omnipay\PayPal\Message\RestAuthorizeResponse;
|
||||
use PKP\config\Config;
|
||||
use PKP\form\Form;
|
||||
use PKP\payment\QueuedPayment;
|
||||
|
||||
class PaypalPaymentForm extends Form
|
||||
{
|
||||
/** @var PaypalPaymentPlugin */
|
||||
public $_paypalPaymentPlugin;
|
||||
|
||||
/** @var QueuedPayment */
|
||||
public $_queuedPayment;
|
||||
|
||||
/**
|
||||
* @param PaypalPaymentPlugin $paypalPaymentPlugin
|
||||
* @param QueuedPayment $queuedPayment
|
||||
*/
|
||||
public function __construct($paypalPaymentPlugin, $queuedPayment)
|
||||
{
|
||||
$this->_paypalPaymentPlugin = $paypalPaymentPlugin;
|
||||
$this->_queuedPayment = $queuedPayment;
|
||||
parent::__construct(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc Form::display()
|
||||
*
|
||||
* @param null|Request $request
|
||||
* @param null|mixed $template
|
||||
*/
|
||||
public function display($request = null, $template = null)
|
||||
{
|
||||
// Application is set to sandbox mode and will not run the features of plugin
|
||||
if (Config::getVar('general', 'sandbox', false)) {
|
||||
error_log('Application is set to sandbox mode and no payment will be done via paypal');
|
||||
TemplateManager::getManager($request)
|
||||
->assign('message', 'common.sandbox')
|
||||
->display('frontend/pages/message.tpl');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$journal = $request->getJournal();
|
||||
$paymentManager = Application::getPaymentManager($journal);
|
||||
$gateway = \Omnipay\Omnipay::create('PayPal_Rest');
|
||||
$gateway->initialize([
|
||||
'clientId' => $this->_paypalPaymentPlugin->getSetting($journal->getId(), 'clientId'),
|
||||
'secret' => $this->_paypalPaymentPlugin->getSetting($journal->getId(), 'secret'),
|
||||
'testMode' => $this->_paypalPaymentPlugin->getSetting($journal->getId(), 'testMode'),
|
||||
]);
|
||||
$transaction = $gateway->purchase([
|
||||
'amount' => number_format($this->_queuedPayment->getAmount(), 2, '.', ''),
|
||||
'currency' => $this->_queuedPayment->getCurrencyCode(),
|
||||
'description' => $paymentManager->getPaymentName($this->_queuedPayment),
|
||||
'returnUrl' => $request->url(null, 'payment', 'plugin', [$this->_paypalPaymentPlugin->getName(), 'return'], ['queuedPaymentId' => $this->_queuedPayment->getId()]),
|
||||
'cancelUrl' => $request->url(null, 'index'),
|
||||
]);
|
||||
/** @var RestAuthorizeResponse */
|
||||
$response = $transaction->send();
|
||||
if ($response->isRedirect()) {
|
||||
$request->redirectUrl($response->getRedirectUrl());
|
||||
}
|
||||
if (!$response->isSuccessful()) {
|
||||
throw new \Exception($response->getMessage());
|
||||
}
|
||||
throw new \Exception('PayPal response was not redirect!');
|
||||
} catch (\Exception $e) {
|
||||
error_log('PayPal transaction exception: ' . $e->getMessage());
|
||||
$templateMgr = TemplateManager::getManager($request);
|
||||
$templateMgr->assign('message', 'plugins.paymethod.paypal.error');
|
||||
$templateMgr->display('frontend/pages/message.tpl');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file plugins/paymethod/paypal/PaypalPaymentPlugin.php
|
||||
*
|
||||
* Copyright (c) 2014-2021 Simon Fraser University
|
||||
* Copyright (c) 2003-2021 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @class PaypalPaymentPlugin
|
||||
*
|
||||
* @ingroup plugins_paymethod_paypal
|
||||
*
|
||||
* @brief Paypal payment plugin class
|
||||
*/
|
||||
|
||||
namespace APP\plugins\paymethod\paypal;
|
||||
|
||||
use APP\core\Application;
|
||||
use APP\core\Request;
|
||||
use APP\template\TemplateManager;
|
||||
use Illuminate\Support\Collection;
|
||||
use Omnipay\Omnipay;
|
||||
use PKP\config\Config;
|
||||
use PKP\db\DAORegistry;
|
||||
use PKP\plugins\Hook;
|
||||
use PKP\plugins\PaymethodPlugin;
|
||||
use Slim\Http\Request as SlimRequest;
|
||||
|
||||
require_once(dirname(__FILE__) . '/vendor/autoload.php');
|
||||
|
||||
class PaypalPaymentPlugin extends PaymethodPlugin
|
||||
{
|
||||
/**
|
||||
* @see Plugin::getName
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'PaypalPayment';
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Plugin::getDisplayName
|
||||
*/
|
||||
public function getDisplayName()
|
||||
{
|
||||
return __('plugins.paymethod.paypal.displayName');
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Plugin::getDescription
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return __('plugins.paymethod.paypal.description');
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc Plugin::register()
|
||||
*
|
||||
* @param null|mixed $mainContextId
|
||||
*/
|
||||
public function register($category, $path, $mainContextId = null)
|
||||
{
|
||||
if (!parent::register($category, $path, $mainContextId)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->addLocaleData();
|
||||
Hook::add('Form::config::before', [$this, 'addSettings']);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add settings to the payments form
|
||||
*
|
||||
* @param string $hookName
|
||||
* @param \PKP\components\forms\FormComponent $form
|
||||
*/
|
||||
public function addSettings($hookName, $form)
|
||||
{
|
||||
import('lib.pkp.classes.components.forms.context.PKPPaymentSettingsForm'); // Load constant
|
||||
if ($form->id !== FORM_PAYMENT_SETTINGS) {
|
||||
return;
|
||||
}
|
||||
|
||||
$context = Application::get()->getRequest()->getContext();
|
||||
if (!$context) {
|
||||
return;
|
||||
}
|
||||
|
||||
$form->addGroup([
|
||||
'id' => 'paypalpayment',
|
||||
'label' => __('plugins.paymethod.paypal.displayName'),
|
||||
'showWhen' => 'paymentsEnabled',
|
||||
])
|
||||
->addField(new \PKP\components\forms\FieldOptions('testMode', [
|
||||
'label' => __('plugins.paymethod.paypal.settings.testMode'),
|
||||
'options' => [
|
||||
['value' => true, 'label' => __('common.enable')]
|
||||
],
|
||||
'value' => (bool) $this->getSetting($context->getId(), 'testMode'),
|
||||
'groupId' => 'paypalpayment',
|
||||
]))
|
||||
->addField(new \PKP\components\forms\FieldText('accountName', [
|
||||
'label' => __('plugins.paymethod.paypal.settings.accountName'),
|
||||
'value' => $this->getSetting($context->getId(), 'accountName'),
|
||||
'groupId' => 'paypalpayment',
|
||||
]))
|
||||
->addField(new \PKP\components\forms\FieldText('clientId', [
|
||||
'label' => __('plugins.paymethod.paypal.settings.clientId'),
|
||||
'value' => $this->getSetting($context->getId(), 'clientId'),
|
||||
'groupId' => 'paypalpayment',
|
||||
]))
|
||||
->addField(new \PKP\components\forms\FieldText('secret', [
|
||||
'label' => __('plugins.paymethod.paypal.settings.secret'),
|
||||
'value' => $this->getSetting($context->getId(), 'secret'),
|
||||
'groupId' => 'paypalpayment',
|
||||
]));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PaymethodPlugin::saveSettings
|
||||
*/
|
||||
public function saveSettings(string $hookname, array $args)
|
||||
{
|
||||
$slimRequest = $args[0]; /** @var SlimRequest $slimRequest */
|
||||
$request = $args[1]; /** @var Request $request */
|
||||
$updatedSettings = $args[3]; /** @var Collection $updatedSettings */
|
||||
|
||||
$allParams = $slimRequest->getParsedBody();
|
||||
$saveParams = [];
|
||||
foreach ($allParams as $param => $val) {
|
||||
switch ($param) {
|
||||
case 'accountName':
|
||||
case 'clientId':
|
||||
case 'secret':
|
||||
$saveParams[$param] = (string) $val;
|
||||
break;
|
||||
case 'testMode':
|
||||
$saveParams[$param] = $val === 'true';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$contextId = $request->getContext()->getId();
|
||||
foreach ($saveParams as $param => $val) {
|
||||
$this->updateSetting($contextId, $param, $val);
|
||||
$updatedSettings->put($param, $val);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PaymethodPlugin::getPaymentForm()
|
||||
*/
|
||||
public function getPaymentForm($context, $queuedPayment)
|
||||
{
|
||||
return new PaypalPaymentForm($this, $queuedPayment);
|
||||
}
|
||||
|
||||
/**
|
||||
* @copydoc PaymethodPlugin::isConfigured
|
||||
*/
|
||||
public function isConfigured($context)
|
||||
{
|
||||
if (!$context) {
|
||||
return false;
|
||||
}
|
||||
if ($this->getSetting($context->getId(), 'accountName') == '') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle a handshake with the PayPal service
|
||||
*/
|
||||
public function handle($args, $request)
|
||||
{
|
||||
// Application is set to sandbox mode and will not run the features of plugin
|
||||
if (Config::getVar('general', 'sandbox', false)) {
|
||||
error_log('Application is set to sandbox mode and no payment will be done via paypal');
|
||||
return;
|
||||
}
|
||||
|
||||
$journal = $request->getJournal();
|
||||
$queuedPaymentDao = DAORegistry::getDAO('QueuedPaymentDAO'); /** @var \PKP\payment\QueuedPaymentDAO $queuedPaymentDao */
|
||||
try {
|
||||
$queuedPayment = $queuedPaymentDao->getById($queuedPaymentId = $request->getUserVar('queuedPaymentId'));
|
||||
if (!$queuedPayment) {
|
||||
throw new \Exception("Invalid queued payment ID {$queuedPaymentId}!");
|
||||
}
|
||||
|
||||
$gateway = Omnipay::create('PayPal_Rest');
|
||||
$gateway->initialize([
|
||||
'clientId' => $this->getSetting($journal->getId(), 'clientId'),
|
||||
'secret' => $this->getSetting($journal->getId(), 'secret'),
|
||||
'testMode' => $this->getSetting($journal->getId(), 'testMode'),
|
||||
]);
|
||||
$transaction = $gateway->completePurchase([
|
||||
'payer_id' => $request->getUserVar('PayerID'),
|
||||
'transactionReference' => $request->getUserVar('paymentId'),
|
||||
]);
|
||||
$response = $transaction->send();
|
||||
if (!$response->isSuccessful()) {
|
||||
throw new \Exception($response->getMessage());
|
||||
}
|
||||
|
||||
$data = $response->getData();
|
||||
if ($data['state'] != 'approved') {
|
||||
throw new \Exception('State ' . $data['state'] . ' is not approved!');
|
||||
}
|
||||
if (count($data['transactions']) != 1) {
|
||||
throw new \Exception('Unexpected transaction count!');
|
||||
}
|
||||
$transaction = $data['transactions'][0];
|
||||
if ((float) $transaction['amount']['total'] != (float) $queuedPayment->getAmount() || $transaction['amount']['currency'] != $queuedPayment->getCurrencyCode()) {
|
||||
throw new \Exception('Amounts (' . $transaction['amount']['total'] . ' ' . $transaction['amount']['currency'] . ' vs ' . $queuedPayment->getAmount() . ' ' . $queuedPayment->getCurrencyCode() . ') don\'t match!');
|
||||
}
|
||||
|
||||
$paymentManager = Application::getPaymentManager($journal);
|
||||
$paymentManager->fulfillQueuedPayment($request, $queuedPayment, $this->getName());
|
||||
$request->redirectUrl($queuedPayment->getRequestUrl());
|
||||
} catch (\Exception $e) {
|
||||
error_log('PayPal transaction exception: ' . $e->getMessage());
|
||||
$templateMgr = TemplateManager::getManager($request);
|
||||
$templateMgr->assign('message', 'plugins.paymethod.paypal.error');
|
||||
$templateMgr->display('frontend/pages/message.tpl');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!PKP_STRICT_MODE) {
|
||||
class_alias('\APP\plugins\paymethod\paypal\PaypalPaymentPlugin', '\PaypalPaymentPlugin');
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"require": {
|
||||
"symfony/event-dispatcher" : "~2.7",
|
||||
"omnipay/paypal": "~3.0",
|
||||
"guzzlehttp/guzzle": "^7.0",
|
||||
"php-http/guzzle7-adapter": "^1.0"
|
||||
},
|
||||
"config": {
|
||||
"platform": {
|
||||
"php": "8.0.2"
|
||||
},
|
||||
"allow-plugins": {
|
||||
"php-http/discovery": true
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+1521
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1008 B |
Binary file not shown.
|
After Width: | Height: | Size: 794 B |
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file plugins/paymethod/paypal/index.php
|
||||
*
|
||||
* Copyright (c) 2014-2022 Simon Fraser University
|
||||
* Copyright (c) 2003-2022 John Willinsky
|
||||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
|
||||
*
|
||||
* @brief Wrapper for PayPal payment plugin.
|
||||
*/
|
||||
|
||||
return new \APP\plugins\paymethod\paypal\PaypalPaymentPlugin();
|
||||
@@ -0,0 +1,40 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:58+00:00\n"
|
||||
"PO-Revision-Date: 2019-11-19T11:05:58+00:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "دفع الرسوم عبر Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "معالجة المدفوعات ستتم عبر خدمة PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "دفع الرسوم عبر Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "إعدادات الدفع المالي عبر Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "نمط الاختبار"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "اسم الحساب"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "الرمز التعريفي للعميل"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "الرمز السري"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"حدث خطأ في المناقلة المالية. لطفاً، راسل رئيس تحرير المجلة لمعرفة التفاصيل."
|
||||
@@ -0,0 +1,42 @@
|
||||
# Osman Durmaz <osmandurmaz@hotmail.de>, 2023.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2023-06-02 22:43+0000\n"
|
||||
"Last-Translator: Osman Durmaz <osmandurmaz@hotmail.de>\n"
|
||||
"Language-Team: Azerbaijani <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/az/>\n"
|
||||
"Language: az\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 4.13.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "PayPal ilə ödəniş"
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "PayPal ilə ödəmə"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Ödənişlər PayPal xidmətindən istifadə etməklə işlənəcəkdir."
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Müştəri identifikasiya nömrəsi"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Gizli"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Əməliyyat xətası baş verdi. Daha ətraflı məlumat üçün jurnal meneceri ilə "
|
||||
"əlaqə saxlayın."
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "PayPal Ödəniş ayarları"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Test rejimi"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Hesab adı"
|
||||
@@ -0,0 +1,42 @@
|
||||
# Cyril Kamburov <cc@intermedia.bg>, 2021.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2021-08-29 20:30+0000\n"
|
||||
"Last-Translator: Cyril Kamburov <cc@intermedia.bg>\n"
|
||||
"Language-Team: Bulgarian <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/bg/>\n"
|
||||
"Language: bg\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Плащане на такса чрез Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Плащанията ще бъдат обработвани с помощта на услугата PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Плащане на такса чрез Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Настройки за плащане на такса чрез Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Тестов режим"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Акаунт (Account Name)"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Клиентски номер (Client ID)"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Секретен код"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Възникна грешка при транзакция. Моля, свържете се с мениджъра на списанието "
|
||||
"за подробности."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2020-05-08 01:16+0000\n"
|
||||
"Last-Translator: Jordi LC <jordi.lacruz@uab.cat>\n"
|
||||
"Language-Team: Catalan <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/ca_ES/>\n"
|
||||
"Language: ca_ES\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Pagament via Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Els pagaments es processaran a través del servei PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Pagament via Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Configuració del pagament PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Mode test"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nom del compte"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID del client"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Contrasenya"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"S'ha produït un error de transacció. Contacteu amb l'administrador/a de la "
|
||||
"revista per obtenir més detalls."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2020-04-05 14:49+0000\n"
|
||||
"Last-Translator: Hewa Salam Khalid <hewa.salam@koyauniversity.org>\n"
|
||||
"Language-Team: Kurdish <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/ku/>\n"
|
||||
"Language: ku_IQ\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "پارەدان لە ڕێگەی پەیپاڵ"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr ".پارەدانەکان لە ڕێگای خزمەتگوزاریی پەیپاڵەوە ئەنجام دەدرێن"
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "پارەدانی پەیپاڵ"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "ڕێکخستنی پارەدانی پەیپاڵ"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "شێوازی ئەزمونکردن"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "ناوی ئەژمار"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ناسنامەی مشتەری"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "نهێنی"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"هەڵەیەک لە ناردنی پارەکە هەیە. تکایە، پەیوەندی بە سەرنوسەری گۆڤارەوە بکە بۆ "
|
||||
"زانیاری زیاتر."
|
||||
@@ -0,0 +1,40 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:58+00:00\n"
|
||||
"PO-Revision-Date: 2019-11-19T11:05:58+00:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Platba pomocí služby PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Platba bude provedena s využítím služby PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Platba pomocí služby PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Nastavení plateb PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Testovací mód"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Jméno účtu"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID klienta"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Tajemství"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Došlo k chybě transakce. Podrobné informace získáte od správce časopisu."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:58+00:00\n"
|
||||
"PO-Revision-Date: 2019-11-19T11:05:58+00:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal Fee Payment - Paypal gebyrbetaling"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Betalinger sker via PayPal-tjenesten."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal gebyrbetaling"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal-betalingsindstillinger"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Testtilstand"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Kontonavn"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Klient-ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Hemmelig"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Der opstod en transaktionsfejl. Kontakt tidsskriftschefen for yderligere "
|
||||
"oplysninger."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-09-30T06:56:47-07:00\n"
|
||||
"PO-Revision-Date: 2019-09-30T06:56:47-07:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Gebührenzahlung mittels PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Zahlungen werden über PayPal abgewickelt."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Gebührenzahlung mittels PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Zahlungseinstellungen für PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Testmodus"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Benutzerkennung"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Kundennummer (Client ID)"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Anmeldedaten (Secret)"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Bei der Ausführung ist ein Fehler aufgetreten. Bitte kontaktieren Sie eine/n "
|
||||
"Zeitschriftenverwalter/in, wenn Sie Details wissen möchten."
|
||||
@@ -0,0 +1,8 @@
|
||||
# Weblate Admin <alec@smecher.bc.ca>, 2023.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Language: dsb\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Weblate\n"
|
||||
@@ -0,0 +1,40 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-09-30T06:56:47-07:00\n"
|
||||
"PO-Revision-Date: 2019-09-30T06:56:47-07:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal Fee Payment"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Payments will be processed using the PayPal service."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal Fee Payment"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal Payment Settings"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Test Mode"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Account Name"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Client ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Secret"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"A transaction error occurred. Please contact the journal manager for details."
|
||||
@@ -0,0 +1,44 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"PO-Revision-Date: 2020-05-08 01:16+0000\n"
|
||||
"Last-Translator: Jordi LC <jordi.lacruz@uab.cat>\n"
|
||||
"Language-Team: Spanish <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/es_ES/>\n"
|
||||
"Language: es_ES\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Pago vía Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Los pagos se procesarán a través del servicio PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Pago vía PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Ajustes del pago PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Modo test"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nombre de la cuenta"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID del cliente"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Contraseña"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Se ha producido un error de transacción. Contacte con el administrador/a de "
|
||||
"la revista para más detalles."
|
||||
@@ -0,0 +1,45 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"PO-Revision-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "پرداخت از طریق PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr ""
|
||||
"بکمک PayPal کاربران صرف نظر از اینکه عضو PayPal باشند یا نباشند قادر میسازد "
|
||||
"تا تمام انواع کارت های اعتباری ماژور را برای پرداخت بکار برند. مدیر مجله "
|
||||
"باید که یک <a href=\"http://www.paypal.com\" target=\"_new\">حساب تجارتی "
|
||||
"PayPal</a> راهاندازی کند."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "پرداخت پول PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "تنظیمات PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "حالت آزمایشی"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "نام حساب کاربری"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "شناسه مشتری"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "کدمخفی"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"در انتقال خطای رخ داده است. برای دریافت اطلاعات بیشتر با مدیر مجله تماس حاصل "
|
||||
"فرمایید."
|
||||
@@ -0,0 +1,39 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2020-12-12 08:52+0000\n"
|
||||
"Last-Translator: Antti-Jussi Nygård <ajnyga@gmail.com>\n"
|
||||
"Language-Team: Finnish <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/fi_FI/>\n"
|
||||
"Language: fi_FI\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal-maksu"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Julkaisun maksuihin käytetään Paypal-palvelua."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal-maksu"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal-maksujen asetukset"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Testaustila"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Tilin nimi"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Asiakkaan tunniste (Client ID)"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Salaisuus (Secret)"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr "Maksussa tapahtui virhe. Ota yhteyttä julkaisun hallinnoijaan."
|
||||
@@ -0,0 +1,45 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-09-30T06:56:47-07:00\n"
|
||||
"PO-Revision-Date: 2020-01-28 23:48+0000\n"
|
||||
"Last-Translator: Marie-Hélène Vézina [UdeMontréal] <marie-"
|
||||
"helene.vezina@umontreal.ca>\n"
|
||||
"Language-Team: French (Canada) <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/fr_CA/>\n"
|
||||
"Language: fr_CA\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paiement PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Les paiements seront effectués par l'intermédiaire du service de paiement PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paiement PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paramètres du service de paiement PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Mode Test"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nom du compte"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID du client"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Clé secrète"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Une erreur de transaction s'est produite. Veuillez contacter un-e "
|
||||
"responsable de la revue pour plus de renseignements."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2020-08-21 14:48+0000\n"
|
||||
"Last-Translator: Paul Heckler <paul.d.heckler@gmail.com>\n"
|
||||
"Language-Team: French <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/fr/>\n"
|
||||
"Language: fr\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paiement par PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Les paiements seront traités par le service PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paiement par PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paramètres du service de paiement par PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Mode de test"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nom du compte"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Identifiant du client"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Clé secrète"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Une erreur de transaction s'est produite. Veuillez contacter le ou la "
|
||||
"responsable de la revue pour plus de renseignements."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2021-06-19 03:25+0000\n"
|
||||
"Last-Translator: Real Academia Galega <reacagal@gmail.com>\n"
|
||||
"Language-Team: Galician <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/gl_ES/>\n"
|
||||
"Language: gl_ES\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Pagamento vía PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Os pagamentos procesaranse mediante o servizo PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Pagamento via PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Configuración de PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Modo de test"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nome da conta"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID do cliente"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Contrasinal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Produciuse un erro na transacción. Póñase en contacto co xestor da revista "
|
||||
"para máis detalles."
|
||||
@@ -0,0 +1,8 @@
|
||||
# Weblate Admin <alec@smecher.bc.ca>, 2023.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Language: hsb\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Weblate\n"
|
||||
@@ -0,0 +1,42 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-02-13T21:07:39+00:00\n"
|
||||
"PO-Revision-Date: 2020-02-14 20:38+0000\n"
|
||||
"Last-Translator: Gabor Klinger <ojshelp@konyvtar.mta.hu>\n"
|
||||
"Language-Team: Hungarian <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/hu/>\n"
|
||||
"Language: hu_HU\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal Díjfizetés"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "A fizetések a PayPal szolgáltatáson keresztül kerülnek lebonylításra."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal Díjfizetés"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal fizetési beállítások"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Teszt mód"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Fióknév"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Kliens ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Titok"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr "Tranzakciós hiba történt. Kérjük, lépjen kapcsolatba a folyóiratmenedzserrel a részletekért."
|
||||
@@ -0,0 +1,43 @@
|
||||
# Artashes Mirzoyan <amirzoyan@sci.am>, 2022.
|
||||
# Tigran Zargaryan <tigran@flib.sci.am>, 2022.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2022-06-29 18:50+0000\n"
|
||||
"Last-Translator: Tigran Zargaryan <tigran@flib.sci.am>\n"
|
||||
"Language-Team: Armenian <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/hy_AM/>\n"
|
||||
"Language: hy_AM\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal գումարի վճարում"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Վճարումները կմշակվեն PayPal ծառայության միջոցով:"
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal գումարի վճարում"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal-ի վճարման կարգավորումներ"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Փորձարկման ռեժիմ"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Հաշվի անուն"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Հաճախորդի ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Գաղտնի"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Գործարքի սխալ է տեղի ունեցել: Մանրամասների համար խնդրում ենք կապվել ամսագրի "
|
||||
"կառավարիչի հետ:"
|
||||
@@ -0,0 +1,94 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"PO-Revision-Date: 2020-01-31 16:21+0000\n"
|
||||
"Last-Translator: Fransisca H <sisca.ojs@gmail.com>\n"
|
||||
"Language-Team: Indonesian <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/id/>\n"
|
||||
"Language: id_ID\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Biaya Pembayaran PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Pembayaran akan diproses menggunakan layanan PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Pembayaran Biaya PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Penyetelan Pembayaran PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Mode Ujicoba"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nama Akun"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID Klien"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Rahasia"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Terjadi kesalahan transaksi. Silakan hubungi manajer jurnal untuk keterangan "
|
||||
"lebih lanjut."
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.settings.paypalenable"
|
||||
#~ msgstr "Memungkinkan "
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.settings.paypalurl"
|
||||
#~ msgstr "URL IPN"
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.settings.paypalurl.description"
|
||||
#~ msgstr ""
|
||||
#~ "URL ini untuk servis Instant Payment Notification (IPN) PayPal. Untuk "
|
||||
#~ "mengecek, gunakan <u>https://www.sandbox.paypal.com/cgi-bin/webscr</u>; "
|
||||
#~ "untuk sistem produksi, gunakan <u>https://www.paypal.com/cgi-bin/webscr</"
|
||||
#~ "u>."
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.settings.selleraccount"
|
||||
#~ msgstr " Akun Penjual "
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.settings.selleraccount.description"
|
||||
#~ msgstr ""
|
||||
#~ "Nama pengguna akun paypal ini untuk akun yang digunakan para penjual, "
|
||||
#~ "biasanya alamat email. Pastikan Anda mengaktifkan Instant Payment "
|
||||
#~ "Notification (IPN) pada profil akun penjual anda."
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.settings.curlNotInstalled"
|
||||
#~ msgstr ""
|
||||
#~ "Peringatan: CURL dukungan PHP tidak diinstal. Dukungan pembayaran paypal "
|
||||
#~ "memerlukan perpustakaan CURL dan tidak akan berfungsi hingga hingga "
|
||||
#~ "setelah diinstal."
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.warning"
|
||||
#~ msgstr ""
|
||||
#~ " Klik tombol lanjutan dibawah untuk menuju ke situs PayPal, dimana kartu "
|
||||
#~ "kredit dapat digunakan untuk membayar biaya (tanpa harus bergabung dengan "
|
||||
#~ "paypal). Gunakan tombol eReturn to Merchanti setelah melakukan pembayaran "
|
||||
#~ "untuk kembali ke situs ini"
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.purchase.title"
|
||||
#~ msgstr " Judul"
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.purchase.fee"
|
||||
#~ msgstr " Biaya"
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.purchase.description"
|
||||
#~ msgstr " Deskripsi"
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.purchase.cancelled"
|
||||
#~ msgstr " Pembelian anda telah dibatalkan."
|
||||
|
||||
#~ msgid "plugins.paymethod.paypal.purchase.cancelled.title"
|
||||
#~ msgstr " Pembelian dibatalkan"
|
||||
@@ -0,0 +1,35 @@
|
||||
# Kolbrun Reynisdottir <kolla@probus.is>, 2022.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Language: is_IS\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Weblate\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
@@ -0,0 +1,44 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"PO-Revision-Date: 2019-12-28 17:34+0000\n"
|
||||
"Last-Translator: Lucia Steele <lucia.steele@aboutscience.eu>\n"
|
||||
"Language-Team: Italian <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/it/>\n"
|
||||
"Language: it_IT\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Pagamento tariffe via PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "I pagamenti verranno processati usando il servizio di PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Pagamento tramite PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Configurazioni di PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Modalità test"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Account"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Client ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Segreto"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"C'è stato un errore nella transazione. Contatta il journal manager per i "
|
||||
"dettagli."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2021-02-07 10:53+0000\n"
|
||||
"Last-Translator: Dimitri Gogelia <dimitri.gogelia@iliauni.edu.ge>\n"
|
||||
"Language-Team: Georgian <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/ka_GE/>\n"
|
||||
"Language: ka_GE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "მოდული „გადახდები PayPal-ით“"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "გადახდები დამუშავდება PayPal-ის საშუალებით."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "გადახდები PayPal-ით"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "PayPal-ით გადახდების მორგება"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "სატესტო რეჟიმი"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "ანგარიშის სახელი"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "კლიენტის ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "საიდუმლო კოდი"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"მოხდა ტრანზაქციის შეცდომა. გთხოვთ, დაუკავშირდეთ ჟურნალის მმართველს "
|
||||
"დამატებითი ინფორმაციის მისაღებად."
|
||||
@@ -0,0 +1,42 @@
|
||||
# Madi <nmdbzk@gmail.com>, 2021.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2021-07-14 06:04+0000\n"
|
||||
"Last-Translator: Madi <nmdbzk@gmail.com>\n"
|
||||
"Language-Team: Kazakh <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/kk_KZ/>\n"
|
||||
"Language: kk_KZ\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "\"PayPal арқылы төлемдер\" модулі"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Төлемдер PayPal қызметі арқылы өңделеді."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "PayPal арқылы төлемдер"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal арқылы төлем параметрлері"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Тест режимі"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Есептік жазбаның аты"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Клиенттің ID-і"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Құпия код"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Транзакция қатесі орын алды. Қосымша ақпарат алу үшін журнал менеджеріне "
|
||||
"хабарласыңыз."
|
||||
@@ -0,0 +1,42 @@
|
||||
# Mahmut VURAL <mahmut.vural@outlook.com>, 2024.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2024-01-03 21:35+0000\n"
|
||||
"Last-Translator: Mahmut VURAL <mahmut.vural@outlook.com>\n"
|
||||
"Language-Team: Kyrgyz <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/ky/>\n"
|
||||
"Language: ky\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 4.18.2\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Модул \"PayPal аркылуу төлөмдөр\""
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Төлөмдөр PayPal аркылуу иштетилет."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "PayPal аркылуу төлөмдөр"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal аркылуу төлөм орнотуулары"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Сыноо режими"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "эсеп аты"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Кардар ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Жашыруун код"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Транзакция катасы кетти. Көбүрөөк маалымат алуу үчүн журналдын менеджери "
|
||||
"менен байланышыңыз."
|
||||
@@ -0,0 +1,43 @@
|
||||
# Ieva Tiltina <pastala@gmail.com>, 2024.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2024-02-19 11:07+0000\n"
|
||||
"Last-Translator: Ieva Tiltina <pastala@gmail.com>\n"
|
||||
"Language-Team: Latvian <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/lv/>\n"
|
||||
"Language: lv\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n % 10 == 0 || n % 100 >= 11 && n % 100 <= "
|
||||
"19) ? 0 : ((n % 10 == 1 && n % 100 != 11) ? 1 : 2);\n"
|
||||
"X-Generator: Weblate 4.18.2\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Maksājuma veikšana ar Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Maksājumi tiks apstrādāti, izmantojot PayPal pakalpojumu."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Maksājuma veikšana ar Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal maksājumu iestatījumi"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Testa režīms"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Konta nosaukums"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Klienta ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Slepenais kods"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Notika darījuma kļūda. Lūdzu, sazinieties ar žurnāla pārvaldnieku, lai "
|
||||
"saņemtu sīkāku informāciju."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2021-01-11 10:59+0000\n"
|
||||
"Last-Translator: Blagoja Grozdanovski <blagoja.grozdanovski@gmail.com>\n"
|
||||
"Language-Team: Macedonian <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/mk_MK/>\n"
|
||||
"Language: mk_MK\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n==1 || n%10==1 ? 0 : 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Плаќање на провизии за Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Плаќањата ќе бидат обработени со користење на услугата PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Плаќање на провизии за Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Поставки за плаќање на Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Режим на тестирање"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Име на сметка"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID на клиент"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Тајна"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Настана грешка во трансакцијата. За детали, контактирајте го менаџерот на "
|
||||
"списанието."
|
||||
@@ -0,0 +1,42 @@
|
||||
# Muhd Muaz <muazhero61@yahoo.com>, 2021.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2021-10-20 21:22+0000\n"
|
||||
"Last-Translator: Muhd Muaz <muazhero61@yahoo.com>\n"
|
||||
"Language-Team: Malay <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/ms/>\n"
|
||||
"Language: ms\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Bayaran Yuran Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Pembayaran akan diproses menggunakan perkhidmatan PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Bayaran Yuran Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Tetapan Pembayaran Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Mod Uji"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nama Akaun"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID Pelanggan"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Rahsia"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Ralat transaksi berlaku. Sila hubungi pengurus jurnal untuk maklumat lebih "
|
||||
"lanjut."
|
||||
@@ -0,0 +1,44 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-03-20T15:57:55+00:00\n"
|
||||
"PO-Revision-Date: 2020-10-19 15:22+0000\n"
|
||||
"Last-Translator: Eirik Hanssen <eirikh@oslomet.no>\n"
|
||||
"Language-Team: Norwegian Bokmål <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/nb_NO/>\n"
|
||||
"Language: nb_NO\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Betaling med Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Betalinger vil bli behandlet ved hjelp av PayPal tjenesten."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Betaling med PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "PayPal-innstillinger"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Testmodus"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Kontonavn"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Klient-ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Hemmelig"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Det oppsto en feil under transaksjonen. Kontakt tidsskriftsadministratoren "
|
||||
"for detaljer."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"PO-Revision-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal betaling"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Betalingen zullen worden verwerkt via PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal betaling"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal instellingen"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Testmodus"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Accountnaam"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Client ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Geheime sleutel"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Er trad een transactiefout op. Contacteer de tijdschriftbeheerder voor "
|
||||
"details."
|
||||
@@ -0,0 +1,45 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"PO-Revision-Date: 2020-11-30 11:43+0000\n"
|
||||
"Last-Translator: rl <biuro@fimagis.pl>\n"
|
||||
"Language-Team: Polish <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/pl_PL/>\n"
|
||||
"Language: pl_PL\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
|
||||
"|| n%100>=20) ? 1 : 2;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Dokonanie płatności przez PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Opłata będzie procedowana przez serwis PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Dokonanie płatności przez PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Ustawienia płatności PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Moduł testowy"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nazwa użytkownika"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID klienta"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Klucz"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Błąd transakcji. Proszę, skontaktuj się z menedżerem czasopisma w sprawie "
|
||||
"szczegółów."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2020-06-04 19:54+0000\n"
|
||||
"Last-Translator: Diego José Macêdo <diegojmacedo@gmail.com>\n"
|
||||
"Language-Team: Portuguese (Brazil) <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/pt_BR/>\n"
|
||||
"Language: pt_BR\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n > 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Plugin de Pagamento via Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Pagamentos processados por meio do serviço PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Pagamento via PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Configurações do PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Modo de Teste"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nome da Conta"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID do Cliente"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Senha"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Ocorreu um erro na transação. Entre em contato com o gerente da revista para "
|
||||
"obter detalhes."
|
||||
@@ -0,0 +1,40 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"PO-Revision-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Plugin de Pagamento via Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Pagamentos processados através do serviço PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Pagamento via PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Configurações do PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Modo de Teste"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Nome da Conta"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID do Cliente"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Senha"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Ocorreu um erro de transação. Contacte o gestor da revista para detalhes."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"PO-Revision-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Модуль «Платежи через PayPal»"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Платежи будут обрабатываться с помощью службы PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Платежи через PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Настройки платежей через Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Тестовый режим"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Имя учетной записи"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID клиента"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Секретный код"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Произошла ошибка транзакции. Пожалуйста, свяжитесь с менеджером журнала для "
|
||||
"получения более подробной информации."
|
||||
@@ -0,0 +1,40 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2020-10-12 11:44+0000\n"
|
||||
"Last-Translator: Miroslav Chladný <klwngbnl@zeroe.ml>\n"
|
||||
"Language-Team: Slovak <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/sk_SK/>\n"
|
||||
"Language: sk_SK\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Platba pomocou služby PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Platba bude vykonaná s využitím služby PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Platba pomocou služby PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Nastavenie platieb PayPal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Testovací mód"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Názov účtu"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID klienta"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Tajomstvo"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Došlo k chybe transakcie. Podrobné informácie získate od správcu časopisu."
|
||||
@@ -0,0 +1,40 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"PO-Revision-Date: 2019-11-19T11:05:59+00:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Plačilo preko Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Plačila se bodo procesirala z uporabo PayPal servisa."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal Fee Payment"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal Payment Settings"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Test Mode"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Account Name"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Client ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Secret"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"A transaction error occurred. Please contact the journal manager for details."
|
||||
@@ -0,0 +1,40 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2021-04-28 15:12+0000\n"
|
||||
"Last-Translator: Magnus Annemark <magnus.annemark@ub.lu.se>\n"
|
||||
"Language-Team: Swedish <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/sv_SE/>\n"
|
||||
"Language: sv_SE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal-betalning"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Betalningar kommer behandlas genom Paypal-tjänsten."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal-betalning"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Inställningar för Paypal-betalning"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Testläge"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Kontonamn"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Klient-ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Hemlighet"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Ett fel uppstod i transaktionen! Kontakta tidskriftsansvarig för detaljer."
|
||||
@@ -0,0 +1,40 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:06:00+00:00\n"
|
||||
"PO-Revision-Date: 2019-11-19T11:06:00+00:00\n"
|
||||
"Last-Translator: \n"
|
||||
"Language-Team: \n"
|
||||
"Language: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal ile Ücret Ödeme"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Ödemeler PayPal servisi kullanılarak yapılacaktır."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal ile Ücret Ödeme"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal Ödeme Ayarları"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Test Modu"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Hesap Adı"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Müşteri ID'si"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Gizli"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Bir işlem hatası oluştu. Detaylar için lütfen dergi yöneticisine başvurun."
|
||||
@@ -0,0 +1,46 @@
|
||||
# Petro Bilous <petrobilous@ukr.net>, 2023.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2019-11-19T11:06:00+00:00\n"
|
||||
"PO-Revision-Date: 2023-06-01 09:27+0000\n"
|
||||
"Last-Translator: Petro Bilous <petrobilous@ukr.net>\n"
|
||||
"Language-Team: Ukrainian <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/uk/>\n"
|
||||
"Language: uk\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
|
||||
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
|
||||
"X-Generator: Weblate 4.13.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Платежі через Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Платежі будуть оброблятися за допомогою послуги PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Платежі через Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Налаштування платежів через Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Тестовий режим"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Ім'я облікового запису"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID клієнта"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Таємний код"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Сталася помилка транзакції. Будь ласка, зверніться до менеджера журналу, щоб "
|
||||
"отримати детальнішу інформацію."
|
||||
@@ -0,0 +1,33 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Weblate\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr ""
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
@@ -0,0 +1,42 @@
|
||||
# Ruslan Shodmonov <belovedspy1209@gmail.com>, 2021.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2021-09-10 08:46+0000\n"
|
||||
"Last-Translator: Ruslan Shodmonov <belovedspy1209@gmail.com>\n"
|
||||
"Language-Team: Uzbek <http://translate.pkp.sfu.ca/projects/ojs/paymethod-"
|
||||
"paypal/uz_UZ@latin/>\n"
|
||||
"Language: uz_UZ@latin\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal uchun to'lov"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "To'lovlar PayPal xizmati yordamida amalga oshiriladi."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal uchun to'lov"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal to'lov sozlamalari"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Sinov rejimi"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Hisob nomi"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "Mijoz identifikatori"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Yashirin"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Tranzaksiyada xatolik yuz berdi. Tafsilotlar uchun jurnal menejeriga "
|
||||
"murojaat qiling."
|
||||
@@ -0,0 +1,41 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2020-04-29 07:38+0000\n"
|
||||
"Last-Translator: Tran Ngoc Trung <khuchatthienduong@gmail.com>\n"
|
||||
"Language-Team: Vietnamese <http://translate.pkp.sfu.ca/projects/ojs/"
|
||||
"paymethod-paypal/vi_VN/>\n"
|
||||
"Language: vi_VN\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Weblate 3.9.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Thanh toán phí Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "Thanh toán sẽ được xử lý bằng dịch vụ PayPal."
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Thanh toán phí Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Cài đặt thanh toán Paypal"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "Chê độ kiểm tra"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "Tên tài khoản"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "ID khách hàng"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "Bí mật"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr ""
|
||||
"Xảy ra lỗi giao dịch. Vui lòng liên hệ với người quản lý tạp chí để biết chi "
|
||||
"tiết."
|
||||
@@ -0,0 +1,40 @@
|
||||
# HKBU Library <libms@hkbu.edu.hk>, 2022.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"PO-Revision-Date: 2022-09-29 03:01+0000\n"
|
||||
"Last-Translator: HKBU Library <libms@hkbu.edu.hk>\n"
|
||||
"Language-Team: Chinese (Traditional) <http://translate.pkp.sfu.ca/projects/"
|
||||
"ojs/paymethod-paypal/zh_Hant/>\n"
|
||||
"Language: zh_Hant\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Weblate 4.13.1\n"
|
||||
|
||||
msgid "plugins.paymethod.paypal.displayName"
|
||||
msgstr "Paypal支付費用"
|
||||
|
||||
msgid "plugins.paymethod.paypal.description"
|
||||
msgstr "費用會透過Paypal服務支付。"
|
||||
|
||||
msgid "plugins.paymethod.paypal"
|
||||
msgstr "Paypal支付費用"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings"
|
||||
msgstr "Paypal支付設定"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.testMode"
|
||||
msgstr "測試模式"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.accountName"
|
||||
msgstr "戶口名稱"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.clientId"
|
||||
msgstr "客戶ID"
|
||||
|
||||
msgid "plugins.paymethod.paypal.settings.secret"
|
||||
msgstr "加密"
|
||||
|
||||
msgid "plugins.paymethod.paypal.error"
|
||||
msgstr "交易出現錯誤。詳情請聯絡期刊管理員。"
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
// autoload.php @generated by Composer
|
||||
|
||||
if (PHP_VERSION_ID < 50600) {
|
||||
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit706f694c5dcef0ef156635e1a4cbe0df::getLoader();
|
||||
@@ -0,0 +1,2 @@
|
||||
github: clue
|
||||
custom: https://clue.engineering/support
|
||||
@@ -0,0 +1,86 @@
|
||||
# Changelog
|
||||
|
||||
## 1.6.0 (2022-02-21)
|
||||
|
||||
* Feature: Support PHP 8.1 release.
|
||||
(#45 by @clue)
|
||||
|
||||
* Improve documentation to use fully-qualified function names.
|
||||
(#43 by @SimonFrings and #42 by @PaulRotmann)
|
||||
|
||||
* Improve test suite and use GitHub actions for continuous integration (CI).
|
||||
(#39 and #40 by @SimonFrings)
|
||||
|
||||
## 1.5.0 (2020-10-02)
|
||||
|
||||
* Feature: Improve performance by using global imports.
|
||||
(#38 by @clue)
|
||||
|
||||
* Improve API documentation and add support / sponsorship info.
|
||||
(#30 by @clue and #35 by @SimonFrings)
|
||||
|
||||
* Improve test suite and add `.gitattributes` to exclude dev files from exports.
|
||||
Prepare PHP 8 support, update to PHPUnit 9 and simplify test matrix.
|
||||
(#32 and #37 by @clue and #34 and #36 by @SimonFrings)
|
||||
|
||||
## 1.4.1 (2019-04-09)
|
||||
|
||||
* Fix: Check if the function is declared before declaring it.
|
||||
(#23 by @Niko9911)
|
||||
|
||||
* Improve test suite to also test against PHP 7.2 and
|
||||
add test for base64 encoding and decoding filters.
|
||||
(#22 by @arubacao and #25 by @Nyholm and @clue)
|
||||
|
||||
## 1.4.0 (2017-08-18)
|
||||
|
||||
* Feature / Fix: The `fun()` function does not pass filter parameter `null`
|
||||
to underlying `stream_filter_append()` by default
|
||||
(#15 by @Nyholm)
|
||||
|
||||
Certain filters (such as `convert.quoted-printable-encode`) do not accept
|
||||
a filter parameter at all. If no explicit filter parameter is given, we no
|
||||
longer pass a default `null` value.
|
||||
|
||||
```php
|
||||
$encode = Filter\fun('convert.quoted-printable-encode');
|
||||
assert('t=C3=A4st' === $encode('täst'));
|
||||
```
|
||||
|
||||
* Add examples and improve documentation
|
||||
(#13 and #20 by @clue and #18 by @Nyholm)
|
||||
|
||||
* Improve test suite by adding PHPUnit to require-dev,
|
||||
fix HHVM build for now again and ignore future HHVM build errors,
|
||||
lock Travis distro so new future defaults will not break the build
|
||||
and test on PHP 7.1
|
||||
(#12, #14 and #19 by @clue and #16 by @Nyholm)
|
||||
|
||||
## 1.3.0 (2015-11-08)
|
||||
|
||||
* Feature: Support accessing built-in filters as callbacks
|
||||
(#5 by @clue)
|
||||
|
||||
```php
|
||||
$fun = Filter\fun('zlib.deflate');
|
||||
|
||||
$ret = $fun('hello') . $fun('world') . $fun();
|
||||
assert('helloworld' === gzinflate($ret));
|
||||
```
|
||||
|
||||
## 1.2.0 (2015-10-23)
|
||||
|
||||
* Feature: Invoke close event when closing filter (flush buffer)
|
||||
(#9 by @clue)
|
||||
|
||||
## 1.1.0 (2015-10-22)
|
||||
|
||||
* Feature: Abort filter operation when catching an Exception
|
||||
(#10 by @clue)
|
||||
|
||||
* Feature: Additional safeguards to prevent filter state corruption
|
||||
(#7 by @clue)
|
||||
|
||||
## 1.0.0 (2015-10-18)
|
||||
|
||||
* First tagged release
|
||||
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Christian Lück
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,326 @@
|
||||
# clue/stream-filter
|
||||
|
||||
[](https://github.com/clue/stream-filter/actions)
|
||||
[](https://packagist.org/packages/clue/stream-filter)
|
||||
|
||||
A simple and modern approach to stream filtering in PHP
|
||||
|
||||
**Table of contents**
|
||||
|
||||
* [Why?](#why)
|
||||
* [Support us](#support-us)
|
||||
* [Usage](#usage)
|
||||
* [append()](#append)
|
||||
* [prepend()](#prepend)
|
||||
* [fun()](#fun)
|
||||
* [remove()](#remove)
|
||||
* [Install](#install)
|
||||
* [Tests](#tests)
|
||||
* [License](#license)
|
||||
|
||||
## Why?
|
||||
|
||||
PHP's stream filtering system is great!
|
||||
|
||||
It offers very powerful stream filtering options and comes with a useful set of built-in filters.
|
||||
These filters can be used to easily and efficiently perform various transformations on-the-fly, such as:
|
||||
|
||||
* read from a gzip'ed input file,
|
||||
* transcode from ISO-8859-1 (Latin1) to UTF-8,
|
||||
* write to a bzip output file
|
||||
* and much more.
|
||||
|
||||
But let's face it:
|
||||
Its API is [*difficult to work with*](https://www.php.net/manual/en/php-user-filter.filter.php)
|
||||
and its documentation is [*subpar*](https://stackoverflow.com/questions/27103269/what-is-a-bucket-brigade).
|
||||
This combined means its powerful features are often neglected.
|
||||
|
||||
This project aims to make these features more accessible to a broader audience.
|
||||
* **Lightweight, SOLID design** -
|
||||
Provides a thin abstraction that is [*just good enough*](https://en.wikipedia.org/wiki/Principle_of_good_enough)
|
||||
and does not get in your way.
|
||||
Custom filters require trivial effort.
|
||||
* **Good test coverage** -
|
||||
Comes with an automated tests suite and is regularly tested in the *real world*
|
||||
|
||||
## Support us
|
||||
|
||||
We invest a lot of time developing, maintaining and updating our awesome
|
||||
open-source projects. You can help us sustain this high-quality of our work by
|
||||
[becoming a sponsor on GitHub](https://github.com/sponsors/clue). Sponsors get
|
||||
numerous benefits in return, see our [sponsoring page](https://github.com/sponsors/clue)
|
||||
for details.
|
||||
|
||||
Let's take these projects to the next level together! 🚀
|
||||
|
||||
## Usage
|
||||
|
||||
This lightweight library consists only of a few simple functions.
|
||||
All functions reside under the `Clue\StreamFilter` namespace.
|
||||
|
||||
The below examples refer to all functions with their fully-qualified names like this:
|
||||
|
||||
```php
|
||||
Clue\StreamFilter\append(…);
|
||||
```
|
||||
|
||||
As of PHP 5.6+ you can also import each required function into your code like this:
|
||||
|
||||
```php
|
||||
use function Clue\StreamFilter\append;
|
||||
|
||||
append(…);
|
||||
```
|
||||
|
||||
Alternatively, you can also use an import statement similar to this:
|
||||
|
||||
```php
|
||||
use Clue\StreamFilter as Filter;
|
||||
|
||||
Filter\append(…);
|
||||
```
|
||||
|
||||
### append()
|
||||
|
||||
The `append(resource<stream> $stream, callable $callback, int $read_write = STREAM_FILTER_ALL): resource<stream filter>` function can be used to
|
||||
append a filter callback to the given stream.
|
||||
|
||||
Each stream can have a list of filters attached.
|
||||
This function appends a filter to the end of this list.
|
||||
|
||||
If the given filter can not be added, it throws an `Exception`.
|
||||
|
||||
The `$stream` can be any valid stream resource, such as:
|
||||
|
||||
```php
|
||||
$stream = fopen('demo.txt', 'w+');
|
||||
```
|
||||
|
||||
The `$callback` should be a valid callable function which accepts
|
||||
an individual chunk of data and should return the updated chunk:
|
||||
|
||||
```php
|
||||
$filter = Clue\StreamFilter\append($stream, function ($chunk) {
|
||||
// will be called each time you read or write a $chunk to/from the stream
|
||||
return $chunk;
|
||||
});
|
||||
```
|
||||
|
||||
As such, you can also use native PHP functions or any other `callable`:
|
||||
|
||||
```php
|
||||
Clue\StreamFilter\append($stream, 'strtoupper');
|
||||
|
||||
// will write "HELLO" to the underlying stream
|
||||
fwrite($stream, 'hello');
|
||||
```
|
||||
|
||||
If the `$callback` accepts invocation without parameters,
|
||||
then this signature will be invoked once ending (flushing) the filter:
|
||||
|
||||
```php
|
||||
Clue\StreamFilter\append($stream, function ($chunk = null) {
|
||||
if ($chunk === null) {
|
||||
// will be called once ending the filter
|
||||
return 'end';
|
||||
}
|
||||
// will be called each time you read or write a $chunk to/from the stream
|
||||
return $chunk;
|
||||
});
|
||||
|
||||
fclose($stream);
|
||||
```
|
||||
|
||||
> Note: Legacy PHP versions (PHP < 5.4) do not support passing additional data
|
||||
from the end signal handler if the stream is being closed.
|
||||
|
||||
If your callback throws an `Exception`, then the filter process will be aborted.
|
||||
In order to play nice with PHP's stream handling,
|
||||
the `Exception` will be transformed to a PHP warning instead:
|
||||
|
||||
```php
|
||||
Clue\StreamFilter\append($stream, function ($chunk) {
|
||||
throw new \RuntimeException('Unexpected chunk');
|
||||
});
|
||||
|
||||
// raises an E_USER_WARNING with "Error invoking filter: Unexpected chunk"
|
||||
fwrite($stream, 'hello');
|
||||
```
|
||||
|
||||
The optional `$read_write` parameter can be used to only invoke the `$callback`
|
||||
when either writing to the stream or only when reading from the stream:
|
||||
|
||||
```php
|
||||
Clue\StreamFilter\append($stream, function ($chunk) {
|
||||
// will be called each time you write to the stream
|
||||
return $chunk;
|
||||
}, STREAM_FILTER_WRITE);
|
||||
|
||||
Clue\StreamFilter\append($stream, function ($chunk) {
|
||||
// will be called each time you read from the stream
|
||||
return $chunk;
|
||||
}, STREAM_FILTER_READ);
|
||||
```
|
||||
|
||||
This function returns a filter resource which can be passed to [`remove()`](#remove).
|
||||
|
||||
> Note that once a filter has been added to stream, the stream can no longer be passed to
|
||||
> [`stream_select()`](https://www.php.net/manual/en/function.stream-select.php)
|
||||
> (and family).
|
||||
>
|
||||
> > Warning: stream_select(): cannot cast a filtered stream on this system in {file} on line {line}
|
||||
>
|
||||
> This is due to limitations of PHP's stream filter support, as it can no longer reliably
|
||||
> tell when the underlying stream resource is actually ready.
|
||||
> As an alternative, consider calling `stream_select()` on the unfiltered stream and
|
||||
> then pass the unfiltered data through the [`fun()`](#fun) function.
|
||||
|
||||
### prepend()
|
||||
|
||||
The `prepend(resource<stream> $stream, callable $callback, int $read_write = STREAM_FILTER_ALL): resource<stream filter>` function can be used to
|
||||
prepend a filter callback to the given stream.
|
||||
|
||||
Each stream can have a list of filters attached.
|
||||
This function prepends a filter to the start of this list.
|
||||
|
||||
If the given filter can not be added, it throws an `Exception`.
|
||||
|
||||
```php
|
||||
$filter = Clue\StreamFilter\prepend($stream, function ($chunk) {
|
||||
// will be called each time you read or write a $chunk to/from the stream
|
||||
return $chunk;
|
||||
});
|
||||
```
|
||||
|
||||
This function returns a filter resource which can be passed to [`remove()`](#remove).
|
||||
|
||||
Except for the position in the list of filters, this function behaves exactly
|
||||
like the [`append()`](#append) function.
|
||||
For more details about its behavior, see also the [`append()`](#append) function.
|
||||
|
||||
### fun()
|
||||
|
||||
The `fun(string $filter, mixed $parameters = null): callable` function can be used to
|
||||
create a filter function which uses the given built-in `$filter`.
|
||||
|
||||
PHP comes with a useful set of [built-in filters](https://www.php.net/manual/en/filters.php).
|
||||
Using `fun()` makes accessing these as easy as passing an input string to filter
|
||||
and getting the filtered output string.
|
||||
|
||||
```php
|
||||
$fun = Clue\StreamFilter\fun('string.rot13');
|
||||
|
||||
assert('grfg' === $fun('test'));
|
||||
assert('test' === $fun($fun('test'));
|
||||
```
|
||||
|
||||
Please note that not all filter functions may be available depending
|
||||
on installed PHP extensions and the PHP version in use.
|
||||
In particular, [HHVM](https://hhvm.com/) may not offer the same filter functions
|
||||
or parameters as Zend PHP.
|
||||
Accessing an unknown filter function will result in a `RuntimeException`:
|
||||
|
||||
```php
|
||||
Clue\StreamFilter\fun('unknown'); // throws RuntimeException
|
||||
```
|
||||
|
||||
Some filters may accept or require additional filter parameters – most
|
||||
filters do not require filter parameters.
|
||||
If given, the optional `$parameters` argument will be passed to the
|
||||
underlying filter handler as-is.
|
||||
In particular, note how *not passing* this parameter at all differs from
|
||||
explicitly passing a `null` value (which many filters do not accept).
|
||||
Please refer to the individual filter definition for more details.
|
||||
For example, the `string.strip_tags` filter can be invoked like this:
|
||||
|
||||
```php
|
||||
$fun = Clue\StreamFilter\fun('string.strip_tags', '<a><b>');
|
||||
|
||||
$ret = $fun('<b>h<br>i</b>');
|
||||
assert('<b>hi</b>' === $ret);
|
||||
```
|
||||
|
||||
Under the hood, this function allocates a temporary memory stream, so it's
|
||||
recommended to clean up the filter function after use.
|
||||
Also, some filter functions (in particular the
|
||||
[zlib compression filters](https://www.php.net/manual/en/filters.compression.php))
|
||||
may use internal buffers and may emit a final data chunk on close.
|
||||
The filter function can be closed by invoking without any arguments:
|
||||
|
||||
```php
|
||||
$fun = Clue\StreamFilter\fun('zlib.deflate');
|
||||
|
||||
$ret = $fun('hello') . $fun('world') . $fun();
|
||||
assert('helloworld' === gzinflate($ret));
|
||||
```
|
||||
|
||||
The filter function must not be used anymore after it has been closed.
|
||||
Doing so will result in a `RuntimeException`:
|
||||
|
||||
```php
|
||||
$fun = Clue\StreamFilter\fun('string.rot13');
|
||||
$fun();
|
||||
|
||||
$fun('test'); // throws RuntimeException
|
||||
```
|
||||
|
||||
> Note: If you're using the zlib compression filters, then you should be wary
|
||||
about engine inconsistencies between different PHP versions and HHVM.
|
||||
These inconsistencies exist in the underlying PHP engines and there's little we
|
||||
can do about this in this library.
|
||||
[Our test suite](tests/) contains several test cases that exhibit these issues.
|
||||
If you feel some test case is missing or outdated, we're happy to accept PRs! :)
|
||||
|
||||
### remove()
|
||||
|
||||
The `remove(resource<stream filter> $filter): bool` function can be used to
|
||||
remove a filter previously added via [`append()`](#append) or [`prepend()`](#prepend).
|
||||
|
||||
```php
|
||||
$filter = Clue\StreamFilter\append($stream, function () {
|
||||
// …
|
||||
});
|
||||
Clue\StreamFilter\remove($filter);
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
The recommended way to install this library is [through Composer](https://getcomposer.org/).
|
||||
[New to Composer?](https://getcomposer.org/doc/00-intro.md)
|
||||
|
||||
This project follows [SemVer](https://semver.org/).
|
||||
This will install the latest supported version:
|
||||
|
||||
```bash
|
||||
$ composer require clue/stream-filter:^1.6
|
||||
```
|
||||
|
||||
See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
|
||||
|
||||
This project aims to run on any platform and thus does not require any PHP
|
||||
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
|
||||
HHVM.
|
||||
It's *highly recommended to use the latest supported PHP version* for this project.
|
||||
Older PHP versions may suffer from a number of inconsistencies documented above.
|
||||
|
||||
## Tests
|
||||
|
||||
To run the test suite, you first need to clone this repo and then install all
|
||||
dependencies [through Composer](https://getcomposer.org/):
|
||||
|
||||
```bash
|
||||
$ composer install
|
||||
```
|
||||
|
||||
To run the test suite, go to the project root and run:
|
||||
|
||||
```bash
|
||||
$ vendor/bin/phpunit
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
This project is released under the permissive [MIT license](LICENSE).
|
||||
|
||||
> Did you know that I offer custom development services and issuing invoices for
|
||||
sponsorships of releases and for contributions? Contact me (@clue) for details.
|
||||
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "clue/stream-filter",
|
||||
"description": "A simple and modern approach to stream filtering in PHP",
|
||||
"keywords": ["stream", "callback", "filter", "php_user_filter", "stream_filter_append", "stream_filter_register", "bucket brigade"],
|
||||
"homepage": "https://github.com/clue/php-stream-filter",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Christian Lück",
|
||||
"email": "christian@clue.engineering"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Clue\\StreamFilter\\": "src/" },
|
||||
"files": [ "src/functions_include.php" ]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "Clue\\Tests\\StreamFilter\\": "tests/" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Clue\StreamFilter;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @see append()
|
||||
* @see prepend()
|
||||
*/
|
||||
class CallbackFilter extends \php_user_filter
|
||||
{
|
||||
private $callback;
|
||||
private $closed = true;
|
||||
private $supportsClose = false;
|
||||
|
||||
/** @return bool */
|
||||
#[\ReturnTypeWillChange]
|
||||
public function onCreate()
|
||||
{
|
||||
$this->closed = false;
|
||||
|
||||
if (!\is_callable($this->params)) {
|
||||
throw new \InvalidArgumentException('No valid callback parameter given to stream_filter_(append|prepend)');
|
||||
}
|
||||
$this->callback = $this->params;
|
||||
|
||||
// callback supports end event if it accepts invocation without arguments
|
||||
$ref = new \ReflectionFunction($this->callback);
|
||||
$this->supportsClose = ($ref->getNumberOfRequiredParameters() === 0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** @return void */
|
||||
#[\ReturnTypeWillChange]
|
||||
public function onClose()
|
||||
{
|
||||
$this->closed = true;
|
||||
|
||||
// callback supports closing and is not already closed
|
||||
if ($this->supportsClose) {
|
||||
$this->supportsClose = false;
|
||||
// invoke without argument to signal end and discard resulting buffer
|
||||
try {
|
||||
\call_user_func($this->callback);
|
||||
} catch (\Exception $ignored) {
|
||||
// this might be called during engine shutdown, so it's not safe
|
||||
// to raise any errors or exceptions here
|
||||
// trigger_error('Error closing filter: ' . $ignored->getMessage(), E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
$this->callback = null;
|
||||
}
|
||||
|
||||
/** @return int */
|
||||
#[\ReturnTypeWillChange]
|
||||
public function filter($in, $out, &$consumed, $closing)
|
||||
{
|
||||
// concatenate whole buffer from input brigade
|
||||
$data = '';
|
||||
while ($bucket = \stream_bucket_make_writeable($in)) {
|
||||
$consumed += $bucket->datalen;
|
||||
$data .= $bucket->data;
|
||||
}
|
||||
|
||||
// skip processing callback that already ended
|
||||
if ($this->closed) {
|
||||
return \PSFS_FEED_ME;
|
||||
}
|
||||
|
||||
// only invoke filter function if buffer is not empty
|
||||
// this may skip flushing a closing filter
|
||||
if ($data !== '') {
|
||||
try {
|
||||
$data = \call_user_func($this->callback, $data);
|
||||
} catch (\Exception $e) {
|
||||
// exception should mark filter as closed
|
||||
$this->onClose();
|
||||
\trigger_error('Error invoking filter: ' . $e->getMessage(), \E_USER_WARNING);
|
||||
|
||||
return \PSFS_ERR_FATAL;
|
||||
}
|
||||
}
|
||||
|
||||
// mark filter as closed after processing closing chunk
|
||||
if ($closing) {
|
||||
$this->closed = true;
|
||||
|
||||
// callback supports closing and is not already closed
|
||||
if ($this->supportsClose) {
|
||||
$this->supportsClose = false;
|
||||
|
||||
// invoke without argument to signal end and append resulting buffer
|
||||
try {
|
||||
$data .= \call_user_func($this->callback);
|
||||
} catch (\Exception $e) {
|
||||
\trigger_error('Error ending filter: ' . $e->getMessage(), \E_USER_WARNING);
|
||||
|
||||
return \PSFS_ERR_FATAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($data !== '') {
|
||||
// create a new bucket for writing the resulting buffer to the output brigade
|
||||
// reusing an existing bucket turned out to be bugged in some environments (ancient PHP versions and HHVM)
|
||||
$bucket = @\stream_bucket_new($this->stream, $data);
|
||||
|
||||
// legacy PHP versions (PHP < 5.4) do not support passing data from the event signal handler
|
||||
// because closing the stream invalidates the stream and its stream bucket brigade before
|
||||
// invoking the filter close handler.
|
||||
if ($bucket !== false) {
|
||||
\stream_bucket_append($out, $bucket);
|
||||
}
|
||||
}
|
||||
|
||||
return \PSFS_PASS_ON;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
<?php
|
||||
|
||||
namespace Clue\StreamFilter;
|
||||
|
||||
/**
|
||||
* Append a filter callback to the given stream.
|
||||
*
|
||||
* Each stream can have a list of filters attached.
|
||||
* This function appends a filter to the end of this list.
|
||||
*
|
||||
* If the given filter can not be added, it throws an `Exception`.
|
||||
*
|
||||
* The `$stream` can be any valid stream resource, such as:
|
||||
*
|
||||
* ```php
|
||||
* $stream = fopen('demo.txt', 'w+');
|
||||
* ```
|
||||
*
|
||||
* The `$callback` should be a valid callable function which accepts
|
||||
* an individual chunk of data and should return the updated chunk:
|
||||
*
|
||||
* ```php
|
||||
* $filter = Clue\StreamFilter\append($stream, function ($chunk) {
|
||||
* // will be called each time you read or write a $chunk to/from the stream
|
||||
* return $chunk;
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* As such, you can also use native PHP functions or any other `callable`:
|
||||
*
|
||||
* ```php
|
||||
* Clue\StreamFilter\append($stream, 'strtoupper');
|
||||
*
|
||||
* // will write "HELLO" to the underlying stream
|
||||
* fwrite($stream, 'hello');
|
||||
* ```
|
||||
*
|
||||
* If the `$callback` accepts invocation without parameters,
|
||||
* then this signature will be invoked once ending (flushing) the filter:
|
||||
*
|
||||
* ```php
|
||||
* Clue\StreamFilter\append($stream, function ($chunk = null) {
|
||||
* if ($chunk === null) {
|
||||
* // will be called once ending the filter
|
||||
* return 'end';
|
||||
* }
|
||||
* // will be called each time you read or write a $chunk to/from the stream
|
||||
* return $chunk;
|
||||
* });
|
||||
*
|
||||
* fclose($stream);
|
||||
* ```
|
||||
*
|
||||
* > Note: Legacy PHP versions (PHP < 5.4) do not support passing additional data
|
||||
* from the end signal handler if the stream is being closed.
|
||||
*
|
||||
* If your callback throws an `Exception`, then the filter process will be aborted.
|
||||
* In order to play nice with PHP's stream handling,
|
||||
* the `Exception` will be transformed to a PHP warning instead:
|
||||
*
|
||||
* ```php
|
||||
* Clue\StreamFilter\append($stream, function ($chunk) {
|
||||
* throw new \RuntimeException('Unexpected chunk');
|
||||
* });
|
||||
*
|
||||
* // raises an E_USER_WARNING with "Error invoking filter: Unexpected chunk"
|
||||
* fwrite($stream, 'hello');
|
||||
* ```
|
||||
*
|
||||
* The optional `$read_write` parameter can be used to only invoke the `$callback`
|
||||
* when either writing to the stream or only when reading from the stream:
|
||||
*
|
||||
* ```php
|
||||
* Clue\StreamFilter\append($stream, function ($chunk) {
|
||||
* // will be called each time you write to the stream
|
||||
* return $chunk;
|
||||
* }, STREAM_FILTER_WRITE);
|
||||
*
|
||||
* Clue\StreamFilter\append($stream, function ($chunk) {
|
||||
* // will be called each time you read from the stream
|
||||
* return $chunk;
|
||||
* }, STREAM_FILTER_READ);
|
||||
* ```
|
||||
*
|
||||
* This function returns a filter resource which can be passed to [`remove()`](#remove).
|
||||
*
|
||||
* > Note that once a filter has been added to stream, the stream can no longer be passed to
|
||||
* > [`stream_select()`](https://www.php.net/manual/en/function.stream-select.php)
|
||||
* > (and family).
|
||||
* >
|
||||
* > > Warning: stream_select(): cannot cast a filtered stream on this system in {file} on line {line}
|
||||
* >
|
||||
* > This is due to limitations of PHP's stream filter support, as it can no longer reliably
|
||||
* > tell when the underlying stream resource is actually ready.
|
||||
* > As an alternative, consider calling `stream_select()` on the unfiltered stream and
|
||||
* > then pass the unfiltered data through the [`fun()`](#fun) function.
|
||||
*
|
||||
* @param resource $stream
|
||||
* @param callable $callback
|
||||
* @param int $read_write
|
||||
* @return resource filter resource which can be used for `remove()`
|
||||
* @throws \Exception on error
|
||||
* @uses stream_filter_append()
|
||||
*/
|
||||
function append($stream, $callback, $read_write = STREAM_FILTER_ALL)
|
||||
{
|
||||
$ret = @\stream_filter_append($stream, register(), $read_write, $callback);
|
||||
|
||||
// PHP 8 throws above on type errors, older PHP and memory issues can throw here
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($ret === false) {
|
||||
$error = \error_get_last() + array('message' => '');
|
||||
throw new \RuntimeException('Unable to append filter: ' . $error['message']);
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepend a filter callback to the given stream.
|
||||
*
|
||||
* Each stream can have a list of filters attached.
|
||||
* This function prepends a filter to the start of this list.
|
||||
*
|
||||
* If the given filter can not be added, it throws an `Exception`.
|
||||
*
|
||||
* ```php
|
||||
* $filter = Clue\StreamFilter\prepend($stream, function ($chunk) {
|
||||
* // will be called each time you read or write a $chunk to/from the stream
|
||||
* return $chunk;
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* This function returns a filter resource which can be passed to [`remove()`](#remove).
|
||||
*
|
||||
* Except for the position in the list of filters, this function behaves exactly
|
||||
* like the [`append()`](#append) function.
|
||||
* For more details about its behavior, see also the [`append()`](#append) function.
|
||||
*
|
||||
* @param resource $stream
|
||||
* @param callable $callback
|
||||
* @param int $read_write
|
||||
* @return resource filter resource which can be used for `remove()`
|
||||
* @throws \Exception on error
|
||||
* @uses stream_filter_prepend()
|
||||
*/
|
||||
function prepend($stream, $callback, $read_write = STREAM_FILTER_ALL)
|
||||
{
|
||||
$ret = @\stream_filter_prepend($stream, register(), $read_write, $callback);
|
||||
|
||||
// PHP 8 throws above on type errors, older PHP and memory issues can throw here
|
||||
// @codeCoverageIgnoreStart
|
||||
if ($ret === false) {
|
||||
$error = \error_get_last() + array('message' => '');
|
||||
throw new \RuntimeException('Unable to prepend filter: ' . $error['message']);
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a filter function which uses the given built-in `$filter`.
|
||||
*
|
||||
* PHP comes with a useful set of [built-in filters](https://www.php.net/manual/en/filters.php).
|
||||
* Using `fun()` makes accessing these as easy as passing an input string to filter
|
||||
* and getting the filtered output string.
|
||||
*
|
||||
* ```php
|
||||
* $fun = Clue\StreamFilter\fun('string.rot13');
|
||||
*
|
||||
* assert('grfg' === $fun('test'));
|
||||
* assert('test' === $fun($fun('test'));
|
||||
* ```
|
||||
*
|
||||
* Please note that not all filter functions may be available depending
|
||||
* on installed PHP extensions and the PHP version in use.
|
||||
* In particular, [HHVM](https://hhvm.com/) may not offer the same filter functions
|
||||
* or parameters as Zend PHP.
|
||||
* Accessing an unknown filter function will result in a `RuntimeException`:
|
||||
*
|
||||
* ```php
|
||||
* Clue\StreamFilter\fun('unknown'); // throws RuntimeException
|
||||
* ```
|
||||
*
|
||||
* Some filters may accept or require additional filter parameters – most
|
||||
* filters do not require filter parameters.
|
||||
* If given, the optional `$parameters` argument will be passed to the
|
||||
* underlying filter handler as-is.
|
||||
* In particular, note how *not passing* this parameter at all differs from
|
||||
* explicitly passing a `null` value (which many filters do not accept).
|
||||
* Please refer to the individual filter definition for more details.
|
||||
* For example, the `string.strip_tags` filter can be invoked like this:
|
||||
*
|
||||
* ```php
|
||||
* $fun = Clue\StreamFilter\fun('string.strip_tags', '<a><b>');
|
||||
*
|
||||
* $ret = $fun('<b>h<br>i</b>');
|
||||
* assert('<b>hi</b>' === $ret);
|
||||
* ```
|
||||
*
|
||||
* Under the hood, this function allocates a temporary memory stream, so it's
|
||||
* recommended to clean up the filter function after use.
|
||||
* Also, some filter functions (in particular the
|
||||
* [zlib compression filters](https://www.php.net/manual/en/filters.compression.php))
|
||||
* may use internal buffers and may emit a final data chunk on close.
|
||||
* The filter function can be closed by invoking without any arguments:
|
||||
*
|
||||
* ```php
|
||||
* $fun = Clue\StreamFilter\fun('zlib.deflate');
|
||||
*
|
||||
* $ret = $fun('hello') . $fun('world') . $fun();
|
||||
* assert('helloworld' === gzinflate($ret));
|
||||
* ```
|
||||
*
|
||||
* The filter function must not be used anymore after it has been closed.
|
||||
* Doing so will result in a `RuntimeException`:
|
||||
*
|
||||
* ```php
|
||||
* $fun = Clue\StreamFilter\fun('string.rot13');
|
||||
* $fun();
|
||||
*
|
||||
* $fun('test'); // throws RuntimeException
|
||||
* ```
|
||||
*
|
||||
* > Note: If you're using the zlib compression filters, then you should be wary
|
||||
* about engine inconsistencies between different PHP versions and HHVM.
|
||||
* These inconsistencies exist in the underlying PHP engines and there's little we
|
||||
* can do about this in this library.
|
||||
* [Our test suite](tests/) contains several test cases that exhibit these issues.
|
||||
* If you feel some test case is missing or outdated, we're happy to accept PRs! :)
|
||||
*
|
||||
* @param string $filter built-in filter name. See stream_get_filters() or http://php.net/manual/en/filters.php
|
||||
* @param mixed $parameters (optional) parameters to pass to the built-in filter as-is
|
||||
* @return callable a filter callback which can be append()'ed or prepend()'ed
|
||||
* @throws \RuntimeException on error
|
||||
* @link http://php.net/manual/en/filters.php
|
||||
* @see stream_get_filters()
|
||||
* @see append()
|
||||
*/
|
||||
function fun($filter, $parameters = null)
|
||||
{
|
||||
$fp = \fopen('php://memory', 'w');
|
||||
if (\func_num_args() === 1) {
|
||||
$filter = @\stream_filter_append($fp, $filter, \STREAM_FILTER_WRITE);
|
||||
} else {
|
||||
$filter = @\stream_filter_append($fp, $filter, \STREAM_FILTER_WRITE, $parameters);
|
||||
}
|
||||
|
||||
if ($filter === false) {
|
||||
\fclose($fp);
|
||||
$error = \error_get_last() + array('message' => '');
|
||||
throw new \RuntimeException('Unable to access built-in filter: ' . $error['message']);
|
||||
}
|
||||
|
||||
// append filter function which buffers internally
|
||||
$buffer = '';
|
||||
append($fp, function ($chunk) use (&$buffer) {
|
||||
$buffer .= $chunk;
|
||||
|
||||
// always return empty string in order to skip actually writing to stream resource
|
||||
return '';
|
||||
}, \STREAM_FILTER_WRITE);
|
||||
|
||||
$closed = false;
|
||||
|
||||
return function ($chunk = null) use ($fp, $filter, &$buffer, &$closed) {
|
||||
if ($closed) {
|
||||
throw new \RuntimeException('Unable to perform operation on closed stream');
|
||||
}
|
||||
if ($chunk === null) {
|
||||
$closed = true;
|
||||
$buffer = '';
|
||||
\fclose($fp);
|
||||
return $buffer;
|
||||
}
|
||||
// initialize buffer and invoke filters by attempting to write to stream
|
||||
$buffer = '';
|
||||
\fwrite($fp, $chunk);
|
||||
|
||||
// buffer now contains everything the filter function returned
|
||||
return $buffer;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a filter previously added via `append()` or `prepend()`.
|
||||
*
|
||||
* ```php
|
||||
* $filter = Clue\StreamFilter\append($stream, function () {
|
||||
* // …
|
||||
* });
|
||||
* Clue\StreamFilter\remove($filter);
|
||||
* ```
|
||||
*
|
||||
* @param resource $filter
|
||||
* @return bool true on success or false on error
|
||||
* @throws \RuntimeException on error
|
||||
* @uses stream_filter_remove()
|
||||
*/
|
||||
function remove($filter)
|
||||
{
|
||||
if (@\stream_filter_remove($filter) === false) {
|
||||
// PHP 8 throws above on type errors, older PHP and memory issues can throw here
|
||||
$error = \error_get_last();
|
||||
throw new \RuntimeException('Unable to remove filter: ' . $error['message']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the callback filter and returns the resulting filter name
|
||||
*
|
||||
* There should be little reason to call this function manually.
|
||||
*
|
||||
* @return string filter name
|
||||
* @uses CallbackFilter
|
||||
*/
|
||||
function register()
|
||||
{
|
||||
static $registered = null;
|
||||
if ($registered === null) {
|
||||
$registered = 'stream-callback';
|
||||
\stream_filter_register($registered, __NAMESPACE__ . '\CallbackFilter');
|
||||
}
|
||||
return $registered;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
if (!\function_exists('Clue\\StreamFilter\\append')) {
|
||||
require __DIR__ . '/functions.php';
|
||||
}
|
||||
@@ -0,0 +1,572 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
/**
|
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
|
||||
*
|
||||
* $loader = new \Composer\Autoload\ClassLoader();
|
||||
*
|
||||
* // register classes with namespaces
|
||||
* $loader->add('Symfony\Component', __DIR__.'/component');
|
||||
* $loader->add('Symfony', __DIR__.'/framework');
|
||||
*
|
||||
* // activate the autoloader
|
||||
* $loader->register();
|
||||
*
|
||||
* // to enable searching the include path (eg. for PEAR packages)
|
||||
* $loader->setUseIncludePath(true);
|
||||
*
|
||||
* In this example, if you try to use a class in the Symfony\Component
|
||||
* namespace or one of its children (Symfony\Component\Console for instance),
|
||||
* the autoloader will first look for the class under the component/
|
||||
* directory, and it will then fallback to the framework/ directory if not
|
||||
* found before giving up.
|
||||
*
|
||||
* This class is loosely based on the Symfony UniversalClassLoader.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @see https://www.php-fig.org/psr/psr-0/
|
||||
* @see https://www.php-fig.org/psr/psr-4/
|
||||
*/
|
||||
class ClassLoader
|
||||
{
|
||||
/** @var ?string */
|
||||
private $vendorDir;
|
||||
|
||||
// PSR-4
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, int>>
|
||||
*/
|
||||
private $prefixLengthsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<int, string>>
|
||||
*/
|
||||
private $prefixDirsPsr4 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr4 = array();
|
||||
|
||||
// PSR-0
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array<string, string[]>>
|
||||
*/
|
||||
private $prefixesPsr0 = array();
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $fallbackDirsPsr0 = array();
|
||||
|
||||
/** @var bool */
|
||||
private $useIncludePath = false;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
* @psalm-var array<string, string>
|
||||
*/
|
||||
private $classMap = array();
|
||||
|
||||
/** @var bool */
|
||||
private $classMapAuthoritative = false;
|
||||
|
||||
/**
|
||||
* @var bool[]
|
||||
* @psalm-var array<string, bool>
|
||||
*/
|
||||
private $missingClasses = array();
|
||||
|
||||
/** @var ?string */
|
||||
private $apcuPrefix;
|
||||
|
||||
/**
|
||||
* @var self[]
|
||||
*/
|
||||
private static $registeredLoaders = array();
|
||||
|
||||
/**
|
||||
* @param ?string $vendorDir
|
||||
*/
|
||||
public function __construct($vendorDir = null)
|
||||
{
|
||||
$this->vendorDir = $vendorDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPrefixes()
|
||||
{
|
||||
if (!empty($this->prefixesPsr0)) {
|
||||
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, array<int, string>>
|
||||
*/
|
||||
public function getPrefixesPsr4()
|
||||
{
|
||||
return $this->prefixDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirs()
|
||||
{
|
||||
return $this->fallbackDirsPsr0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getFallbackDirsPsr4()
|
||||
{
|
||||
return $this->fallbackDirsPsr4;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[] Array of classname => path
|
||||
* @psalm-return array<string, string>
|
||||
*/
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $classMap Class to filename map
|
||||
* @psalm-param array<string, string> $classMap
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addClassMap(array $classMap)
|
||||
{
|
||||
if ($this->classMap) {
|
||||
$this->classMap = array_merge($this->classMap, $classMap);
|
||||
} else {
|
||||
$this->classMap = $classMap;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix, either
|
||||
* appending or prepending to the ones previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 root directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function add($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr0
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr0 = array_merge(
|
||||
$this->fallbackDirsPsr0,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$first = $prefix[0];
|
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) {
|
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
|
||||
|
||||
return;
|
||||
}
|
||||
if ($prepend) {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixesPsr0[$first][$prefix]
|
||||
);
|
||||
} else {
|
||||
$this->prefixesPsr0[$first][$prefix] = array_merge(
|
||||
$this->prefixesPsr0[$first][$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace, either
|
||||
* appending or prepending to the ones previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
* @param bool $prepend Whether to prepend the directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addPsr4($prefix, $paths, $prepend = false)
|
||||
{
|
||||
if (!$prefix) {
|
||||
// Register directories for the root namespace.
|
||||
if ($prepend) {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
(array) $paths,
|
||||
$this->fallbackDirsPsr4
|
||||
);
|
||||
} else {
|
||||
$this->fallbackDirsPsr4 = array_merge(
|
||||
$this->fallbackDirsPsr4,
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
|
||||
// Register directories for a new namespace.
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
} elseif ($prepend) {
|
||||
// Prepend directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
(array) $paths,
|
||||
$this->prefixDirsPsr4[$prefix]
|
||||
);
|
||||
} else {
|
||||
// Append directories for an already registered namespace.
|
||||
$this->prefixDirsPsr4[$prefix] = array_merge(
|
||||
$this->prefixDirsPsr4[$prefix],
|
||||
(array) $paths
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-0 directories for a given prefix,
|
||||
* replacing any others previously set for this prefix.
|
||||
*
|
||||
* @param string $prefix The prefix
|
||||
* @param string[]|string $paths The PSR-0 base directories
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function set($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr0 = (array) $paths;
|
||||
} else {
|
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a set of PSR-4 directories for a given namespace,
|
||||
* replacing any others previously set for this namespace.
|
||||
*
|
||||
* @param string $prefix The prefix/namespace, with trailing '\\'
|
||||
* @param string[]|string $paths The PSR-4 base directories
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPsr4($prefix, $paths)
|
||||
{
|
||||
if (!$prefix) {
|
||||
$this->fallbackDirsPsr4 = (array) $paths;
|
||||
} else {
|
||||
$length = strlen($prefix);
|
||||
if ('\\' !== $prefix[$length - 1]) {
|
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
|
||||
}
|
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
|
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns on searching the include path for class files.
|
||||
*
|
||||
* @param bool $useIncludePath
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setUseIncludePath($useIncludePath)
|
||||
{
|
||||
$this->useIncludePath = $useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can be used to check if the autoloader uses the include path to check
|
||||
* for classes.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getUseIncludePath()
|
||||
{
|
||||
return $this->useIncludePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns off searching the prefix and fallback directories for classes
|
||||
* that have not been registered with the class map.
|
||||
*
|
||||
* @param bool $classMapAuthoritative
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setClassMapAuthoritative($classMapAuthoritative)
|
||||
{
|
||||
$this->classMapAuthoritative = $classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should class lookup fail if not found in the current class map?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isClassMapAuthoritative()
|
||||
{
|
||||
return $this->classMapAuthoritative;
|
||||
}
|
||||
|
||||
/**
|
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
|
||||
*
|
||||
* @param string|null $apcuPrefix
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setApcuPrefix($apcuPrefix)
|
||||
{
|
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The APCu prefix in use, or null if APCu caching is not enabled.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getApcuPrefix()
|
||||
{
|
||||
return $this->apcuPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers this instance as an autoloader.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register($prepend = false)
|
||||
{
|
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
|
||||
|
||||
if (null === $this->vendorDir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($prepend) {
|
||||
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
|
||||
} else {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
self::$registeredLoaders[$this->vendorDir] = $this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters this instance as an autoloader.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function unregister()
|
||||
{
|
||||
spl_autoload_unregister(array($this, 'loadClass'));
|
||||
|
||||
if (null !== $this->vendorDir) {
|
||||
unset(self::$registeredLoaders[$this->vendorDir]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the given class or interface.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
* @return true|null True if loaded, null otherwise
|
||||
*/
|
||||
public function loadClass($class)
|
||||
{
|
||||
if ($file = $this->findFile($class)) {
|
||||
includeFile($file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the path to the file where the class is defined.
|
||||
*
|
||||
* @param string $class The name of the class
|
||||
*
|
||||
* @return string|false The path if found, false otherwise
|
||||
*/
|
||||
public function findFile($class)
|
||||
{
|
||||
// class map lookup
|
||||
if (isset($this->classMap[$class])) {
|
||||
return $this->classMap[$class];
|
||||
}
|
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
|
||||
return false;
|
||||
}
|
||||
if (null !== $this->apcuPrefix) {
|
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
|
||||
if ($hit) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
$file = $this->findFileWithExtension($class, '.php');
|
||||
|
||||
// Search for Hack files if we are running on HHVM
|
||||
if (false === $file && defined('HHVM_VERSION')) {
|
||||
$file = $this->findFileWithExtension($class, '.hh');
|
||||
}
|
||||
|
||||
if (null !== $this->apcuPrefix) {
|
||||
apcu_add($this->apcuPrefix.$class, $file);
|
||||
}
|
||||
|
||||
if (false === $file) {
|
||||
// Remember that this class does not exist.
|
||||
$this->missingClasses[$class] = true;
|
||||
}
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently registered loaders indexed by their corresponding vendor directories.
|
||||
*
|
||||
* @return self[]
|
||||
*/
|
||||
public static function getRegisteredLoaders()
|
||||
{
|
||||
return self::$registeredLoaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $ext
|
||||
* @return string|false
|
||||
*/
|
||||
private function findFileWithExtension($class, $ext)
|
||||
{
|
||||
// PSR-4 lookup
|
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
|
||||
|
||||
$first = $class[0];
|
||||
if (isset($this->prefixLengthsPsr4[$first])) {
|
||||
$subPath = $class;
|
||||
while (false !== $lastPos = strrpos($subPath, '\\')) {
|
||||
$subPath = substr($subPath, 0, $lastPos);
|
||||
$search = $subPath . '\\';
|
||||
if (isset($this->prefixDirsPsr4[$search])) {
|
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
|
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) {
|
||||
if (file_exists($file = $dir . $pathEnd)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-4 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr4 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 lookup
|
||||
if (false !== $pos = strrpos($class, '\\')) {
|
||||
// namespaced class name
|
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
|
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
|
||||
} else {
|
||||
// PEAR-like class name
|
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
|
||||
}
|
||||
|
||||
if (isset($this->prefixesPsr0[$first])) {
|
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
|
||||
if (0 === strpos($class, $prefix)) {
|
||||
foreach ($dirs as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 fallback dirs
|
||||
foreach ($this->fallbackDirsPsr0 as $dir) {
|
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
|
||||
// PSR-0 include paths.
|
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
|
||||
return $file;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope isolated include.
|
||||
*
|
||||
* Prevents access to $this/self from included files.
|
||||
*
|
||||
* @param string $file
|
||||
* @return void
|
||||
* @private
|
||||
*/
|
||||
function includeFile($file)
|
||||
{
|
||||
include $file;
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer;
|
||||
|
||||
use Composer\Autoload\ClassLoader;
|
||||
use Composer\Semver\VersionParser;
|
||||
|
||||
/**
|
||||
* This class is copied in every Composer installed project and available to all
|
||||
*
|
||||
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
||||
*
|
||||
* To require its presence, you can require `composer-runtime-api ^2.0`
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class InstalledVersions
|
||||
{
|
||||
/**
|
||||
* @var mixed[]|null
|
||||
* @psalm-var array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}|array{}|null
|
||||
*/
|
||||
private static $installed;
|
||||
|
||||
/**
|
||||
* @var bool|null
|
||||
*/
|
||||
private static $canGetVendors;
|
||||
|
||||
/**
|
||||
* @var array[]
|
||||
* @psalm-var array<string, array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static $installedByVendor = array();
|
||||
|
||||
/**
|
||||
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
||||
*
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackages()
|
||||
{
|
||||
$packages = array();
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
$packages[] = array_keys($installed['versions']);
|
||||
}
|
||||
|
||||
if (1 === \count($packages)) {
|
||||
return $packages[0];
|
||||
}
|
||||
|
||||
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all package names with a specific type e.g. 'library'
|
||||
*
|
||||
* @param string $type
|
||||
* @return string[]
|
||||
* @psalm-return list<string>
|
||||
*/
|
||||
public static function getInstalledPackagesByType($type)
|
||||
{
|
||||
$packagesByType = array();
|
||||
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
foreach ($installed['versions'] as $name => $package) {
|
||||
if (isset($package['type']) && $package['type'] === $type) {
|
||||
$packagesByType[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $packagesByType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package is installed
|
||||
*
|
||||
* This also returns true if the package name is provided or replaced by another package
|
||||
*
|
||||
* @param string $packageName
|
||||
* @param bool $includeDevRequirements
|
||||
* @return bool
|
||||
*/
|
||||
public static function isInstalled($packageName, $includeDevRequirements = true)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (isset($installed['versions'][$packageName])) {
|
||||
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the given package satisfies a version constraint
|
||||
*
|
||||
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
||||
*
|
||||
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
||||
*
|
||||
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
||||
* @param string $packageName
|
||||
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
||||
* @return bool
|
||||
*/
|
||||
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
||||
{
|
||||
$constraint = $parser->parseConstraints($constraint);
|
||||
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
||||
|
||||
return $provided->matches($constraint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a version constraint representing all the range(s) which are installed for a given package
|
||||
*
|
||||
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
||||
* whether a given version of a package is installed, and not just whether it exists
|
||||
*
|
||||
* @param string $packageName
|
||||
* @return string Version constraint usable with composer/semver
|
||||
*/
|
||||
public static function getVersionRanges($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$ranges = array();
|
||||
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
||||
}
|
||||
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
||||
}
|
||||
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
||||
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
||||
}
|
||||
|
||||
return implode(' || ', $ranges);
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
||||
*/
|
||||
public static function getPrettyVersion($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['pretty_version'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
||||
*/
|
||||
public static function getReference($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isset($installed['versions'][$packageName]['reference'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $installed['versions'][$packageName]['reference'];
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $packageName
|
||||
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
||||
*/
|
||||
public static function getInstallPath($packageName)
|
||||
{
|
||||
foreach (self::getInstalled() as $installed) {
|
||||
if (!isset($installed['versions'][$packageName])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
||||
}
|
||||
|
||||
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}
|
||||
*/
|
||||
public static function getRootPackage()
|
||||
{
|
||||
$installed = self::getInstalled();
|
||||
|
||||
return $installed[0]['root'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw installed.php data for custom implementations
|
||||
*
|
||||
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
||||
* @return array[]
|
||||
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}
|
||||
*/
|
||||
public static function getRawData()
|
||||
{
|
||||
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = include __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
|
||||
return self::$installed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
||||
*
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
public static function getAllRawData()
|
||||
{
|
||||
return self::getInstalled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Lets you reload the static array from another file
|
||||
*
|
||||
* This is only useful for complex integrations in which a project needs to use
|
||||
* this class but then also needs to execute another project's autoloader in process,
|
||||
* and wants to ensure both projects have access to their version of installed.php.
|
||||
*
|
||||
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
||||
* the data it needs from this class, then call reload() with
|
||||
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
||||
* the project in which it runs can then also use this class safely, without
|
||||
* interference between PHPUnit's dependencies and the project's dependencies.
|
||||
*
|
||||
* @param array[] $data A vendor/composer/installed.php data set
|
||||
* @return void
|
||||
*
|
||||
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>} $data
|
||||
*/
|
||||
public static function reload($data)
|
||||
{
|
||||
self::$installed = $data;
|
||||
self::$installedByVendor = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array[]
|
||||
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string, type: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string, type?: string}>}>
|
||||
*/
|
||||
private static function getInstalled()
|
||||
{
|
||||
if (null === self::$canGetVendors) {
|
||||
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
||||
}
|
||||
|
||||
$installed = array();
|
||||
|
||||
if (self::$canGetVendors) {
|
||||
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
||||
if (isset(self::$installedByVendor[$vendorDir])) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir];
|
||||
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
||||
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
||||
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
||||
self::$installed = $installed[count($installed) - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (null === self::$installed) {
|
||||
// only require the installed.php file if this file is loaded from its dumped location,
|
||||
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
|
||||
if (substr(__DIR__, -8, 1) !== 'C') {
|
||||
self::$installed = require __DIR__ . '/installed.php';
|
||||
} else {
|
||||
self::$installed = array();
|
||||
}
|
||||
}
|
||||
$installed[] = self::$installed;
|
||||
|
||||
return $installed;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// autoload_classmap.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
|
||||
'Omnipay\\Omnipay' => $vendorDir . '/omnipay/common/src/Omnipay.php',
|
||||
);
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
// autoload_files.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
|
||||
'9c67151ae59aff4788964ce8eb2a0f43' => $vendorDir . '/clue/stream-filter/src/functions_include.php',
|
||||
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'8cff32064859f4559445b89279f3199c' => $vendorDir . '/php-http/message/src/filters.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
// autoload_namespaces.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
);
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
// autoload_psr4.php @generated by Composer
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
|
||||
'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'),
|
||||
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
|
||||
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src', $vendorDir . '/psr/http-factory/src'),
|
||||
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
|
||||
'Omnipay\\PayPal\\' => array($vendorDir . '/omnipay/paypal/src'),
|
||||
'Omnipay\\Common\\' => array($vendorDir . '/omnipay/common/src/Common'),
|
||||
'Money\\' => array($vendorDir . '/moneyphp/money/src'),
|
||||
'Http\\Promise\\' => array($vendorDir . '/php-http/promise/src'),
|
||||
'Http\\Message\\' => array($vendorDir . '/php-http/message-factory/src', $vendorDir . '/php-http/message/src'),
|
||||
'Http\\Discovery\\' => array($vendorDir . '/php-http/discovery/src'),
|
||||
'Http\\Client\\' => array($vendorDir . '/php-http/httplug/src'),
|
||||
'Http\\Adapter\\Guzzle7\\' => array($vendorDir . '/php-http/guzzle7-adapter/src'),
|
||||
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
|
||||
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
|
||||
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
|
||||
'Clue\\StreamFilter\\' => array($vendorDir . '/clue/stream-filter/src'),
|
||||
);
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit706f694c5dcef0ef156635e1a4cbe0df
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
public static function loadClassLoader($class)
|
||||
{
|
||||
if ('Composer\Autoload\ClassLoader' === $class) {
|
||||
require __DIR__ . '/ClassLoader.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Composer\Autoload\ClassLoader
|
||||
*/
|
||||
public static function getLoader()
|
||||
{
|
||||
if (null !== self::$loader) {
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
require __DIR__ . '/platform_check.php';
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit706f694c5dcef0ef156635e1a4cbe0df', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit706f694c5dcef0ef156635e1a4cbe0df', 'loadClassLoader'));
|
||||
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit706f694c5dcef0ef156635e1a4cbe0df::getInitializer($loader));
|
||||
|
||||
$loader->register(true);
|
||||
|
||||
$includeFiles = \Composer\Autoload\ComposerStaticInit706f694c5dcef0ef156635e1a4cbe0df::$files;
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire706f694c5dcef0ef156635e1a4cbe0df($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fileIdentifier
|
||||
* @param string $file
|
||||
* @return void
|
||||
*/
|
||||
function composerRequire706f694c5dcef0ef156635e1a4cbe0df($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
|
||||
|
||||
require $file;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
// autoload_static.php @generated by Composer
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit706f694c5dcef0ef156635e1a4cbe0df
|
||||
{
|
||||
public static $files = array (
|
||||
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
|
||||
'9c67151ae59aff4788964ce8eb2a0f43' => __DIR__ . '/..' . '/clue/stream-filter/src/functions_include.php',
|
||||
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
||||
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
|
||||
'8cff32064859f4559445b89279f3199c' => __DIR__ . '/..' . '/php-http/message/src/filters.php',
|
||||
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
|
||||
);
|
||||
|
||||
public static $prefixLengthsPsr4 = array (
|
||||
'S' =>
|
||||
array (
|
||||
'Symfony\\Polyfill\\Mbstring\\' => 26,
|
||||
'Symfony\\Component\\HttpFoundation\\' => 33,
|
||||
'Symfony\\Component\\EventDispatcher\\' => 34,
|
||||
),
|
||||
'P' =>
|
||||
array (
|
||||
'Psr\\Http\\Message\\' => 17,
|
||||
'Psr\\Http\\Client\\' => 16,
|
||||
),
|
||||
'O' =>
|
||||
array (
|
||||
'Omnipay\\PayPal\\' => 15,
|
||||
'Omnipay\\Common\\' => 15,
|
||||
),
|
||||
'M' =>
|
||||
array (
|
||||
'Money\\' => 6,
|
||||
),
|
||||
'H' =>
|
||||
array (
|
||||
'Http\\Promise\\' => 13,
|
||||
'Http\\Message\\' => 13,
|
||||
'Http\\Discovery\\' => 15,
|
||||
'Http\\Client\\' => 12,
|
||||
'Http\\Adapter\\Guzzle7\\' => 21,
|
||||
),
|
||||
'G' =>
|
||||
array (
|
||||
'GuzzleHttp\\Psr7\\' => 16,
|
||||
'GuzzleHttp\\Promise\\' => 19,
|
||||
'GuzzleHttp\\' => 11,
|
||||
),
|
||||
'C' =>
|
||||
array (
|
||||
'Clue\\StreamFilter\\' => 18,
|
||||
),
|
||||
);
|
||||
|
||||
public static $prefixDirsPsr4 = array (
|
||||
'Symfony\\Polyfill\\Mbstring\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
|
||||
),
|
||||
'Symfony\\Component\\HttpFoundation\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/http-foundation',
|
||||
),
|
||||
'Symfony\\Component\\EventDispatcher\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/symfony/event-dispatcher',
|
||||
),
|
||||
'Psr\\Http\\Message\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/http-message/src',
|
||||
1 => __DIR__ . '/..' . '/psr/http-factory/src',
|
||||
),
|
||||
'Psr\\Http\\Client\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/psr/http-client/src',
|
||||
),
|
||||
'Omnipay\\PayPal\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/omnipay/paypal/src',
|
||||
),
|
||||
'Omnipay\\Common\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/omnipay/common/src/Common',
|
||||
),
|
||||
'Money\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/moneyphp/money/src',
|
||||
),
|
||||
'Http\\Promise\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/php-http/promise/src',
|
||||
),
|
||||
'Http\\Message\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/php-http/message-factory/src',
|
||||
1 => __DIR__ . '/..' . '/php-http/message/src',
|
||||
),
|
||||
'Http\\Discovery\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/php-http/discovery/src',
|
||||
),
|
||||
'Http\\Client\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/php-http/httplug/src',
|
||||
),
|
||||
'Http\\Adapter\\Guzzle7\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/php-http/guzzle7-adapter/src',
|
||||
),
|
||||
'GuzzleHttp\\Psr7\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
|
||||
),
|
||||
'GuzzleHttp\\Promise\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
|
||||
),
|
||||
'GuzzleHttp\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
|
||||
),
|
||||
'Clue\\StreamFilter\\' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/clue/stream-filter/src',
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
||||
'Omnipay\\Omnipay' => __DIR__ . '/..' . '/omnipay/common/src/Omnipay.php',
|
||||
);
|
||||
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit706f694c5dcef0ef156635e1a4cbe0df::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit706f694c5dcef0ef156635e1a4cbe0df::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit706f694c5dcef0ef156635e1a4cbe0df::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
}
|
||||
+1568
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,253 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'pretty_version' => 'dev-8d31babfa19c0b27ae35d46a24014dbeb8e4f77d',
|
||||
'version' => 'dev-8d31babfa19c0b27ae35d46a24014dbeb8e4f77d',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '8d31babfa19c0b27ae35d46a24014dbeb8e4f77d',
|
||||
'name' => '__root__',
|
||||
'dev' => false,
|
||||
),
|
||||
'versions' => array(
|
||||
'__root__' => array(
|
||||
'pretty_version' => 'dev-8d31babfa19c0b27ae35d46a24014dbeb8e4f77d',
|
||||
'version' => 'dev-8d31babfa19c0b27ae35d46a24014dbeb8e4f77d',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '8d31babfa19c0b27ae35d46a24014dbeb8e4f77d',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'clue/stream-filter' => array(
|
||||
'pretty_version' => 'v1.6.0',
|
||||
'version' => '1.6.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../clue/stream-filter',
|
||||
'aliases' => array(),
|
||||
'reference' => 'd6169430c7731d8509da7aecd0af756a5747b78e',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'guzzlehttp/guzzle' => array(
|
||||
'pretty_version' => '7.8.1',
|
||||
'version' => '7.8.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../guzzlehttp/guzzle',
|
||||
'aliases' => array(),
|
||||
'reference' => '41042bc7ab002487b876a0683fc8dce04ddce104',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'guzzlehttp/promises' => array(
|
||||
'pretty_version' => '2.0.2',
|
||||
'version' => '2.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../guzzlehttp/promises',
|
||||
'aliases' => array(),
|
||||
'reference' => 'bbff78d96034045e58e13dedd6ad91b5d1253223',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'guzzlehttp/psr7' => array(
|
||||
'pretty_version' => '2.6.2',
|
||||
'version' => '2.6.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../guzzlehttp/psr7',
|
||||
'aliases' => array(),
|
||||
'reference' => '45b30f99ac27b5ca93cb4831afe16285f57b8221',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'moneyphp/money' => array(
|
||||
'pretty_version' => 'v3.3.3',
|
||||
'version' => '3.3.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../moneyphp/money',
|
||||
'aliases' => array(),
|
||||
'reference' => '0dc40e3791c67e8793e3aa13fead8cf4661ec9cd',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'omnipay/common' => array(
|
||||
'pretty_version' => 'v3.2.1',
|
||||
'version' => '3.2.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../omnipay/common',
|
||||
'aliases' => array(),
|
||||
'reference' => '80545e9f4faab0efad36cc5f1e11a184dda22baf',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'omnipay/paypal' => array(
|
||||
'pretty_version' => 'v3.0.2',
|
||||
'version' => '3.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../omnipay/paypal',
|
||||
'aliases' => array(),
|
||||
'reference' => '519db61b32ff0c1e56cbec94762b970ee9674f65',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'php-http/async-client-implementation' => array(
|
||||
'dev_requirement' => false,
|
||||
'provided' => array(
|
||||
0 => '*',
|
||||
1 => '1.0',
|
||||
),
|
||||
),
|
||||
'php-http/client-implementation' => array(
|
||||
'dev_requirement' => false,
|
||||
'provided' => array(
|
||||
0 => '*',
|
||||
1 => '1.0',
|
||||
),
|
||||
),
|
||||
'php-http/discovery' => array(
|
||||
'pretty_version' => '1.19.2',
|
||||
'version' => '1.19.2.0',
|
||||
'type' => 'composer-plugin',
|
||||
'install_path' => __DIR__ . '/../php-http/discovery',
|
||||
'aliases' => array(),
|
||||
'reference' => '61e1a1eb69c92741f5896d9e05fb8e9d7e8bb0cb',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'php-http/guzzle7-adapter' => array(
|
||||
'pretty_version' => '1.0.0',
|
||||
'version' => '1.0.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../php-http/guzzle7-adapter',
|
||||
'aliases' => array(),
|
||||
'reference' => 'fb075a71dbfa4847cf0c2938c4e5a9c478ef8b01',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'php-http/httplug' => array(
|
||||
'pretty_version' => '2.4.0',
|
||||
'version' => '2.4.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../php-http/httplug',
|
||||
'aliases' => array(),
|
||||
'reference' => '625ad742c360c8ac580fcc647a1541d29e257f67',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'php-http/message' => array(
|
||||
'pretty_version' => '1.16.0',
|
||||
'version' => '1.16.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../php-http/message',
|
||||
'aliases' => array(),
|
||||
'reference' => '47a14338bf4ebd67d317bf1144253d7db4ab55fd',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'php-http/message-factory' => array(
|
||||
'pretty_version' => '1.1.0',
|
||||
'version' => '1.1.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../php-http/message-factory',
|
||||
'aliases' => array(),
|
||||
'reference' => '4d8778e1c7d405cbb471574821c1ff5b68cc8f57',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'php-http/message-factory-implementation' => array(
|
||||
'dev_requirement' => false,
|
||||
'provided' => array(
|
||||
0 => '1.0',
|
||||
),
|
||||
),
|
||||
'php-http/promise' => array(
|
||||
'pretty_version' => '1.2.1',
|
||||
'version' => '1.2.1.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../php-http/promise',
|
||||
'aliases' => array(),
|
||||
'reference' => '44a67cb59f708f826f3bec35f22030b3edb90119',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'psr/http-client' => array(
|
||||
'pretty_version' => '1.0.3',
|
||||
'version' => '1.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../psr/http-client',
|
||||
'aliases' => array(),
|
||||
'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'psr/http-client-implementation' => array(
|
||||
'dev_requirement' => false,
|
||||
'provided' => array(
|
||||
0 => '*',
|
||||
1 => '1.0',
|
||||
),
|
||||
),
|
||||
'psr/http-factory' => array(
|
||||
'pretty_version' => '1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../psr/http-factory',
|
||||
'aliases' => array(),
|
||||
'reference' => 'e616d01114759c4c489f93b099585439f795fe35',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'psr/http-factory-implementation' => array(
|
||||
'dev_requirement' => false,
|
||||
'provided' => array(
|
||||
0 => '*',
|
||||
1 => '1.0',
|
||||
),
|
||||
),
|
||||
'psr/http-message' => array(
|
||||
'pretty_version' => '2.0',
|
||||
'version' => '2.0.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../psr/http-message',
|
||||
'aliases' => array(),
|
||||
'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'psr/http-message-implementation' => array(
|
||||
'dev_requirement' => false,
|
||||
'provided' => array(
|
||||
0 => '*',
|
||||
1 => '1.0',
|
||||
),
|
||||
),
|
||||
'ralouphie/getallheaders' => array(
|
||||
'pretty_version' => '3.0.3',
|
||||
'version' => '3.0.3.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../ralouphie/getallheaders',
|
||||
'aliases' => array(),
|
||||
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/deprecation-contracts' => array(
|
||||
'pretty_version' => 'v3.0.2',
|
||||
'version' => '3.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
|
||||
'aliases' => array(),
|
||||
'reference' => '26954b3d62a6c5fd0ea8a2a00c0353a14978d05c',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/event-dispatcher' => array(
|
||||
'pretty_version' => 'v2.8.52',
|
||||
'version' => '2.8.52.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/event-dispatcher',
|
||||
'aliases' => array(),
|
||||
'reference' => 'a77e974a5fecb4398833b0709210e3d5e334ffb0',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/http-foundation' => array(
|
||||
'pretty_version' => 'v6.0.20',
|
||||
'version' => '6.0.20.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/http-foundation',
|
||||
'aliases' => array(),
|
||||
'reference' => 'e16b2676a4b3b1fa12378a20b29c364feda2a8d6',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'symfony/polyfill-mbstring' => array(
|
||||
'pretty_version' => 'v1.28.0',
|
||||
'version' => '1.28.0.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
|
||||
'aliases' => array(),
|
||||
'reference' => '42292d99c55abe617799667f454222c54c60e229',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
// platform_check.php @generated by Composer
|
||||
|
||||
$issues = array();
|
||||
|
||||
if (!(PHP_VERSION_ID >= 80002)) {
|
||||
$issues[] = 'Your Composer dependencies require a PHP version ">= 8.0.2". You are running ' . PHP_VERSION . '.';
|
||||
}
|
||||
|
||||
if ($issues) {
|
||||
if (!headers_sent()) {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
}
|
||||
if (!ini_get('display_errors')) {
|
||||
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
|
||||
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
|
||||
} elseif (!headers_sent()) {
|
||||
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
|
||||
}
|
||||
}
|
||||
trigger_error(
|
||||
'Composer detected issues in your platform: ' . implode(' ', $issues),
|
||||
E_USER_ERROR
|
||||
);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,27 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011 Michael Dowling <mtdowling@gmail.com>
|
||||
Copyright (c) 2012 Jeremy Lindblom <jeremeamia@gmail.com>
|
||||
Copyright (c) 2014 Graham Campbell <hello@gjcampbell.co.uk>
|
||||
Copyright (c) 2015 Márk Sági-Kazár <mark.sagikazar@gmail.com>
|
||||
Copyright (c) 2015 Tobias Schultze <webmaster@tubo-world.de>
|
||||
Copyright (c) 2016 Tobias Nyholm <tobias.nyholm@gmail.com>
|
||||
Copyright (c) 2016 George Mponos <gmponos@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -0,0 +1,94 @@
|
||||

|
||||
|
||||
# Guzzle, PHP HTTP client
|
||||
|
||||
[](https://github.com/guzzle/guzzle/releases)
|
||||
[](https://github.com/guzzle/guzzle/actions?query=workflow%3ACI)
|
||||
[](https://packagist.org/packages/guzzlehttp/guzzle)
|
||||
|
||||
Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and
|
||||
trivial to integrate with web services.
|
||||
|
||||
- Simple interface for building query strings, POST requests, streaming large
|
||||
uploads, streaming large downloads, using HTTP cookies, uploading JSON data,
|
||||
etc...
|
||||
- Can send both synchronous and asynchronous requests using the same interface.
|
||||
- Uses PSR-7 interfaces for requests, responses, and streams. This allows you
|
||||
to utilize other PSR-7 compatible libraries with Guzzle.
|
||||
- Supports PSR-18 allowing interoperability between other PSR-18 HTTP Clients.
|
||||
- Abstracts away the underlying HTTP transport, allowing you to write
|
||||
environment and transport agnostic code; i.e., no hard dependency on cURL,
|
||||
PHP streams, sockets, or non-blocking event loops.
|
||||
- Middleware system allows you to augment and compose client behavior.
|
||||
|
||||
```php
|
||||
$client = new \GuzzleHttp\Client();
|
||||
$response = $client->request('GET', 'https://api.github.com/repos/guzzle/guzzle');
|
||||
|
||||
echo $response->getStatusCode(); // 200
|
||||
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
|
||||
echo $response->getBody(); // '{"id": 1420053, "name": "guzzle", ...}'
|
||||
|
||||
// Send an asynchronous request.
|
||||
$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org');
|
||||
$promise = $client->sendAsync($request)->then(function ($response) {
|
||||
echo 'I completed! ' . $response->getBody();
|
||||
});
|
||||
|
||||
$promise->wait();
|
||||
```
|
||||
|
||||
## Help and docs
|
||||
|
||||
We use GitHub issues only to discuss bugs and new features. For support please refer to:
|
||||
|
||||
- [Documentation](https://docs.guzzlephp.org)
|
||||
- [Stack Overflow](https://stackoverflow.com/questions/tagged/guzzle)
|
||||
- [#guzzle](https://app.slack.com/client/T0D2S9JCT/CE6UAAKL4) channel on [PHP-HTTP Slack](https://slack.httplug.io/)
|
||||
- [Gitter](https://gitter.im/guzzle/guzzle)
|
||||
|
||||
|
||||
## Installing Guzzle
|
||||
|
||||
The recommended way to install Guzzle is through
|
||||
[Composer](https://getcomposer.org/).
|
||||
|
||||
```bash
|
||||
composer require guzzlehttp/guzzle
|
||||
```
|
||||
|
||||
|
||||
## Version Guidance
|
||||
|
||||
| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | PHP Version |
|
||||
|---------|---------------------|---------------------|--------------|---------------------|---------------------|-------|--------------|
|
||||
| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | >=5.3.3,<7.0 |
|
||||
| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v4][guzzle-4-repo] | N/A | No | >=5.4,<7.0 |
|
||||
| 5.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | >=5.4,<7.4 |
|
||||
| 6.x | Security fixes only | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | >=5.5,<8.0 |
|
||||
| 7.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v7][guzzle-7-repo] | [v7][guzzle-7-docs] | Yes | >=7.2.5,<8.4 |
|
||||
|
||||
[guzzle-3-repo]: https://github.com/guzzle/guzzle3
|
||||
[guzzle-4-repo]: https://github.com/guzzle/guzzle/tree/4.x
|
||||
[guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3
|
||||
[guzzle-6-repo]: https://github.com/guzzle/guzzle/tree/6.5
|
||||
[guzzle-7-repo]: https://github.com/guzzle/guzzle
|
||||
[guzzle-3-docs]: https://guzzle3.readthedocs.io/
|
||||
[guzzle-5-docs]: https://docs.guzzlephp.org/en/5.3/
|
||||
[guzzle-6-docs]: https://docs.guzzlephp.org/en/6.5/
|
||||
[guzzle-7-docs]: https://docs.guzzlephp.org/en/latest/
|
||||
|
||||
|
||||
## Security
|
||||
|
||||
If you discover a security vulnerability within this package, please send an email to security@tidelift.com. All security vulnerabilities will be promptly addressed. Please do not disclose security-related issues publicly until a fix has been announced. Please see [Security Policy](https://github.com/guzzle/guzzle/security/policy) for more information.
|
||||
|
||||
## License
|
||||
|
||||
Guzzle is made available under the MIT License (MIT). Please see [License File](LICENSE) for more information.
|
||||
|
||||
## For Enterprise
|
||||
|
||||
Available as part of the Tidelift Subscription
|
||||
|
||||
The maintainers of Guzzle and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/packagist-guzzlehttp-guzzle?utm_source=packagist-guzzlehttp-guzzle&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,103 @@
|
||||
{
|
||||
"name": "guzzlehttp/guzzle",
|
||||
"description": "Guzzle is a PHP HTTP client library",
|
||||
"keywords": [
|
||||
"framework",
|
||||
"http",
|
||||
"rest",
|
||||
"web service",
|
||||
"curl",
|
||||
"client",
|
||||
"HTTP client",
|
||||
"PSR-7",
|
||||
"PSR-18"
|
||||
],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "hello@gjcampbell.co.uk",
|
||||
"homepage": "https://github.com/GrahamCampbell"
|
||||
},
|
||||
{
|
||||
"name": "Michael Dowling",
|
||||
"email": "mtdowling@gmail.com",
|
||||
"homepage": "https://github.com/mtdowling"
|
||||
},
|
||||
{
|
||||
"name": "Jeremy Lindblom",
|
||||
"email": "jeremeamia@gmail.com",
|
||||
"homepage": "https://github.com/jeremeamia"
|
||||
},
|
||||
{
|
||||
"name": "George Mponos",
|
||||
"email": "gmponos@gmail.com",
|
||||
"homepage": "https://github.com/gmponos"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Nyholm",
|
||||
"email": "tobias.nyholm@gmail.com",
|
||||
"homepage": "https://github.com/Nyholm"
|
||||
},
|
||||
{
|
||||
"name": "Márk Sági-Kazár",
|
||||
"email": "mark.sagikazar@gmail.com",
|
||||
"homepage": "https://github.com/sagikazarmark"
|
||||
},
|
||||
{
|
||||
"name": "Tobias Schultze",
|
||||
"email": "webmaster@tubo-world.de",
|
||||
"homepage": "https://github.com/Tobion"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.2.5 || ^8.0",
|
||||
"ext-json": "*",
|
||||
"guzzlehttp/promises": "^1.5.3 || ^2.0.1",
|
||||
"guzzlehttp/psr7": "^1.9.1 || ^2.5.1",
|
||||
"psr/http-client": "^1.0",
|
||||
"symfony/deprecation-contracts": "^2.2 || ^3.0"
|
||||
},
|
||||
"provide": {
|
||||
"psr/http-client-implementation": "1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"bamarni/composer-bin-plugin": "^1.8.2",
|
||||
"php-http/client-integration-tests": "dev-master#2c025848417c1135031fdf9c728ee53d0a7ceaee as 3.0.999",
|
||||
"php-http/message-factory": "^1.1",
|
||||
"phpunit/phpunit": "^8.5.36 || ^9.6.15",
|
||||
"psr/log": "^1.1 || ^2.0 || ^3.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-curl": "Required for CURL handler support",
|
||||
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
|
||||
"psr/log": "Required for using the Log middleware"
|
||||
},
|
||||
"config": {
|
||||
"allow-plugins": {
|
||||
"bamarni/composer-bin-plugin": true
|
||||
},
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"bamarni-bin": {
|
||||
"bin-links": true,
|
||||
"forward-command": false
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\": "src/"
|
||||
},
|
||||
"files": [
|
||||
"src/functions_include.php"
|
||||
]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"GuzzleHttp\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp;
|
||||
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
|
||||
final class BodySummarizer implements BodySummarizerInterface
|
||||
{
|
||||
/**
|
||||
* @var int|null
|
||||
*/
|
||||
private $truncateAt;
|
||||
|
||||
public function __construct(int $truncateAt = null)
|
||||
{
|
||||
$this->truncateAt = $truncateAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a summarized message body.
|
||||
*/
|
||||
public function summarize(MessageInterface $message): ?string
|
||||
{
|
||||
return $this->truncateAt === null
|
||||
? \GuzzleHttp\Psr7\Message::bodySummary($message)
|
||||
: \GuzzleHttp\Psr7\Message::bodySummary($message, $this->truncateAt);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp;
|
||||
|
||||
use Psr\Http\Message\MessageInterface;
|
||||
|
||||
interface BodySummarizerInterface
|
||||
{
|
||||
/**
|
||||
* Returns a summarized message body.
|
||||
*/
|
||||
public function summarize(MessageInterface $message): ?string;
|
||||
}
|
||||
@@ -0,0 +1,483 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp;
|
||||
|
||||
use GuzzleHttp\Cookie\CookieJar;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Exception\InvalidArgumentException;
|
||||
use GuzzleHttp\Promise as P;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* @final
|
||||
*/
|
||||
class Client implements ClientInterface, \Psr\Http\Client\ClientInterface
|
||||
{
|
||||
use ClientTrait;
|
||||
|
||||
/**
|
||||
* @var array Default request options
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* Clients accept an array of constructor parameters.
|
||||
*
|
||||
* Here's an example of creating a client using a base_uri and an array of
|
||||
* default request options to apply to each request:
|
||||
*
|
||||
* $client = new Client([
|
||||
* 'base_uri' => 'http://www.foo.com/1.0/',
|
||||
* 'timeout' => 0,
|
||||
* 'allow_redirects' => false,
|
||||
* 'proxy' => '192.168.16.1:10'
|
||||
* ]);
|
||||
*
|
||||
* Client configuration settings include the following options:
|
||||
*
|
||||
* - handler: (callable) Function that transfers HTTP requests over the
|
||||
* wire. The function is called with a Psr7\Http\Message\RequestInterface
|
||||
* and array of transfer options, and must return a
|
||||
* GuzzleHttp\Promise\PromiseInterface that is fulfilled with a
|
||||
* Psr7\Http\Message\ResponseInterface on success.
|
||||
* If no handler is provided, a default handler will be created
|
||||
* that enables all of the request options below by attaching all of the
|
||||
* default middleware to the handler.
|
||||
* - base_uri: (string|UriInterface) Base URI of the client that is merged
|
||||
* into relative URIs. Can be a string or instance of UriInterface.
|
||||
* - **: any request option
|
||||
*
|
||||
* @param array $config Client configuration settings.
|
||||
*
|
||||
* @see \GuzzleHttp\RequestOptions for a list of available request options.
|
||||
*/
|
||||
public function __construct(array $config = [])
|
||||
{
|
||||
if (!isset($config['handler'])) {
|
||||
$config['handler'] = HandlerStack::create();
|
||||
} elseif (!\is_callable($config['handler'])) {
|
||||
throw new InvalidArgumentException('handler must be a callable');
|
||||
}
|
||||
|
||||
// Convert the base_uri to a UriInterface
|
||||
if (isset($config['base_uri'])) {
|
||||
$config['base_uri'] = Psr7\Utils::uriFor($config['base_uri']);
|
||||
}
|
||||
|
||||
$this->configureDefaults($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
*
|
||||
* @return PromiseInterface|ResponseInterface
|
||||
*
|
||||
* @deprecated Client::__call will be removed in guzzlehttp/guzzle:8.0.
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (\count($args) < 1) {
|
||||
throw new InvalidArgumentException('Magic request methods require a URI and optional options array');
|
||||
}
|
||||
|
||||
$uri = $args[0];
|
||||
$opts = $args[1] ?? [];
|
||||
|
||||
return \substr($method, -5) === 'Async'
|
||||
? $this->requestAsync(\substr($method, 0, -5), $uri, $opts)
|
||||
: $this->request($method, $uri, $opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asynchronously send an HTTP request.
|
||||
*
|
||||
* @param array $options Request options to apply to the given
|
||||
* request and to the transfer. See \GuzzleHttp\RequestOptions.
|
||||
*/
|
||||
public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface
|
||||
{
|
||||
// Merge the base URI into the request URI if needed.
|
||||
$options = $this->prepareDefaults($options);
|
||||
|
||||
return $this->transfer(
|
||||
$request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')),
|
||||
$options
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an HTTP request.
|
||||
*
|
||||
* @param array $options Request options to apply to the given
|
||||
* request and to the transfer. See \GuzzleHttp\RequestOptions.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send(RequestInterface $request, array $options = []): ResponseInterface
|
||||
{
|
||||
$options[RequestOptions::SYNCHRONOUS] = true;
|
||||
|
||||
return $this->sendAsync($request, $options)->wait();
|
||||
}
|
||||
|
||||
/**
|
||||
* The HttpClient PSR (PSR-18) specify this method.
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sendRequest(RequestInterface $request): ResponseInterface
|
||||
{
|
||||
$options[RequestOptions::SYNCHRONOUS] = true;
|
||||
$options[RequestOptions::ALLOW_REDIRECTS] = false;
|
||||
$options[RequestOptions::HTTP_ERRORS] = false;
|
||||
|
||||
return $this->sendAsync($request, $options)->wait();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an asynchronous HTTP request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well. Use an array to provide a URL
|
||||
* template and additional variables to use in the URL template expansion.
|
||||
*
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
|
||||
*/
|
||||
public function requestAsync(string $method, $uri = '', array $options = []): PromiseInterface
|
||||
{
|
||||
$options = $this->prepareDefaults($options);
|
||||
// Remove request modifying parameter because it can be done up-front.
|
||||
$headers = $options['headers'] ?? [];
|
||||
$body = $options['body'] ?? null;
|
||||
$version = $options['version'] ?? '1.1';
|
||||
// Merge the URI into the base URI.
|
||||
$uri = $this->buildUri(Psr7\Utils::uriFor($uri), $options);
|
||||
if (\is_array($body)) {
|
||||
throw $this->invalidBody();
|
||||
}
|
||||
$request = new Psr7\Request($method, $uri, $headers, $body, $version);
|
||||
// Remove the option so that they are not doubly-applied.
|
||||
unset($options['headers'], $options['body'], $options['version']);
|
||||
|
||||
return $this->transfer($request, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an HTTP request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string $method HTTP method.
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply. See \GuzzleHttp\RequestOptions.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function request(string $method, $uri = '', array $options = []): ResponseInterface
|
||||
{
|
||||
$options[RequestOptions::SYNCHRONOUS] = true;
|
||||
|
||||
return $this->requestAsync($method, $uri, $options)->wait();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a client configuration option.
|
||||
*
|
||||
* These options include default request options of the client, a "handler"
|
||||
* (if utilized by the concrete client), and a "base_uri" if utilized by
|
||||
* the concrete client.
|
||||
*
|
||||
* @param string|null $option The config option to retrieve.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @deprecated Client::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
||||
*/
|
||||
public function getConfig(string $option = null)
|
||||
{
|
||||
return $option === null
|
||||
? $this->config
|
||||
: ($this->config[$option] ?? null);
|
||||
}
|
||||
|
||||
private function buildUri(UriInterface $uri, array $config): UriInterface
|
||||
{
|
||||
if (isset($config['base_uri'])) {
|
||||
$uri = Psr7\UriResolver::resolve(Psr7\Utils::uriFor($config['base_uri']), $uri);
|
||||
}
|
||||
|
||||
if (isset($config['idn_conversion']) && ($config['idn_conversion'] !== false)) {
|
||||
$idnOptions = ($config['idn_conversion'] === true) ? \IDNA_DEFAULT : $config['idn_conversion'];
|
||||
$uri = Utils::idnUriConvert($uri, $idnOptions);
|
||||
}
|
||||
|
||||
return $uri->getScheme() === '' && $uri->getHost() !== '' ? $uri->withScheme('http') : $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the default options for a client.
|
||||
*/
|
||||
private function configureDefaults(array $config): void
|
||||
{
|
||||
$defaults = [
|
||||
'allow_redirects' => RedirectMiddleware::$defaultSettings,
|
||||
'http_errors' => true,
|
||||
'decode_content' => true,
|
||||
'verify' => true,
|
||||
'cookies' => false,
|
||||
'idn_conversion' => false,
|
||||
];
|
||||
|
||||
// Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set.
|
||||
|
||||
// We can only trust the HTTP_PROXY environment variable in a CLI
|
||||
// process due to the fact that PHP has no reliable mechanism to
|
||||
// get environment variables that start with "HTTP_".
|
||||
if (\PHP_SAPI === 'cli' && ($proxy = Utils::getenv('HTTP_PROXY'))) {
|
||||
$defaults['proxy']['http'] = $proxy;
|
||||
}
|
||||
|
||||
if ($proxy = Utils::getenv('HTTPS_PROXY')) {
|
||||
$defaults['proxy']['https'] = $proxy;
|
||||
}
|
||||
|
||||
if ($noProxy = Utils::getenv('NO_PROXY')) {
|
||||
$cleanedNoProxy = \str_replace(' ', '', $noProxy);
|
||||
$defaults['proxy']['no'] = \explode(',', $cleanedNoProxy);
|
||||
}
|
||||
|
||||
$this->config = $config + $defaults;
|
||||
|
||||
if (!empty($config['cookies']) && $config['cookies'] === true) {
|
||||
$this->config['cookies'] = new CookieJar();
|
||||
}
|
||||
|
||||
// Add the default user-agent header.
|
||||
if (!isset($this->config['headers'])) {
|
||||
$this->config['headers'] = ['User-Agent' => Utils::defaultUserAgent()];
|
||||
} else {
|
||||
// Add the User-Agent header if one was not already set.
|
||||
foreach (\array_keys($this->config['headers']) as $name) {
|
||||
if (\strtolower($name) === 'user-agent') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->config['headers']['User-Agent'] = Utils::defaultUserAgent();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges default options into the array.
|
||||
*
|
||||
* @param array $options Options to modify by reference
|
||||
*/
|
||||
private function prepareDefaults(array $options): array
|
||||
{
|
||||
$defaults = $this->config;
|
||||
|
||||
if (!empty($defaults['headers'])) {
|
||||
// Default headers are only added if they are not present.
|
||||
$defaults['_conditional'] = $defaults['headers'];
|
||||
unset($defaults['headers']);
|
||||
}
|
||||
|
||||
// Special handling for headers is required as they are added as
|
||||
// conditional headers and as headers passed to a request ctor.
|
||||
if (\array_key_exists('headers', $options)) {
|
||||
// Allows default headers to be unset.
|
||||
if ($options['headers'] === null) {
|
||||
$defaults['_conditional'] = [];
|
||||
unset($options['headers']);
|
||||
} elseif (!\is_array($options['headers'])) {
|
||||
throw new InvalidArgumentException('headers must be an array');
|
||||
}
|
||||
}
|
||||
|
||||
// Shallow merge defaults underneath options.
|
||||
$result = $options + $defaults;
|
||||
|
||||
// Remove null values.
|
||||
foreach ($result as $k => $v) {
|
||||
if ($v === null) {
|
||||
unset($result[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transfers the given request and applies request options.
|
||||
*
|
||||
* The URI of the request is not modified and the request options are used
|
||||
* as-is without merging in default options.
|
||||
*
|
||||
* @param array $options See \GuzzleHttp\RequestOptions.
|
||||
*/
|
||||
private function transfer(RequestInterface $request, array $options): PromiseInterface
|
||||
{
|
||||
$request = $this->applyOptions($request, $options);
|
||||
/** @var HandlerStack $handler */
|
||||
$handler = $options['handler'];
|
||||
|
||||
try {
|
||||
return P\Create::promiseFor($handler($request, $options));
|
||||
} catch (\Exception $e) {
|
||||
return P\Create::rejectionFor($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the array of request options to a request.
|
||||
*/
|
||||
private function applyOptions(RequestInterface $request, array &$options): RequestInterface
|
||||
{
|
||||
$modify = [
|
||||
'set_headers' => [],
|
||||
];
|
||||
|
||||
if (isset($options['headers'])) {
|
||||
if (array_keys($options['headers']) === range(0, count($options['headers']) - 1)) {
|
||||
throw new InvalidArgumentException('The headers array must have header name as keys.');
|
||||
}
|
||||
$modify['set_headers'] = $options['headers'];
|
||||
unset($options['headers']);
|
||||
}
|
||||
|
||||
if (isset($options['form_params'])) {
|
||||
if (isset($options['multipart'])) {
|
||||
throw new InvalidArgumentException('You cannot use '
|
||||
.'form_params and multipart at the same time. Use the '
|
||||
.'form_params option if you want to send application/'
|
||||
.'x-www-form-urlencoded requests, and the multipart '
|
||||
.'option to send multipart/form-data requests.');
|
||||
}
|
||||
$options['body'] = \http_build_query($options['form_params'], '', '&');
|
||||
unset($options['form_params']);
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
|
||||
$options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
}
|
||||
|
||||
if (isset($options['multipart'])) {
|
||||
$options['body'] = new Psr7\MultipartStream($options['multipart']);
|
||||
unset($options['multipart']);
|
||||
}
|
||||
|
||||
if (isset($options['json'])) {
|
||||
$options['body'] = Utils::jsonEncode($options['json']);
|
||||
unset($options['json']);
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
|
||||
$options['_conditional']['Content-Type'] = 'application/json';
|
||||
}
|
||||
|
||||
if (!empty($options['decode_content'])
|
||||
&& $options['decode_content'] !== true
|
||||
) {
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Accept-Encoding'], $options['_conditional']);
|
||||
$modify['set_headers']['Accept-Encoding'] = $options['decode_content'];
|
||||
}
|
||||
|
||||
if (isset($options['body'])) {
|
||||
if (\is_array($options['body'])) {
|
||||
throw $this->invalidBody();
|
||||
}
|
||||
$modify['body'] = Psr7\Utils::streamFor($options['body']);
|
||||
unset($options['body']);
|
||||
}
|
||||
|
||||
if (!empty($options['auth']) && \is_array($options['auth'])) {
|
||||
$value = $options['auth'];
|
||||
$type = isset($value[2]) ? \strtolower($value[2]) : 'basic';
|
||||
switch ($type) {
|
||||
case 'basic':
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$modify['set_headers'] = Psr7\Utils::caselessRemove(['Authorization'], $modify['set_headers']);
|
||||
$modify['set_headers']['Authorization'] = 'Basic '
|
||||
.\base64_encode("$value[0]:$value[1]");
|
||||
break;
|
||||
case 'digest':
|
||||
// @todo: Do not rely on curl
|
||||
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_DIGEST;
|
||||
$options['curl'][\CURLOPT_USERPWD] = "$value[0]:$value[1]";
|
||||
break;
|
||||
case 'ntlm':
|
||||
$options['curl'][\CURLOPT_HTTPAUTH] = \CURLAUTH_NTLM;
|
||||
$options['curl'][\CURLOPT_USERPWD] = "$value[0]:$value[1]";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['query'])) {
|
||||
$value = $options['query'];
|
||||
if (\is_array($value)) {
|
||||
$value = \http_build_query($value, '', '&', \PHP_QUERY_RFC3986);
|
||||
}
|
||||
if (!\is_string($value)) {
|
||||
throw new InvalidArgumentException('query must be a string or array');
|
||||
}
|
||||
$modify['query'] = $value;
|
||||
unset($options['query']);
|
||||
}
|
||||
|
||||
// Ensure that sink is not an invalid value.
|
||||
if (isset($options['sink'])) {
|
||||
// TODO: Add more sink validation?
|
||||
if (\is_bool($options['sink'])) {
|
||||
throw new InvalidArgumentException('sink must not be a boolean');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['version'])) {
|
||||
$modify['version'] = $options['version'];
|
||||
}
|
||||
|
||||
$request = Psr7\Utils::modifyRequest($request, $modify);
|
||||
if ($request->getBody() instanceof Psr7\MultipartStream) {
|
||||
// Use a multipart/form-data POST if a Content-Type is not set.
|
||||
// Ensure that we don't have the header in different case and set the new value.
|
||||
$options['_conditional'] = Psr7\Utils::caselessRemove(['Content-Type'], $options['_conditional']);
|
||||
$options['_conditional']['Content-Type'] = 'multipart/form-data; boundary='
|
||||
.$request->getBody()->getBoundary();
|
||||
}
|
||||
|
||||
// Merge in conditional headers if they are not present.
|
||||
if (isset($options['_conditional'])) {
|
||||
// Build up the changes so it's in a single clone of the message.
|
||||
$modify = [];
|
||||
foreach ($options['_conditional'] as $k => $v) {
|
||||
if (!$request->hasHeader($k)) {
|
||||
$modify['set_headers'][$k] = $v;
|
||||
}
|
||||
}
|
||||
$request = Psr7\Utils::modifyRequest($request, $modify);
|
||||
// Don't pass this internal value along to middleware/handlers.
|
||||
unset($options['_conditional']);
|
||||
}
|
||||
|
||||
return $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an InvalidArgumentException with pre-set message.
|
||||
*/
|
||||
private function invalidBody(): InvalidArgumentException
|
||||
{
|
||||
return new InvalidArgumentException('Passing in the "body" request '
|
||||
.'option as an array to send a request is not supported. '
|
||||
.'Please use the "form_params" request option to send a '
|
||||
.'application/x-www-form-urlencoded request, or the "multipart" '
|
||||
.'request option to send a multipart/form-data request.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp;
|
||||
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* Client interface for sending HTTP requests.
|
||||
*/
|
||||
interface ClientInterface
|
||||
{
|
||||
/**
|
||||
* The Guzzle major version.
|
||||
*/
|
||||
public const MAJOR_VERSION = 7;
|
||||
|
||||
/**
|
||||
* Send an HTTP request.
|
||||
*
|
||||
* @param RequestInterface $request Request to send
|
||||
* @param array $options Request options to apply to the given
|
||||
* request and to the transfer.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function send(RequestInterface $request, array $options = []): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Asynchronously send an HTTP request.
|
||||
*
|
||||
* @param RequestInterface $request Request to send
|
||||
* @param array $options Request options to apply to the given
|
||||
* request and to the transfer.
|
||||
*/
|
||||
public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Create and send an HTTP request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string $method HTTP method.
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function request(string $method, $uri, array $options = []): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Create and send an asynchronous HTTP request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well. Use an array to provide a URL
|
||||
* template and additional variables to use in the URL template expansion.
|
||||
*
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*/
|
||||
public function requestAsync(string $method, $uri, array $options = []): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Get a client configuration option.
|
||||
*
|
||||
* These options include default request options of the client, a "handler"
|
||||
* (if utilized by the concrete client), and a "base_uri" if utilized by
|
||||
* the concrete client.
|
||||
*
|
||||
* @param string|null $option The config option to retrieve.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @deprecated ClientInterface::getConfig will be removed in guzzlehttp/guzzle:8.0.
|
||||
*/
|
||||
public function getConfig(string $option = null);
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp;
|
||||
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* Client interface for sending HTTP requests.
|
||||
*/
|
||||
trait ClientTrait
|
||||
{
|
||||
/**
|
||||
* Create and send an HTTP request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string $method HTTP method.
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
abstract public function request(string $method, $uri, array $options = []): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Create and send an HTTP GET request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function get($uri, array $options = []): ResponseInterface
|
||||
{
|
||||
return $this->request('GET', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an HTTP HEAD request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function head($uri, array $options = []): ResponseInterface
|
||||
{
|
||||
return $this->request('HEAD', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an HTTP PUT request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function put($uri, array $options = []): ResponseInterface
|
||||
{
|
||||
return $this->request('PUT', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an HTTP POST request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function post($uri, array $options = []): ResponseInterface
|
||||
{
|
||||
return $this->request('POST', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an HTTP PATCH request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function patch($uri, array $options = []): ResponseInterface
|
||||
{
|
||||
return $this->request('PATCH', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an HTTP DELETE request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function delete($uri, array $options = []): ResponseInterface
|
||||
{
|
||||
return $this->request('DELETE', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an asynchronous HTTP request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well. Use an array to provide a URL
|
||||
* template and additional variables to use in the URL template expansion.
|
||||
*
|
||||
* @param string $method HTTP method
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*/
|
||||
abstract public function requestAsync(string $method, $uri, array $options = []): PromiseInterface;
|
||||
|
||||
/**
|
||||
* Create and send an asynchronous HTTP GET request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well. Use an array to provide a URL
|
||||
* template and additional variables to use in the URL template expansion.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*/
|
||||
public function getAsync($uri, array $options = []): PromiseInterface
|
||||
{
|
||||
return $this->requestAsync('GET', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an asynchronous HTTP HEAD request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well. Use an array to provide a URL
|
||||
* template and additional variables to use in the URL template expansion.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*/
|
||||
public function headAsync($uri, array $options = []): PromiseInterface
|
||||
{
|
||||
return $this->requestAsync('HEAD', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an asynchronous HTTP PUT request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well. Use an array to provide a URL
|
||||
* template and additional variables to use in the URL template expansion.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*/
|
||||
public function putAsync($uri, array $options = []): PromiseInterface
|
||||
{
|
||||
return $this->requestAsync('PUT', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an asynchronous HTTP POST request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well. Use an array to provide a URL
|
||||
* template and additional variables to use in the URL template expansion.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*/
|
||||
public function postAsync($uri, array $options = []): PromiseInterface
|
||||
{
|
||||
return $this->requestAsync('POST', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an asynchronous HTTP PATCH request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well. Use an array to provide a URL
|
||||
* template and additional variables to use in the URL template expansion.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*/
|
||||
public function patchAsync($uri, array $options = []): PromiseInterface
|
||||
{
|
||||
return $this->requestAsync('PATCH', $uri, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and send an asynchronous HTTP DELETE request.
|
||||
*
|
||||
* Use an absolute path to override the base path of the client, or a
|
||||
* relative path to append to the base path of the client. The URL can
|
||||
* contain the query string as well. Use an array to provide a URL
|
||||
* template and additional variables to use in the URL template expansion.
|
||||
*
|
||||
* @param string|UriInterface $uri URI object or string.
|
||||
* @param array $options Request options to apply.
|
||||
*/
|
||||
public function deleteAsync($uri, array $options = []): PromiseInterface
|
||||
{
|
||||
return $this->requestAsync('DELETE', $uri, $options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Cookie;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Cookie jar that stores cookies as an array
|
||||
*/
|
||||
class CookieJar implements CookieJarInterface
|
||||
{
|
||||
/**
|
||||
* @var SetCookie[] Loaded cookie data
|
||||
*/
|
||||
private $cookies = [];
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $strictMode;
|
||||
|
||||
/**
|
||||
* @param bool $strictMode Set to true to throw exceptions when invalid
|
||||
* cookies are added to the cookie jar.
|
||||
* @param array $cookieArray Array of SetCookie objects or a hash of
|
||||
* arrays that can be used with the SetCookie
|
||||
* constructor
|
||||
*/
|
||||
public function __construct(bool $strictMode = false, array $cookieArray = [])
|
||||
{
|
||||
$this->strictMode = $strictMode;
|
||||
|
||||
foreach ($cookieArray as $cookie) {
|
||||
if (!($cookie instanceof SetCookie)) {
|
||||
$cookie = new SetCookie($cookie);
|
||||
}
|
||||
$this->setCookie($cookie);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new Cookie jar from an associative array and domain.
|
||||
*
|
||||
* @param array $cookies Cookies to create the jar from
|
||||
* @param string $domain Domain to set the cookies to
|
||||
*/
|
||||
public static function fromArray(array $cookies, string $domain): self
|
||||
{
|
||||
$cookieJar = new self();
|
||||
foreach ($cookies as $name => $value) {
|
||||
$cookieJar->setCookie(new SetCookie([
|
||||
'Domain' => $domain,
|
||||
'Name' => $name,
|
||||
'Value' => $value,
|
||||
'Discard' => true,
|
||||
]));
|
||||
}
|
||||
|
||||
return $cookieJar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Evaluate if this cookie should be persisted to storage
|
||||
* that survives between requests.
|
||||
*
|
||||
* @param SetCookie $cookie Being evaluated.
|
||||
* @param bool $allowSessionCookies If we should persist session cookies
|
||||
*/
|
||||
public static function shouldPersist(SetCookie $cookie, bool $allowSessionCookies = false): bool
|
||||
{
|
||||
if ($cookie->getExpires() || $allowSessionCookies) {
|
||||
if (!$cookie->getDiscard()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds and returns the cookie based on the name
|
||||
*
|
||||
* @param string $name cookie name to search for
|
||||
*
|
||||
* @return SetCookie|null cookie that was found or null if not found
|
||||
*/
|
||||
public function getCookieByName(string $name): ?SetCookie
|
||||
{
|
||||
foreach ($this->cookies as $cookie) {
|
||||
if ($cookie->getName() !== null && \strcasecmp($cookie->getName(), $name) === 0) {
|
||||
return $cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return \array_map(static function (SetCookie $cookie): array {
|
||||
return $cookie->toArray();
|
||||
}, $this->getIterator()->getArrayCopy());
|
||||
}
|
||||
|
||||
public function clear(string $domain = null, string $path = null, string $name = null): void
|
||||
{
|
||||
if (!$domain) {
|
||||
$this->cookies = [];
|
||||
|
||||
return;
|
||||
} elseif (!$path) {
|
||||
$this->cookies = \array_filter(
|
||||
$this->cookies,
|
||||
static function (SetCookie $cookie) use ($domain): bool {
|
||||
return !$cookie->matchesDomain($domain);
|
||||
}
|
||||
);
|
||||
} elseif (!$name) {
|
||||
$this->cookies = \array_filter(
|
||||
$this->cookies,
|
||||
static function (SetCookie $cookie) use ($path, $domain): bool {
|
||||
return !($cookie->matchesPath($path)
|
||||
&& $cookie->matchesDomain($domain));
|
||||
}
|
||||
);
|
||||
} else {
|
||||
$this->cookies = \array_filter(
|
||||
$this->cookies,
|
||||
static function (SetCookie $cookie) use ($path, $domain, $name) {
|
||||
return !($cookie->getName() == $name
|
||||
&& $cookie->matchesPath($path)
|
||||
&& $cookie->matchesDomain($domain));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function clearSessionCookies(): void
|
||||
{
|
||||
$this->cookies = \array_filter(
|
||||
$this->cookies,
|
||||
static function (SetCookie $cookie): bool {
|
||||
return !$cookie->getDiscard() && $cookie->getExpires();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
public function setCookie(SetCookie $cookie): bool
|
||||
{
|
||||
// If the name string is empty (but not 0), ignore the set-cookie
|
||||
// string entirely.
|
||||
$name = $cookie->getName();
|
||||
if (!$name && $name !== '0') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only allow cookies with set and valid domain, name, value
|
||||
$result = $cookie->validate();
|
||||
if ($result !== true) {
|
||||
if ($this->strictMode) {
|
||||
throw new \RuntimeException('Invalid cookie: '.$result);
|
||||
}
|
||||
$this->removeCookieIfEmpty($cookie);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Resolve conflicts with previously set cookies
|
||||
foreach ($this->cookies as $i => $c) {
|
||||
// Two cookies are identical, when their path, and domain are
|
||||
// identical.
|
||||
if ($c->getPath() != $cookie->getPath()
|
||||
|| $c->getDomain() != $cookie->getDomain()
|
||||
|| $c->getName() != $cookie->getName()
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The previously set cookie is a discard cookie and this one is
|
||||
// not so allow the new cookie to be set
|
||||
if (!$cookie->getDiscard() && $c->getDiscard()) {
|
||||
unset($this->cookies[$i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the new cookie's expiration is further into the future, then
|
||||
// replace the old cookie
|
||||
if ($cookie->getExpires() > $c->getExpires()) {
|
||||
unset($this->cookies[$i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the value has changed, we better change it
|
||||
if ($cookie->getValue() !== $c->getValue()) {
|
||||
unset($this->cookies[$i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// The cookie exists, so no need to continue
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->cookies[] = $cookie;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return \count($this->cookies);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \ArrayIterator<int, SetCookie>
|
||||
*/
|
||||
public function getIterator(): \ArrayIterator
|
||||
{
|
||||
return new \ArrayIterator(\array_values($this->cookies));
|
||||
}
|
||||
|
||||
public function extractCookies(RequestInterface $request, ResponseInterface $response): void
|
||||
{
|
||||
if ($cookieHeader = $response->getHeader('Set-Cookie')) {
|
||||
foreach ($cookieHeader as $cookie) {
|
||||
$sc = SetCookie::fromString($cookie);
|
||||
if (!$sc->getDomain()) {
|
||||
$sc->setDomain($request->getUri()->getHost());
|
||||
}
|
||||
if (0 !== \strpos($sc->getPath(), '/')) {
|
||||
$sc->setPath($this->getCookiePathFromRequest($request));
|
||||
}
|
||||
if (!$sc->matchesDomain($request->getUri()->getHost())) {
|
||||
continue;
|
||||
}
|
||||
// Note: At this point `$sc->getDomain()` being a public suffix should
|
||||
// be rejected, but we don't want to pull in the full PSL dependency.
|
||||
$this->setCookie($sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes cookie path following RFC 6265 section 5.1.4
|
||||
*
|
||||
* @see https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.4
|
||||
*/
|
||||
private function getCookiePathFromRequest(RequestInterface $request): string
|
||||
{
|
||||
$uriPath = $request->getUri()->getPath();
|
||||
if ('' === $uriPath) {
|
||||
return '/';
|
||||
}
|
||||
if (0 !== \strpos($uriPath, '/')) {
|
||||
return '/';
|
||||
}
|
||||
if ('/' === $uriPath) {
|
||||
return '/';
|
||||
}
|
||||
$lastSlashPos = \strrpos($uriPath, '/');
|
||||
if (0 === $lastSlashPos || false === $lastSlashPos) {
|
||||
return '/';
|
||||
}
|
||||
|
||||
return \substr($uriPath, 0, $lastSlashPos);
|
||||
}
|
||||
|
||||
public function withCookieHeader(RequestInterface $request): RequestInterface
|
||||
{
|
||||
$values = [];
|
||||
$uri = $request->getUri();
|
||||
$scheme = $uri->getScheme();
|
||||
$host = $uri->getHost();
|
||||
$path = $uri->getPath() ?: '/';
|
||||
|
||||
foreach ($this->cookies as $cookie) {
|
||||
if ($cookie->matchesPath($path)
|
||||
&& $cookie->matchesDomain($host)
|
||||
&& !$cookie->isExpired()
|
||||
&& (!$cookie->getSecure() || $scheme === 'https')
|
||||
) {
|
||||
$values[] = $cookie->getName().'='
|
||||
.$cookie->getValue();
|
||||
}
|
||||
}
|
||||
|
||||
return $values
|
||||
? $request->withHeader('Cookie', \implode('; ', $values))
|
||||
: $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a cookie already exists and the server asks to set it again with a
|
||||
* null value, the cookie must be deleted.
|
||||
*/
|
||||
private function removeCookieIfEmpty(SetCookie $cookie): void
|
||||
{
|
||||
$cookieValue = $cookie->getValue();
|
||||
if ($cookieValue === null || $cookieValue === '') {
|
||||
$this->clear(
|
||||
$cookie->getDomain(),
|
||||
$cookie->getPath(),
|
||||
$cookie->getName()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Cookie;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Stores HTTP cookies.
|
||||
*
|
||||
* It extracts cookies from HTTP requests, and returns them in HTTP responses.
|
||||
* CookieJarInterface instances automatically expire contained cookies when
|
||||
* necessary. Subclasses are also responsible for storing and retrieving
|
||||
* cookies from a file, database, etc.
|
||||
*
|
||||
* @see https://docs.python.org/2/library/cookielib.html Inspiration
|
||||
*
|
||||
* @extends \IteratorAggregate<SetCookie>
|
||||
*/
|
||||
interface CookieJarInterface extends \Countable, \IteratorAggregate
|
||||
{
|
||||
/**
|
||||
* Create a request with added cookie headers.
|
||||
*
|
||||
* If no matching cookies are found in the cookie jar, then no Cookie
|
||||
* header is added to the request and the same request is returned.
|
||||
*
|
||||
* @param RequestInterface $request Request object to modify.
|
||||
*
|
||||
* @return RequestInterface returns the modified request.
|
||||
*/
|
||||
public function withCookieHeader(RequestInterface $request): RequestInterface;
|
||||
|
||||
/**
|
||||
* Extract cookies from an HTTP response and store them in the CookieJar.
|
||||
*
|
||||
* @param RequestInterface $request Request that was sent
|
||||
* @param ResponseInterface $response Response that was received
|
||||
*/
|
||||
public function extractCookies(RequestInterface $request, ResponseInterface $response): void;
|
||||
|
||||
/**
|
||||
* Sets a cookie in the cookie jar.
|
||||
*
|
||||
* @param SetCookie $cookie Cookie to set.
|
||||
*
|
||||
* @return bool Returns true on success or false on failure
|
||||
*/
|
||||
public function setCookie(SetCookie $cookie): bool;
|
||||
|
||||
/**
|
||||
* Remove cookies currently held in the cookie jar.
|
||||
*
|
||||
* Invoking this method without arguments will empty the whole cookie jar.
|
||||
* If given a $domain argument only cookies belonging to that domain will
|
||||
* be removed. If given a $domain and $path argument, cookies belonging to
|
||||
* the specified path within that domain are removed. If given all three
|
||||
* arguments, then the cookie with the specified name, path and domain is
|
||||
* removed.
|
||||
*
|
||||
* @param string|null $domain Clears cookies matching a domain
|
||||
* @param string|null $path Clears cookies matching a domain and path
|
||||
* @param string|null $name Clears cookies matching a domain, path, and name
|
||||
*/
|
||||
public function clear(string $domain = null, string $path = null, string $name = null): void;
|
||||
|
||||
/**
|
||||
* Discard all sessions cookies.
|
||||
*
|
||||
* Removes cookies that don't have an expire field or a have a discard
|
||||
* field set to true. To be called when the user agent shuts down according
|
||||
* to RFC 2965.
|
||||
*/
|
||||
public function clearSessionCookies(): void;
|
||||
|
||||
/**
|
||||
* Converts the cookie jar to an array.
|
||||
*/
|
||||
public function toArray(): array;
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Cookie;
|
||||
|
||||
use GuzzleHttp\Utils;
|
||||
|
||||
/**
|
||||
* Persists non-session cookies using a JSON formatted file
|
||||
*/
|
||||
class FileCookieJar extends CookieJar
|
||||
{
|
||||
/**
|
||||
* @var string filename
|
||||
*/
|
||||
private $filename;
|
||||
|
||||
/**
|
||||
* @var bool Control whether to persist session cookies or not.
|
||||
*/
|
||||
private $storeSessionCookies;
|
||||
|
||||
/**
|
||||
* Create a new FileCookieJar object
|
||||
*
|
||||
* @param string $cookieFile File to store the cookie data
|
||||
* @param bool $storeSessionCookies Set to true to store session cookies
|
||||
* in the cookie jar.
|
||||
*
|
||||
* @throws \RuntimeException if the file cannot be found or created
|
||||
*/
|
||||
public function __construct(string $cookieFile, bool $storeSessionCookies = false)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->filename = $cookieFile;
|
||||
$this->storeSessionCookies = $storeSessionCookies;
|
||||
|
||||
if (\file_exists($cookieFile)) {
|
||||
$this->load($cookieFile);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the file when shutting down
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->save($this->filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the cookies to a file.
|
||||
*
|
||||
* @param string $filename File to save
|
||||
*
|
||||
* @throws \RuntimeException if the file cannot be found or created
|
||||
*/
|
||||
public function save(string $filename): void
|
||||
{
|
||||
$json = [];
|
||||
/** @var SetCookie $cookie */
|
||||
foreach ($this as $cookie) {
|
||||
if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
|
||||
$json[] = $cookie->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
$jsonStr = Utils::jsonEncode($json);
|
||||
if (false === \file_put_contents($filename, $jsonStr, \LOCK_EX)) {
|
||||
throw new \RuntimeException("Unable to save file {$filename}");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load cookies from a JSON formatted file.
|
||||
*
|
||||
* Old cookies are kept unless overwritten by newly loaded ones.
|
||||
*
|
||||
* @param string $filename Cookie file to load.
|
||||
*
|
||||
* @throws \RuntimeException if the file cannot be loaded.
|
||||
*/
|
||||
public function load(string $filename): void
|
||||
{
|
||||
$json = \file_get_contents($filename);
|
||||
if (false === $json) {
|
||||
throw new \RuntimeException("Unable to load file {$filename}");
|
||||
}
|
||||
if ($json === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$data = Utils::jsonDecode($json, true);
|
||||
if (\is_array($data)) {
|
||||
foreach ($data as $cookie) {
|
||||
$this->setCookie(new SetCookie($cookie));
|
||||
}
|
||||
} elseif (\is_scalar($data) && !empty($data)) {
|
||||
throw new \RuntimeException("Invalid cookie file: {$filename}");
|
||||
}
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Cookie;
|
||||
|
||||
/**
|
||||
* Persists cookies in the client session
|
||||
*/
|
||||
class SessionCookieJar extends CookieJar
|
||||
{
|
||||
/**
|
||||
* @var string session key
|
||||
*/
|
||||
private $sessionKey;
|
||||
|
||||
/**
|
||||
* @var bool Control whether to persist session cookies or not.
|
||||
*/
|
||||
private $storeSessionCookies;
|
||||
|
||||
/**
|
||||
* Create a new SessionCookieJar object
|
||||
*
|
||||
* @param string $sessionKey Session key name to store the cookie
|
||||
* data in session
|
||||
* @param bool $storeSessionCookies Set to true to store session cookies
|
||||
* in the cookie jar.
|
||||
*/
|
||||
public function __construct(string $sessionKey, bool $storeSessionCookies = false)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->sessionKey = $sessionKey;
|
||||
$this->storeSessionCookies = $storeSessionCookies;
|
||||
$this->load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves cookies to session when shutting down
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Save cookies to the client session
|
||||
*/
|
||||
public function save(): void
|
||||
{
|
||||
$json = [];
|
||||
/** @var SetCookie $cookie */
|
||||
foreach ($this as $cookie) {
|
||||
if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) {
|
||||
$json[] = $cookie->toArray();
|
||||
}
|
||||
}
|
||||
|
||||
$_SESSION[$this->sessionKey] = \json_encode($json);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the contents of the client session into the data array
|
||||
*/
|
||||
protected function load(): void
|
||||
{
|
||||
if (!isset($_SESSION[$this->sessionKey])) {
|
||||
return;
|
||||
}
|
||||
$data = \json_decode($_SESSION[$this->sessionKey], true);
|
||||
if (\is_array($data)) {
|
||||
foreach ($data as $cookie) {
|
||||
$this->setCookie(new SetCookie($cookie));
|
||||
}
|
||||
} elseif (\strlen($data)) {
|
||||
throw new \RuntimeException('Invalid cookie data');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,488 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Cookie;
|
||||
|
||||
/**
|
||||
* Set-Cookie object
|
||||
*/
|
||||
class SetCookie
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private static $defaults = [
|
||||
'Name' => null,
|
||||
'Value' => null,
|
||||
'Domain' => null,
|
||||
'Path' => '/',
|
||||
'Max-Age' => null,
|
||||
'Expires' => null,
|
||||
'Secure' => false,
|
||||
'Discard' => false,
|
||||
'HttpOnly' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array Cookie data
|
||||
*/
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* Create a new SetCookie object from a string.
|
||||
*
|
||||
* @param string $cookie Set-Cookie header string
|
||||
*/
|
||||
public static function fromString(string $cookie): self
|
||||
{
|
||||
// Create the default return array
|
||||
$data = self::$defaults;
|
||||
// Explode the cookie string using a series of semicolons
|
||||
$pieces = \array_filter(\array_map('trim', \explode(';', $cookie)));
|
||||
// The name of the cookie (first kvp) must exist and include an equal sign.
|
||||
if (!isset($pieces[0]) || \strpos($pieces[0], '=') === false) {
|
||||
return new self($data);
|
||||
}
|
||||
|
||||
// Add the cookie pieces into the parsed data array
|
||||
foreach ($pieces as $part) {
|
||||
$cookieParts = \explode('=', $part, 2);
|
||||
$key = \trim($cookieParts[0]);
|
||||
$value = isset($cookieParts[1])
|
||||
? \trim($cookieParts[1], " \n\r\t\0\x0B")
|
||||
: true;
|
||||
|
||||
// Only check for non-cookies when cookies have been found
|
||||
if (!isset($data['Name'])) {
|
||||
$data['Name'] = $key;
|
||||
$data['Value'] = $value;
|
||||
} else {
|
||||
foreach (\array_keys(self::$defaults) as $search) {
|
||||
if (!\strcasecmp($search, $key)) {
|
||||
if ($search === 'Max-Age') {
|
||||
if (is_numeric($value)) {
|
||||
$data[$search] = (int) $value;
|
||||
}
|
||||
} else {
|
||||
$data[$search] = $value;
|
||||
}
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
$data[$key] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return new self($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data Array of cookie data provided by a Cookie parser
|
||||
*/
|
||||
public function __construct(array $data = [])
|
||||
{
|
||||
$this->data = self::$defaults;
|
||||
|
||||
if (isset($data['Name'])) {
|
||||
$this->setName($data['Name']);
|
||||
}
|
||||
|
||||
if (isset($data['Value'])) {
|
||||
$this->setValue($data['Value']);
|
||||
}
|
||||
|
||||
if (isset($data['Domain'])) {
|
||||
$this->setDomain($data['Domain']);
|
||||
}
|
||||
|
||||
if (isset($data['Path'])) {
|
||||
$this->setPath($data['Path']);
|
||||
}
|
||||
|
||||
if (isset($data['Max-Age'])) {
|
||||
$this->setMaxAge($data['Max-Age']);
|
||||
}
|
||||
|
||||
if (isset($data['Expires'])) {
|
||||
$this->setExpires($data['Expires']);
|
||||
}
|
||||
|
||||
if (isset($data['Secure'])) {
|
||||
$this->setSecure($data['Secure']);
|
||||
}
|
||||
|
||||
if (isset($data['Discard'])) {
|
||||
$this->setDiscard($data['Discard']);
|
||||
}
|
||||
|
||||
if (isset($data['HttpOnly'])) {
|
||||
$this->setHttpOnly($data['HttpOnly']);
|
||||
}
|
||||
|
||||
// Set the remaining values that don't have extra validation logic
|
||||
foreach (array_diff(array_keys($data), array_keys(self::$defaults)) as $key) {
|
||||
$this->data[$key] = $data[$key];
|
||||
}
|
||||
|
||||
// Extract the Expires value and turn it into a UNIX timestamp if needed
|
||||
if (!$this->getExpires() && $this->getMaxAge()) {
|
||||
// Calculate the Expires date
|
||||
$this->setExpires(\time() + $this->getMaxAge());
|
||||
} elseif (null !== ($expires = $this->getExpires()) && !\is_numeric($expires)) {
|
||||
$this->setExpires($expires);
|
||||
}
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
$str = $this->data['Name'].'='.($this->data['Value'] ?? '').'; ';
|
||||
foreach ($this->data as $k => $v) {
|
||||
if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) {
|
||||
if ($k === 'Expires') {
|
||||
$str .= 'Expires='.\gmdate('D, d M Y H:i:s \G\M\T', $v).'; ';
|
||||
} else {
|
||||
$str .= ($v === true ? $k : "{$k}={$v}").'; ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return \rtrim($str, '; ');
|
||||
}
|
||||
|
||||
public function toArray(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cookie name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->data['Name'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cookie name.
|
||||
*
|
||||
* @param string $name Cookie name
|
||||
*/
|
||||
public function setName($name): void
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
$this->data['Name'] = (string) $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the cookie value.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->data['Value'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the cookie value.
|
||||
*
|
||||
* @param string $value Cookie value
|
||||
*/
|
||||
public function setValue($value): void
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
$this->data['Value'] = (string) $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the domain.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDomain()
|
||||
{
|
||||
return $this->data['Domain'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the domain of the cookie.
|
||||
*
|
||||
* @param string|null $domain
|
||||
*/
|
||||
public function setDomain($domain): void
|
||||
{
|
||||
if (!is_string($domain) && null !== $domain) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
$this->data['Domain'] = null === $domain ? null : (string) $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPath()
|
||||
{
|
||||
return $this->data['Path'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the path of the cookie.
|
||||
*
|
||||
* @param string $path Path of the cookie
|
||||
*/
|
||||
public function setPath($path): void
|
||||
{
|
||||
if (!is_string($path)) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a string to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
$this->data['Path'] = (string) $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum lifetime of the cookie in seconds.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getMaxAge()
|
||||
{
|
||||
return null === $this->data['Max-Age'] ? null : (int) $this->data['Max-Age'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the max-age of the cookie.
|
||||
*
|
||||
* @param int|null $maxAge Max age of the cookie in seconds
|
||||
*/
|
||||
public function setMaxAge($maxAge): void
|
||||
{
|
||||
if (!is_int($maxAge) && null !== $maxAge) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
$this->data['Max-Age'] = $maxAge === null ? null : (int) $maxAge;
|
||||
}
|
||||
|
||||
/**
|
||||
* The UNIX timestamp when the cookie Expires.
|
||||
*
|
||||
* @return string|int|null
|
||||
*/
|
||||
public function getExpires()
|
||||
{
|
||||
return $this->data['Expires'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the unix timestamp for which the cookie will expire.
|
||||
*
|
||||
* @param int|string|null $timestamp Unix timestamp or any English textual datetime description.
|
||||
*/
|
||||
public function setExpires($timestamp): void
|
||||
{
|
||||
if (!is_int($timestamp) && !is_string($timestamp) && null !== $timestamp) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an int, string or null to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
$this->data['Expires'] = null === $timestamp ? null : (\is_numeric($timestamp) ? (int) $timestamp : \strtotime((string) $timestamp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether or not this is a secure cookie.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getSecure()
|
||||
{
|
||||
return $this->data['Secure'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not the cookie is secure.
|
||||
*
|
||||
* @param bool $secure Set to true or false if secure
|
||||
*/
|
||||
public function setSecure($secure): void
|
||||
{
|
||||
if (!is_bool($secure)) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
$this->data['Secure'] = (bool) $secure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether or not this is a session cookie.
|
||||
*
|
||||
* @return bool|null
|
||||
*/
|
||||
public function getDiscard()
|
||||
{
|
||||
return $this->data['Discard'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not this is a session cookie.
|
||||
*
|
||||
* @param bool $discard Set to true or false if this is a session cookie
|
||||
*/
|
||||
public function setDiscard($discard): void
|
||||
{
|
||||
if (!is_bool($discard)) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
$this->data['Discard'] = (bool) $discard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether or not this is an HTTP only cookie.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getHttpOnly()
|
||||
{
|
||||
return $this->data['HttpOnly'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not this is an HTTP only cookie.
|
||||
*
|
||||
* @param bool $httpOnly Set to true or false if this is HTTP only
|
||||
*/
|
||||
public function setHttpOnly($httpOnly): void
|
||||
{
|
||||
if (!is_bool($httpOnly)) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing a bool to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
$this->data['HttpOnly'] = (bool) $httpOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the cookie matches a path value.
|
||||
*
|
||||
* A request-path path-matches a given cookie-path if at least one of
|
||||
* the following conditions holds:
|
||||
*
|
||||
* - The cookie-path and the request-path are identical.
|
||||
* - The cookie-path is a prefix of the request-path, and the last
|
||||
* character of the cookie-path is %x2F ("/").
|
||||
* - The cookie-path is a prefix of the request-path, and the first
|
||||
* character of the request-path that is not included in the cookie-
|
||||
* path is a %x2F ("/") character.
|
||||
*
|
||||
* @param string $requestPath Path to check against
|
||||
*/
|
||||
public function matchesPath(string $requestPath): bool
|
||||
{
|
||||
$cookiePath = $this->getPath();
|
||||
|
||||
// Match on exact matches or when path is the default empty "/"
|
||||
if ($cookiePath === '/' || $cookiePath == $requestPath) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ensure that the cookie-path is a prefix of the request path.
|
||||
if (0 !== \strpos($requestPath, $cookiePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Match if the last character of the cookie-path is "/"
|
||||
if (\substr($cookiePath, -1, 1) === '/') {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Match if the first character not included in cookie path is "/"
|
||||
return \substr($requestPath, \strlen($cookiePath), 1) === '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the cookie matches a domain value.
|
||||
*
|
||||
* @param string $domain Domain to check against
|
||||
*/
|
||||
public function matchesDomain(string $domain): bool
|
||||
{
|
||||
$cookieDomain = $this->getDomain();
|
||||
if (null === $cookieDomain) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Remove the leading '.' as per spec in RFC 6265.
|
||||
// https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.3
|
||||
$cookieDomain = \ltrim(\strtolower($cookieDomain), '.');
|
||||
|
||||
$domain = \strtolower($domain);
|
||||
|
||||
// Domain not set or exact match.
|
||||
if ('' === $cookieDomain || $domain === $cookieDomain) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Matching the subdomain according to RFC 6265.
|
||||
// https://datatracker.ietf.org/doc/html/rfc6265#section-5.1.3
|
||||
if (\filter_var($domain, \FILTER_VALIDATE_IP)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (bool) \preg_match('/\.'.\preg_quote($cookieDomain, '/').'$/', $domain);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the cookie is expired.
|
||||
*/
|
||||
public function isExpired(): bool
|
||||
{
|
||||
return $this->getExpires() !== null && \time() > $this->getExpires();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the cookie is valid according to RFC 6265.
|
||||
*
|
||||
* @return bool|string Returns true if valid or an error message if invalid
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
$name = $this->getName();
|
||||
if ($name === '') {
|
||||
return 'The cookie name must not be empty';
|
||||
}
|
||||
|
||||
// Check if any of the invalid characters are present in the cookie name
|
||||
if (\preg_match(
|
||||
'/[\x00-\x20\x22\x28-\x29\x2c\x2f\x3a-\x40\x5c\x7b\x7d\x7f]/',
|
||||
$name
|
||||
)) {
|
||||
return 'Cookie name must not contain invalid characters: ASCII '
|
||||
.'Control characters (0-31;127), space, tab and the '
|
||||
.'following characters: ()<>@,;:\"/?={}';
|
||||
}
|
||||
|
||||
// Value must not be null. 0 and empty string are valid. Empty strings
|
||||
// are technically against RFC 6265, but known to happen in the wild.
|
||||
$value = $this->getValue();
|
||||
if ($value === null) {
|
||||
return 'The cookie value must not be empty';
|
||||
}
|
||||
|
||||
// Domains must not be empty, but can be 0. "0" is not a valid internet
|
||||
// domain, but may be used as server name in a private network.
|
||||
$domain = $this->getDomain();
|
||||
if ($domain === null || $domain === '') {
|
||||
return 'The cookie domain must not be empty';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Exception when an HTTP error occurs (4xx or 5xx error)
|
||||
*/
|
||||
class BadResponseException extends RequestException
|
||||
{
|
||||
public function __construct(
|
||||
string $message,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response,
|
||||
\Throwable $previous = null,
|
||||
array $handlerContext = []
|
||||
) {
|
||||
parent::__construct($message, $request, $response, $previous, $handlerContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Current exception and the ones that extend it will always have a response.
|
||||
*/
|
||||
public function hasResponse(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function narrows the return type from the parent class and does not allow it to be nullable.
|
||||
*/
|
||||
public function getResponse(): ResponseInterface
|
||||
{
|
||||
/** @var ResponseInterface */
|
||||
return parent::getResponse();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
/**
|
||||
* Exception when a client error is encountered (4xx codes)
|
||||
*/
|
||||
class ClientException extends BadResponseException
|
||||
{
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
use Psr\Http\Client\NetworkExceptionInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Exception thrown when a connection cannot be established.
|
||||
*
|
||||
* Note that no response is present for a ConnectException
|
||||
*/
|
||||
class ConnectException extends TransferException implements NetworkExceptionInterface
|
||||
{
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $handlerContext;
|
||||
|
||||
public function __construct(
|
||||
string $message,
|
||||
RequestInterface $request,
|
||||
\Throwable $previous = null,
|
||||
array $handlerContext = []
|
||||
) {
|
||||
parent::__construct($message, 0, $previous);
|
||||
$this->request = $request;
|
||||
$this->handlerContext = $handlerContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request that caused the exception
|
||||
*/
|
||||
public function getRequest(): RequestInterface
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get contextual information about the error from the underlying handler.
|
||||
*
|
||||
* The contents of this array will vary depending on which handler you are
|
||||
* using. It may also be just an empty array. Relying on this data will
|
||||
* couple you to a specific handler, but can give more debug information
|
||||
* when needed.
|
||||
*/
|
||||
public function getHandlerContext(): array
|
||||
{
|
||||
return $this->handlerContext;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
|
||||
interface GuzzleException extends ClientExceptionInterface
|
||||
{
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
final class InvalidArgumentException extends \InvalidArgumentException implements GuzzleException
|
||||
{
|
||||
}
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
use GuzzleHttp\BodySummarizer;
|
||||
use GuzzleHttp\BodySummarizerInterface;
|
||||
use Psr\Http\Client\RequestExceptionInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\UriInterface;
|
||||
|
||||
/**
|
||||
* HTTP Request exception
|
||||
*/
|
||||
class RequestException extends TransferException implements RequestExceptionInterface
|
||||
{
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
private $request;
|
||||
|
||||
/**
|
||||
* @var ResponseInterface|null
|
||||
*/
|
||||
private $response;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $handlerContext;
|
||||
|
||||
public function __construct(
|
||||
string $message,
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response = null,
|
||||
\Throwable $previous = null,
|
||||
array $handlerContext = []
|
||||
) {
|
||||
// Set the code of the exception if the response is set and not future.
|
||||
$code = $response ? $response->getStatusCode() : 0;
|
||||
parent::__construct($message, $code, $previous);
|
||||
$this->request = $request;
|
||||
$this->response = $response;
|
||||
$this->handlerContext = $handlerContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap non-RequestExceptions with a RequestException
|
||||
*/
|
||||
public static function wrapException(RequestInterface $request, \Throwable $e): RequestException
|
||||
{
|
||||
return $e instanceof RequestException ? $e : new RequestException($e->getMessage(), $request, null, $e);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create a new exception with a normalized error message
|
||||
*
|
||||
* @param RequestInterface $request Request sent
|
||||
* @param ResponseInterface $response Response received
|
||||
* @param \Throwable|null $previous Previous exception
|
||||
* @param array $handlerContext Optional handler context
|
||||
* @param BodySummarizerInterface|null $bodySummarizer Optional body summarizer
|
||||
*/
|
||||
public static function create(
|
||||
RequestInterface $request,
|
||||
ResponseInterface $response = null,
|
||||
\Throwable $previous = null,
|
||||
array $handlerContext = [],
|
||||
BodySummarizerInterface $bodySummarizer = null
|
||||
): self {
|
||||
if (!$response) {
|
||||
return new self(
|
||||
'Error completing request',
|
||||
$request,
|
||||
null,
|
||||
$previous,
|
||||
$handlerContext
|
||||
);
|
||||
}
|
||||
|
||||
$level = (int) \floor($response->getStatusCode() / 100);
|
||||
if ($level === 4) {
|
||||
$label = 'Client error';
|
||||
$className = ClientException::class;
|
||||
} elseif ($level === 5) {
|
||||
$label = 'Server error';
|
||||
$className = ServerException::class;
|
||||
} else {
|
||||
$label = 'Unsuccessful request';
|
||||
$className = __CLASS__;
|
||||
}
|
||||
|
||||
$uri = $request->getUri();
|
||||
$uri = static::obfuscateUri($uri);
|
||||
|
||||
// Client Error: `GET /` resulted in a `404 Not Found` response:
|
||||
// <html> ... (truncated)
|
||||
$message = \sprintf(
|
||||
'%s: `%s %s` resulted in a `%s %s` response',
|
||||
$label,
|
||||
$request->getMethod(),
|
||||
$uri->__toString(),
|
||||
$response->getStatusCode(),
|
||||
$response->getReasonPhrase()
|
||||
);
|
||||
|
||||
$summary = ($bodySummarizer ?? new BodySummarizer())->summarize($response);
|
||||
|
||||
if ($summary !== null) {
|
||||
$message .= ":\n{$summary}\n";
|
||||
}
|
||||
|
||||
return new $className($message, $request, $response, $previous, $handlerContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obfuscates URI if there is a username and a password present
|
||||
*/
|
||||
private static function obfuscateUri(UriInterface $uri): UriInterface
|
||||
{
|
||||
$userInfo = $uri->getUserInfo();
|
||||
|
||||
if (false !== ($pos = \strpos($userInfo, ':'))) {
|
||||
return $uri->withUserInfo(\substr($userInfo, 0, $pos), '***');
|
||||
}
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the request that caused the exception
|
||||
*/
|
||||
public function getRequest(): RequestInterface
|
||||
{
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the associated response
|
||||
*/
|
||||
public function getResponse(): ?ResponseInterface
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a response was received
|
||||
*/
|
||||
public function hasResponse(): bool
|
||||
{
|
||||
return $this->response !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get contextual information about the error from the underlying handler.
|
||||
*
|
||||
* The contents of this array will vary depending on which handler you are
|
||||
* using. It may also be just an empty array. Relying on this data will
|
||||
* couple you to a specific handler, but can give more debug information
|
||||
* when needed.
|
||||
*/
|
||||
public function getHandlerContext(): array
|
||||
{
|
||||
return $this->handlerContext;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
/**
|
||||
* Exception when a server error is encountered (5xx codes)
|
||||
*/
|
||||
class ServerException extends BadResponseException
|
||||
{
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
class TooManyRedirectsException extends RequestException
|
||||
{
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Exception;
|
||||
|
||||
class TransferException extends \RuntimeException implements GuzzleException
|
||||
{
|
||||
}
|
||||
+638
@@ -0,0 +1,638 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Handler;
|
||||
|
||||
use GuzzleHttp\Exception\ConnectException;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Promise as P;
|
||||
use GuzzleHttp\Promise\FulfilledPromise;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use GuzzleHttp\Psr7\LazyOpenStream;
|
||||
use GuzzleHttp\TransferStats;
|
||||
use GuzzleHttp\Utils;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Creates curl resources from a request
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class CurlFactory implements CurlFactoryInterface
|
||||
{
|
||||
public const CURL_VERSION_STR = 'curl_version';
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public const LOW_CURL_VERSION_NUMBER = '7.21.2';
|
||||
|
||||
/**
|
||||
* @var resource[]|\CurlHandle[]
|
||||
*/
|
||||
private $handles = [];
|
||||
|
||||
/**
|
||||
* @var int Total number of idle handles to keep in cache
|
||||
*/
|
||||
private $maxHandles;
|
||||
|
||||
/**
|
||||
* @param int $maxHandles Maximum number of idle handles.
|
||||
*/
|
||||
public function __construct(int $maxHandles)
|
||||
{
|
||||
$this->maxHandles = $maxHandles;
|
||||
}
|
||||
|
||||
public function create(RequestInterface $request, array $options): EasyHandle
|
||||
{
|
||||
if (isset($options['curl']['body_as_string'])) {
|
||||
$options['_body_as_string'] = $options['curl']['body_as_string'];
|
||||
unset($options['curl']['body_as_string']);
|
||||
}
|
||||
|
||||
$easy = new EasyHandle();
|
||||
$easy->request = $request;
|
||||
$easy->options = $options;
|
||||
$conf = $this->getDefaultConf($easy);
|
||||
$this->applyMethod($easy, $conf);
|
||||
$this->applyHandlerOptions($easy, $conf);
|
||||
$this->applyHeaders($easy, $conf);
|
||||
unset($conf['_headers']);
|
||||
|
||||
// Add handler options from the request configuration options
|
||||
if (isset($options['curl'])) {
|
||||
$conf = \array_replace($conf, $options['curl']);
|
||||
}
|
||||
|
||||
$conf[\CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy);
|
||||
$easy->handle = $this->handles ? \array_pop($this->handles) : \curl_init();
|
||||
curl_setopt_array($easy->handle, $conf);
|
||||
|
||||
return $easy;
|
||||
}
|
||||
|
||||
public function release(EasyHandle $easy): void
|
||||
{
|
||||
$resource = $easy->handle;
|
||||
unset($easy->handle);
|
||||
|
||||
if (\count($this->handles) >= $this->maxHandles) {
|
||||
\curl_close($resource);
|
||||
} else {
|
||||
// Remove all callback functions as they can hold onto references
|
||||
// and are not cleaned up by curl_reset. Using curl_setopt_array
|
||||
// does not work for some reason, so removing each one
|
||||
// individually.
|
||||
\curl_setopt($resource, \CURLOPT_HEADERFUNCTION, null);
|
||||
\curl_setopt($resource, \CURLOPT_READFUNCTION, null);
|
||||
\curl_setopt($resource, \CURLOPT_WRITEFUNCTION, null);
|
||||
\curl_setopt($resource, \CURLOPT_PROGRESSFUNCTION, null);
|
||||
\curl_reset($resource);
|
||||
$this->handles[] = $resource;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Completes a cURL transaction, either returning a response promise or a
|
||||
* rejected promise.
|
||||
*
|
||||
* @param callable(RequestInterface, array): PromiseInterface $handler
|
||||
* @param CurlFactoryInterface $factory Dictates how the handle is released
|
||||
*/
|
||||
public static function finish(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface
|
||||
{
|
||||
if (isset($easy->options['on_stats'])) {
|
||||
self::invokeStats($easy);
|
||||
}
|
||||
|
||||
if (!$easy->response || $easy->errno) {
|
||||
return self::finishError($handler, $easy, $factory);
|
||||
}
|
||||
|
||||
// Return the response if it is present and there is no error.
|
||||
$factory->release($easy);
|
||||
|
||||
// Rewind the body of the response if possible.
|
||||
$body = $easy->response->getBody();
|
||||
if ($body->isSeekable()) {
|
||||
$body->rewind();
|
||||
}
|
||||
|
||||
return new FulfilledPromise($easy->response);
|
||||
}
|
||||
|
||||
private static function invokeStats(EasyHandle $easy): void
|
||||
{
|
||||
$curlStats = \curl_getinfo($easy->handle);
|
||||
$curlStats['appconnect_time'] = \curl_getinfo($easy->handle, \CURLINFO_APPCONNECT_TIME);
|
||||
$stats = new TransferStats(
|
||||
$easy->request,
|
||||
$easy->response,
|
||||
$curlStats['total_time'],
|
||||
$easy->errno,
|
||||
$curlStats
|
||||
);
|
||||
($easy->options['on_stats'])($stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callable(RequestInterface, array): PromiseInterface $handler
|
||||
*/
|
||||
private static function finishError(callable $handler, EasyHandle $easy, CurlFactoryInterface $factory): PromiseInterface
|
||||
{
|
||||
// Get error information and release the handle to the factory.
|
||||
$ctx = [
|
||||
'errno' => $easy->errno,
|
||||
'error' => \curl_error($easy->handle),
|
||||
'appconnect_time' => \curl_getinfo($easy->handle, \CURLINFO_APPCONNECT_TIME),
|
||||
] + \curl_getinfo($easy->handle);
|
||||
$ctx[self::CURL_VERSION_STR] = \curl_version()['version'];
|
||||
$factory->release($easy);
|
||||
|
||||
// Retry when nothing is present or when curl failed to rewind.
|
||||
if (empty($easy->options['_err_message']) && (!$easy->errno || $easy->errno == 65)) {
|
||||
return self::retryFailedRewind($handler, $easy, $ctx);
|
||||
}
|
||||
|
||||
return self::createRejection($easy, $ctx);
|
||||
}
|
||||
|
||||
private static function createRejection(EasyHandle $easy, array $ctx): PromiseInterface
|
||||
{
|
||||
static $connectionErrors = [
|
||||
\CURLE_OPERATION_TIMEOUTED => true,
|
||||
\CURLE_COULDNT_RESOLVE_HOST => true,
|
||||
\CURLE_COULDNT_CONNECT => true,
|
||||
\CURLE_SSL_CONNECT_ERROR => true,
|
||||
\CURLE_GOT_NOTHING => true,
|
||||
];
|
||||
|
||||
if ($easy->createResponseException) {
|
||||
return P\Create::rejectionFor(
|
||||
new RequestException(
|
||||
'An error was encountered while creating the response',
|
||||
$easy->request,
|
||||
$easy->response,
|
||||
$easy->createResponseException,
|
||||
$ctx
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// If an exception was encountered during the onHeaders event, then
|
||||
// return a rejected promise that wraps that exception.
|
||||
if ($easy->onHeadersException) {
|
||||
return P\Create::rejectionFor(
|
||||
new RequestException(
|
||||
'An error was encountered during the on_headers event',
|
||||
$easy->request,
|
||||
$easy->response,
|
||||
$easy->onHeadersException,
|
||||
$ctx
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$message = \sprintf(
|
||||
'cURL error %s: %s (%s)',
|
||||
$ctx['errno'],
|
||||
$ctx['error'],
|
||||
'see https://curl.haxx.se/libcurl/c/libcurl-errors.html'
|
||||
);
|
||||
$uriString = (string) $easy->request->getUri();
|
||||
if ($uriString !== '' && false === \strpos($ctx['error'], $uriString)) {
|
||||
$message .= \sprintf(' for %s', $uriString);
|
||||
}
|
||||
|
||||
// Create a connection exception if it was a specific error code.
|
||||
$error = isset($connectionErrors[$easy->errno])
|
||||
? new ConnectException($message, $easy->request, null, $ctx)
|
||||
: new RequestException($message, $easy->request, $easy->response, null, $ctx);
|
||||
|
||||
return P\Create::rejectionFor($error);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int|string, mixed>
|
||||
*/
|
||||
private function getDefaultConf(EasyHandle $easy): array
|
||||
{
|
||||
$conf = [
|
||||
'_headers' => $easy->request->getHeaders(),
|
||||
\CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(),
|
||||
\CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''),
|
||||
\CURLOPT_RETURNTRANSFER => false,
|
||||
\CURLOPT_HEADER => false,
|
||||
\CURLOPT_CONNECTTIMEOUT => 300,
|
||||
];
|
||||
|
||||
if (\defined('CURLOPT_PROTOCOLS')) {
|
||||
$conf[\CURLOPT_PROTOCOLS] = \CURLPROTO_HTTP | \CURLPROTO_HTTPS;
|
||||
}
|
||||
|
||||
$version = $easy->request->getProtocolVersion();
|
||||
if ($version == 1.1) {
|
||||
$conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_1;
|
||||
} elseif ($version == 2.0) {
|
||||
$conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_2_0;
|
||||
} else {
|
||||
$conf[\CURLOPT_HTTP_VERSION] = \CURL_HTTP_VERSION_1_0;
|
||||
}
|
||||
|
||||
return $conf;
|
||||
}
|
||||
|
||||
private function applyMethod(EasyHandle $easy, array &$conf): void
|
||||
{
|
||||
$body = $easy->request->getBody();
|
||||
$size = $body->getSize();
|
||||
|
||||
if ($size === null || $size > 0) {
|
||||
$this->applyBody($easy->request, $easy->options, $conf);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$method = $easy->request->getMethod();
|
||||
if ($method === 'PUT' || $method === 'POST') {
|
||||
// See https://datatracker.ietf.org/doc/html/rfc7230#section-3.3.2
|
||||
if (!$easy->request->hasHeader('Content-Length')) {
|
||||
$conf[\CURLOPT_HTTPHEADER][] = 'Content-Length: 0';
|
||||
}
|
||||
} elseif ($method === 'HEAD') {
|
||||
$conf[\CURLOPT_NOBODY] = true;
|
||||
unset(
|
||||
$conf[\CURLOPT_WRITEFUNCTION],
|
||||
$conf[\CURLOPT_READFUNCTION],
|
||||
$conf[\CURLOPT_FILE],
|
||||
$conf[\CURLOPT_INFILE]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function applyBody(RequestInterface $request, array $options, array &$conf): void
|
||||
{
|
||||
$size = $request->hasHeader('Content-Length')
|
||||
? (int) $request->getHeaderLine('Content-Length')
|
||||
: null;
|
||||
|
||||
// Send the body as a string if the size is less than 1MB OR if the
|
||||
// [curl][body_as_string] request value is set.
|
||||
if (($size !== null && $size < 1000000) || !empty($options['_body_as_string'])) {
|
||||
$conf[\CURLOPT_POSTFIELDS] = (string) $request->getBody();
|
||||
// Don't duplicate the Content-Length header
|
||||
$this->removeHeader('Content-Length', $conf);
|
||||
$this->removeHeader('Transfer-Encoding', $conf);
|
||||
} else {
|
||||
$conf[\CURLOPT_UPLOAD] = true;
|
||||
if ($size !== null) {
|
||||
$conf[\CURLOPT_INFILESIZE] = $size;
|
||||
$this->removeHeader('Content-Length', $conf);
|
||||
}
|
||||
$body = $request->getBody();
|
||||
if ($body->isSeekable()) {
|
||||
$body->rewind();
|
||||
}
|
||||
$conf[\CURLOPT_READFUNCTION] = static function ($ch, $fd, $length) use ($body) {
|
||||
return $body->read($length);
|
||||
};
|
||||
}
|
||||
|
||||
// If the Expect header is not present, prevent curl from adding it
|
||||
if (!$request->hasHeader('Expect')) {
|
||||
$conf[\CURLOPT_HTTPHEADER][] = 'Expect:';
|
||||
}
|
||||
|
||||
// cURL sometimes adds a content-type by default. Prevent this.
|
||||
if (!$request->hasHeader('Content-Type')) {
|
||||
$conf[\CURLOPT_HTTPHEADER][] = 'Content-Type:';
|
||||
}
|
||||
}
|
||||
|
||||
private function applyHeaders(EasyHandle $easy, array &$conf): void
|
||||
{
|
||||
foreach ($conf['_headers'] as $name => $values) {
|
||||
foreach ($values as $value) {
|
||||
$value = (string) $value;
|
||||
if ($value === '') {
|
||||
// cURL requires a special format for empty headers.
|
||||
// See https://github.com/guzzle/guzzle/issues/1882 for more details.
|
||||
$conf[\CURLOPT_HTTPHEADER][] = "$name;";
|
||||
} else {
|
||||
$conf[\CURLOPT_HTTPHEADER][] = "$name: $value";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the Accept header if one was not set
|
||||
if (!$easy->request->hasHeader('Accept')) {
|
||||
$conf[\CURLOPT_HTTPHEADER][] = 'Accept:';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a header from the options array.
|
||||
*
|
||||
* @param string $name Case-insensitive header to remove
|
||||
* @param array $options Array of options to modify
|
||||
*/
|
||||
private function removeHeader(string $name, array &$options): void
|
||||
{
|
||||
foreach (\array_keys($options['_headers']) as $key) {
|
||||
if (!\strcasecmp($key, $name)) {
|
||||
unset($options['_headers'][$key]);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function applyHandlerOptions(EasyHandle $easy, array &$conf): void
|
||||
{
|
||||
$options = $easy->options;
|
||||
if (isset($options['verify'])) {
|
||||
if ($options['verify'] === false) {
|
||||
unset($conf[\CURLOPT_CAINFO]);
|
||||
$conf[\CURLOPT_SSL_VERIFYHOST] = 0;
|
||||
$conf[\CURLOPT_SSL_VERIFYPEER] = false;
|
||||
} else {
|
||||
$conf[\CURLOPT_SSL_VERIFYHOST] = 2;
|
||||
$conf[\CURLOPT_SSL_VERIFYPEER] = true;
|
||||
if (\is_string($options['verify'])) {
|
||||
// Throw an error if the file/folder/link path is not valid or doesn't exist.
|
||||
if (!\file_exists($options['verify'])) {
|
||||
throw new \InvalidArgumentException("SSL CA bundle not found: {$options['verify']}");
|
||||
}
|
||||
// If it's a directory or a link to a directory use CURLOPT_CAPATH.
|
||||
// If not, it's probably a file, or a link to a file, so use CURLOPT_CAINFO.
|
||||
if (
|
||||
\is_dir($options['verify'])
|
||||
|| (
|
||||
\is_link($options['verify']) === true
|
||||
&& ($verifyLink = \readlink($options['verify'])) !== false
|
||||
&& \is_dir($verifyLink)
|
||||
)
|
||||
) {
|
||||
$conf[\CURLOPT_CAPATH] = $options['verify'];
|
||||
} else {
|
||||
$conf[\CURLOPT_CAINFO] = $options['verify'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options['curl'][\CURLOPT_ENCODING]) && !empty($options['decode_content'])) {
|
||||
$accept = $easy->request->getHeaderLine('Accept-Encoding');
|
||||
if ($accept) {
|
||||
$conf[\CURLOPT_ENCODING] = $accept;
|
||||
} else {
|
||||
// The empty string enables all available decoders and implicitly
|
||||
// sets a matching 'Accept-Encoding' header.
|
||||
$conf[\CURLOPT_ENCODING] = '';
|
||||
// But as the user did not specify any acceptable encodings we need
|
||||
// to overwrite this implicit header with an empty one.
|
||||
$conf[\CURLOPT_HTTPHEADER][] = 'Accept-Encoding:';
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options['sink'])) {
|
||||
// Use a default temp stream if no sink was set.
|
||||
$options['sink'] = \GuzzleHttp\Psr7\Utils::tryFopen('php://temp', 'w+');
|
||||
}
|
||||
$sink = $options['sink'];
|
||||
if (!\is_string($sink)) {
|
||||
$sink = \GuzzleHttp\Psr7\Utils::streamFor($sink);
|
||||
} elseif (!\is_dir(\dirname($sink))) {
|
||||
// Ensure that the directory exists before failing in curl.
|
||||
throw new \RuntimeException(\sprintf('Directory %s does not exist for sink value of %s', \dirname($sink), $sink));
|
||||
} else {
|
||||
$sink = new LazyOpenStream($sink, 'w+');
|
||||
}
|
||||
$easy->sink = $sink;
|
||||
$conf[\CURLOPT_WRITEFUNCTION] = static function ($ch, $write) use ($sink): int {
|
||||
return $sink->write($write);
|
||||
};
|
||||
|
||||
$timeoutRequiresNoSignal = false;
|
||||
if (isset($options['timeout'])) {
|
||||
$timeoutRequiresNoSignal |= $options['timeout'] < 1;
|
||||
$conf[\CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000;
|
||||
}
|
||||
|
||||
// CURL default value is CURL_IPRESOLVE_WHATEVER
|
||||
if (isset($options['force_ip_resolve'])) {
|
||||
if ('v4' === $options['force_ip_resolve']) {
|
||||
$conf[\CURLOPT_IPRESOLVE] = \CURL_IPRESOLVE_V4;
|
||||
} elseif ('v6' === $options['force_ip_resolve']) {
|
||||
$conf[\CURLOPT_IPRESOLVE] = \CURL_IPRESOLVE_V6;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['connect_timeout'])) {
|
||||
$timeoutRequiresNoSignal |= $options['connect_timeout'] < 1;
|
||||
$conf[\CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000;
|
||||
}
|
||||
|
||||
if ($timeoutRequiresNoSignal && \strtoupper(\substr(\PHP_OS, 0, 3)) !== 'WIN') {
|
||||
$conf[\CURLOPT_NOSIGNAL] = true;
|
||||
}
|
||||
|
||||
if (isset($options['proxy'])) {
|
||||
if (!\is_array($options['proxy'])) {
|
||||
$conf[\CURLOPT_PROXY] = $options['proxy'];
|
||||
} else {
|
||||
$scheme = $easy->request->getUri()->getScheme();
|
||||
if (isset($options['proxy'][$scheme])) {
|
||||
$host = $easy->request->getUri()->getHost();
|
||||
if (isset($options['proxy']['no']) && Utils::isHostInNoProxy($host, $options['proxy']['no'])) {
|
||||
unset($conf[\CURLOPT_PROXY]);
|
||||
} else {
|
||||
$conf[\CURLOPT_PROXY] = $options['proxy'][$scheme];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['crypto_method'])) {
|
||||
if (\STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT === $options['crypto_method']) {
|
||||
if (!defined('CURL_SSLVERSION_TLSv1_0')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.0 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_0;
|
||||
} elseif (\STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT === $options['crypto_method']) {
|
||||
if (!defined('CURL_SSLVERSION_TLSv1_1')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.1 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_1;
|
||||
} elseif (\STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT === $options['crypto_method']) {
|
||||
if (!defined('CURL_SSLVERSION_TLSv1_2')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.2 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_2;
|
||||
} elseif (defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT') && \STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT === $options['crypto_method']) {
|
||||
if (!defined('CURL_SSLVERSION_TLSv1_3')) {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: TLS 1.3 not supported by your version of cURL');
|
||||
}
|
||||
$conf[\CURLOPT_SSLVERSION] = \CURL_SSLVERSION_TLSv1_3;
|
||||
} else {
|
||||
throw new \InvalidArgumentException('Invalid crypto_method request option: unknown version provided');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($options['cert'])) {
|
||||
$cert = $options['cert'];
|
||||
if (\is_array($cert)) {
|
||||
$conf[\CURLOPT_SSLCERTPASSWD] = $cert[1];
|
||||
$cert = $cert[0];
|
||||
}
|
||||
if (!\file_exists($cert)) {
|
||||
throw new \InvalidArgumentException("SSL certificate not found: {$cert}");
|
||||
}
|
||||
// OpenSSL (versions 0.9.3 and later) also support "P12" for PKCS#12-encoded files.
|
||||
// see https://curl.se/libcurl/c/CURLOPT_SSLCERTTYPE.html
|
||||
$ext = pathinfo($cert, \PATHINFO_EXTENSION);
|
||||
if (preg_match('#^(der|p12)$#i', $ext)) {
|
||||
$conf[\CURLOPT_SSLCERTTYPE] = strtoupper($ext);
|
||||
}
|
||||
$conf[\CURLOPT_SSLCERT] = $cert;
|
||||
}
|
||||
|
||||
if (isset($options['ssl_key'])) {
|
||||
if (\is_array($options['ssl_key'])) {
|
||||
if (\count($options['ssl_key']) === 2) {
|
||||
[$sslKey, $conf[\CURLOPT_SSLKEYPASSWD]] = $options['ssl_key'];
|
||||
} else {
|
||||
[$sslKey] = $options['ssl_key'];
|
||||
}
|
||||
}
|
||||
|
||||
$sslKey = $sslKey ?? $options['ssl_key'];
|
||||
|
||||
if (!\file_exists($sslKey)) {
|
||||
throw new \InvalidArgumentException("SSL private key not found: {$sslKey}");
|
||||
}
|
||||
$conf[\CURLOPT_SSLKEY] = $sslKey;
|
||||
}
|
||||
|
||||
if (isset($options['progress'])) {
|
||||
$progress = $options['progress'];
|
||||
if (!\is_callable($progress)) {
|
||||
throw new \InvalidArgumentException('progress client option must be callable');
|
||||
}
|
||||
$conf[\CURLOPT_NOPROGRESS] = false;
|
||||
$conf[\CURLOPT_PROGRESSFUNCTION] = static function ($resource, int $downloadSize, int $downloaded, int $uploadSize, int $uploaded) use ($progress) {
|
||||
$progress($downloadSize, $downloaded, $uploadSize, $uploaded);
|
||||
};
|
||||
}
|
||||
|
||||
if (!empty($options['debug'])) {
|
||||
$conf[\CURLOPT_STDERR] = Utils::debugResource($options['debug']);
|
||||
$conf[\CURLOPT_VERBOSE] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function ensures that a response was set on a transaction. If one
|
||||
* was not set, then the request is retried if possible. This error
|
||||
* typically means you are sending a payload, curl encountered a
|
||||
* "Connection died, retrying a fresh connect" error, tried to rewind the
|
||||
* stream, and then encountered a "necessary data rewind wasn't possible"
|
||||
* error, causing the request to be sent through curl_multi_info_read()
|
||||
* without an error status.
|
||||
*
|
||||
* @param callable(RequestInterface, array): PromiseInterface $handler
|
||||
*/
|
||||
private static function retryFailedRewind(callable $handler, EasyHandle $easy, array $ctx): PromiseInterface
|
||||
{
|
||||
try {
|
||||
// Only rewind if the body has been read from.
|
||||
$body = $easy->request->getBody();
|
||||
if ($body->tell() > 0) {
|
||||
$body->rewind();
|
||||
}
|
||||
} catch (\RuntimeException $e) {
|
||||
$ctx['error'] = 'The connection unexpectedly failed without '
|
||||
.'providing an error. The request would have been retried, '
|
||||
.'but attempting to rewind the request body failed. '
|
||||
.'Exception: '.$e;
|
||||
|
||||
return self::createRejection($easy, $ctx);
|
||||
}
|
||||
|
||||
// Retry no more than 3 times before giving up.
|
||||
if (!isset($easy->options['_curl_retries'])) {
|
||||
$easy->options['_curl_retries'] = 1;
|
||||
} elseif ($easy->options['_curl_retries'] == 2) {
|
||||
$ctx['error'] = 'The cURL request was retried 3 times '
|
||||
.'and did not succeed. The most likely reason for the failure '
|
||||
.'is that cURL was unable to rewind the body of the request '
|
||||
.'and subsequent retries resulted in the same error. Turn on '
|
||||
.'the debug option to see what went wrong. See '
|
||||
.'https://bugs.php.net/bug.php?id=47204 for more information.';
|
||||
|
||||
return self::createRejection($easy, $ctx);
|
||||
} else {
|
||||
++$easy->options['_curl_retries'];
|
||||
}
|
||||
|
||||
return $handler($easy->request, $easy->options);
|
||||
}
|
||||
|
||||
private function createHeaderFn(EasyHandle $easy): callable
|
||||
{
|
||||
if (isset($easy->options['on_headers'])) {
|
||||
$onHeaders = $easy->options['on_headers'];
|
||||
|
||||
if (!\is_callable($onHeaders)) {
|
||||
throw new \InvalidArgumentException('on_headers must be callable');
|
||||
}
|
||||
} else {
|
||||
$onHeaders = null;
|
||||
}
|
||||
|
||||
return static function ($ch, $h) use (
|
||||
$onHeaders,
|
||||
$easy,
|
||||
&$startingResponse
|
||||
) {
|
||||
$value = \trim($h);
|
||||
if ($value === '') {
|
||||
$startingResponse = true;
|
||||
try {
|
||||
$easy->createResponse();
|
||||
} catch (\Exception $e) {
|
||||
$easy->createResponseException = $e;
|
||||
|
||||
return -1;
|
||||
}
|
||||
if ($onHeaders !== null) {
|
||||
try {
|
||||
$onHeaders($easy->response);
|
||||
} catch (\Exception $e) {
|
||||
// Associate the exception with the handle and trigger
|
||||
// a curl header write error by returning 0.
|
||||
$easy->onHeadersException = $e;
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
} elseif ($startingResponse) {
|
||||
$startingResponse = false;
|
||||
$easy->headers = [$value];
|
||||
} else {
|
||||
$easy->headers[] = $value;
|
||||
}
|
||||
|
||||
return \strlen($h);
|
||||
};
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
foreach ($this->handles as $id => $handle) {
|
||||
\curl_close($handle);
|
||||
unset($this->handles[$id]);
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Handler;
|
||||
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
interface CurlFactoryInterface
|
||||
{
|
||||
/**
|
||||
* Creates a cURL handle resource.
|
||||
*
|
||||
* @param RequestInterface $request Request
|
||||
* @param array $options Transfer options
|
||||
*
|
||||
* @throws \RuntimeException when an option cannot be applied
|
||||
*/
|
||||
public function create(RequestInterface $request, array $options): EasyHandle;
|
||||
|
||||
/**
|
||||
* Release an easy handle, allowing it to be reused or closed.
|
||||
*
|
||||
* This function must call unset on the easy handle's "handle" property.
|
||||
*/
|
||||
public function release(EasyHandle $easy): void;
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Handler;
|
||||
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* HTTP handler that uses cURL easy handles as a transport layer.
|
||||
*
|
||||
* When using the CurlHandler, custom curl options can be specified as an
|
||||
* associative array of curl option constants mapping to values in the
|
||||
* **curl** key of the "client" key of the request.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class CurlHandler
|
||||
{
|
||||
/**
|
||||
* @var CurlFactoryInterface
|
||||
*/
|
||||
private $factory;
|
||||
|
||||
/**
|
||||
* Accepts an associative array of options:
|
||||
*
|
||||
* - handle_factory: Optional curl factory used to create cURL handles.
|
||||
*
|
||||
* @param array{handle_factory?: ?CurlFactoryInterface} $options Array of options to use with the handler
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->factory = $options['handle_factory']
|
||||
?? new CurlFactory(3);
|
||||
}
|
||||
|
||||
public function __invoke(RequestInterface $request, array $options): PromiseInterface
|
||||
{
|
||||
if (isset($options['delay'])) {
|
||||
\usleep($options['delay'] * 1000);
|
||||
}
|
||||
|
||||
$easy = $this->factory->create($request, $options);
|
||||
\curl_exec($easy->handle);
|
||||
$easy->errno = \curl_errno($easy->handle);
|
||||
|
||||
return CurlFactory::finish($this, $easy, $this->factory);
|
||||
}
|
||||
}
|
||||
+267
@@ -0,0 +1,267 @@
|
||||
<?php
|
||||
|
||||
namespace GuzzleHttp\Handler;
|
||||
|
||||
use GuzzleHttp\Promise as P;
|
||||
use GuzzleHttp\Promise\Promise;
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use GuzzleHttp\Utils;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
* Returns an asynchronous response using curl_multi_* functions.
|
||||
*
|
||||
* When using the CurlMultiHandler, custom curl options can be specified as an
|
||||
* associative array of curl option constants mapping to values in the
|
||||
* **curl** key of the provided request options.
|
||||
*
|
||||
* @final
|
||||
*/
|
||||
class CurlMultiHandler
|
||||
{
|
||||
/**
|
||||
* @var CurlFactoryInterface
|
||||
*/
|
||||
private $factory;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $selectTimeout;
|
||||
|
||||
/**
|
||||
* @var int Will be higher than 0 when `curl_multi_exec` is still running.
|
||||
*/
|
||||
private $active = 0;
|
||||
|
||||
/**
|
||||
* @var array Request entry handles, indexed by handle id in `addRequest`.
|
||||
*
|
||||
* @see CurlMultiHandler::addRequest
|
||||
*/
|
||||
private $handles = [];
|
||||
|
||||
/**
|
||||
* @var array<int, float> An array of delay times, indexed by handle id in `addRequest`.
|
||||
*
|
||||
* @see CurlMultiHandler::addRequest
|
||||
*/
|
||||
private $delays = [];
|
||||
|
||||
/**
|
||||
* @var array<mixed> An associative array of CURLMOPT_* options and corresponding values for curl_multi_setopt()
|
||||
*/
|
||||
private $options = [];
|
||||
|
||||
/** @var resource|\CurlMultiHandle */
|
||||
private $_mh;
|
||||
|
||||
/**
|
||||
* This handler accepts the following options:
|
||||
*
|
||||
* - handle_factory: An optional factory used to create curl handles
|
||||
* - select_timeout: Optional timeout (in seconds) to block before timing
|
||||
* out while selecting curl handles. Defaults to 1 second.
|
||||
* - options: An associative array of CURLMOPT_* options and
|
||||
* corresponding values for curl_multi_setopt()
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->factory = $options['handle_factory'] ?? new CurlFactory(50);
|
||||
|
||||
if (isset($options['select_timeout'])) {
|
||||
$this->selectTimeout = $options['select_timeout'];
|
||||
} elseif ($selectTimeout = Utils::getenv('GUZZLE_CURL_SELECT_TIMEOUT')) {
|
||||
@trigger_error('Since guzzlehttp/guzzle 7.2.0: Using environment variable GUZZLE_CURL_SELECT_TIMEOUT is deprecated. Use option "select_timeout" instead.', \E_USER_DEPRECATED);
|
||||
$this->selectTimeout = (int) $selectTimeout;
|
||||
} else {
|
||||
$this->selectTimeout = 1;
|
||||
}
|
||||
|
||||
$this->options = $options['options'] ?? [];
|
||||
|
||||
// unsetting the property forces the first access to go through
|
||||
// __get().
|
||||
unset($this->_mh);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return resource|\CurlMultiHandle
|
||||
*
|
||||
* @throws \BadMethodCallException when another field as `_mh` will be gotten
|
||||
* @throws \RuntimeException when curl can not initialize a multi handle
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
if ($name !== '_mh') {
|
||||
throw new \BadMethodCallException("Can not get other property as '_mh'.");
|
||||
}
|
||||
|
||||
$multiHandle = \curl_multi_init();
|
||||
|
||||
if (false === $multiHandle) {
|
||||
throw new \RuntimeException('Can not initialize curl multi handle.');
|
||||
}
|
||||
|
||||
$this->_mh = $multiHandle;
|
||||
|
||||
foreach ($this->options as $option => $value) {
|
||||
// A warning is raised in case of a wrong option.
|
||||
curl_multi_setopt($this->_mh, $option, $value);
|
||||
}
|
||||
|
||||
return $this->_mh;
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
if (isset($this->_mh)) {
|
||||
\curl_multi_close($this->_mh);
|
||||
unset($this->_mh);
|
||||
}
|
||||
}
|
||||
|
||||
public function __invoke(RequestInterface $request, array $options): PromiseInterface
|
||||
{
|
||||
$easy = $this->factory->create($request, $options);
|
||||
$id = (int) $easy->handle;
|
||||
|
||||
$promise = new Promise(
|
||||
[$this, 'execute'],
|
||||
function () use ($id) {
|
||||
return $this->cancel($id);
|
||||
}
|
||||
);
|
||||
|
||||
$this->addRequest(['easy' => $easy, 'deferred' => $promise]);
|
||||
|
||||
return $promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticks the curl event loop.
|
||||
*/
|
||||
public function tick(): void
|
||||
{
|
||||
// Add any delayed handles if needed.
|
||||
if ($this->delays) {
|
||||
$currentTime = Utils::currentTime();
|
||||
foreach ($this->delays as $id => $delay) {
|
||||
if ($currentTime >= $delay) {
|
||||
unset($this->delays[$id]);
|
||||
\curl_multi_add_handle(
|
||||
$this->_mh,
|
||||
$this->handles[$id]['easy']->handle
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Step through the task queue which may add additional requests.
|
||||
P\Utils::queue()->run();
|
||||
|
||||
if ($this->active && \curl_multi_select($this->_mh, $this->selectTimeout) === -1) {
|
||||
// Perform a usleep if a select returns -1.
|
||||
// See: https://bugs.php.net/bug.php?id=61141
|
||||
\usleep(250);
|
||||
}
|
||||
|
||||
while (\curl_multi_exec($this->_mh, $this->active) === \CURLM_CALL_MULTI_PERFORM) {
|
||||
}
|
||||
|
||||
$this->processMessages();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs until all outstanding connections have completed.
|
||||
*/
|
||||
public function execute(): void
|
||||
{
|
||||
$queue = P\Utils::queue();
|
||||
|
||||
while ($this->handles || !$queue->isEmpty()) {
|
||||
// If there are no transfers, then sleep for the next delay
|
||||
if (!$this->active && $this->delays) {
|
||||
\usleep($this->timeToNext());
|
||||
}
|
||||
$this->tick();
|
||||
}
|
||||
}
|
||||
|
||||
private function addRequest(array $entry): void
|
||||
{
|
||||
$easy = $entry['easy'];
|
||||
$id = (int) $easy->handle;
|
||||
$this->handles[$id] = $entry;
|
||||
if (empty($easy->options['delay'])) {
|
||||
\curl_multi_add_handle($this->_mh, $easy->handle);
|
||||
} else {
|
||||
$this->delays[$id] = Utils::currentTime() + ($easy->options['delay'] / 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels a handle from sending and removes references to it.
|
||||
*
|
||||
* @param int $id Handle ID to cancel and remove.
|
||||
*
|
||||
* @return bool True on success, false on failure.
|
||||
*/
|
||||
private function cancel($id): bool
|
||||
{
|
||||
if (!is_int($id)) {
|
||||
trigger_deprecation('guzzlehttp/guzzle', '7.4', 'Not passing an integer to %s::%s() is deprecated and will cause an error in 8.0.', __CLASS__, __FUNCTION__);
|
||||
}
|
||||
|
||||
// Cannot cancel if it has been processed.
|
||||
if (!isset($this->handles[$id])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$handle = $this->handles[$id]['easy']->handle;
|
||||
unset($this->delays[$id], $this->handles[$id]);
|
||||
\curl_multi_remove_handle($this->_mh, $handle);
|
||||
\curl_close($handle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function processMessages(): void
|
||||
{
|
||||
while ($done = \curl_multi_info_read($this->_mh)) {
|
||||
if ($done['msg'] !== \CURLMSG_DONE) {
|
||||
// if it's not done, then it would be premature to remove the handle. ref https://github.com/guzzle/guzzle/pull/2892#issuecomment-945150216
|
||||
continue;
|
||||
}
|
||||
$id = (int) $done['handle'];
|
||||
\curl_multi_remove_handle($this->_mh, $done['handle']);
|
||||
|
||||
if (!isset($this->handles[$id])) {
|
||||
// Probably was cancelled.
|
||||
continue;
|
||||
}
|
||||
|
||||
$entry = $this->handles[$id];
|
||||
unset($this->handles[$id], $this->delays[$id]);
|
||||
$entry['easy']->errno = $done['result'];
|
||||
$entry['deferred']->resolve(
|
||||
CurlFactory::finish($this, $entry['easy'], $this->factory)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function timeToNext(): int
|
||||
{
|
||||
$currentTime = Utils::currentTime();
|
||||
$nextTime = \PHP_INT_MAX;
|
||||
foreach ($this->delays as $time) {
|
||||
if ($time < $nextTime) {
|
||||
$nextTime = $time;
|
||||
}
|
||||
}
|
||||
|
||||
return ((int) \max(0, $nextTime - $currentTime)) * 1000000;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user