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

Getting list of all CodeDefinitions #58

Open
pedjas opened this issue Jun 3, 2015 · 4 comments
Open

Getting list of all CodeDefinitions #58

pedjas opened this issue Jun 3, 2015 · 4 comments

Comments

@pedjas
Copy link

pedjas commented Jun 3, 2015

I needed list of all code definitions Parser can handle, but could not find a way to get it.

I suggest expanding class Parser with something like this:

public function getCodeDefinitions() {
  return $this->bbcodes;
}
@Kubo2
Copy link
Contributor

Kubo2 commented Jun 11, 2015

It wouldn't be bad, but I suggest a little change to your patch:

-public function getCodeDefinitions() {
+public function getCodeDefinitions() : CodeDefinitionSet {
  return $this->bbcodes;
}

And then let CodeDefinitionSet interface extend the IteratorAggregate interface, create a base abstract class implementing Iterator and CodeDefinitionSet interfaces, and let IteratorAggregate::getIterator() return $this. Oh, this is pretty theorethical and I think really impossible. Oh, hell.
But it would be beatiful code :-) I will take a look at it when I have some time.

@DaSourcerer
Copy link
Contributor

But it would be beatiful code :-)

@Kubo2 Really? This sounds a bit like "let's use SPL for the sake of having used SPL"

When I was working on the parser, I've been tempted to let it implement an iterator interface, which would make sense to some degree. But in the end I found this to bring little advantage while introducing bc-breaking api changes.

It may still be worth to let nodes and nodevisitors implement \SplSubject and \SplObserver once a major release is in sight.

@Kubo2
Copy link
Contributor

Kubo2 commented Mar 15, 2017 via email

@pedjas
Copy link
Author

pedjas commented Mar 15, 2017

Actually, there is getter for Tag name: getTagName();
I did not notice it before, my bad.

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

3 participants