Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add php stubs for IDE support #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andheiberg
Copy link

For IDE's to pickup the classes you're generating with C you need to write stub files.

Here you go for the current interface. Doesn't seem like there's an automatic way to generate these :(

Side note: I was looking into the involved in adding proper AST classes instead of returning as array. It's fairly involved :( this is a script that does it for Ruby. But then on top of that we would need to make something that creates stub files for those automatically. I don't know if this is worth it, but it sure would be nice. Might just do a conversion from array to AST in PHP for now.

Copy link
Owner

@dosten dosten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Andreas!

Thanks for your PR, I've never used a stub for a PHP extension, how do you use it?

This is a first implementation of a parser, limited but functional, the general idea is, as you said, add a proper AST implementation, but actually I'm quite busy :( Any PR is welcome!


namespace GraphQL\Error;

class ParseError extends \Exception {}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, ParseError extends from RuntimeException


class Parser
{
/**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a simple description for this method?

*
* @return array
*/
public function parse(string $input): array {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't works for versions before 7.0 right? Can you remove the type hint and the return type?

@@ -0,0 +1,5 @@
<?php

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that is required to add a copyright notice here:

/*
 * This file is part of the GraphQL parser extension.
 *
 * (c) Diego Saint Esteben <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

@@ -0,0 +1,15 @@
<?php

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, (probably) missing copyright notice.

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

Successfully merging this pull request may close these issues.

2 participants