yiisoft / yiisoft/injector

Make `MissingRequiredArgumentException` more friendly

Open
#87 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:ready for adoption type:enhancement
Dominant language
PHP
Stars
94
Forks
17
Avg merge
56m
Merged PRs (30d)
1

Description

It would be nice to improve the MissingRequiredArgumentException - add a flag whether the Container is passed to the Injector.

And if the Container is not passed, and the argument being resolved is a class, then output a friendly message (FriendlyException) will be like "pass an object of the required type as an argument to invoke()/make() or pass a Container when creating the Injector"

If the Container parameter was set, then the friendly message will be like "add an object of the required type to the argument list or make sure that the configured Container can resolve it"

Originally posted by @roxblnfk in https://github.com/yiisoft/injector/issues/86#issuecomment-1864146016

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 by locating MissingRequiredArgumentException and the Injector paths for invoke() and make(), then inspect how Container presence is currently available during resolution. Implement the two requested messages based on whether a Container was passed, and verify that missing class arguments produce the appropriate FriendlyException wording.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.