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

Created a PhpStorm stub for ext-ds. #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hopeseekr
Copy link

@hopeseekr hopeseekr commented Mar 30, 2019

This PR requires PR #50 [Fixed the documentation].

Steps to recreate / maintain:

  1. For every class, interface, and trait:
    a. Remove every private access method and property.
    b. Remove every @internal class, inteface, and trait.
    c. Remove all of the contents between { } in the methods.
    d. Ensure that no third party, non-standard PHP external classes are called from the stubs. If they are, then it will still work, but PhpStorm will likely reject it for publishing.

  2. For every trait:
    a. Add a comment at the first line that says // BEGIN Trait.
    b. Add a comment at the last line that says // END <TraitName Trait.

  3. For every class:
    a. Move constants to the top of the class declaration.
    b. Move public and protected properties below the constants.
    c. Replace each "use ;" declaration with the pasted contents of the stripped-down Trait.
    d. Rectify any and all PHP compilation issues. [No return statements are allowed by the PHP 7.x linter, even when strict return types are enforced).]

  4. Concatenate every class, interface and abstract class into the phpstorm-stub.php file.

  5. Carefully import (via use statements) every external class (e.g., ArrayAccess).

Next Steps

For instructions on how to test + publish this stub to PhpStorm, see

For php-ds/ext-ds#128


This change is Reviewable

This is needed in preparation for the PhpStorm stub (php-ds/ext-ds#128).
1. "All methods and properties of classes and interfaces must specify their
   visibility: public, protected or private.", from the PSR-12 draft.
2. It is required by convention for inclusion as a PhpStorm stub
   (see php-ds/ext-ds#128).
## Steps to Create + Maintain:

0. For every class, interface, and trait:
   a. Remove every private access method and property.
   b. Remove every @internal class, inteface, and trait.
   c. Remove all of the contents between { } in the methods.
   d. Ensure that no third party, non-standard PHP external classes are called from the stubs.
      If they are, then it will still work, but PhpStorm will likely reject it for publishing.

1. For every trait:
   a. Add a comment at the first line that says // BEGIN <TraitName> Trait.
   b. Add a comment at the last line that says // END <TraitName Trait.

2. For every class:
   a. Move constants to the top of the class declaration.
   b. Move public and protected properties below the constants.
   c. Replace each "use <trait>;" declaration with the pasted contents of the
      stripped-down Trait.
   d. Rectify any and all PHP compilation issues. [No return statements are allowed
      by the PHP 7.x linter, even when strict return types are enforced).]

3. Concatenate every class, interface and abstract class into the phpstorm-stub.php file.

4. Carefully import (via use statements) every external class (e.g., ArrayAccess).

## Next Steps

For instructions on how to test + publish this stub to PhpStorm, see
* https://blog.jetbrains.com/phpstorm/2018/03/how-to-provide-stubs-for-phpstorm/

For php-ds/ext-ds#128

# Please enter the commit message for your changes. Lines starting
# with '#' will be kept; you may remove them yourself if you want to.
# An empty message aborts the commit.
#
# Date:      Sat Mar 30 09:04:59 2019 -0500
#
# On branch phpstorm_stub
# Your branch is up to date with 'origin/phpstorm_stub'.
#
# Changes to be committed:
#	new file:   phpstorm-stub.php
#
# Changes not staged for commit:
#	modified:   src/Deque.php
#	modified:   src/Map.php
#	modified:   src/Pair.php
#	modified:   src/PriorityQueue.php
#	modified:   src/Queue.php
#	modified:   src/Set.php
#	modified:   src/Stack.php
#	modified:   src/Traits/Capacity.php
#	modified:   src/Traits/GenericCollection.php
#	modified:   src/Traits/GenericSequence.php
#	modified:   src/Traits/SquaredCapacity.php
#	modified:   src/Vector.php
#
# Untracked files:
#	.idea/
#
@hopeseekr
Copy link
Author

Can I please get an update on the status of this PR?

@rtheunissen
Copy link
Member

This looks solid @hopeseekr.

Do you know if:

  1. The stubs must be a single file?
  2. Whether we could potentially generate the stubs using reflection?

@dktapps
Copy link

dktapps commented May 15, 2019

It's possible to generate stubs (minus documentation) with reflection indeed. This stub was generated by this script. It requires that the arginfo must be perfect though.

@hopeseekr
Copy link
Author

@dktapps Arg info was anything but perfect when I had a go at it. You'd definitely have to apply my first two commits.

@rtheunissen They can be multiple files, but

  1. Multiple files are harder to maintain and test.
  2. Multiple files clutter the project.
  3. It's harder to submit to JetBrains.

@dktapps
Copy link

dktapps commented May 15, 2019

@hopeseekr I'm referring to the internal arginfo defined in the extension itself. The only problems I encountered was the invariance of the return types defined on the \Ds\Sequence interface (they can't be specialized due to language limitations).

@rtheunissen
Copy link
Member

@dktapps @hopeseekr that's correct, eg. you can't have the equivalent of static as a return type so there are limitations. Seems the case then that auto-generation is not viable, which is okay.

@hopeseekr do you know how PHPStorm handles versioning of stubs? Eg. if we release 2.0 with a decent amount of changes, that would be okay right?

@dktapps
Copy link

dktapps commented May 16, 2019

unfortunately it doesn't handle versioning very well (or at all). you can see this with the problems created by the pthreads V2 vs V3 rewrite.

@rtheunissen
Copy link
Member

master now allows nightly builds to fail.

@rtheunissen
Copy link
Member

unfortunately it doesn't handle versioning very well (or at all)

This makes me wonder whether we should wait for the 2.0 API before we submit official stubs. The polyfill solves that problem well enough in the meantime. @krakjoe did you oversee/experience the pthreads stubs?

@Hikariii
Copy link

Why is this stalled for almost a year now? What's needed to get this going (again?)

@enumag
Copy link

enumag commented Nov 26, 2020

This can be closed. PHPStorm has stubs for this extension now.
https://github.com/JetBrains/phpstorm-stubs/blob/master/ds/ds.php

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.

None yet

5 participants