phpstan / phpdoc-parser

Next-gen phpDoc parser with support for intersection types and generics
MIT License
1.31k stars 62 forks source link

Call to a member function getNodeStartPointer() on null #204

Closed kamil-tekiela closed 1 year ago

kamil-tekiela commented 1 year ago

I don't know exactly how to reproduce it but I get it when executing this:

php8.1.17/php vendor/bin/phpcbf libraries/classes/Controllers/Table/ReplaceController.php 

This is from the https://github.com/phpmyadmin/phpmyadmin repo when executing phpcbf. This does not happen when phpdoc-parser is downgraded to 1.22.1. Downgrading phpcbf itself to last working version doesn't resolve the issue. I decided to open the issue here but if the issue is with incorrect usage in phpcbf, please let me know and I will move it there.

Error:

Error: Call to a member function getNodeStartPointer() on null in D:\projects\phpmyadmin\vendor\slevomat\coding-standard\SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff.php on line 115

Call Stack:
    0.4067     423784   1. {main}() D:\projects\phpmyadmin\vendor\bin\phpcbf:0
    0.4070     425528   2. include('D:\projects\phpmyadmin\vendor\squizlabs\php_codesniffer\bin\phpcbf') D:\projects\phpmyadmin\vendor\bin\phpcbf:120
    0.4323    4618720   3. PHP_CodeSniffer\Runner->runPHPCBF() D:\projects\phpmyadmin\vendor\squizlabs\php_codesniffer\bin\phpcbf:18
    0.5608   11811592   4. PHP_CodeSniffer\Runner->run() D:\projects\phpmyadmin\vendor\squizlabs\php_codesniffer\src\Runner.php:204
    0.5654   12444576   5. PHP_CodeSniffer\Runner->processFile($file = class PHP_CodeSniffer\Files\LocalFile { public $path = 'D:\\projects\\phpmyadmin\\libraries\\classes\\Controllers\\Table\\ReplaceController.php'; protected $content = '<?php\n\ndeclare(strict_types=1);\n\nnamespace PhpMyAdmin\\Controllers\\Table;\n\nuse PhpMyAdmin\\ConfigStorage\\Relation;\nuse PhpMyAdmin\\Controllers\\AbstractController;\nuse PhpMyAdmin\\Controllers\\Database\\SqlController as DatabaseSqlController;\nuse PhpMyAdmin\\Controllers\\Sql\\SqlController;\nuse PhpMyAdmin\\Controllers\\Table\\SqlController as TableSqlController;\nuse PhpMyAdmin\\Core;\nuse PhpMyAdmin\\DatabaseInterface;\nuse PhpMyAdmin\\EditField;\nuse PhpMyAdmin\\File;\nuse PhpMyAdmin\\Html\\Generator;\nuse PhpMyAdmin\\Http\\ServerR'...; public $config = class PHP_CodeSniffer\Config { private $settings = [...]; public $dieOnUnknownArg = FALSE; private $cliArgs = [...] }; public $ruleset = class PHP_CodeSniffer\Ruleset { public $name = ''; public $paths = [...]; public $ignorePatterns = [...]; public $includePatterns = [...]; public $sniffs = [...]; public $sniffCodes = [...]; public $tokenListeners = [...]; public $ruleset = [...]; protected $rulesetDirs = [...]; private $config = class PHP_CodeSniffer\Config { ... } }; public $ignored = FALSE; public $eolChar = '\n'; public $fixer = class PHP_CodeSniffer\Fixer { public 
$enabled = FALSE; public $loops = 0; private $currentFile = ...; private $tokens = [...]; private $fixedTokens = [...]; private $oldTokenValues = [...]; private $changeset = [...]; private $inChangeset = FALSE; private $inConflict = FALSE; private $numFixes = 0 }; public $tokenizer = class PHP_CodeSniffer\Tokenizers\PHP { protected $config = class PHP_CodeSniffer\Config { ... }; protected $eolChar = '\n'; protected $tokens = [...]; protected $numTokens = 4301; public $scopeOpeners = [...]; public $endScopeTokens = [...]; public $knownLengths = [...]; public $ignoredLines = [...]; protected $tstringContexts = [...] }; public $tokenizerType = 'PHP'; public $fromCache = FALSE; public $numTokens = 4301; protected $tokens = [0 => [...], 1 => [...], 2 => [...], 3 => [...], 4 => [...], 5 => [...], 6 => [...], 7 => [...], 8 => [...], 9 => [...], 10 => [...], 11 => [...], 12 => [...], 13 => [...], 14 => [...], 15 => [...], 16 => [...], 17 => [...], 18 => [...], 19 => [...], 20 => [...], 21 => [...], 22 => [...], 23 => [...], 24 => [...], 25 => [...], 26 => [...], 27 => [...], 28 => [...], 29 => [...], 30 => [...], 31 => [...], 32 => [...], 33 => [...], 34 => [...], 35 => [...], 36 => [...], 37 => [...], 38 => [...], 39 => [...], 40 => [...], 41 => [...], 42 => [...], 43 => [...], 44 => [...], 45 => [...], 46 => [...], 47 => [...], 48 => [...], 49 => [...], 50 => [...], 51 => [...], 52 => [...], 53 => [...], 54 => [...], 55 => [...], 56 => [...], 57 => [...], 58 => [...], 59 => [...], 60 => [...], 61 => [...], 62 => [...], 63 => [...], 64 => [...], 65 => [...], 66 => [...], 67 => [...], 68 => [...], 69 => [...], 70 => [...], 71 => [...], 72 => [...], 73 => [...], 74 => [...], 75 => [...], 76 => [...], 77 => [...], 78 => [...], 79 => [...], 80 => [...], 81 => [...], 82 => [...], 83 => [...], 84 => [...], 85 => [...], 86 => [...], 87 => [...], 88 => [...], 89 => [...], 90 => [...], 91 => [...], 92 => [...], 93 => [...], 94 => [...], 95 => [...], 96 => [...], 97 => [...], 98 => [...], 99 => [...], 100 => [...], 101 => [...], 102 => [...], 103 => [...], 104 => [...], 105 => [...], 106 => [...], 107 => [...], 108 => [...], 109 => [...], 110 => [...], 111 => [...], 112 => [...], 113 => [...], 114 => [...], 115 => [...], 116 => [...], 117 => [...], 118 => [...], 119 => [...], 120 => [...], 121 => [...], 122 => [...], 123 => [...], 124 => [...], 125 => [...], 126 => [...], 127 => [...], ...]; protected $errors = []; protected $warnings = []; protected $metrics = ['Declarations and side effects mixed' => [...], 'PHP short open tag used' => [...], 'EOL char' => [...], 'Number of newlines at EOF' => [...], 'PHP closing tag at end of PHP-only file' => [...], 'Line length' => [...], 'Line indent' => [...], 'PHP keyword case' => [...], 'Multiple statements on same line' => [...], 'One class per file' => [...], 'Class defined in namespace' => [...], 'PascalCase class name' => [...], 'Class opening brace placement' => [...], 'Function has doc comment' => [...], 'Function spacing after' => [...], 'Function spacing before first' => [...], 'Spacing before object operator' => [...], 'Spacing after object operator' => [...], 'PHP type case' => [...], 'Function opening brace placement' => [...], 'PHP constant case' => [...], 'Short array syntax used' => [...], 'Array end comma' => [...], 'Spaces after control structure open parenthesis' => [...], 'Spaces before control structure close parenthesis' => [...], 'Blank lines at start of control structure' => [...], 'Blank lines at end of control structure' => [...], 'Control structure defined inline' => [...], 'Inline comment style' => [...], 'Use of ELSE IF or ELSEIF' => [...], 'Spacing before string concat' => [...], 'Spacing after string concat' => [...], 'Spacing after cast statement' => [...], 'CamelCase method name' => [...]]; private ${PHP_CodeSniffer\Files\File}metricTokens = ['Declarations and side effects mixed' => [...], 'PHP short open tag used' => [...], 'EOL char' => [...], 'Number of newlines at EOF' => [...], 'PHP closing tag at end of PHP-only file' => [...], 'Line length' => [...], 'Line indent' => [...], 'PHP keyword case' => [...], 'Multiple statements on same line' => [...], 'One class per file' => [...], 'Class defined in namespace' => [...], 'PascalCase class name' => [...], 'Class opening brace placement' => [...], 'Function has doc comment' => [...], 'Function spacing after' => [...], 'Function spacing before first' => [...], 'Spacing before object operator' => [...], 'Spacing after object operator' => [...], 'PHP type case' => [...], 'Function opening brace placement' => [...], 'PHP constant case' => [...], 'Short array syntax used' => [...], 'Array end comma' => [...], 'Spaces after control structure open parenthesis' => [...], 'Spaces before control structure close parenthesis' => [...], 'Blank lines at start of control structure' => [...], 'Blank lines at end of control structure' => [...], 'Control structure defined inline' => [...], 'Inline comment style' => [...], 'Use of ELSE IF or ELSEIF' => [...], 'Spacing before string concat' => [...], 'Spacing after string concat' => [...], 'Spacing after cast statement' => [...], 'CamelCase method name' => [...]]; protected $errorCount = 0; protected $warningCount = 0; protected $fixableCount = 0; 
protected $fixedCount = 0; protected $replayingErrors = FALSE; protected $ignoredListeners = []; protected $ignoredCodes = []; protected $listeners = []; protected $activeListener = 'SlevomatCodingStandard\\Sniffs\\Commenting\\DocCommentSpacingSniff'; protected $listenerTimes = []; protected $configCache = ['cache' => FALSE, 'sniffs' => [...], 'exclude' => [...], 'errorSeverity' => 5, 'warningSeverity' => 5, 'recordErrors' => FALSE, 'ignorePatterns' => [...], 'includePatterns' => [...]] }) D:\projects\phpmyadmin\vendor\squizlabs\php_codesniffer\src\Runner.php:438
    0.5654   12444576   6. PHP_CodeSniffer\Files\LocalFile->process() D:\projects\phpmyadmin\vendor\squizlabs\php_codesniffer\src\Runner.php:632
    0.5654   12444576   7. PHP_CodeSniffer\Files\File->process() D:\projects\phpmyadmin\vendor\squizlabs\php_codesniffer\src\Files\LocalFile.php:92
    0.8853   17438256   8. SlevomatCodingStandard\Sniffs\Commenting\DocCommentSpacingSniff->process($phpcsFile = class PHP_CodeSniffer\Files\LocalFile { public $path = 'D:\\projects\\phpmyadmin\\libraries\\classes\\Controllers\\Table\\ReplaceController.php'; protected $content 
= '<?php\n\ndeclare(strict_types=1);\n\nnamespace PhpMyAdmin\\Controllers\\Table;\n\nuse PhpMyAdmin\\ConfigStorage\\Relation;\nuse PhpMyAdmin\\Controllers\\AbstractController;\nuse PhpMyAdmin\\Controllers\\Database\\SqlController as DatabaseSqlController;\nuse PhpMyAdmin\\Controllers\\Sql\\SqlController;\nuse PhpMyAdmin\\Controllers\\Table\\SqlController as TableSqlController;\nuse PhpMyAdmin\\Core;\nuse PhpMyAdmin\\DatabaseInterface;\nuse PhpMyAdmin\\EditField;\nuse PhpMyAdmin\\File;\nuse PhpMyAdmin\\Html\\Generator;\nuse PhpMyAdmin\\Http\\ServerR'...; public $config = class PHP_CodeSniffer\Config { private $settings = [...]; public $dieOnUnknownArg = FALSE; private $cliArgs = [...] }; public $ruleset = class PHP_CodeSniffer\Ruleset { public $name = ''; public $paths = [...]; public $ignorePatterns = [...]; public $includePatterns = [...]; public $sniffs = [...]; public $sniffCodes = [...]; public $tokenListeners = [...]; public $ruleset = [...]; protected $rulesetDirs = [...]; private $config = class PHP_CodeSniffer\Config { ... } }; public $ignored = FALSE; public $eolChar = '\n'; public $fixer = class PHP_CodeSniffer\Fixer { public $enabled = FALSE; public $loops = 0; private $currentFile = ...; private $tokens = [...]; private $fixedTokens = [...]; private $oldTokenValues = [...]; private $changeset = [...]; private $inChangeset = FALSE; private $inConflict = FALSE; private $numFixes = 0 }; public $tokenizer = class PHP_CodeSniffer\Tokenizers\PHP { protected $config = class PHP_CodeSniffer\Config { ... }; protected $eolChar = '\n'; protected $tokens = [...]; protected $numTokens = 4301; public $scopeOpeners = [...]; public $endScopeTokens = [...]; public $knownLengths = [...]; public $ignoredLines = [...]; protected $tstringContexts = [...] }; public $tokenizerType = 'PHP'; public $fromCache = FALSE; public $numTokens = 4301; protected $tokens = [0 => [...], 1 => [...], 2 => [...], 3 => [...], 4 => [...], 5 
=> [...], 6 => [...], 7 => [...], 8 => [...], 9 => [...], 10 => [...], 11 => [...], 12 => [...], 13 => [...], 14 => [...], 15 => [...], 16 => [...], 17 => [...], 18 => [...], 19 => [...], 20 => [...], 21 => [...], 22 => [...], 23 => [...], 24 => [...], 25 => [...], 26 => [...], 27 => [...], 28 => [...], 29 => [...], 30 => [...], 31 => [...], 32 => [...], 33 => [...], 34 => [...], 35 => [...], 36 => [...], 37 => [...], 38 => [...], 39 => [...], 40 => [...], 41 => [...], 42 => [...], 43 => [...], 44 => [...], 45 => [...], 46 => [...], 47 => [...], 48 => [...], 49 => [...], 50 => [...], 51 => [...], 52 => [...], 53 => [...], 54 => [...], 55 => [...], 56 => [...], 57 => [...], 58 => [...], 59 => [...], 60 => [...], 61 => [...], 62 => [...], 63 => [...], 64 => [...], 65 => [...], 66 => [...], 67 => [...], 68 => [...], 69 => [...], 70 => [...], 71 => [...], 72 => [...], 73 => [...], 74 => [...], 75 => [...], 76 => [...], 77 => [...], 78 => [...], 79 => [...], 80 => [...], 81 => [...], 82 => [...], 83 => [...], 84 => [...], 85 => [...], 86 => [...], 87 => [...], 88 => [...], 89 => [...], 90 => [...], 91 => [...], 92 => [...], 93 => [...], 94 => [...], 95 => [...], 96 => [...], 97 => [...], 98 => [...], 99 => [...], 100 => [...], 101 => [...], 102 => [...], 103 => [...], 104 => [...], 105 => [...], 106 => [...], 107 => [...], 108 => [...], 109 => [...], 110 => [...], 111 => [...], 112 => [...], 113 => [...], 114 => [...], 115 => [...], 116 => [...], 117 => [...], 118 => [...], 119 => [...], 120 => [...], 121 => [...], 122 => [...], 123 => [...], 124 => [...], 125 => [...], 126 => [...], 127 => [...], ...]; protected $errors = []; protected $warnings = []; protected $metrics = ['Declarations and side effects mixed' => [...], 'PHP short open tag used' => [...], 'EOL char' => [...], 'Number of newlines at EOF' => [...], 'PHP closing tag at end of PHP-only file' => [...], 'Line length' => [...], 'Line indent' => [...], 'PHP 
keyword case' => [...], 'Multiple statements on same line' => [...], 'One class per file' => [...], 'Class defined in namespace' => [...], 'PascalCase class name' => [...], 'Class opening brace placement' => [...], 'Function has doc comment' => [...], 'Function spacing after' => [...], 'Function spacing before first' => [...], 'Spacing before object operator' => [...], 'Spacing after object operator' => [...], 'PHP type case' => [...], 'Function opening brace placement' => [...], 'PHP constant case' => [...], 'Short array syntax used' => [...], 'Array end comma' => [...], 'Spaces after control structure open parenthesis' => [...], 'Spaces before control structure close parenthesis' => [...], 'Blank lines at start of control structure' => [...], 'Blank lines at end of control structure' => [...], 'Control structure defined 
inline' => [...], 'Inline comment style' => [...], 'Use of ELSE IF or ELSEIF' => [...], 'Spacing before string concat' => [...], 'Spacing after string concat' => [...], 'Spacing after cast statement' => [...], 'CamelCase method name' => [...]]; private ${PHP_CodeSniffer\Files\File}metricTokens = ['Declarations and side effects mixed' => [...], 'PHP short open tag used' => [...], 'EOL char' => [...], 'Number of newlines at EOF' => [...], 'PHP closing tag at end of PHP-only file' => [...], 'Line length' => [...], 'Line indent' => [...], 'PHP keyword case' => [...], 'Multiple statements on same line' => [...], 'One class per file' => [...], 'Class defined in namespace' => [...], 'PascalCase class name' => [...], 'Class opening brace placement' => [...], 'Function has doc comment' => [...], 'Function spacing after' => [...], 'Function spacing before first' => [...], 'Spacing before object operator' => [...], 'Spacing after object operator' => [...], 'PHP type case' => [...], 'Function opening brace placement' => [...], 'PHP constant case' => [...], 'Short array syntax used' => [...], 'Array end comma' => [...], 'Spaces after control structure open parenthesis' => [...], 'Spaces before control structure close parenthesis' => [...], 'Blank lines at start of control structure' => [...], 'Blank lines at end of control structure' => [...], 'Control structure defined inline' => [...], 'Inline comment style' => [...], 'Use of ELSE IF or ELSEIF' => [...], 'Spacing before string concat' => [...], 'Spacing after string concat' => [...], 'Spacing after cast statement' => [...], 'CamelCase method name' => [...]]; protected $errorCount = 0; protected $warningCount = 0; protected $fixableCount = 0; protected $fixedCount = 0; protected $replayingErrors = FALSE; protected $ignoredListeners = []; protected $ignoredCodes = []; protected $listeners = []; protected $activeListener = 'SlevomatCodingStandard\\Sniffs\\Commenting\\DocCommentSpacingSniff'; protected $listenerTimes = []; protected $configCache = ['cache' => FALSE, 'sniffs' => [...], 'exclude' => [...], 'errorSeverity' => 5, 'warningSeverity' => 5, 'recordErrors' => FALSE, 'ignorePatterns' => [...], 'includePatterns' => [...]] }, $docCommentOpenerPointer = 3624) D:\projects\phpmyadmin\vendor\squizlabs\php_codesniffer\src\Files\File.php:498
kamil-tekiela commented 1 year ago

Already reported and fixed by phpcbf https://github.com/slevomat/coding-standard/issues/1600

github-actions[bot] commented 1 year ago

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.