1
0
Fork 0

Allow ints in source/dist reference

pull/9864/head
Jordi Boggiano 2021-04-30 09:40:58 +02:00
parent 832af78e28
commit 832f4007d6
No known key found for this signature in database
GPG Key ID: 7BBD42C429EC80BC
2 changed files with 9 additions and 2 deletions

View File

@ -323,8 +323,8 @@ class ValidatingArrayLoader implements LoaderInterface
if (!is_string($this->config[$srcType]['url'])) {
$this->errors[] = $srcType . '.url : should be a string, '.gettype($this->config[$srcType]['url']).' given';
}
if (isset($this->config[$srcType]['reference']) && !is_string($this->config[$srcType]['reference'])) {
$this->errors[] = $srcType . '.reference : should be a string, '.gettype($this->config[$srcType]['reference']).' given';
if (isset($this->config[$srcType]['reference']) && !is_string($this->config[$srcType]['reference']) && !is_int($this->config[$srcType]['reference'])) {
$this->errors[] = $srcType . '.reference : should be a string or int, '.gettype($this->config[$srcType]['reference']).' given';
}
if (isset($this->config[$srcType]['reference']) && preg_match('{^\s*-}', $this->config[$srcType]['reference'])) {
$this->errors[] = $srcType . '.reference : must not start with a "-", "'.$this->config[$srcType]['reference'].'" given';

View File

@ -194,6 +194,13 @@ class ValidatingArrayLoaderTest extends TestCase
'name' => 'npm-asset/angular--core',
),
),
array( // refs as int or string
array(
'name' => 'foo/bar',
'source' => array('url' => 'https://example.org', 'reference' => 1234, 'type' => 'baz'),
'dist' => array('url' => 'https://example.org', 'reference' => 'foobar', 'type' => 'baz'),
),
),
);
}