Skip to content

Allow getting type from define() node #363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2017

Conversation

sunverwerth
Copy link
Contributor

@sunverwerth sunverwerth commented Apr 22, 2017

fixes #364

DefinitionResolver::getTypeFromNode() was missing a case for define() function call nodes.
This caused the stubs file to contain lots of constants without an associated type.

Added the missing case and added checks to other parts concerning define() nodes so that incomplete defines (only one argument) are not resolved as constants.

@codecov
Copy link

codecov bot commented Apr 22, 2017

Codecov Report

Merging #363 into master will increase coverage by 0.22%.
The diff coverage is 100%.

@@             Coverage Diff              @@
##             master     #363      +/-   ##
============================================
+ Coverage     84.11%   84.33%   +0.22%     
- Complexity      826      834       +8     
============================================
  Files            59       59              
  Lines          1712     1724      +12     
============================================
+ Hits           1440     1454      +14     
+ Misses          272      270       -2
Impacted Files Coverage Δ Complexity Δ
src/DefinitionResolver.php 82.63% <100%> (+0.83%) 288 <0> (+7) ⬆️
src/Protocol/SymbolInformation.php 96.77% <100%> (+0.1%) 32 <0> (+1) ⬆️

jens1o
jens1o previously approved these changes Apr 23, 2017
@felixfbecker
Copy link
Owner

Would it be possible to add a test that fails before the changes to prevent a regression?

felixfbecker
felixfbecker previously approved these changes Apr 23, 2017
@sunverwerth
Copy link
Contributor Author

sunverwerth commented Apr 23, 2017

Sure. Should I maybe add a folder for bugfixes?

@felixfbecker
Copy link
Owner

felixfbecker commented Apr 23, 2017

No, all tests are to prevent regressions. A test should not be coupled to a specific "bug", it should assert that the program behaves correctly.

@sunverwerth sunverwerth dismissed stale reviews from felixfbecker and jens1o via 6752c26 April 23, 2017 22:16
Copy link
Owner

@felixfbecker felixfbecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding unit tests to DefinitionResolver, long overdue!


public function testGetDefinedFqn()
{
// define('XXX') (only one argument) must not introduce a new symbol
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should also be a test for the normal case

@felixfbecker felixfbecker merged commit 08cf1a3 into felixfbecker:master Apr 24, 2017
@sunverwerth sunverwerth deleted the 252-null-type branch April 24, 2017 13:10
lialan pushed a commit to lambdalab/php-language-server that referenced this pull request Apr 30, 2017
* Allow getting type from define() node
- fixes felixfbecker#364

* Add test case for DefinitionResolver
zfy0701 pushed a commit to lambdalab/php-language-server that referenced this pull request May 10, 2017
* Allow getting type from define() node
- fixes felixfbecker#364

* Add test case for DefinitionResolver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants