Skip to content
This repository has been archived by the owner on May 2, 2018. It is now read-only.

Wrong type argument: stringp, nil while in class method #28

Open
MarTango opened this issue Mar 31, 2017 · 8 comments
Open

Wrong type argument: stringp, nil while in class method #28

MarTango opened this issue Mar 31, 2017 · 8 comments

Comments

@MarTango
Copy link
Contributor

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)
@ejmr
Copy link
Collaborator

ejmr commented Mar 31, 2017

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.

@MarTango
Copy link
Contributor Author

This is the example that I tested. (| is my cursor position).

<?php

class MyClass
{
    public function __construct()
    {
        array_chunk|
    }
}

@ejmr
Copy link
Collaborator

ejmr commented Mar 31, 2017

That is one-hundred percent a bug due on the part of this package then.

@MarTango
Copy link
Contributor Author

MarTango commented Mar 31, 2017

I don't quite understand how though.
at [1], [2], [3], [4] and [5] below, evaluating (thing-at-point 'sexp) returns:

  1. nil
  2. nil
  3. #("array_chunk" 0 11 (fontified t))
  4. #("array_chunk" 0 11 (c-in-sws t fontified t face font-lock-doc-face))
  5. #("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]

@ejmr
Copy link
Collaborator

ejmr commented Apr 2, 2017

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.

@chrissound
Copy link

I get this same issue in a constructor of a object. So just new Classname(|) where | is my cursor.

@ejmr
Copy link
Collaborator

ejmr commented May 26, 2017

@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.

@chrissound
Copy link

@ejmr No need to apologize! Thank you for your effort and this plugin!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants