Skip to content

Commit

Permalink
Merge branch '1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-feek committed Jun 21, 2022
2 parents c82b7c7 + 823119c commit e56a90f
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
11 changes: 11 additions & 0 deletions stubs/helpers.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,14 @@ function logger($message = null, array $context = [])

return app('log')->debug($message, $context);
}

/**
* Get / set the specified configuration value.
*
* If an array is passed as the key, we will assume you want to set an array of values.
*
* @param array<string, mixed>|string|null $key
* @param mixed $default
* @return ($key is null ? \Illuminate\Config\Repository : ($key is array ? null : mixed))
*/
function config($key = null, $default = null) {}
73 changes: 73 additions & 0 deletions tests/acceptance/ConfigTypes.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Feature: Config helper
The global config helper will return a strict type

Background:
Given I have the following config
"""
<?xml version="1.0"?>
<psalm errorLevel="1">
<projectFiles>
<directory name="."/>
<ignoreFiles> <directory name="../../vendor"/> </ignoreFiles>
</projectFiles>
<plugins>
<pluginClass class="Psalm\LaravelPlugin\Plugin"/>
</plugins>
</psalm>
"""
And I have the following code preamble
"""
<?php declare(strict_types=1);
"""

Scenario: config with no arguments returns a repository instance
Given I have the following code
"""
function test(): \Illuminate\Config\Repository {
return config();
}
"""
When I run Psalm
Then I see no errors

Scenario: config with one argument
Given I have the following code
"""
/**
* @return mixed
*/
function test()
{
return config('app.name');
}
"""
When I run Psalm
Then I see no errors

Scenario: config with first null argument and second argument provided
Given I have the following code
"""
/**
* @return mixed
*/
function test()
{
return config('app.non-existent', false);
}
"""
When I run Psalm
Then I see no errors

Scenario: config setting at runtime
Given I have the following code
"""
/**
* @return null
*/
function test()
{
return config(['app.non-existent' => false]);
}
"""
When I run Psalm
Then I see no errors

0 comments on commit e56a90f

Please sign in to comment.