forked from ppy/osu-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ppy#10771 from nanaya/static-provider
Change data provider to static method
- Loading branch information
Showing
83 changed files
with
241 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Libraries; | ||
|
||
class Base64Url | ||
{ | ||
public static function decode(string $value): ?string | ||
{ | ||
return null_if_false(base64_decode(strtr($value, '-_', '+/'), true)); | ||
} | ||
|
||
public static function encode(string $value): string | ||
{ | ||
// url safe base64 | ||
// reference: https://datatracker.ietf.org/doc/html/rfc4648#section-5 | ||
return rtrim(strtr(base64_encode($value), '+/', '-_'), '='); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
use App\Libraries\Base64Url; | ||
use App\Libraries\LocaleMeta; | ||
use App\Models\LoginAttempt; | ||
use Egulias\EmailValidator\EmailValidator; | ||
|
@@ -60,18 +61,6 @@ function background_image($url, $proxy = true) | |
return sprintf(' style="background-image:url(\'%s\');" ', e($url)); | ||
} | ||
|
||
function base64url_decode(string $value): ?string | ||
{ | ||
return null_if_false(base64_decode(strtr($value, '-_', '+/'), true)); | ||
} | ||
|
||
function base64url_encode(string $value): string | ||
{ | ||
// url safe base64 | ||
// reference: https://datatracker.ietf.org/doc/html/rfc4648#section-5 | ||
return rtrim(strtr(base64_encode($value), '+/', '-_'), '='); | ||
} | ||
|
||
function beatmap_timestamp_format($ms) | ||
{ | ||
$s = $ms / 1000; | ||
|
@@ -310,7 +299,7 @@ function current_locale_meta(): LocaleMeta | |
function cursor_decode($cursorString): ?array | ||
{ | ||
if (is_string($cursorString) && present($cursorString)) { | ||
$cursor = json_decode(base64_decode(strtr($cursorString, '-_', '+/'), true), true); | ||
$cursor = json_decode(Base64Url::decode($cursorString) ?? '', true); | ||
|
||
if (is_array($cursor)) { | ||
return $cursor; | ||
|
@@ -324,7 +313,7 @@ function cursor_encode(?array $cursor): ?string | |
{ | ||
return $cursor === null | ||
? null | ||
: base64url_encode(json_encode($cursor)); | ||
: Base64Url::encode(json_encode($cursor)); | ||
} | ||
|
||
function cursor_for_response(?array $cursor): array | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false"> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" | ||
> | ||
<extensions> | ||
<extension class="Tests\SeederExtension" /> | ||
<extension class="Tests\SeederExtension"/> | ||
</extensions> | ||
<testsuites> | ||
<testsuite name="Browser Test Suite"> | ||
<directory suffix="Test.php">./tests/Browser</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">./app</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.