Skip to content

Commit 2dd7100

Browse files
committed
Merge branch 'master' into v0.1
Conflicts: .travis.yml
2 parents 5fd5ebe + f3f3e14 commit 2dd7100

File tree

5 files changed

+768
-581
lines changed

5 files changed

+768
-581
lines changed

.gitattributes

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/tests export-ignore
2-
phpunit.xml.dist export-ignore
3-
.gitignore export-ignore
4-
.gitattributes export-ignore
1+
/tests export-ignore
2+
.travis.yml export-ignore
3+
phpunit.xml export-ignore
4+
.gitignore export-ignore
5+
.gitattributes export-ignore

README.md

Lines changed: 86 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,86 @@
1-
# PHP Platform Annotations
2-
This package provides APIs to access annotations in PHP
3-
4-
[![Build Status](https://travis-ci.org/PHPPlatform/annotations.svg?branch=master)](https://travis-ci.org/PHPPlatform/annotations)
5-
6-
7-
## Usage
8-
9-
``` PHP
10-
PhpPlatform\Annotations\Annotation::getAnnotations($className, $propertyName="*", $constantName="*", $methodName="*");
11-
```
12-
where
13-
- `$className` is complete name of the class for which annotations are needed
14-
- `$propertyName` is a *string* of a property or *array* of properties for which annotations are needed
15-
- `$constantName` is a *string* of a constant or *array* of constants for which annotations are needed
16-
- `$methodName` is a *string* of a method name or *array* of method names for which annotations are needed
17-
18-
## Example
19-
20-
For example , please see the test case [TestAnnotation][TestAnnotation]
21-
22-
[TestAnnotation]:https://github.com/PHPPlatform/annotations/blob/master/tests/Annotations/TestAnnotation.php
1+
# PHP Platform Annotations
2+
This package provides APIs to access annotations in PHP
3+
4+
[![Build Status](https://travis-ci.org/PHPPlatform/annotations.svg?branch=master)](https://travis-ci.org/PHPPlatform/annotations)
5+
6+
7+
## Usage
8+
9+
### Getting the Annotations
10+
``` PHP
11+
PhpPlatform\Annotations\Annotation::getAnnotations($className, $propertyName="*", $constantName="*", $methodName="*");
12+
```
13+
where
14+
- `$className` is complete name of the class for which annotations are needed
15+
- `$propertyName` is a *string* of a property or *array* of properties for which annotations are needed
16+
- `$constantName` is a *string* of a constant or *array* of constants for which annotations are needed
17+
- `$methodName` is a *string* of a method name or *array* of method names for which annotations are needed
18+
19+
### Declaring Annotations
20+
21+
This library supports annotations in DocComments
22+
Annotation declaration has the format of
23+
```
24+
* @KEY VALUE(S)
25+
```
26+
Where `KEY` may contain subkeys seperated by `.`
27+
and `VALUES` are `space` or `comma` seperated strings
28+
29+
30+
## Example
31+
This Example shows the different forms of annotations and their expected values
32+
```php
33+
/**
34+
* @key1
35+
* @key2
36+
* @key3.subKey1
37+
* @key3.subKey2.subkey21 success
38+
* @key4 v1
39+
* @key5 (v2)
40+
* @key6 v3 v4
41+
* @key7 "v5\"With Space and Quotes\""
42+
* @key8 ("v6\"With Space and Quotes\"", v7)
43+
* @key9 ("v8\"With Space and Quotes\"", v9) description1
44+
* @key10 ("v10 With \\", v11) description2
45+
* @key11 ("123", v12) description3
46+
* @key12 ("true", "false")
47+
* @key13 v13
48+
* @key13 1234
49+
* @key14 (v14)
50+
* @key14 v15
51+
* @ notKey
52+
* @wrongKey(v16) desc
53+
*
54+
*/
55+
public $testDifferrentFormatsOfAnnoptations;
56+
```
57+
The array of annotations returned from
58+
```PHP
59+
PhpPlatform\Annotations\Annotation::getAnnotations($className, 'testDifferrentFormatsOfAnnoptations');
60+
```
61+
Will be
62+
```php
63+
[
64+
"testDifferrentFormatsOfAnnoptations" => [
65+
"key1" => true,
66+
"key2" => true,
67+
"key3" => [
68+
"subKey1" => true,
69+
"subKey2" => [
70+
"subkey21" => "success"
71+
]
72+
],
73+
"key4" => "v1",
74+
"key5" => ["v2"],
75+
"key6" => ["v3", "v4"],
76+
"key7" => 'v5"With Space and Quotes"',
77+
"key8" => ['v6"With Space and Quotes"', "v7"],
78+
"key9" => ['v8"With Space and Quotes"', "v9"],
79+
"key10" => ["v10 With \\", "v11"],
80+
"key11" => [123, "v12"],
81+
"key12" => [true, false],
82+
"key13" => ['v13', 1234],
83+
"key14" => ["v14", "v15"]
84+
]
85+
]
86+
```

0 commit comments

Comments
 (0)