Dev#40
Conversation
…thod Co-authored-by: Copilot <copilot@github.com>
… PassphraseServiceProvider Co-authored-by: Copilot <copilot@github.com>
…Provider to use it Co-authored-by: Copilot <copilot@github.com>
…te PassphraseServiceProvider to utilize them Co-authored-by: Copilot <copilot@github.com>
…_separator, non-boolean capitalize, and non-boolean include_number configurations Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
…e hint Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
chore(deps): update dependency ubuntu to v24
WalkthroughThis PR introduces a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.1.51)PHP Parse error: syntax error, unexpected token "->" in /vendor/phpunit/phpunit/src/Runner/Version.php on line 38 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/PassphraseServiceProvider.php`:
- Around line 21-33: The provider currently only checks that $excludedWords and
$wordList are arrays, allowing non-string elements to slip through and later
raise WordListException; update the validation in PassphraseServiceProvider to
ensure every element is a string before calling WordList::fromArray — for
example, after confirming is_array($excludedWords) and is_array($wordList)
validate with array_filter/is_string (or a simple loop) and if any element is
not a string throw ConfigException::invalidExcludedWords() or
ConfigException::invalidWordList() respectively so the config-validation
exception contract is preserved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 865bab7b-94e6-4854-834a-f61cde03a26d
📒 Files selected for processing (12)
.github/workflows/test.yml.github/workflows/trivy.yml.gitignorecomposer.jsonphpstan.dist.neonrector.phprenovate.jsonsrc/Exceptions/ConfigException.phpsrc/Exceptions/WordListException.phpsrc/PassphraseServiceProvider.phpsrc/WordList.phptests/LaravelIntegrationTest.php
💤 Files with no reviewable changes (1)
- src/Exceptions/WordListException.php
| if (! is_array($excludedWords)) { | ||
| throw WordListException::invalidExcludedWordsConfigType(); | ||
| throw ConfigException::invalidExcludedWords(); | ||
| } | ||
|
|
||
| /** @var array<string> $excludedWords */ | ||
| if ($wordList !== null) { | ||
| if (! is_array($wordList)) { | ||
| throw WordListException::invalidConfigType(); | ||
| throw ConfigException::invalidWordList(); | ||
| } | ||
|
|
||
| /** @var array<string> $wordList */ | ||
|
|
||
| return WordList::fromArray($wordList)->excludeWords($excludedWords); |
There was a problem hiding this comment.
Validate word_list/excluded_words element types in provider.
Line 21 and Line 27 only validate that values are arrays. Arrays containing non-strings currently bypass this layer and fail later with WordListException, which breaks the new config-validation exception contract.
🔧 Proposed fix
if (! is_array($excludedWords)) {
throw ConfigException::invalidExcludedWords();
}
+ foreach ($excludedWords as $excludedWord) {
+ if (! is_string($excludedWord)) {
+ throw ConfigException::invalidExcludedWords();
+ }
+ }
/** `@var` array<string> $excludedWords */
if ($wordList !== null) {
if (! is_array($wordList)) {
throw ConfigException::invalidWordList();
}
+ foreach ($wordList as $configuredWord) {
+ if (! is_string($configuredWord)) {
+ throw ConfigException::invalidWordList();
+ }
+ }
/** `@var` array<string> $wordList */As per coding guidelines: "Keep error handling explicit with package exception types where appropriate".
🧰 Tools
🪛 PHPMD (2.15.0)
[error] 22-22: Avoid using static access to class '\NicoBleiler\Passphrase\Exceptions\ConfigException' in method 'register'. (undefined)
(StaticAccess)
[error] 28-28: Avoid using static access to class '\NicoBleiler\Passphrase\Exceptions\ConfigException' in method 'register'. (undefined)
(StaticAccess)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/PassphraseServiceProvider.php` around lines 21 - 33, The provider
currently only checks that $excludedWords and $wordList are arrays, allowing
non-string elements to slip through and later raise WordListException; update
the validation in PassphraseServiceProvider to ensure every element is a string
before calling WordList::fromArray — for example, after confirming
is_array($excludedWords) and is_array($wordList) validate with
array_filter/is_string (or a simple loop) and if any element is not a string
throw ConfigException::invalidExcludedWords() or
ConfigException::invalidWordList() respectively so the config-validation
exception contract is preserved.
|
🎉 This PR is included in version 2.2.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 2.2.0-beta.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary by CodeRabbit
Release Notes
Configuration & Error Handling
Performance
Code Quality