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

PHPstorm stubs #128

Closed
mjpvandenberg opened this issue Nov 23, 2018 · 5 comments
Closed

PHPstorm stubs #128

mjpvandenberg opened this issue Nov 23, 2018 · 5 comments

Comments

@mjpvandenberg
Copy link

mjpvandenberg commented Nov 23, 2018

Jetbrains offers a repository for PHP extension stubs used in PHPstorm:
https://github.com/jetbrains/phpstorm-stubs
I expect that contributing the DS stubs there would help a significant portion of your users, and would (somewhat) relieve the need for maintaining the polyfill (#92)

@rtheunissen
Copy link
Member

I had no idea. 😮

I'll request that ds and decimal be added, thank you. ✨

@edmondscommerce
Copy link

looks like this hasn't happened yet, agreed it would great if it could be organised

@hopeseekr
Copy link

I've picked up the mantle and will be developing it right now. I've done this sort of stuff in the past.

I'll also (::gasp::) create the first Unit test in this project that will instantly check and confirm that the PhpStorm stub is up-to-date and current (using reflection).

it's actually pretty fun project for me.

I'll create a PR against the polyfill project and stick it in the root directory of the project, entitled "phpstorm-stub.php". It is a single file that contains all of the classes with their public constants, properties and methods.

hopeseekr added a commit to hopeseekr-contribs/ext-ds-polyfill that referenced this issue Mar 30, 2019
This is needed in preparation for the PhpStorm stub (php-ds/ext-ds#128).
hopeseekr added a commit to hopeseekr-contribs/ext-ds-polyfill that referenced this issue Mar 30, 2019
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).
hopeseekr added a commit to hopeseekr-contribs/ext-ds-polyfill that referenced this issue Mar 30, 2019
## 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

Great use of my first 2 1/2 hours on this beautiful Saturday!

Thanks for such an awesome project, guys!! The datatypes of HackLang that seemingly inspired this project were my #1 reason for flipping over to that project, back when they were attempting to take on the PHP leadership mantle a few years ago.

I'm so happy I found this project today and can once again use Collections and actual functional data structures in actual PHP for the first time, without the idiosyncrasies of the unmaintained SPL.

Cheers!

@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

No branches or pull requests

5 participants