plugin-php icon indicating copy to clipboard operation
plugin-php copied to clipboard

if parser return AST ,TypeError: Cannot read property 'startsWith' of undefined

Open leiyoulin opened this issue 2 years ago • 1 comments

Prettier ^2.6.1

PHP Plugin ^0.18.4

# Options (if any):
--single-quote

Input:

var codeStr = `<?php
namespace app\develop\model;
use think\Model;
use think\model\concern\SoftDelete;
class AppsSqlField extends Model
{
}`

prettier.format(codeStr , {
  parser:function(text,{php}){
	  let ast = php(text)
	  return ast;
  },
  plugins: [phpPlugin],
});

Output:

TypeError: Cannot read property 'startsWith' of undefined

Expected behavior:

leiyoulin avatar Apr 01 '22 15:04 leiyoulin

I dont think this is a pretter problem, it works on the playground: https://loilo.github.io/prettier-php-playground/#N4IgDgTgpgLjCWUIHkwIPYDsDOIBcok8mMA6vACYwAW+AHAAwA0IMAhgEblW14AsLAK7YoAFU648AMzYAbES2zEA5rKgBFQehhR8M+VBZhqYAGpIlWfCACsAOj4gWMCG3iyVAYXQBbH2wAFAAkA-BdBQxAOVwBjKABlGABPNWswbAgAWgAmJxBoAEdBeGgA12V-PTkFEGIRCBgytgq2KoMAXxYoCngYdBQ0eCxJUDZsGDaRTtrMMEEJvBAAHgB+YzAAHUxMNh8obDA2OIACNjBNjYooADcoWXQLn3Qr2QBuLeEoY5piAGsNjYAWWed3emE+32ofwBTxeAJiWDiEEwAPi6CkMAAIndYFAwTFZGNsMcAILnbDxAqyABiiFkFGOUAAHjpMBRicC4ZhgFt2iB2kA

I think the problem will be to do with using an incompatible prettier version. this plugin actually uses an older prettier version (v2.1.2)

cseufert avatar Jun 03 '22 01:06 cseufert