php-auto-yasnippets
php-auto-yasnippets copied to clipboard
`Wrong type argument: stringp, nil` while in class method
It looks like somehow, (thing-at-point 'sexp)
is returning nil
when I call (yas/create-php-snippet)
inside a class method. If I bring the cursor out of the method, then the function works correctly.
Is this a problem with thing-at-point
or php-auto-yasnippets
? (Calling (thing-at-point 'string)
is also returning nil
).
I'm not sure.
Click for error.
Debugger entered--Lisp error: (wrong-type-argument stringp nil)
string-match("[ \f \n
]+" nil 0)
split-string(nil)
payas/create-template(nil)
payas/define-template(nil)
yas/create-php-snippet(nil)
funcall-interactively(yas/create-php-snippet nil)
call-interactively(yas/create-php-snippet nil nil)
command-execute(yas/create-php-snippet)
Are you calling (yas/create-php-snippet)
inside a method for a method call that's not the method you're currently inside? I.e. a different method? If so that's a bug with php-auto-yasnippets. If you're trying to call (yas/create-php-snippet)
inside a method of the same name it's arguably probably a bug anyways too.
This is the example that I tested. (|
is my cursor position).
<?php
class MyClass
{
public function __construct()
{
array_chunk|
}
}
That is one-hundred percent a bug due on the part of this package then.
I don't quite understand how though.
at [1]
, [2]
, [3]
, [4]
and [5]
below, evaluating (thing-at-point 'sexp)
returns:
-
nil
-
nil
-
#("array_chunk" 0 11 (fontified t))
-
#("array_chunk" 0 11 (c-in-sws t fontified t face font-lock-doc-face))
-
#("array_chunk" 0 11 (c-in-sws t fontified t face font-lock-comment-face))
<?php
class MyClass
{
/**
* @comment array_chunk[4]
*/
public function hello() // array_chunk[5]
{
array_chunk[1]
}
array_chunk[2]
}
array_chunk[3]
I half-wonder if the problems of instances 1 and 2 are not caused by bugs of my own in PHP Mode. Regardless, php-auto-yasnippets should be smarter about looking (backwards) at the current thing at point to see if whether or not it matches a known function or method it can expand.
I get this same issue in a constructor of a object. So just new Classname(|)
where |
is my cursor.
@chrissound Thank you for the additional info. I have to apologize because I am busy over this weekend and next week, so I won't be able to look into this again soon. But I will try to fix it when my personal life schedule allows me a big chunk of free time. Sorry again for the delay.
@ejmr No need to apologize! Thank you for your effort and this plugin!