phpnsc icon indicating copy to clipboard operation
phpnsc copied to clipboard

cleanContent obliterates entire classes when it mistakes a quote inside a comment for the start of a string

Open ExplodingCabbage opened this issue 9 years ago • 1 comments

Calling cleanContent on this file...

<?php namespace Foo;

// By the gods' wounds, this was an annoying bug!
class Bla {
  public function helloWorld() {
    return 'hello world';
  }
}

will result in this:

<?php namespace Foo;


  }
}

and as a result parseFileWithRegexForDefinedEntities will later fail to find the Foo class.

I'd be happy to apply some regex wizardry to find a way to clean this up, but it's very difficult to do so at the moment because cleanContent is completely undocumented and I dunno for sure what stuff it's supposed to be removing from the file content.

ExplodingCabbage avatar Aug 12 '16 17:08 ExplodingCabbage

The cleanContent implementation is extremely hacky, the plan was always to replace it with using a proper PHP AST Parser (e.g. https://github.com/nikic/PHP-Parser) completely. Since this a bit of a larger project and the current hacky and buggy solution is good enough for our use-case this did not have a huge priority so far unfortunately. I also can't give you an estimate when we will get around to do it, but feel free to chip in there :)

bashofmann avatar Aug 16 '16 22:08 bashofmann