mirror of
https://github.com/danog/psalm-plugin-laravel.git
synced 2024-11-26 20:34:48 +01:00
Merge pull request #230 from psalm/config-helper
feature: add basic stub for config helper
This commit is contained in:
commit
823119c293
@ -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
tests/acceptance/ConfigTypes.feature
Normal file
73
tests/acceptance/ConfigTypes.feature
Normal 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
|
Loading…
Reference in New Issue
Block a user