martin-helmich / typo3-typoscript-lint

Find coding errors in your TypoScript files.
MIT License
82 stars 19 forks source link

PHP Fatal error for wrong type in strpos() #70

Closed spoonerWeb closed 5 years ago

spoonerWeb commented 5 years ago

When linting my project (https://git-t3o.typo3.org/t3o/t3olayout/tree/feature/introduce-typoscript-linter) I get the error:

Fatal error: Uncaught TypeError: strpos() expects parameter 1 to be string, int given in /tmp/vendor/helmich/typo3-typoscript-lint/src/Linter/Sniff/Visitor/NestingConsistencyVisitor.php:88
Stack trace:
#0 /tmp/vendor/helmich/typo3-typoscript-lint/src/Linter/Sniff/Visitor/NestingConsistencyVisitor.php(88): strpos(1, '2.')
#1 /tmp/vendor/helmich/typo3-typoscript-lint/src/Linter/Sniff/Visitor/NestingConsistencyVisitor.php(42): Helmich\TypoScriptLint\Linter\Sniff\Visitor\NestingConsistencyVisitor->walkStatementList(Array)
#2 /tmp/vendor/helmich/typo3-typoscript-parser/src/Helmich/TypoScriptParser/Parser/Traverser/AggregatingVisitor.php(45): Helmich\TypoScriptLint\Linter\Sniff\Visitor\NestingConsistencyVisitor->enterNode(Object(Helmich\TypoScriptParser\Parser\AST\NestedAssignment))
#3 /tmp/vendor/helmich/typo3-typoscript-parser/src/Helmich/TypoScriptParser/Parser/Traverser/Traverser.php(57): Helmich\TypoScriptParser\Parser\Traverser\AggregatingVisitor->enterNode(Object(Helmich\TypoScriptParser\Parser\AST\NestedAssignment))
#4  in /tmp/vendor/helmich/typo3-typoscript-lint/src/Linter/Sniff/Visitor/NestingConsistencyVisitor.php on line 88

Is there some typing issue on your side or a wrong TypoScript on our side?

martin-helmich commented 5 years ago

Ouch. This is not intended, even with bad typoscript input. I'll take a look asap. 

spoonerWeb commented 5 years ago

Thanks. Do you need more information? Using v2.0.0 and this yaml configuration:

paths:
  - Configuration/TypoScript/
  - .
filePatterns:
  - "*.typoscript"
  - "ext_typoscript_*.txt"
sniffs:
  - class: Indentation
    parameters:
      useSpaces: true
      indentPerLevel: 4
      indentConditions: false
  - class: DeadCode
  - class: OperatorWhitespace
  - class: RepeatingRValue
  - class: DuplicateAssignment
  - class: EmptySection
  - class: NestingConsistency
    parameters:
      commonPathPrefixThreshold: 1
martin-helmich commented 5 years ago

@spoonerWeb Should be fixed with #71. Could you give the newly released version 2.0.1 a try?