Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strings: add base64UrlEncode() and base64UrlDecode() #287

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a795df5
updated github workflow
dg Oct 12, 2022
6b4eac6
cs
dg Oct 12, 2022
d9a5ce7
refactoring
dg Mar 1, 2022
a2c2295
opened 4.0-dev
dg Mar 1, 2021
7ca6cf6
requires PHP 8.0
dg Sep 6, 2022
7d10dff
composer: updated dependencies
dg Mar 1, 2021
cc145b4
removed support for PHP 7
dg Sep 20, 2021
7f0392f
removed deprecated stuff
dg Mar 2, 2021
3fb7c00
coding style
dg Sep 19, 2021
0500166
coding style: reformatted Assert::exception
dg Mar 12, 2022
85e5f2f
added property typehints
dg Mar 1, 2021
35e81ad
added PHP 8 typehints
dg Dec 12, 2021
ab3099b
removed community health files
dg Mar 11, 2021
3ed69fc
tests: added
dg Apr 22, 2021
fd48f67
used native PHP 8 functions
dg Jul 28, 2021
96d090d
Reflection: uses PhpToken
dg Aug 27, 2021
490d0bb
Reflection: getReturnType(), getParameterType(), getPropertyType() re…
dg Sep 19, 2021
aa3002f
Html: removed $xhtml (BC break)
dg Sep 26, 2021
8f128f6
Strings, Arrays, Json, Image: $flags replaced with parameters
dg Jan 9, 2022
8e0c1e4
Strings::replace() added parameters $captureOffset, $unmatchedAsNull
dg Oct 25, 2021
e5ab463
Strings::split() added parameter $limit
dg Oct 27, 2021
ef54d69
Strings: added support for UTF8 offsets in regexp
dg Oct 26, 2021
4020d6f
added Strings::ord()
dg Nov 1, 2021
4b122ae
Translator: changed interface, accepts and returns string|Stringable …
dg Nov 16, 2021
f31ee44
Reflection::getParameterDefaultValue() is deprecated
dg Dec 11, 2021
67dc7f9
added Helpers::compare()
dg Jan 5, 2022
4f5ac1a
Json: added decodeFile()
dg Jan 21, 2022
05d81ef
RegexpException: uses preg_last_error_msg()
dg Feb 24, 2022
fac1f2b
some methods use real default values instead of nulls (BC break)
dg Mar 1, 2022
712f0cf
Strings: added base64UrlEncode() and base64UrlDecode()
milo Nov 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/Bug_report.md

This file was deleted.

9 changes: 0 additions & 9 deletions .github/ISSUE_TEMPLATE/Feature_request.md

This file was deleted.

12 changes: 0 additions & 12 deletions .github/ISSUE_TEMPLATE/Support_question.md

This file was deleted.

21 changes: 0 additions & 21 deletions .github/ISSUE_TEMPLATE/Support_us.md

This file was deleted.

2 changes: 0 additions & 2 deletions .github/funding.yml

This file was deleted.

11 changes: 0 additions & 11 deletions .github/pull_request_template.md

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/coding-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
name: Nette Code Checker
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
coverage: none

- run: composer create-project nette/code-checker temp/code-checker ^3 --no-progress
Expand All @@ -21,7 +21,7 @@ jobs:
name: Nette Coding Standard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 8.0
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ jobs:
name: PHPStan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
coverage: none

- run: composer install --no-progress --prefer-dist
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['8.0', '8.1', '8.2']

fail-fast: false

name: PHP ${{ matrix.php }} tests on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
Expand All @@ -24,7 +24,7 @@ jobs:
- run: composer install --no-progress --prefer-dist
- run: vendor/bin/tester tests -s -C
- if: failure()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: output
path: tests/**/output
Expand All @@ -34,10 +34,10 @@ jobs:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: 7.4
php-version: 8.0
extensions: iconv, json, mbstring, xml, gd, intl, tokenizer
coverage: none

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
}
],
"require": {
"php": ">=7.2 <8.3"
"php": ">=8.0 <8.3"
},
"require-dev": {
"nette/tester": "~2.0",
"tracy/tracy": "^2.3",
"nette/tester": "^2.4",
"tracy/tracy": "^2.8",
"phpstan/phpstan": "^1.0"
},
"conflict": {
Expand All @@ -44,7 +44,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
"dev-master": "4.0-dev"
}
}
}
33 changes: 0 additions & 33 deletions contributing.md

This file was deleted.

2 changes: 2 additions & 0 deletions ncs.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
// use function in Arrays.php, Callback.php, Html.php, Strings.php
'single_import_per_statement' => false,
'ordered_imports' => false,
// Reflection.php
'Nette/statement_indentation' => false,
];
9 changes: 2 additions & 7 deletions ncs.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
<?xml version="1.0"?>
<ruleset name="Custom" namespace="Nette">
<rule ref="$presets/php72.xml"/>

<!-- bug in SlevomatCodingStandard -->
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator">
<severity>0</severity>
</rule>
<rule ref="$presets/php80.xml"/>

<!-- bug in FunctionSpacingSniff -->
<exclude-pattern>./tests/Utils/Reflection.getDeclaringMethod.alias.phpt</exclude-pattern>
<exclude-pattern>./tests/Utils/Reflection.getDeclaringMethod.insteadof.phpt</exclude-pattern>

<!-- use function in Arrays.php, Callback.php, Html.php, Strings.php -->
<rule ref="SlevomatCodingStandard.Namespaces.MultipleUsesPerLine.MultipleUsesPerLine">
<severity>0</severity>
<exclude-pattern>./src/*/*.php</exclude-pattern>
</rule>
</ruleset>
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The recommended way to install is via Composer:
composer require nette/utils
```

- Nette Utils 4.0 is compatible with PHP 8.0 to 8.2
- Nette Utils 3.2 is compatible with PHP 7.2 to 8.2
- Nette Utils 3.1 is compatible with PHP 7.1 to 8.0
- Nette Utils 3.0 is compatible with PHP 7.1 to 8.0
Expand Down
11 changes: 4 additions & 7 deletions src/Iterators/CachingIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class CachingIterator extends \CachingIterator implements \Countable
{
use Nette\SmartObject;

/** @var int */
private $counter = 0;
private int $counter = 0;


public function __construct($iterator)
Expand All @@ -48,7 +47,7 @@ public function __construct($iterator)
} elseif ($iterator instanceof \Traversable) {
$iterator = new \IteratorIterator($iterator);
} else {
throw new Nette\InvalidArgumentException(sprintf('Invalid argument passed to %s; array or Traversable expected, %s given.', self::class, is_object($iterator) ? get_class($iterator) : gettype($iterator)));
throw new Nette\InvalidArgumentException(sprintf('Invalid argument passed to %s; array or Traversable expected, %s given.', self::class, is_object($iterator) ? $iterator::class : gettype($iterator)));
}

parent::__construct($iterator, 0);
Expand Down Expand Up @@ -148,19 +147,17 @@ public function rewind(): void

/**
* Returns the next key.
* @return mixed
*/
public function getNextKey()
public function getNextKey(): mixed
{
return $this->getInnerIterator()->key();
}


/**
* Returns the next element.
* @return mixed
*/
public function getNextValue()
public function getNextValue(): mixed
{
return $this->getInnerIterator()->current();
}
Expand Down
3 changes: 1 addition & 2 deletions src/Iterators/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public function __construct(\Traversable $iterator, callable $callback)
}


#[\ReturnTypeWillChange]
public function current()
public function current(): mixed
{
return ($this->callback)(parent::current(), parent::key());
}
Expand Down
20 changes: 9 additions & 11 deletions src/SmartObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait SmartObject
/**
* @throws MemberAccessException
*/
public function __call(string $name, array $args)
public function __call(string $name, array $args): mixed
{
$class = static::class;

Expand All @@ -37,26 +37,27 @@ public function __call(string $name, array $args)
} elseif ($handlers !== null) {
throw new UnexpectedValueException("Property $class::$$name must be iterable or null, " . gettype($handlers) . ' given.');
}
} else {
ObjectHelpers::strictCall($class, $name);

return null;
}

ObjectHelpers::strictCall($class, $name);
}


/**
* @throws MemberAccessException
*/
public static function __callStatic(string $name, array $args)
public static function __callStatic(string $name, array $args): mixed
{
ObjectHelpers::strictStaticCall(static::class, $name);
}


/**
* @return mixed
* @throws MemberAccessException if the property is not defined.
*/
public function &__get(string $name)
public function &__get(string $name): mixed
{
$class = static::class;

Expand Down Expand Up @@ -87,11 +88,9 @@ public function &__get(string $name)


/**
* @param mixed $value
* @return void
* @throws MemberAccessException if the property is not defined or is read-only
*/
public function __set(string $name, $value)
public function __set(string $name, mixed $value): void
{
$class = static::class;

Expand Down Expand Up @@ -121,10 +120,9 @@ public function __set(string $name, $value)


/**
* @return void
* @throws MemberAccessException
*/
public function __unset(string $name)
public function __unset(string $name): void
{
$class = static::class;
if (!ObjectHelpers::hasProperty($class, $name)) {
Expand Down
3 changes: 1 addition & 2 deletions src/StaticClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ final public function __construct()

/**
* Call to undefined static method.
* @return void
* @throws MemberAccessException
*/
public static function __callStatic(string $name, array $args)
public static function __callStatic(string $name, array $args): mixed
{
Utils\ObjectHelpers::strictStaticCall(static::class, $name);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ interface Translator
{
/**
* Translates the given string.
* @param mixed $message
* @param mixed ...$parameters
*/
function translate($message, ...$parameters): string;
function translate(string|\Stringable $message, mixed ...$parameters): string|\Stringable;
}


Expand Down
Loading