Skip to content
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

Editor URLs are unusable for traits #5030

Closed
BladeMF opened this issue May 18, 2021 · 3 comments
Closed

Editor URLs are unusable for traits #5030

BladeMF opened this issue May 18, 2021 · 3 comments

Comments

@BladeMF
Copy link

BladeMF commented May 18, 2021

Bug report

When using editorUrl and getting errors for a trait, the link becomes unusable because it contains the context of the class that checks the trait:

parameters:
  editorUrl: '%%file%%:%%line%%'

the link is:

/some/path/SettingsCreatorTrait.php (in context of class Some\Namespace\SelectionAwareMailerTests):21

Test code

<?php

namespace Tests;

trait Trait1
{
	protected function func1(\DateTime $date)
	{
		$date->someUndefinedMethod();
	}
}

class HelloWorld
{
	use Trait1;
}

Actual ouput:

❯ php7.4 bin/phpstan analyse tests/HelloWorld.php
Note: Using configuration file /some/path/phpstan.neon.
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ------------------------------------------------------------------------------------------------ 
  Line   HelloWorld.php (in context of class Tests\HelloWorld)                                           
 ------ ------------------------------------------------------------------------------------------------ 
  9      Call to an undefined method DateTime::someUndefinedMethod().                                    
         ✏️  /some/path/HelloWorld.php (in context of class Tests\HelloWorld):9  
 ------ ------------------------------------------------------------------------------------------------ 

Expected output

❯ php7.4 bin/phpstan analyse tests/HelloWorld.php
Note: Using configuration file /some/path/phpstan.neon.
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

 ------ ------------------------------------------------------------------------------------------------ 
  Line   HelloWorld.php (in context of class Tests\HelloWorld)                                           
 ------ ------------------------------------------------------------------------------------------------ 
  9      Call to an undefined method DateTime::someUndefinedMethod().                                    
         ✏️  /some/path/HelloWorld.php:9   (in context of class Tests\HelloWorld)
 ------ ------------------------------------------------------------------------------------------------ 
@mergeable
Copy link

mergeable bot commented May 18, 2021

This bug report is missing a link to reproduction on phpstan.org.

It will most likely be closed after manual review.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@bb841d2

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants