Skip to content

Commit

Permalink
Merge pull request #1228 from geekwright/patch_1227
Browse files Browse the repository at this point in the history
Missing files from PR 1227
  • Loading branch information
geekwright authored Apr 17, 2022
2 parents afb1618 + 5d01adb commit dfc2ef6
Show file tree
Hide file tree
Showing 7 changed files with 259 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor/
composer.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Vasil Rangelov

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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "boenrobot/money_format_polyfill",
"description": "A polyfill for PHP's money_format() function, intended for Windows. Source from Rafael M. Salvioni (in the comments for money_format()).",
"license": "MIT",
"authors": [
{
"name": "Vasil Rangelov",
"email": "[email protected]"
}
],
"require": {
},
"require-dev": {
"squizlabs/php_codesniffer": "@stable"
},
"suggest": {
"boenrobot/composer-install-library-of-functions": "To remove the polyfill from the autoloader if not needed."
},
"extra": {
"functionmap": {
"autoload": {
"money_format": "src/money_format.php"
}
}
},
"autoload": {
"files": [
"src/money_format.php"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset name="money_format">
<description>The money_format polyfill CS (which is PEAR).</description>
<file>src</file>
<!-- Include the whole PEAR standard -->
<rule ref="PEAR">
<exclude name="PEAR.NamingConventions.ValidFunctionName" />
<exclude name="PEAR.Commenting.FileComment" />
</rule>

</ruleset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php

if (!function_exists('money_format')) {

/**
* Formats a number as a currency string.
*
* @param string $format The format specification.
* See {@link http://php.net/money_format}.
* @param number $number The number to be formatted.
*
* @return string Returns the formatted string.
* Characters before and after the formatting string will be returned unchanged.
*/
function money_format($format, $number)
{
$regex = '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?'.
'(?:#([0-9]+))?(?:\.([0-9]+))?([in%])/';
if (setlocale(LC_MONETARY, 0) == 'C') {
setlocale(LC_MONETARY, '');
}
$locale = localeconv();
preg_match_all($regex, $format, $matches, PREG_SET_ORDER);
foreach ($matches as $fmatch) {
$value = floatval($number);
$flags = array(
'fillchar' => preg_match('/\=(.)/', $fmatch[1], $match) ?
$match[1] : ' ',
'nogroup' => preg_match('/\^/', $fmatch[1]) > 0,
'usesignal' => preg_match('/\+|\(/', $fmatch[1], $match) ?
$match[0] : '+',
'nosimbol' => preg_match('/\!/', $fmatch[1]) > 0,
'isleft' => preg_match('/\-/', $fmatch[1]) > 0
);
$width = trim($fmatch[2]) ? (int)$fmatch[2] : 0;
$left = trim($fmatch[3]) ? (int)$fmatch[3] : 0;
$right = trim($fmatch[4]) === ''
? $locale['int_frac_digits'] : (int)$fmatch[4];
$conversion = $fmatch[5];

$positive = true;
if ($value < 0) {
$positive = false;
$value *= -1;
}
$letter = $positive ? 'p' : 'n';

$prefix = $suffix = $cprefix = $csuffix = $signal = '';

$signal = $positive
? $locale['positive_sign'] : $locale['negative_sign'];
switch (true) {
case $locale["{$letter}_sign_posn"] == 1 && $flags['usesignal'] == '+':
$prefix = $signal;
break;
case $locale["{$letter}_sign_posn"] == 2 && $flags['usesignal'] == '+':
$suffix = $signal;
break;
case $locale["{$letter}_sign_posn"] == 3 && $flags['usesignal'] == '+':
$cprefix = $signal;
break;
case $locale["{$letter}_sign_posn"] == 4 && $flags['usesignal'] == '+':
$csuffix = $signal;
break;
case $flags['usesignal'] == '(' && $letter === 'n':
case $locale["{$letter}_sign_posn"] == 0:
$prefix = '(';
$suffix = ')';
break;
}
if (!$flags['nosimbol']) {
$currency = $cprefix . ($conversion == 'i'
? $locale['int_curr_symbol'] : $locale['currency_symbol']
) . $csuffix;
} else {
$currency = '';
}
$space = $locale["{$letter}_sep_by_space"] ? ' ' : '';

$value = number_format(
$value,
$right,
$locale['mon_decimal_point'],
$flags['nogroup'] ? '' : $locale['mon_thousands_sep']
);
$value = @explode($locale['mon_decimal_point'], $value);

$n = strlen($prefix) + strlen($currency) + strlen($value[0]);
if ($left > 0 && $left > $n) {
$value[0] = str_repeat($flags['fillchar'], $left - $n) . $value[0];
}
$value = implode($locale['mon_decimal_point'], $value);
if ($locale["{$letter}_cs_precedes"]) {
$value = $prefix . $currency . $space . $value . $suffix;
} else {
$value = $prefix . $value . $space . $currency . $suffix;
}
if ($width > 0) {
$value = str_pad(
$value,
$width,
$flags['fillchar'],
$flags['isleft'] ? STR_PAD_RIGHT : STR_PAD_LEFT
);
}

$format = str_replace($fmatch[0], $value, $format);
}
return $format;
}
}
59 changes: 59 additions & 0 deletions htdocs/class/libraries/vendor/firebase/php-jwt/src/Key.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace Firebase\JWT;

use InvalidArgumentException;
use OpenSSLAsymmetricKey;

class Key
{
/** @var string $algorithm */
private $algorithm;

/** @var string|resource|OpenSSLAsymmetricKey $keyMaterial */
private $keyMaterial;

/**
* @param string|resource|OpenSSLAsymmetricKey $keyMaterial
* @param string $algorithm
*/
public function __construct($keyMaterial, $algorithm)
{
if (
!is_string($keyMaterial)
&& !is_resource($keyMaterial)
&& !$keyMaterial instanceof OpenSSLAsymmetricKey
) {
throw new InvalidArgumentException('Type error: $keyMaterial must be a string, resource, or OpenSSLAsymmetricKey');
}

if (empty($keyMaterial)) {
throw new InvalidArgumentException('Type error: $keyMaterial must not be empty');
}

if (!is_string($algorithm)|| empty($keyMaterial)) {
throw new InvalidArgumentException('Type error: $algorithm must be a string');
}

$this->keyMaterial = $keyMaterial;
$this->algorithm = $algorithm;
}

/**
* Return the algorithm valid for this key
*
* @return string
*/
public function getAlgorithm()
{
return $this->algorithm;
}

/**
* @return string|resource|OpenSSLAsymmetricKey
*/
public function getKeyMaterial()
{
return $this->keyMaterial;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on: [push, pull_request]

jobs:
phpunit:
strategy:
fail-fast: false
matrix:
php_version: ["7.1", "7.4"]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: php-actions/composer@v6
with:
php_version: "7.4"
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php_version }}
coverage: xdebug
- name: Unit Tests
run: vendor/bin/phpunit --stderr

0 comments on commit dfc2ef6

Please sign in to comment.