You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by "Junichi Yamamoto (Jira)" <ji...@apache.org> on 2019/10/31 13:10:00 UTC

[jira] [Resolved] (NETBEANS-3002) NullPointerExceptions during PHPStan inspection

     [ https://issues.apache.org/jira/browse/NETBEANS-3002?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Junichi Yamamoto resolved NETBEANS-3002.
----------------------------------------
    Fix Version/s: 11.3
       Resolution: Fixed

Fixed.

> NullPointerExceptions during PHPStan inspection
> -----------------------------------------------
>
>                 Key: NETBEANS-3002
>                 URL: https://issues.apache.org/jira/browse/NETBEANS-3002
>             Project: NetBeans
>          Issue Type: Bug
>          Components: php - Code Analysis
>    Affects Versions: 11.0, 11.1
>         Environment: Windows 10
>            Reporter: Czukowski
>            Assignee: Junichi Yamamoto
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 11.3
>
>         Attachments: PHPStanException.zip
>
>          Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> PHPStan code analysis support reports NullPointerExceptions at some occasions. When the exception occurs, the Inspect dialog window is not closed on its own.
> I've been able to reproduce it using the uploaded sample project. Run {{composer install}}, then configure NetBeans to use PHPStan from {{vendor/bin}} and the configuration from {{phpstan.neon}} file in the project root.
> The configuration file contains {{ignoreErrors}} section with a pattern to ignore known errors. The exception seems to depend on whether this pattern is there or not (to disable, comment the line with {{#}}). 
> To reproduce, select the {{app}} folder and run PHPStan inspection with the scope: Current folder (app).
> With the setup above I've encountered two types of the stack traces:
> *Without ignore pattern (commented line)*
> Output:
> {code}
> "C:\Workspace\Test\PHPStanException\vendor\bin\phpstan.bat" "analyse" "--no-ansi" "--no-progress" "--no-interaction" "--error-format=checkstyle" "--level=5" "--configuration=C:\Workspace\Test\PHPStanException\phpstan.neon" "C:\Workspace\Test\PHPStanException\app"
> <?xml version="1.0" encoding="UTF-8"?>
> <checkstyle>
> <file name="app\Something.php">
>   <error line="13" column="1" severity="error" message="Binary operation &quot;+&quot; between string and 2 results in an error." />
> </file>
> <file name="app\index.php">
>   <error line="9" column="1" severity="error" message="Anonymous function should return string but returns void." />
>   <error line="9" column="1" severity="error" message="Result of closure (void) is used." />
> </file>
> </checkstyle>
> Done.
> {code}
> Stack trace:
> {code}
> java.lang.NullPointerException
> 	at org.netbeans.modules.php.analysis.util.Mappers.map(Mappers.java:54)
> 	at org.netbeans.modules.php.analysis.PHPStanAnalyzerImpl.doAnalyze(PHPStanAnalyzerImpl.java:140)
> 	at org.netbeans.modules.php.analysis.PHPStanAnalyzerImpl.analyze(PHPStanAnalyzerImpl.java:92)
> 	at org.netbeans.modules.analysis.RunAnalysis$1$1.doRunAnalyzer(RunAnalysis.java:186)
> 	at org.netbeans.modules.analysis.RunAnalysis$1$1.run(RunAnalysis.java:142)
> 	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
> 	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
> 	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
> [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
> {code}
> *With ignore pattern*
> Output:
> {code}
> "C:\Workspace\Test\PHPStanException\vendor\bin\phpstan.bat" "analyse" "--no-ansi" "--no-progress" "--no-interaction" "--error-format=checkstyle" "--level=5" "--configuration=C:\Workspace\Test\PHPStanException\phpstan.neon" "C:\Workspace\Test\PHPStanException\app"
> <?xml version="1.0" encoding="UTF-8"?>
> <checkstyle>
> <file name="app\Something.php">
>   <error line="13" column="1" severity="error" message="Binary operation &quot;+&quot; between string and 2 results in an error." />
> </file>
> <file name="app\index.php">
>   <error line="9" column="1" severity="error" message="Anonymous function should return string but returns void." />
>   <error line="9" column="1" severity="error" message="Result of closure (void) is used." />
> </file>
> <file>
>   <error severity="error" message="Ignored error pattern #Call to an undefined method Cz\\Test\\Nothing# was not matched in reported errors." />
> </file>
> </checkstyle>
> Done.
> {code}
> Stack trace:
> {code}
> java.lang.NullPointerException
> 	at org.netbeans.modules.php.analysis.parsers.PHPStanReportParser.sanitizeFileName(PHPStanReportParser.java:199)
> 	at org.netbeans.modules.php.analysis.parsers.PHPStanReportParser.getCurrentFile(PHPStanReportParser.java:180)
> 	at org.netbeans.modules.php.analysis.parsers.PHPStanReportParser.processFileStart(PHPStanReportParser.java:133)
> 	at org.netbeans.modules.php.analysis.parsers.PHPStanReportParser.startElement(PHPStanReportParser.java:114)
> 	at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:510)
> 	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1397)
> 	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2710)
> 	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
> 	at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:534)
> 	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:888)
> 	at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:824)
> 	at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
> 	at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1216)
> 	at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:635)
> 	at org.netbeans.modules.php.analysis.parsers.PHPStanReportParser.create(PHPStanReportParser.java:68)
> 	at org.netbeans.modules.php.analysis.parsers.PHPStanReportParser.parse(PHPStanReportParser.java:77)
> 	at org.netbeans.modules.php.analysis.commands.PHPStan.analyze(PHPStan.java:117)
> 	at org.netbeans.modules.php.analysis.PHPStanAnalyzerImpl.doAnalyze(PHPStanAnalyzerImpl.java:133)
> 	at org.netbeans.modules.php.analysis.PHPStanAnalyzerImpl.analyze(PHPStanAnalyzerImpl.java:92)
> 	at org.netbeans.modules.analysis.RunAnalysis$1$1.doRunAnalyzer(RunAnalysis.java:186)
> 	at org.netbeans.modules.analysis.RunAnalysis$1$1.run(RunAnalysis.java:142)
> 	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1418)
> 	at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:45)
> 	at org.openide.util.lookup.Lookups.executeWith(Lookups.java:278)
> [catch] at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2033)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists