polyfill
polyfill copied to clipboard
Created a PhpStorm stub for ext-ds.
This PR requires PR #50 [Fixed the documentation].
Steps to recreate / maintain:
-
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.
-
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.
-
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).] -
Concatenate every class, interface and abstract class into the phpstorm-stub.php file.
-
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
Can I please get an update on the status of this PR?
This looks solid @hopeseekr.
Do you know if:
- The stubs must be a single file?
- Whether we could potentially generate the stubs using reflection?
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 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
- Multiple files are harder to maintain and test.
- Multiple files clutter the project.
- It's harder to submit to JetBrains.
@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 @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?
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.
master
now allows nightly builds to fail.
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?
Why is this stalled for almost a year now? What's needed to get this going (again?)
This can be closed. PHPStorm has stubs for this extension now. https://github.com/JetBrains/phpstorm-stubs/blob/master/ds/ds.php