mirror of
https://github.com/vlucas/valitron.git
synced 2025-12-30 23:01:52 +00:00
fix bug moving message loading to constructor and replace require with include to avoid fatal error
This commit is contained in:
parent
ca4f6737dc
commit
367ec9a7c7
@ -44,8 +44,8 @@ class Validator
|
||||
// set langDir in the follow order: constructor param, static::$_langDir, default to package lang dir
|
||||
$langDir = $langDir ?: static::langDir();
|
||||
|
||||
static::langDir($langDir);
|
||||
static::lang($lang);
|
||||
// Load language file in directory
|
||||
static::$_ruleMessages = include rtrim($langDir, '/') . '/' . $lang . '.php';
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,10 +55,6 @@ class Validator
|
||||
{
|
||||
if($lang !== null) {
|
||||
static::$_lang = $lang;
|
||||
|
||||
// Load language file in directory
|
||||
$langDir = static::langDir();
|
||||
static::$_ruleMessages = require rtrim($langDir, '/') . '/' . $lang . '.php';
|
||||
}
|
||||
return static::$_lang ?: 'en';
|
||||
}
|
||||
|
||||
@ -3,11 +3,11 @@ use Valitron\Validator;
|
||||
|
||||
class StaticVsInstanceTest extends BaseTestCase
|
||||
{
|
||||
public function testInstanceOverrideStatic()
|
||||
public function testInstanceOverrideStaticLang()
|
||||
{
|
||||
Validator::lang('ar');
|
||||
new Validator(array(), array(), 'en');
|
||||
$this->assertEquals('ar', Validator::lang(),
|
||||
'lang defined statically should not be override by instance lang');
|
||||
'instance defined lang should not replace static global lang');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user