nextcloud / nextcloud/server

OCP class throws private exception

Open
#35,633 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop enhancement technical debt
Dominant language
PHP
Stars
36.9k
Forks
5.2k
Avg merge
2d 3h
Merged PRs (30d)
713

Description

Talk was catching it for a while but with the Psalm5 update it started complaining:

ERROR: UndefinedClass - lib/TInitialState.php:143:13 - Class, interface or enum named OC\User\NoUserException does not exist (see https://psalm.dev/019)
			} catch (NoUserException $e) {

https://github.com/nextcloud/server/blob/44a8ebdc1fa796d4f7dc453c58561b64902ca12f/lib/public/Files/IRootFolder.php#L28
https://github.com/nextcloud/server/blob/44a8ebdc1fa796d4f7dc453c58561b64902ca12f/lib/public/Files/IRootFolder.php#L42

Also extending the non public Emitter is not too good, but I'm totally fine providing a stub for that. But the OC catch I don't want to "mock".

I guess we need to make a new class, but if that extends the private one Psalm will complain again...

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Psalm5 error at lib/TInitialState.php:143 and inspect the public exception declarations referenced in lib/public/Files/IRootFolder.php. Determine how the NoUserException catch can use a public class without extending the private exception, and account for the non-public Emitter concern. Done means the intended OCP classes are available without Psalm UndefinedClass errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.