-
Notifications
You must be signed in to change notification settings - Fork 13
Annotation-powered method registration #71
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
Open
bradjones1
wants to merge
8
commits into
yoanm:master
Choose a base branch
from
bradjones1:annotations
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7c38ef4
Annotation-powered method registration
bradjones1 95a30db
Fix incorrect version constraint in package suggestion
bradjones1 08b4bcd
Make invocation of annotation reader safer
bradjones1 da3748e
Fix existing test run, still needs coverage for annotations
bradjones1 6c79222
Fix code style inspection
bradjones1 1af4fa2
Remaining code style fixes
bradjones1 a9975e9
Include annotations library as dev dependency
bradjones1 11f29d9
Address PR feedback
bradjones1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
; top-most EditorConfig file | ||
root = true | ||
|
||
; Unix-style newlines | ||
[*] | ||
charset = utf-8 | ||
end_of_line = LF | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.php] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[composer.{json,lock}] | ||
indent_size = 2 | ||
|
||
[*.md] | ||
max_line_length = 80 | ||
|
||
[COMMIT_EDITMSG] | ||
max_line_length = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Yoanm\SymfonyJsonRpcHttpServer\Annotation; | ||
|
||
/** | ||
* Annotation class for @JsonRpcMethod(). | ||
* | ||
* @Annotation | ||
* @Target({"CLASS"}) | ||
*/ | ||
class JsonRpcMethod | ||
{ | ||
/** @var string */ | ||
private $name; | ||
|
||
/** | ||
* @param array $data An array of key/value parameters | ||
* | ||
* @throws \BadMethodCallException | ||
*/ | ||
public function __construct(array $data) | ||
{ | ||
foreach ($data as $key => $value) { | ||
$method = 'set'.str_replace('_', '', $key); | ||
if (!method_exists($this, $method)) { | ||
throw new \BadMethodCallException( | ||
sprintf('Unknown property "%s" on annotation "%s".', $key, static::class) | ||
); | ||
} | ||
$this->$method($value); | ||
} | ||
} | ||
|
||
public function setName(string $name) | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.