mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Update config key to be more accurate ref #85
This commit is contained in:
parent
d3abc0011d
commit
a0711de023
@ -23,7 +23,7 @@
|
||||
<xs:attribute name="allowFileIncludes" type="xs:string" />
|
||||
<xs:attribute name="totallyTyped" type="xs:string" />
|
||||
<xs:attribute name="strictBinaryOperands" type="xs:string" />
|
||||
<xs:attribute name="addVoidDocblockReturnType" type="xs:string" />
|
||||
<xs:attribute name="requireVoidReturnType" type="xs:string" />
|
||||
<xs:attribute name="useAssertForType" type="xs:string" />
|
||||
</xs:complexType>
|
||||
|
||||
|
@ -297,8 +297,8 @@ class Config
|
||||
$config->strict_binary_operands = $attribute_text === 'true' || $attribute_text === '1';
|
||||
}
|
||||
|
||||
if (isset($config_xml['addVoidDocblockReturnType'])) {
|
||||
$attribute_text = (string) $config_xml['addVoidDocblockReturnType'];
|
||||
if (isset($config_xml['requireVoidReturnType'])) {
|
||||
$attribute_text = (string) $config_xml['requireVoidReturnType'];
|
||||
$config->add_void_docblocks = $attribute_text === 'true' || $attribute_text === '1';
|
||||
}
|
||||
|
||||
|
@ -305,4 +305,60 @@ class ConfigTest extends PHPUnit_Framework_TestCase
|
||||
$context = new Context();
|
||||
$file_checker->visitAndAnalyzeMethods($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Psalm\Exception\CodeException
|
||||
* @expectedExceptionMessage MissingReturnType
|
||||
* @return void
|
||||
*/
|
||||
public function testRequireVoidReturnTypeExists()
|
||||
{
|
||||
$this->project_checker->setConfig(
|
||||
TestConfig::loadFromXML(
|
||||
'psalm.xml',
|
||||
'<?xml version="1.0"?>
|
||||
<psalm
|
||||
requireVoidReturnType="true">
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
</projectFiles>
|
||||
</psalm>'
|
||||
)
|
||||
);
|
||||
|
||||
$stmts = self::$parser->parse('<?php
|
||||
function foo() {}
|
||||
');
|
||||
|
||||
$file_checker = new FileChecker(getcwd() . '/src/somefile.php', $this->project_checker, $stmts);
|
||||
$context = new Context();
|
||||
$file_checker->visitAndAnalyzeMethods($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function testDoNotRequireVoidReturnTypeExists()
|
||||
{
|
||||
$this->project_checker->setConfig(
|
||||
TestConfig::loadFromXML(
|
||||
'psalm.xml',
|
||||
'<?xml version="1.0"?>
|
||||
<psalm
|
||||
requireVoidReturnType="false">
|
||||
<projectFiles>
|
||||
<directory name="src" />
|
||||
</projectFiles>
|
||||
</psalm>'
|
||||
)
|
||||
);
|
||||
|
||||
$stmts = self::$parser->parse('<?php
|
||||
function foo() {}
|
||||
');
|
||||
|
||||
$file_checker = new FileChecker(getcwd() . '/src/somefile.php', $this->project_checker, $stmts);
|
||||
$context = new Context();
|
||||
$file_checker->visitAndAnalyzeMethods($context);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user