polyfill icon indicating copy to clipboard operation
polyfill copied to clipboard

Created a PhpStorm stub for ext-ds.

Open hopeseekr opened this issue 5 years ago • 11 comments

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 <TraitName> 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

  • https://blog.jetbrains.com/phpstorm/2018/03/how-to-provide-stubs-for-phpstorm/

For php-ds/ext-ds#128


This change is Reviewable

hopeseekr avatar Mar 30 '19 14:03 hopeseekr

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

hopeseekr avatar May 12 '19 19:05 hopeseekr

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?

rtheunissen avatar May 15 '19 05:05 rtheunissen

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.

dktapps avatar May 15 '19 13:05 dktapps

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

hopeseekr avatar May 15 '19 14:05 hopeseekr

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

dktapps avatar May 15 '19 15:05 dktapps

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

rtheunissen avatar May 16 '19 10:05 rtheunissen

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.

dktapps avatar May 16 '19 11:05 dktapps

master now allows nightly builds to fail.

rtheunissen avatar May 16 '19 17:05 rtheunissen

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?

rtheunissen avatar May 16 '19 17:05 rtheunissen

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

Hikariii avatar Mar 20 '20 08:03 Hikariii

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

enumag avatar Nov 26 '20 13:11 enumag