Closed Amegatron closed 2 years ago
Thank you @Amegatron!!
Could you please pin PHP Parser dependency in composer.json
(line 21) to 4.11.0
. It looks like 4.13 uses incompatible type declarations
"nikic/php-parser": "4.11.0"
Done 👍 Also, found some other bugs in parsing and will make PRs once I figure them out.
Damn, forgot to start new branch for other issues. Should I recreate the PR, or it is OK to merge them all-together? There is still one more bug I wanna fix today concerning that same "references": compound types like array<type1,type2>
are not understood well by parser and they go as separate "references".
I'm okay with fixing #18 and #20 in this PR. Could you please also open an issue for array<type1, type2>
?
I'm not sure how standard is that notation and how it should look in the diagram.
Could you please elaborate a little bit more in a new issue?
Also not sure if Git hooks are working. I thought they would validate commit format (I've been following the conventional commits specification)
It's not a big deal, but was wondering if I need to fix the Git hooks set up.
Thank you @Amegatron!
You're welcome!
As for array<...>
notation, it is pretty common in PhpDoc if you want to specify the contents of an array. For example, array<int>
means that this is array of only int
s. array<string,MyClass>
essentially means a hash-map: keys are string
s, and elements themselves are objects of MyClass
. For now I'm not yet sure how exactly does it look in "out-of-the-box" diagrams, but since I use this library mostly as an tool to generate my own formats of diagrams, I get those array<...>
when I try to get TypeDeclaration::rerefences()
. I'll try to check it out today.
Also, this notation is used not only in arrays, but for any kinds of "lists". For example, if you're using any Collection
class (implementing ArrayAccess
or related), you can also specifcy the types for keys and values in the same format, like Collection<MyClass>
. Concerning this last scenario, I also sometimes get strange references
, though not yet sure how to reproduce it: sometimes I get such references as Collection<
, or MyType>
- with those junky brackets added to the type itself. Still need to investigate this issue more.
P.S. it is also worth noting, that this notation allows lots of nested levels, for example array<int,array<string,MyClass>>
, etc, which means literally this: array with number-keys, elements of which are arrays with string-keys (hash-map) and values are objects of MyClass
:)
As for the git hooks, I believe all the tests have passed automatically, but it told me approval was still needed for new contributors, that's why it didn't merge itself. If that was the question :)
You're welcome!
As for
array<...>
notation, it is pretty common in PhpDoc if you want to specify the contents of an array. For example,array<int>
means that this is array of onlyint
s.array<string,MyClass>
essentially means a hash-map: keys arestring
s, and elements themselves are objects ofMyClass
. For now I'm not yet sure how exactly does it look in "out-of-the-box" diagrams, but since I use this library mostly as an tool to generate my own formats of diagrams, I get thosearray<...>
when I try to getTypeDeclaration::rerefences()
. I'll try to check it out today.Also, this notation is used not only in arrays, but for any kinds of "lists". For example, if you're using any
Collection
class (implementingArrayAccess
or related), you can also specifcy the types for keys and values in the same format, likeCollection<MyClass>
. Concerning this last scenario, I also sometimes get strangereferences
, though not yet sure how to reproduce it: sometimes I get such references asCollection<
, orMyType>
- with those junky brackets added to the type itself. Still need to investigate this issue more.P.S. it is also worth noting, that this notation allows lots of nested levels, for example
array<int,array<string,MyClass>>
, etc, which means literally this: array with number-keys, elements of which are arrays with string-keys (hash-map) and values are objects ofMyClass
:)
I see. Thank you for the explanation. I think this would be a feature request to support "generics" in doc blocks.
As for the git hooks, I believe all the tests have passed automatically, but it told me approval was still needed for new contributors, that's why it didn't merge itself. If that was the question :)
When you committed a few tasks should have been run automatically, and if you ran your commit from a terminal, you should have seen an output similar to the one below.
GrumPHP detected a pre-commit command.
GrumPHP is sniffing your code!
Running tasks with priority 0!
==============================
Running task 1/6: composer...
Running task 2/6: composer_normalize...
Running task 3/6: phpstan...
Running task 4/6: phpunit...
Running task 5/6: phpcsfixer2...
Running task 6/6: phpcsfixer2_test...
Running task 1/6: composer... ✔
Running task 2/6: composer_normalize... ✔
Running task 3/6: phpstan...
Running task 4/6: phpunit...
Running task 5/6: phpcsfixer2...
Running task 6/6: phpcsfixer2_test...
GrumPHP detected a commit-msg command.
GrumPHP is sniffing your code!
Running tasks with priority 0!
==============================
Running task 1/1: git_commit_message...
Running task 1/1: git_commit_message... ✔
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▄▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▀█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▀▀▓▓▓▓▓▓▓▓▓▓▓▓█▀▀▀▀▀▀▀▀▀▀▀▀▀▀████████████▄
▄████████▀▀▀▀▀ ██████████
███████▀ ██████▀
▐████ ██▌ ██ ████▌
▐█▌ ███
█▌ ▄▄ ▄▄ ▐███
███ ▄▄▄▄▄▄▄▄▄▄▄▄ ▐███
██▄ ▐███████████████████████████
█▀█████████▌▀▀▀▀▀▀▀▀▀██████████▌▐
███████████▄▄▄▄▄▄▄███████████▌
▐█████████████████████████████
█████████████████████████████
██ █████████████████████▐██▀
▀ ▐███████████████████▌ ▐▀
████▀████████▀▐███
▀█▌ ▐█████ ▐█▌
██▀ ▐▀
_ _ _ _ _
/ \ | | | __ _ ___ ___ __| | |
/ _ \ | | | / _` |/ _ \ / _ \ / _` | |
/ ___ \| | | | (_| | (_) | (_) | (_| |_|
/_/ \_\_|_| \__, |\___/ \___/ \__,_(_)
|___/
I don't know if that's how it worked for you.
This PR addresses https://github.com/MontealegreLuis/phuml/issues/18