Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
->notPath('l10n')
->notPath('src')
->notPath('vendor')
->notPath('tests/stubs')
->in(__DIR__);
return $config;
235 changes: 235 additions & 0 deletions LICENSES/AGPL-3.0-only.txt

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,21 @@ path = ["img/circles-dark.svg", "img/circles.svg"]
precedence = "aggregate"
SPDX-FileCopyrightText = "2018-2024 Google LLC"
SPDX-License-Identifier = "Apache-2.0"

[[annotations]]
path = ["tests/stubs/doctrine_dbal_**"]
precedence = "aggregate"
SPDX-FileCopyrightText = "none"
SPDX-License-Identifier = "MIT"

[[annotations]]
path = ["tests/stubs/symfony_component_**"]
precedence = "aggregate"
SPDX-FileCopyrightText = "none"
SPDX-License-Identifier = "MIT"

[[annotations]]
path = ["tests/stubs/stecman_component_**"]
precedence = "aggregate"
SPDX-FileCopyrightText = "none"
SPDX-License-Identifier = "MIT"
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@
"scripts": {
"cs:check": "php-cs-fixer fix --dry-run --diff",
"cs:fix": "php-cs-fixer fix",
"psalm": "psalm.phar --threads=1 --update-baseline",
"psalm:update-baseline": "psalm.phar --threads=1 --update-baseline",
"psalm": "psalm.phar --threads=1 --no-cache",
"psalm:update-baseline": "psalm.phar --threads=1 --no-cache --update-baseline",
"psalm:clear": "psalm.phar --clear-cache && psalm.phar --clear-global-cache",
"psalm:fix": "psalm.phar --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
"test": [
"@test:unit"
],
"test:unit": "vendor/bin/phpunit -c tests/phpunit.xml",
"lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l"
"lint": "find . -name \\*.php -not -path './vendor/*' -not -path './tests/stubs/*' -print0 | xargs -0 -n1 php -l"
},
"require-dev": {
"phpunit/phpunit": "^10.5",
"psalm/phar": "^5.22",
"psalm/phar": "^6.7",
"nextcloud/ocp": "dev-master",
"nextcloud/coding-standard": "^1.2"
}
Expand Down
18 changes: 9 additions & 9 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions lib/CirclesQueryHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CirclesQueryHelper {
/** @var CoreRequestBuilder */
private $coreRequestBuilder;

/** @var CoreQueryBuilder */
/** @var CoreQueryBuilder&IQueryBuilder */
private $queryBuilder;

/** @var FederatedUserService */
Expand All @@ -54,9 +54,9 @@ public function __construct(


/**
* @return IQueryBuilder
* @return CoreQueryBuilder&IQueryBuilder
*/
public function getQueryBuilder(): IQueryBuilder {
public function getQueryBuilder(): CoreQueryBuilder {
$this->queryBuilder = $this->coreRequestBuilder->getQueryBuilder();

return $this->queryBuilder;
Expand Down
24 changes: 16 additions & 8 deletions lib/Command/CirclesCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use OCA\Circles\Tools\Traits\TNCRequest;
use OCA\Circles\Tools\Traits\TStringTools;
use OCP\IAppConfig;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -181,6 +182,7 @@ private function checkLoopback(InputInterface $input, OutputInterface $output, s
$output->writeln('- <comment>You do not have a valid loopback address setup right now.</comment>');
$output->writeln('');

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
while (true) {
$question = new Question('<info>Please write down a new loopback address to test</info>: ', '');
Expand Down Expand Up @@ -265,13 +267,13 @@ private function testLoopback(InputInterface $input, OutputInterface $output): b
return false;
}

$timer = round(microtime(true) * 1000);
$timer = round(microtime(true) * 1000.0);
$output->write('- Creating async FederatedEvent ');
$test = new FederatedEvent(LoopbackTest::class);
$this->federatedEventService->newEvent($test);
$output->writeln(
'<info>' . $test->getWrapperToken() . '</info> ' .
'(took ' . (round(microtime(true) * 1000) - $timer) . 'ms)'
'(took ' . ((string)(round(microtime(true) * 1000.0) - $timer)) . 'ms)'
);

$output->writeln('- Waiting for async process to finish (5s)');
Expand All @@ -290,18 +292,18 @@ private function testLoopback(InputInterface $input, OutputInterface $output): b

$checkVerify = $wrapper->getEvent()->getData()->gInt('verify');
if ($checkVerify === LoopbackTest::VERIFY) {
$output->write('<info>verify=' . $checkVerify . '</info> ');
$output->write('<info>verify=' . ((string)$checkVerify) . '</info> ');
} else {
$output->writeln('<error>verify=' . $checkVerify . '</error>');
$output->writeln('<error>verify=' . ((string)$checkVerify) . '</error>');

return false;
}

$checkManage = $wrapper->getResult()->gInt('manage');
if ($checkManage === LoopbackTest::MANAGE) {
$output->write('<info>manage=' . $checkManage . '</info> ');
$output->write('<info>manage=' . ((string)$checkManage) . '</info> ');
} else {
$output->writeln('<error>manage=' . $checkManage . '</error>');
$output->writeln('<error>manage=' . ((string)$checkManage) . '</error>');

return false;
}
Expand All @@ -328,6 +330,7 @@ private function saveLoopback(InputInterface $input, OutputInterface $output, st
false, '/^(y|Y)/i'
);

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
if (!$helper->ask($input, $output, $question)) {
$output->writeln('skipping.');
Expand Down Expand Up @@ -364,6 +367,7 @@ private function checkInternal(InputInterface $input, OutputInterface $output, s
'- <comment>Do you want to enable this feature ?</comment> (y/N) ', false, '/^(y|Y)/i'
);

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
if (!$helper->ask($input, $output, $question)) {
$output->writeln('skipping.');
Expand Down Expand Up @@ -508,6 +512,7 @@ private function saveInternal(InputInterface $input, OutputInterface $output, st
false, '/^(y|Y)/i'
);

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
if (!$helper->ask($input, $output, $question)) {
$output->writeln('skipping.');
Expand Down Expand Up @@ -543,6 +548,7 @@ private function checkFrontal(InputInterface $input, OutputInterface $output, st
'- <comment>Do you want to enable this feature ?</comment> (y/N) ', false, '/^(y|Y)/i'
);

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
if (!$helper->ask($input, $output, $question)) {
$output->writeln('skipping.');
Expand Down Expand Up @@ -686,6 +692,7 @@ private function saveFrontal(InputInterface $input, OutputInterface $output, str
false, '/^(y|Y)/i'
);

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
if (!$helper->ask($input, $output, $question)) {
$output->writeln('skipping.');
Expand Down Expand Up @@ -733,7 +740,7 @@ private function testRequest(
$color = 'info';
}

$output->writeln('<' . $color . '>' . $result->getStatusCode() . '</' . $color . '>');
$output->writeln('<' . $color . '>' . ((string)$result->getStatusCode()) . '</' . $color . '>');
if ($result->getStatusCode() === 200) {
return true;
}
Expand All @@ -759,6 +766,7 @@ private function saveUrl(InputInterface $input, OutputInterface $output, string
'The address <info>' . $address . '</info> seems to reach your local Nextcloud.'
);

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
$output->writeln('');
$question = new ConfirmationQuestion(
Expand Down Expand Up @@ -801,7 +809,7 @@ private function parseAddress(string $test): array {
$path = rtrim($path, '/');

if (!is_null($cloudIdPort)) {
$cloudId = $cloudId . ':' . $cloudIdPort;
$cloudId = $cloudId . ':' . ((string)$cloudIdPort);
}

return [$scheme, $cloudId, $path];
Expand Down
2 changes: 1 addition & 1 deletion lib/Command/CirclesConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (FederatedItemException $e) {
if ($input->getOption('status-code')) {
throw new FederatedItemException(
' [' . get_class($e) . ', ' . $e->getStatus() . ']' . "\n" . $e->getMessage()
' [' . get_class($e) . ', ' . ((string)$e->getStatus()) . ']' . "\n" . $e->getMessage()
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Command/CirclesCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (FederatedItemException $e) {
if ($input->getOption('status-code')) {
throw new FederatedItemException(
' [' . get_class($e) . ', ' . $e->getStatus() . ']' . "\n" . $e->getMessage()
' [' . get_class($e) . ', ' . ((string)$e->getStatus()) . ']' . "\n" . $e->getMessage()
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Command/CirclesDestroy.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (FederatedItemException $e) {
if ($input->getOption('status-code')) {
throw new FederatedItemException(
' [' . get_class($e) . ', ' . $e->getStatus() . ']' . "\n" . $e->getMessage()
' [' . get_class($e) . ', ' . ((string)$e->getStatus()) . ']' . "\n" . $e->getMessage()
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Command/CirclesDetails.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (FederatedItemException $e) {
if ($input->getOption('status-code')) {
throw new FederatedItemException(
' [' . get_class($e) . ', ' . $e->getStatus() . ']' . "\n" . $e->getMessage()
' [' . get_class($e) . ', ' . ((string)$e->getStatus()) . ']' . "\n" . $e->getMessage()
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Command/CirclesEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (FederatedItemException $e) {
if ($input->getOption('status-code')) {
throw new FederatedItemException(
' [' . get_class($e) . ', ' . $e->getStatus() . ']' . "\n" . $e->getMessage()
' [' . get_class($e) . ', ' . ((string)$e->getStatus()) . ']' . "\n" . $e->getMessage()
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Command/CirclesJoin.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (FederatedItemException $e) {
if ($input->getOption('status-code')) {
throw new FederatedItemException(
' [' . get_class($e) . ', ' . $e->getStatus() . ']' . "\n" . $e->getMessage()
' [' . get_class($e) . ', ' . ((string)$e->getStatus()) . ']' . "\n" . $e->getMessage()
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Command/CirclesLeave.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
} catch (FederatedItemException $e) {
if ($input->getOption('status-code')) {
throw new FederatedItemException(
' [' . get_class($e) . ', ' . $e->getStatus() . ']' . "\n" . $e->getMessage()
' [' . get_class($e) . ', ' . ((string)$e->getStatus()) . ']' . "\n" . $e->getMessage()
);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/Command/CirclesList.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ private function displayCircles(array $circles): void {
Circle::$DEF_SOURCE[$circle->getSource()],
$this->cut($displayName ? $owner->getDisplayName() : $owner->getUserId(), 40),
$this->configService->displayInstance($owner->getInstance()),
$circle->getPopulation() . '/'
. $this->getInt('members_limit', $circle->getSettings(), -1)
. ' (' . $circle->getPopulationInherited() . ')'
((string)$circle->getPopulation()) . '/'
. ((string)$this->getInt('members_limit', $circle->getSettings(), -1))
. ' (' . ((string)$circle->getPopulationInherited()) . ')'
]
);
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Command/CirclesMaintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use OCA\Circles\Service\MaintenanceService;
use OCA\Circles\Service\OutputService;
use OCP\IDBConnection;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand Down Expand Up @@ -92,6 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'/^(y|Y)/i'
);

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
if (!$helper->ask($input, $output, $question)) {
$output->writeln('aborted.');
Expand All @@ -107,6 +109,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
. '\'</comment>: ', ''
);

/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
$confirmation = $helper->ask($input, $output, $question);
if (strtolower($confirmation) !== $action) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Command/CirclesMemberships.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($count === 0) {
$output->writeln('(database not updated)');
} else {
$output->writeln('(' . $count . ' entries generated/updated in the database)');
$output->writeln('(' . ((string)$count) . ' entries generated/updated in the database)');
}

foreach ($federatedUser->getMemberships() as $membership) {
Expand Down Expand Up @@ -379,6 +379,6 @@ private function manageAllMemberships() {
);
}

$output->writeln($count . ' memberships updated');
$output->writeln(((string)$count) . ' memberships updated');
}
}
5 changes: 4 additions & 1 deletion lib/Command/CirclesRemote.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCA\Circles\Tools\Model\NCSignedRequest;
use OCA\Circles\Tools\Traits\TNCWellKnown;
use OCA\Circles\Tools\Traits\TStringTools;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand Down Expand Up @@ -246,7 +247,7 @@ private function requestInstance(string $host): void {

$result = $signedRequest->getOutgoingRequest()->getResult();
$code = $result->getStatusCode();
$this->output->writeln(' * Result: ' . (($code === 200) ? '<info>' . $code . '</info>' : $code));
$this->output->writeln(' * Result: ' . (($code === 200) ? '<info>' . ((string)$code) . '</info>' : $code));
$this->output->writeln(
json_encode(json_decode($result->getContent(), true), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
);
Expand Down Expand Up @@ -318,6 +319,7 @@ private function requestInstance(string $host): void {
*/
private function saveRemote(RemoteInstance $remoteSignatory) {
$this->output->writeln('');
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');

$this->output->writeln(
Expand Down Expand Up @@ -349,6 +351,7 @@ private function saveRemote(RemoteInstance $remoteSignatory) {
*/
private function updateRemote(RemoteInstance $remoteSignatory): void {
$this->output->writeln('');
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');

$this->output->writeln(
Expand Down
Loading
Loading