Skip to content

Commit

Permalink
feat(psalm): Add all stubs
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed Feb 18, 2025
1 parent 32cfbb8 commit 313d9be
Show file tree
Hide file tree
Showing 74 changed files with 13,744 additions and 1,193 deletions.
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;
8 changes: 8 additions & 0 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 @@ -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 @@ -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
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
3 changes: 3 additions & 0 deletions 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 @@ -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
100 changes: 68 additions & 32 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,74 @@
phpVersion="8.1"
>
<stubs>
<file name="tests/stub.phpstub" preloadClasses="true"/>
<file name="tests/stubs/doctrine_dbal_driver_exception.php" />
<file name="tests/stubs/doctrine_dbal_connections_primaryreadreplicaconnection.php" />
<file name="tests/stubs/doctrine_dbal_connection.php" />
<file name="tests/stubs/doctrine_dbal_exception.php" />
<file name="tests/stubs/doctrine_dbal_exception_serverexception.php" />
<file name="tests/stubs/doctrine_dbal_exception_driverexception.php" />
<file name="tests/stubs/doctrine_dbal_exception_constraintviolationexception.php" />
<file name="tests/stubs/doctrine_dbal_exception_uniqueconstraintviolationexception.php" />
<file name="tests/stubs/doctrine_dbal_query_querybuilder.php" />
<file name="tests/stubs/doctrine_dbal_schema_abstractasset.php" />
<file name="tests/stubs/doctrine_dbal_schema_index.php" />
<file name="tests/stubs/doctrine_dbal_schema_schemaexception.php" />
<file name="tests/stubs/doctrine_dbal_schema_table.php" />
<file name="tests/stubs/doctrine_dbal_schema_constraint.php" />
<file name="tests/stubs/oc.php" />
<file name="tests/stubs/oc_appframework_utility_simplecontainer.php" />
<file name="tests/stubs/oc_db_connectionadapter.php" />
<file name="tests/stubs/oc_db_exceptions_dbalexception.php" />
<file name="tests/stubs/oc_db_querybuilder_querybuilder.php" />
<file name="tests/stubs/oc_files_cache_cache.php" />
<file name="tests/stubs/oc_files_cache_cacheentry.php" />
<file name="tests/stubs/oc_files_mount_manager.php" />
<file name="tests/stubs/oc_files_mount_mountpoint.php" />
<file name="tests/stubs/oc_group_group.php" />
<file name="tests/stubs/oc_group_manager.php" />
<file name="tests/stubs/oc_hooks_basicemitter.php" />
<file name="tests/stubs/oc_hooks_emitter.php" />
<file name="tests/stubs/oc_hooks_publicemitter.php" />
<file name="tests/stubs/oc_server.php" />
<file name="tests/stubs/oc_servercontainer.php" />
<file name="tests/stubs/oc_share20_share.php" />
<file name="tests/stubs/oc_share20_shareattributes.php" />
<file name="tests/stubs/oc_systemconfig.php" />
<file name="tests/stubs/oc_user_manager.php" />
<file name="tests/stubs/oc_user_nouserexception.php" />
<file name="tests/stubs/oc_user_user.php" />
<file name="tests/stubs/oca_dav_carddav_contactsmanager.php" />
<file name="tests/stubs/oca_files_sharing_external_manager.php" />
<file name="tests/stubs/symfony_component_console_output_outputinterface.php" />
<file name="tests/stubs/oca_files_app.php" />
<file name="tests/stubs/oc_appframework_bootstrap_coordinator.php" />
<file name="tests/stubs/oc_appframework_bootstrap_serviceregistration.php" />
<file name="tests/stubs/oca_federatedfilesharing_notifications.php" />
<file name="tests/stubs/oc_core_command_base.php" />
<file name="tests/stubs/oc_appframework_middleware_security_exceptions_notloggedinexception.php" />
<file name="tests/stubs/oc_appframework_middleware_security_exceptions_securityexception.php" />
<file name="tests/stubs/oc_appframework_bootstrap_registrationcontext.php" />
<file name="tests/stubs/oc_appframework_bootstrap_aregistration.php" />
<file name="tests/stubs/symfony_component_console_command_command.php" />
<file name="tests/stubs/stecman_component_symfony_console_bashcompletion_completion_completionawareinterface.php" />
<file name="tests/stubs/symfony_component_console_output_consoleoutput.php" />
<file name="tests/stubs/symfony_component_console_output_streamoutput.php" />
<file name="tests/stubs/symfony_component_console_output_output.php" />
<file name="tests/stubs/symfony_component_console_output_consoleoutputinterface.php" />
<file name="tests/stubs/symfony_component_console_input_inputoption.php" />
<file name="tests/stubs/symfony_component_console_input_inputinterface.php" />
<file name="tests/stubs/symfony_component_console_input_inputargument.php" />
<file name="tests/stubs/symfony_component_console_input_inputoption.php" />
<file name="tests/stubs/symfony_component_console_question_question.php" />
<file name="tests/stubs/symfony_component_console_question_confirmationquestion.php" />
<file name="tests/stubs/symfony_component_console_helper_helperinterface.php" />
<file name="tests/stubs/symfony_component_console_helper_questionhelper.php" />
<file name="tests/stubs/symfony_component_console_helper_helper.php" />
<file name="tests/stubs/symfony_component_console_helper_table.php" />
<file name="tests/stubs/symfony_component_console_output_consolesectionoutput.php" />
<file name="tests/stubs/oc_db_schemawrapper.php" />
<file name="tests/stubs/oc_db_connection.php" />
<file name="tests/stubs/symfony_component_process_process.php" />
</stubs>
<projectFiles>
<directory name="lib" />
Expand All @@ -24,35 +91,4 @@
<directory name="vendor/phpunit/php-code-coverage" />
</ignoreFiles>
</extraFiles>
<issueHandlers>
<UndefinedClass>
<errorLevel type="suppress">
<referencedClass name="OC" />
<referencedClass name="OC\DB\Exceptions\DbalException" />
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
<referencedClass name="OCA\Files\App" />
<referencedClass name="OCA\Files_Sharing\External\Manager" />
<referencedClass name="OCP\Accounts\UserUpdatedEvent" />
<referencedClass name="OCA\Files\Event\LoadAdditionalScriptsEvent" />
<referencedClass name="OC\Share20\ShareAttributes" />
<referencedClass name="Symfony\Component\Console\Question\Question" />
<referencedClass name="Symfony\Component\Console\Output\ConsoleOutput" />
<referencedClass name="Symfony\Component\Console\Exception\MissingInputException" />
<referencedClass name="Symfony\Component\Process\Process" />
</errorLevel>
</UndefinedClass>
<UndefinedDocblockClass>
<errorLevel type="suppress">
<referencedClass name="Doctrine\DBAL\Schema\Schema" />
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
<referencedClass name="Doctrine\DBAL\Driver\Statement" />
<referencedClass name="Doctrine\DBAL\Schema\Table" />
</errorLevel>
</UndefinedDocblockClass>
<InvalidThrow>
<errorLevel type="suppress">
<referencedClass name="OC\DB\Exceptions\DbalException" />
</errorLevel>
</InvalidThrow>
</issueHandlers>
</psalm>
83 changes: 28 additions & 55 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
<code><![CDATA[str_starts_with($sK, '_')]]></code>
</TypeDoesNotContainType>
</file>
<file src="lib/AppInfo/Application.php">
<InvalidArgument>
<code><![CDATA[function () {
$l = OC::$server->getL10N('circles');
return [
'id' => 'circlesfilter',
'appname' => 'circles',
'script' => 'files/list.php',
'order' => 25,
'name' => $l->t('Shared to Circles'),
];
}]]></code>
</InvalidArgument>
</file>
<file src="lib/Circles/FileSharingBroadcaster.php">
<InvalidScalarArgument>
<code><![CDATA[$share->getId()]]></code>
Expand All @@ -17,16 +32,10 @@
<code><![CDATA[!$sendPasswordByMail]]></code>
<code><![CDATA[$sendPasswordByMail]]></code>
</TypeDoesNotContainType>
<UndefinedClass>
<code><![CDATA[Notifications]]></code>
</UndefinedClass>
<UndefinedDocblockClass>
<code><![CDATA[$this->federationNotifications]]></code>
<code><![CDATA[Notifications]]></code>
</UndefinedDocblockClass>
<UndefinedInterfaceMethod>
<code><![CDATA[getLazyRootFolder]]></code>
</UndefinedInterfaceMethod>
<UndefinedMethod>
<code><![CDATA[getLogger]]></code>
<code><![CDATA[getLogger]]></code>
</UndefinedMethod>
</file>
<file src="lib/Command/CirclesRemote.php">
<UndefinedMethod>
Expand All @@ -43,15 +52,6 @@
<code><![CDATA[retrieveJson]]></code>
</UndefinedMethod>
</file>
<file src="lib/Db/CoreRequestBuilder.php">
<UndefinedClass>
<code><![CDATA[Connection]]></code>
</UndefinedClass>
<UndefinedMethod>
<code><![CDATA[dropTable]]></code>
<code><![CDATA[hasTable]]></code>
</UndefinedMethod>
</file>
<file src="lib/Db/FileSharesRequest.php">
<InvalidScalarArgument>
<code><![CDATA[self::SHARE_TYPE]]></code>
Expand Down Expand Up @@ -79,9 +79,6 @@
<code><![CDATA[$shareId]]></code>
<code><![CDATA[$shareId]]></code>
</InvalidScalarArgument>
<UndefinedClass>
<code><![CDATA[UniqueConstraintViolationException]]></code>
</UndefinedClass>
</file>
<file src="lib/FederatedItems/SharedItemsSync.php">
<UndefinedClass>
Expand All @@ -97,15 +94,6 @@
<code><![CDATA[$shareWrapper->getFileSource()]]></code>
</InvalidOperand>
</file>
<file src="lib/Migration/Version0022Date20220526111723.php">
<UndefinedClass>
<code><![CDATA[Connection]]></code>
</UndefinedClass>
<UndefinedDocblockClass>
<code><![CDATA[$this->connection]]></code>
<code><![CDATA[Connection]]></code>
</UndefinedDocblockClass>
</file>
<file src="lib/Migration/Version0022Date20220526113601.php">
<UndefinedClass>
<code><![CDATA[Types]]></code>
Expand Down Expand Up @@ -190,23 +178,12 @@
<code><![CDATA[self]]></code>
</LessSpecificImplementedReturnType>
</file>
<file src="lib/Model/Mount.php">
<MissingDependency>
<code><![CDATA[CircleMountManager]]></code>
<code><![CDATA[CircleMountManager]]></code>
<code><![CDATA[CircleMountManager]]></code>
</MissingDependency>
</file>
<file src="lib/Model/Probes/BasicProbe.php">
<InvalidReturnType>
<code><![CDATA[$this]]></code>
</InvalidReturnType>
</file>
<file src="lib/Model/ShareWrapper.php">
<InvalidArgument>
<code><![CDATA[$attributes]]></code>
<code><![CDATA[Cache::cacheEntryFromData($this->getFileCache()->toCache(), OC::$server->getMimeTypeLoader())]]></code>
</InvalidArgument>
<InvalidNullableReturnType>
<code><![CDATA[Circle]]></code>
<code><![CDATA[FileCacheWrapper]]></code>
Expand Down Expand Up @@ -245,10 +222,18 @@
<code><![CDATA[MoveableMount]]></code>
</UndefinedClass>
</file>
<file src="lib/MountManager/CircleMountManager.php">
<InvalidReturnStatement>
<code><![CDATA[$this]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[bool]]></code>
<code><![CDATA[getMountManager]]></code>
</InvalidReturnType>
</file>
<file src="lib/MountManager/CircleMountProvider.php">
<MissingDependency>
<code><![CDATA[CircleMount]]></code>
<code><![CDATA[private]]></code>
</MissingDependency>
<UndefinedClass>
<code><![CDATA[ExternalStorage]]></code>
Expand All @@ -265,11 +250,6 @@
<code><![CDATA[$loopback['port']]]></code>
</InvalidOperand>
</file>
<file src="lib/Service/ContactService.php">
<UndefinedClass>
<code><![CDATA[ContactsManager]]></code>
</UndefinedClass>
</file>
<file src="lib/Service/FederatedShareService.php">
<InvalidMethodCall>
<code><![CDATA[gObj]]></code>
Expand Down Expand Up @@ -302,9 +282,6 @@
<InvalidOperand>
<code><![CDATA[$data->gInt('id')]]></code>
</InvalidOperand>
<UndefinedClass>
<code><![CDATA[ContactsManager]]></code>
</UndefinedClass>
</file>
<file src="lib/Service/MiscService.php">
<InvalidOperand>
Expand All @@ -316,10 +293,6 @@
<TypeDoesNotContainType>
<code><![CDATA[is_array($contact)]]></code>
</TypeDoesNotContainType>
<UndefinedDocblockClass>
<code><![CDATA[$cManager]]></code>
<code><![CDATA[$cManager]]></code>
</UndefinedDocblockClass>
</file>
<file src="lib/Service/RemoteStreamService.php">
<RedundantCondition>
Expand Down
Loading

0 comments on commit 313d9be

Please sign in to comment.