chore: merge, lint, stan

This commit is contained in:
Binyamin Yawitz
2024-09-04 14:52:01 -04:00
parent cedf3cf28d
commit feb775d2c4
32 changed files with 705 additions and 440 deletions
+1 -1
View File
@@ -393,7 +393,7 @@ Http::post('/v1/account')
$existingTarget = $dbForProject->findOne('targets', [
Query::equal('identifier', [$email]),
]);
if($existingTarget) {
if ($existingTarget) {
$user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND);
}
}
+14 -14
View File
@@ -43,9 +43,11 @@ use Utopia\Database\Validator\Datetime as DatetimeValidator;
use Utopia\Database\Validator\Roles;
use Utopia\Database\Validator\UID;
use Utopia\Http\Http;
use Utopia\Http\Validator\AnyOf;
use Utopia\Http\Validator\ArrayList;
use Utopia\Http\Validator\Assoc;
use Utopia\Http\Validator\Boolean;
use Utopia\Http\Validator\Nullable;
use Utopia\Http\Validator\Range;
use Utopia\Http\Validator\Text;
use Utopia\Http\Validator\WhiteList;
@@ -55,8 +57,6 @@ use Utopia\Storage\Validator\FileExt;
use Utopia\Storage\Validator\FileSize;
use Utopia\Storage\Validator\Upload;
use Utopia\System\System;
use Utopia\Validator\AnyOf;
use Utopia\Validator\Nullable;
use Utopia\VCS\Adapter\Git\GitHub;
use Utopia\VCS\Exception\RepositoryNotFound;
@@ -173,8 +173,8 @@ Http::post('/v1/functions')
->param('specification', APP_FUNCTION_SPECIFICATION_DEFAULT, fn (array $plan) => new RuntimeSpecification(
$plan,
Config::getParam('runtime-specifications', []),
App::getEnv('_APP_FUNCTIONS_CPUS', APP_FUNCTION_CPUS_DEFAULT),
App::getEnv('_APP_FUNCTIONS_MEMORY', APP_FUNCTION_MEMORY_DEFAULT)
System::getEnv('_APP_FUNCTIONS_CPUS', APP_FUNCTION_CPUS_DEFAULT),
System::getEnv('_APP_FUNCTIONS_MEMORY', APP_FUNCTION_MEMORY_DEFAULT)
), 'Runtime specification for the function and builds.', true, ['plan'])
->inject('request')
->inject('response')
@@ -299,7 +299,7 @@ Http::post('/v1/functions')
if (!empty($providerRepositoryId)) {
// Deploy VCS
$redeployVcs($request, $function, $project, $installation, $dbForProject, $queueForBuilds, $template, $github);
} elseif(!$template->isEmpty()) {
} elseif (!$template->isEmpty()) {
// Deploy non-VCS from template
$deploymentId = ID::unique();
$deployment = $dbForProject->createDocument('deployments', new Document([
@@ -785,8 +785,8 @@ Http::put('/v1/functions/:functionId')
->param('specification', APP_FUNCTION_SPECIFICATION_DEFAULT, fn (array $plan) => new RuntimeSpecification(
$plan,
Config::getParam('runtime-specifications', []),
App::getEnv('_APP_FUNCTIONS_CPUS', APP_FUNCTION_CPUS_DEFAULT),
App::getEnv('_APP_FUNCTIONS_MEMORY', APP_FUNCTION_MEMORY_DEFAULT)
System::getEnv('_APP_FUNCTIONS_CPUS', APP_FUNCTION_CPUS_DEFAULT),
System::getEnv('_APP_FUNCTIONS_MEMORY', APP_FUNCTION_MEMORY_DEFAULT)
), 'Runtime specification for the function and builds.', true, ['plan'])
->inject('request')
->inject('response')
@@ -900,7 +900,7 @@ Http::put('/v1/functions/:functionId')
// Enforce Cold Start if spec limits change.
if ($function->getAttribute('specification') !== $specification && !empty($function->getAttribute('deployment'))) {
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
$executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST'));
try {
$executor->deleteRuntime($project->getId(), $function->getAttribute('deployment'));
} catch (\Throwable $th) {
@@ -1590,7 +1590,7 @@ Http::post('/v1/functions/:functionId/deployments/:deploymentId/build')
}
$path = $deployment->getAttribute('path');
if(empty($path) || !$deviceForFunctions->exists($path)) {
if (empty($path) || !$deviceForFunctions->exists($path)) {
throw new Exception(Exception::DEPLOYMENT_NOT_FOUND);
}
@@ -1697,7 +1697,7 @@ Http::patch('/v1/functions/:functionId/deployments/:deploymentId/build')
$dbForProject->purgeCachedDocument('deployments', $deployment->getId());
try {
$executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
$executor = new Executor(System::getEnv('_APP_EXECUTOR_HOST'));
$executor->deleteRuntime($project->getId(), $deploymentId . "-build");
} catch (\Throwable $th) {
// Don't throw if the deployment doesn't exist
@@ -1747,7 +1747,7 @@ Http::post('/v1/functions/:functionId/executions')
->inject('authentication')
->action(function (string $functionId, string $body, bool $async, string $path, string $method, array $headers, ?string $scheduledAt, Response $response, Request $request, Document $project, Database $dbForProject, Database $dbForConsole, Document $user, Event $queueForEvents, Usage $queueForUsage, Func $queueForFunctions, Reader $geodb, Authorization $authorization, Authentication $authentication) {
if(!$async && !is_null($scheduledAt)) {
if (!$async && !is_null($scheduledAt)) {
throw new Exception(Exception::GENERAL_BAD_REQUEST, 'Scheduled executions must run asynchronously. Set scheduledAt to a future date, or set async to true.');
}
@@ -1878,7 +1878,7 @@ Http::post('/v1/functions/:functionId/executions')
$status = $async ? 'waiting' : 'processing';
if(!is_null($scheduledAt)) {
if (!is_null($scheduledAt)) {
$status = 'scheduled';
}
@@ -1909,7 +1909,7 @@ Http::post('/v1/functions/:functionId/executions')
if ($async) {
if(is_null($scheduledAt)) {
if (is_null($scheduledAt)) {
$execution = $authorization->skip(fn () => $dbForProject->createDocument('executions', $execution));
$queueForFunctions
->setType('http')
@@ -2087,7 +2087,7 @@ Http::post('/v1/functions/:functionId/executions')
$acceptTypes = \explode(', ', $request->getHeader('accept'));
foreach ($acceptTypes as $acceptType) {
if(\str_starts_with($acceptType, 'application/json') || \str_starts_with($acceptType, 'application/*')) {
if (\str_starts_with($acceptType, 'application/json') || \str_starts_with($acceptType, 'application/*')) {
$response->setContentType(Response::CONTENT_TYPE_JSON);
break;
} elseif (\str_starts_with($acceptType, 'multipart/form-data') || \str_starts_with($acceptType, 'multipart/*')) {
-2
View File
@@ -275,8 +275,6 @@ Http::get('/v1/project/usage')
'filesStorageTotal' => $total[METRIC_FILES_STORAGE],
'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE],
'executionsBreakdown' => $executionsBreakdown,
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
'bucketsBreakdown' => $bucketsBreakdown,
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
+3 -3
View File
@@ -140,7 +140,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e
$existingTarget = $dbForProject->findOne('targets', [
Query::equal('identifier', [$email]),
]);
if($existingTarget) {
if ($existingTarget) {
$user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND);
}
}
@@ -164,7 +164,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e
$existingTarget = $dbForProject->findOne('targets', [
Query::equal('identifier', [$phone]),
]);
if($existingTarget) {
if ($existingTarget) {
$user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND);
}
}
@@ -2125,7 +2125,7 @@ Http::post('/v1/users/:userId/jwts')
$sessions = $user->getAttribute('sessions', []);
$session = new Document();
if($sessionId === 'recent') {
if ($sessionId === 'recent') {
// Get most recent
$session = \count($sessions) > 0 ? $sessions[\count($sessions) - 1] : new Document();
} else {
+1 -1
View File
@@ -508,7 +508,7 @@ Http::get('/v1/vcs/github/installations/:installationId/providerRepositories/:pr
$vcsContents = [];
foreach ($contents as $content) {
$isDirectory = false;
if($content['type'] === GitHub::CONTENTS_DIRECTORY) {
if ($content['type'] === GitHub::CONTENTS_DIRECTORY) {
$isDirectory = true;
}
+3 -3
View File
@@ -209,14 +209,14 @@ Http::init()
}
// Remove after migration
if(!\str_contains($apiKey, '_')) {
if (!\str_contains($apiKey, '_')) {
$keyType = API_KEY_STANDARD;
$authKey = $apiKey;
} else {
[ $keyType, $authKey ] = \explode('_', $apiKey, 2);
}
if($keyType === API_KEY_DYNAMIC) {
if ($keyType === API_KEY_DYNAMIC) {
// Dynamic key
$jwtObj = new JWT(System::getEnv('_APP_OPENSSL_KEY_V1'), 'HS256', 3600, 0);
@@ -246,7 +246,7 @@ Http::init()
$authorization->addRole(Auth::USER_ROLE_APPS);
$authorization->setDefaultStatus(false); // Cancel security segmentation for API keys.
}
} elseif($keyType === API_KEY_STANDARD) {
} elseif ($keyType === API_KEY_STANDARD) {
// No underline means no prefix. Backwards compatibility.
// Regular key
+1 -1
View File
@@ -55,7 +55,7 @@ Http::init()
return;
}
if(str_contains($route->getPath(), '/v1/graphql')) { // Skip for graphQL recursive call
if (str_contains($route->getPath(), '/v1/graphql')) { // Skip for graphQL recursive call
return;
}
+1 -1
View File
@@ -6,7 +6,7 @@ require_once __DIR__ . '/controllers/general.php';
use Appwrite\Utopia\Queue\Connections;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\Response;
use Utopia\Abuse\Adapters\Database as TimeLimit;
use Utopia\Abuse\Adapters\Database\TimeLimit;
use Utopia\Audit\Audit;
use Utopia\Cache\Cache;
use Utopia\CLI\Console;
+5 -5
View File
@@ -84,11 +84,11 @@
//use Utopia\Storage\Device\Wasabi;
//use Utopia\Storage\Storage;
//use Utopia\System\System;
//use Utopia\Validator\Hostname;
//use Utopia\Validator\IP;
//use Utopia\Validator\Range;
//use Utopia\Validator\URL;
//use Utopia\Validator\WhiteList;
//use Utopia\Http\Validator\Hostname;
//use Utopia\Http\Validator\IP;
//use Utopia\Http\Validator\Range;
//use Utopia\Http\Validator\URL;
//use Utopia\Http\Validator\WhiteList;
//use Utopia\VCS\Adapter\Git\GitHub as VcsGitHub;
//
//const APP_NAME = 'Appwrite';
-1
View File
@@ -4,7 +4,6 @@ use Appwrite\OpenSSL\OpenSSL;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Query;
use Utopia\System\System;
Database::addFilter(
+4 -4
View File
@@ -35,7 +35,7 @@ use Swoole\Database\PDOPool;
use Swoole\Database\RedisConfig;
use Swoole\Database\RedisPool;
use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\Database as TimeLimit;
use Utopia\Abuse\Adapters\Database\TimeLimit;
use Utopia\Cache\Adapter\Redis as CacheRedis;
use Utopia\Cache\Adapter\Sharding;
use Utopia\Cache\Cache;
@@ -201,7 +201,7 @@ $global->set('logger', function () {
'logowl' => ['ticket' => $loggingProvider->getUser() ?? '', 'host' => $loggingProvider->getHost()],
default => ['key' => $loggingProvider->getHost()],
};
} catch (Throwable) {
} catch (Throwable $th) {
Console::warning('Using deprecated logging configuration. Please update your configuration to use DSN format.' . $th->getMessage());
// Fallback for older Appwrite versions up to 1.5.x that use _APP_LOGGING_PROVIDER and _APP_LOGGING_CONFIG environment variables
$configChunks = \explode(";", $providerConfig);
@@ -233,7 +233,7 @@ $global->set('logger', function () {
$adapter = null;
}
if($adapter === null) {
if ($adapter === null) {
Console::error("Logging provider not supported. Logging is disabled");
return;
}
@@ -647,7 +647,7 @@ $user
}
$jwtSessionId = $payload['sessionId'] ?? '';
if(!empty($jwtSessionId)) {
if (!empty($jwtSessionId)) {
if (empty($user->find('$id', $jwtSessionId, 'sessions'))) { // Match JWT to active token
$user = new Document([]);
}
+5 -5
View File
@@ -51,12 +51,12 @@
"utopia-php/analytics": "dev-feat-framework-v2 as 0.10.99",
"utopia-php/audit": "dev-feat-framework-v2 as 0.40.99",
"utopia-php/cache": "0.10.*",
"utopia-php/cli": "dev-dev-coroutines as 0.17.99",
"utopia-php/cli": "1.0.*",
"utopia-php/config": "0.2.*",
"utopia-php/database": "dev-feat-framework-v2 as 0.50.99",
"utopia-php/database": "1.0.*",
"utopia-php/domains": "dev-feat-framework-v2 as 0.5.99",
"utopia-php/dsn": "0.2.*",
"utopia-php/framework": "dev-feat-di-upgrade as 0.34.99",
"utopia-php/framework": "1.0.0-RC2",
"utopia-php/fetch": "0.2.*",
"utopia-php/image": "0.6.*",
"utopia-php/locale": "0.4.*",
@@ -72,8 +72,8 @@
"utopia-php/registry": "0.5.*",
"utopia-php/storage": "dev-feat-framework-v2-v2 as 0.18.99",
"utopia-php/system": "0.8.*",
"utopia-php/vcs": "0.8.*",
"utopia-php/websocket": "0.1.*",
"utopia-php/vcs": "dev-feat-di",
"utopia-php/websocket": "0.2.*",
"matomo/device-detector": "6.1.*",
"dragonmantank/cron-expression": "3.3.2",
"phpmailer/phpmailer": "6.9.1",
Generated
+631 -364
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -313,7 +313,7 @@ class Exception extends \Exception
$this->code = $code ?? $this->errors[$type]['code'];
// Mark string errors like HY001 from PDO as 500 errors
if(\is_string($this->code)) {
if (\is_string($this->code)) {
if (\is_numeric($this->code)) {
$this->code = (int) $this->code;
} else {
+3 -3
View File
@@ -2,7 +2,7 @@
namespace Appwrite\Functions\Validator;
use Utopia\Validator;
use Utopia\Http\Validator;
/**
* Headers.
@@ -44,7 +44,7 @@ class Headers extends Validator
return false;
}
if(\count($value) > $this->maxKeys) {
if (\count($value) > $this->maxKeys) {
return false;
}
@@ -57,7 +57,7 @@ class Headers extends Validator
}
$size += $length + \strlen($val);
if($size >= $this->maxSize) {
if ($size >= $this->maxSize) {
return false;
}
+1 -1
View File
@@ -2,7 +2,7 @@
namespace Appwrite\Functions\Validator;
use Utopia\Validator\Text;
use Utopia\Http\Validator\Text;
class Payload extends Text
{
@@ -2,7 +2,7 @@
namespace Appwrite\Functions\Validator;
use Utopia\Validator;
use Utopia\Http\Validator;
class RuntimeSpecification extends Validator
{
+5 -5
View File
@@ -211,7 +211,7 @@ class Builds extends Action
}
try {
if($isNewBuild && !$isVcsEnabled) {
if ($isNewBuild && !$isVcsEnabled) {
// Non-vcs+Template
$templateRepositoryName = $template->getAttribute('repositoryName', '');
@@ -231,7 +231,7 @@ class Builds extends Action
$exit = Console::execute($gitCloneCommandForTemplate, '', $output);
if ($exit !== 0) {
throw new \Exception('Unable to clone code repository: ' . $stderr);
throw new \Exception('Unable to clone code repository: ' . $output);
}
// Ensure directories
@@ -281,7 +281,7 @@ class Builds extends Action
$cloneVersion = $branchName;
$cloneType = GitHub::CLONE_TYPE_BRANCH;
if(!empty($commitHash)) {
if (!empty($commitHash)) {
$cloneVersion = $commitHash;
$cloneType = GitHub::CLONE_TYPE_COMMIT;
}
@@ -307,7 +307,7 @@ class Builds extends Action
$exit = Console::execute('mv "' . \escapeshellarg($from) . '" "' . \escapeshellarg($to) . '"', '', $output);
if ($exit !== 0) {
throw new \Exception('Unable to move function with spaces' . $stderr);
throw new \Exception('Unable to move function with spaces' . $output);
}
$rootDirectory = $rootDirectoryWithoutSpaces;
}
@@ -541,7 +541,7 @@ class Builds extends Action
deploymentId: $deployment->getId(),
projectId: $project->getId(),
callback: function ($logs) use (&$response, &$err, &$build, $dbForProject, $allEvents, $project, &$isCanceled) {
if($isCanceled) {
if ($isCanceled) {
return;
}
+1 -1
View File
@@ -669,7 +669,7 @@ class Messaging extends Action
private function getLocalDevice($project): Local
{
if($this->localDevice === null) {
if ($this->localDevice === null) {
$this->localDevice = new Local(APP_STORAGE_UPLOADS . '/app-' . $project->getId());
}
@@ -240,7 +240,7 @@ class OpenAPI3 extends Format
if ($route->getLabel('sdk.response.code', 500) === 204) {
$labelCode = (string)$route->getLabel('sdk.response.code', '500');
$temp['responses'][$labelCode]['description'] = 'No content';
if(isset($temp['responses'][$labelCode]['schema'])) {
if (isset($temp['responses'][$labelCode]['schema'])) {
unset($temp['responses'][$labelCode]['schema']);
}
}
@@ -274,7 +274,7 @@ class OpenAPI3 extends Format
foreach ($route->getParams() as $name => $param) { // Set params
$injections = [];
if(isset($param['injections'])) {
if (isset($param['injections'])) {
$injections = array_map(fn ($injection) => $this->http->getContainer()->get($injection), $param['injections']);
}
@@ -272,7 +272,7 @@ class Swagger2 extends Format
foreach ($parameters as $name => $param) { // Set params
$injections = [];
if(isset($param['injections'])) {
if (isset($param['injections'])) {
$injections = array_map(fn ($injection) => $this->http->getContainer()->get($injection), $param['injections']);
}
@@ -293,13 +293,13 @@ class Swagger2 extends Format
}
$validatorClass = (!empty($validator)) ? \get_class($validator) : '';
if($validatorClass === 'Utopia\Validator\AnyOf') {
if ($validatorClass === 'Utopia\Http\Validator\AnyOf') {
$validator = $param['validator']->getValidators()[0];
$validatorClass = \get_class($validator);
}
switch ($validatorClass) {
case 'Utopia\Validator\Text':
case 'Utopia\Http\Validator\Text':
case 'Utopia\Database\Validator\UID':
$node['type'] = $validator->getType();
$node['x-example'] = '<' . \strtoupper(Template::fromCamelCaseToSnake($node['name'])) . '>';
+1 -1
View File
@@ -134,7 +134,7 @@ class Request extends HttpRequest
*/
public function getHeaders(): array
{
if($this->headers !== null) {
if ($this->headers !== null) {
return $this->headers;
}
+2 -2
View File
@@ -8,7 +8,7 @@ use Exception;
use JsonException;
// Keep last
use Utopia\Database\Document;
use Utopia\Swoole\Response as SwooleResponse;
use Utopia\Http\Adapter\Swoole\Response as HttpResponse;
// Keep last
@@ -16,7 +16,7 @@ use Utopia\Swoole\Response as SwooleResponse;
* @method int getStatusCode()
* @method Response setStatusCode(int $code = 200)
*/
class Response extends SwooleResponse
class Response extends HttpResponse
{
// General
public const MODEL_NONE = 'none';
+2 -2
View File
@@ -33,13 +33,13 @@ class V16 extends Filter
protected function parseDeployment(array $content)
{
if(isset($content['buildLogs'])) {
if (isset($content['buildLogs'])) {
$content['buildStderr'] = '';
$content['buildStdout'] = $content['buildLogs'];
unset($content['buildLogs']);
}
if(isset($content['buildSize'])) {
if (isset($content['buildSize'])) {
$content['size'] += + $content['buildSize'] ?? 0;
unset($content['buildSize']);
}
+2 -2
View File
@@ -25,8 +25,8 @@ class V18 extends Filter
protected function parseExecution(array $content)
{
if(!empty($content['status']) && !empty($content['statusCode'])) {
if($content['status'] === 'completed' && $content['statusCode'] >= 400 && $content['statusCode'] < 500) {
if (!empty($content['status']) && !empty($content['statusCode'])) {
if ($content['status'] === 'completed' && $content['statusCode'] >= 400 && $content['statusCode'] < 500) {
$content['status'] = 'failed';
}
}
+1
View File
@@ -2,6 +2,7 @@
namespace Appwrite\Utopia\Response;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model\Account;
use Appwrite\Utopia\Response\Model\AlgoArgon2;
use Appwrite\Utopia\Response\Model\AlgoBcrypt;
+1 -1
View File
@@ -217,7 +217,7 @@ class Executor
'restartPolicy' => 'always' // Once utopia/orchestration has it, use DockerAPI::ALWAYS (0.13+)
];
if(!empty($body)) {
if (!empty($body)) {
$params['body'] = $body;
}
@@ -33,7 +33,7 @@ trait FunctionsBase
\sleep(1);
}
if($checkForSuccess) {
if ($checkForSuccess) {
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertEquals('ready', $deployment['body']['status'], \json_encode($deployment['body']));
}
@@ -10,12 +10,12 @@ use Tests\E2E\Client;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\SideServer;
use Utopia\App;
use Utopia\Database\Document;
use Utopia\Database\Helpers\ID;
use Utopia\Database\Helpers\Role;
use Utopia\Database\Query;
use Utopia\Database\Validator\Datetime as DatetimeValidator;
use Utopia\System\System;
class FunctionsCustomServerTest extends Scope
{
@@ -1072,7 +1072,7 @@ class FunctionsCustomServerTest extends Scope
$found = false;
foreach ($response['body']['deployments'] as $deployment) {
if($deployment['$id'] === $deploymentId) {
if ($deployment['$id'] === $deploymentId) {
$found = true;
$this->assertEquals($deploymentSize, $deployment['size']);
break;
@@ -2434,7 +2434,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($cookie, $response['body']);
// Await Aggregation
sleep(App::getEnv('_APP_USAGE_AGGREGATION_INTERVAL', 30));
sleep(System::getEnv('_APP_USAGE_AGGREGATION_INTERVAL', 30));
$tries = 0;
while (true) {
+1 -1
View File
@@ -31,7 +31,7 @@ trait WebhooksBase
\sleep(1);
}
if($checkForSuccess) {
if ($checkForSuccess) {
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertEquals('ready', $deployment['body']['status'], \json_encode($deployment['body']));
}
@@ -27,19 +27,19 @@ final class HeadersBench
yield 'empty' => [ 'value' => [] ];
$value = [];
for($i = 0; $i < 10; $i++) {
for ($i = 0; $i < 10; $i++) {
$value[bin2hex(random_bytes(8))] = bin2hex(random_bytes(8));
}
yield 'items_10-size_320' => [ 'value' => $value ];
$value = [];
for($i = 0; $i < 100; $i++) {
for ($i = 0; $i < 100; $i++) {
$value[bin2hex(random_bytes(8))] = bin2hex(random_bytes(8));
}
yield 'items_100-size_3200' => [ 'value' => $value ];
$value = [];
for($i = 0; $i < 100; $i++) {
for ($i = 0; $i < 100; $i++) {
$value[bin2hex(random_bytes(32))] = bin2hex(random_bytes(32));
}
yield 'items_100-size_12800' => [ 'value' => $value ];
@@ -53,7 +53,7 @@ final class HeadersBench
public function benchHeadersValidator(array $data): void
{
$assertion = $this->validator->isValid($data['value']);
if(!$assertion) {
if (!$assertion) {
exit(1);
}
}
@@ -109,7 +109,7 @@ class HeadersTest extends TestCase
$this->assertTrue($this->object->isValid($headers));
$headers = [];
for($i = 0; $i < 100; $i++) {
for ($i = 0; $i < 100; $i++) {
$headers['key-' . $i] = 'value_' . $i;
}
$this->assertTrue($this->object->isValid($headers));