fix: validate types of excluded words and word list in PassphraseServ…#41
Conversation
…iceProvider Co-authored-by: Copilot <copilot@github.com>
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR introduces configuration-level type validation for word lists in the service provider, adds PHPDoc mixin annotation to the facade, updates PHPStan configuration to analyze both source and test code, and hardens tests with null-safe operators and explicit error handling. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 47 minutes and 49 seconds.Comment |
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
…tan configuration Co-authored-by: Copilot <copilot@github.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/LaravelIntegrationTest.php (1)
126-149: 🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick winAdd tests for non-string elements in
word_listandexcluded_words.The new runtime behavior in
PassphraseServiceProvidervalidates array element types, but this file currently only tests non-array config values. Please add assertions for mixed arrays (e.g.,['ok', 123]) expectingWordListException::invalidType()andWordListException::invalidExcludedWordsType().Proposed test additions
+ public function test_non_string_word_list_item_throws_clear_message(): void + { + config(['passphrase.word_list' => ['correct', 123, 'staple']]); + $this->refreshServiceProvider(); + $this->expectExceptionObject(\NicoBleiler\Passphrase\Exceptions\WordListException::invalidType()); + $this->app?->make(WordList::class); + } + + public function test_non_string_excluded_words_item_throws_clear_message(): void + { + config([ + 'passphrase.word_list' => ['correct', 'horse', 'battery', 'staple'], + 'passphrase.excluded_words' => ['horse', 999], + ]); + $this->refreshServiceProvider(); + $this->expectExceptionObject(\NicoBleiler\Passphrase\Exceptions\WordListException::invalidExcludedWordsType()); + $this->app?->make(WordList::class); + }As per coding guidelines:
tests/**/*.php: Add/adjust tests intests/for any behavioral change.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/LaravelIntegrationTest.php` around lines 126 - 149, Add two tests in tests/LaravelIntegrationTest.php after the existing non-array tests that verify mixed-type arrays throw the new WordList exceptions: create test_word_list_with_non_string_element_throws which sets config(['passphrase.word_list' => ['ok', 123]]) then calls $this->refreshServiceProvider(), asserts $this->expectExceptionObject(WordListException::invalidType()), and invokes $this->app?->make(WordList::class); and create test_excluded_words_with_non_string_element_throws which sets config(['passphrase.word_list' => ['ok','horse'], 'passphrase.excluded_words' => ['ok', 123]]), calls $this->refreshServiceProvider(), asserts $this->expectExceptionObject(WordListException::invalidExcludedWordsType()), and invokes $this->app?->make(WordList::class); ensure names reference WordListException and the WordList binding so failures map to PassphraseServiceProvider validation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@tests/LaravelIntegrationTest.php`:
- Around line 126-149: Add two tests in tests/LaravelIntegrationTest.php after
the existing non-array tests that verify mixed-type arrays throw the new
WordList exceptions: create test_word_list_with_non_string_element_throws which
sets config(['passphrase.word_list' => ['ok', 123]]) then calls
$this->refreshServiceProvider(), asserts
$this->expectExceptionObject(WordListException::invalidType()), and invokes
$this->app?->make(WordList::class); and create
test_excluded_words_with_non_string_element_throws which sets
config(['passphrase.word_list' => ['ok','horse'], 'passphrase.excluded_words' =>
['ok', 123]]), calls $this->refreshServiceProvider(), asserts
$this->expectExceptionObject(WordListException::invalidExcludedWordsType()), and
invokes $this->app?->make(WordList::class); ensure names reference
WordListException and the WordList binding so failures map to
PassphraseServiceProvider validation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 3b26f1c3-7af8-4b8e-8461-f4ba05187bf0
📒 Files selected for processing (4)
phpstan.dist.neonsrc/Facades/Passphrase.phpsrc/PassphraseServiceProvider.phptests/LaravelIntegrationTest.php
…uded words Co-authored-by: Copilot <copilot@github.com>
|
🎉 This PR is included in version 2.2.0-alpha.2 🎉 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 📦🚀 |
…iceProvider
Summary by CodeRabbit
New Features
Chores