Merge branch '1.x'

This commit is contained in:
Fiachra Mcdermott 2022-06-21 14:50:45 -04:00
commit e56a90f322
2 changed files with 84 additions and 0 deletions

View File

@ -116,3 +116,14 @@ function logger($message = null, array $context = [])
return app('log')->debug($message, $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) {}

View File

@ -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