Completed
Pull Request — master (#22)
by James
15:13 queued 02:42
created
src/Core/HooksReader.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
 	/**
49 49
 	 * Shared implementation of hook reading logic.
50 50
 	 *
51
-	 * @param  object   $target    Object to read annotations from.
51
+	 * @param  Annotatable   $target    Object to read annotations from.
52 52
 	 * @param  \Closure $condition Whether the annotation should be registered.
53 53
 	 * @return array
54 54
 	 */
Please login to merge, or discard this patch.
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -11,66 +11,66 @@
 block discarded – undo
11 11
  */
12 12
 class HooksReader {
13 13
 
14
-	/**
15
-	 * Construct a new HooksReader instance.
16
-	 */
17
-	private function __construct() {
18
-		$this->reader = new AnnotationReader();
19
-		AnnotationRegistry::registerFile(
20
-			__DIR__ . '/Annotations.php'
21
-		);
22
-	}
14
+    /**
15
+     * Construct a new HooksReader instance.
16
+     */
17
+    private function __construct() {
18
+        $this->reader = new AnnotationReader();
19
+        AnnotationRegistry::registerFile(
20
+            __DIR__ . '/Annotations.php'
21
+        );
22
+    }
23 23
 
24
-	/**
25
-	 * Get the Annotation reader.
26
-	 *
27
-	 * @return AnnotationReader
28
-	 */
29
-	private function reader() {
30
-		return $this->reader;
31
-	}
24
+    /**
25
+     * Get the Annotation reader.
26
+     *
27
+     * @return AnnotationReader
28
+     */
29
+    private function reader() {
30
+        return $this->reader;
31
+    }
32 32
 
33
-	/**
34
-	 * Get the shared reader instance.
35
-	 *
36
-	 * @return HooksReader
37
-	 */
38
-	static private function instance() {
39
-		static $instance;
33
+    /**
34
+     * Get the shared reader instance.
35
+     *
36
+     * @return HooksReader
37
+     */
38
+    static private function instance() {
39
+        static $instance;
40 40
 
41
-		if ( ! $instance ) {
42
-			$instance = new HooksReader();
43
-		}
41
+        if ( ! $instance ) {
42
+            $instance = new HooksReader();
43
+        }
44 44
 
45
-		return $instance;
46
-	}
45
+        return $instance;
46
+    }
47 47
 
48
-	/**
49
-	 * Shared implementation of hook reading logic.
50
-	 *
51
-	 * @param  object   $target    Object to read annotations from.
52
-	 * @param  \Closure $condition Whether the annotation should be registered.
53
-	 * @return array
54
-	 */
55
-	static public function read( $target, $condition ) {
56
-		$reader = static::instance()->reader();
57
-		$rmethods = (new ReflectionClass( $target ))->getMethods();
48
+    /**
49
+     * Shared implementation of hook reading logic.
50
+     *
51
+     * @param  object   $target    Object to read annotations from.
52
+     * @param  \Closure $condition Whether the annotation should be registered.
53
+     * @return array
54
+     */
55
+    static public function read( $target, $condition ) {
56
+        $reader = static::instance()->reader();
57
+        $rmethods = (new ReflectionClass( $target ))->getMethods();
58 58
 
59
-		$hooks = [];
59
+        $hooks = [];
60 60
 
61
-		foreach ( $rmethods as $rmethod ) {
62
-			foreach ( $reader->getMethodAnnotations( $rmethod ) as $annotation ) {
63
-				if ( $condition( $annotation ) ) {
64
-					$hooks[] = [
65
-						'hook' => $annotation->hook,
66
-						'method' => $rmethod->getName(),
67
-						'priority' => $annotation->priority,
68
-						'args' => $annotation->args,
69
-					];
70
-				}
71
-			}
72
-		}
61
+        foreach ( $rmethods as $rmethod ) {
62
+            foreach ( $reader->getMethodAnnotations( $rmethod ) as $annotation ) {
63
+                if ( $condition( $annotation ) ) {
64
+                    $hooks[] = [
65
+                        'hook' => $annotation->hook,
66
+                        'method' => $rmethod->getName(),
67
+                        'priority' => $annotation->priority,
68
+                        'args' => $annotation->args,
69
+                    ];
70
+                }
71
+            }
72
+        }
73 73
 
74
-		return $hooks;
75
-	}
74
+        return $hooks;
75
+    }
76 76
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	private function __construct() {
18 18
 		$this->reader = new AnnotationReader();
19 19
 		AnnotationRegistry::registerFile(
20
-			__DIR__ . '/Annotations.php'
20
+			__DIR__.'/Annotations.php'
21 21
 		);
22 22
 	}
23 23
 
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	static private function instance() {
39 39
 		static $instance;
40 40
 
41
-		if ( ! $instance ) {
41
+		if (!$instance) {
42 42
 			$instance = new HooksReader();
43 43
 		}
44 44
 
@@ -52,15 +52,15 @@  discard block
 block discarded – undo
52 52
 	 * @param  \Closure $condition Whether the annotation should be registered.
53 53
 	 * @return array
54 54
 	 */
55
-	static public function read( $target, $condition ) {
55
+	static public function read($target, $condition) {
56 56
 		$reader = static::instance()->reader();
57
-		$rmethods = (new ReflectionClass( $target ))->getMethods();
57
+		$rmethods = (new ReflectionClass($target))->getMethods();
58 58
 
59 59
 		$hooks = [];
60 60
 
61
-		foreach ( $rmethods as $rmethod ) {
62
-			foreach ( $reader->getMethodAnnotations( $rmethod ) as $annotation ) {
63
-				if ( $condition( $annotation ) ) {
61
+		foreach ($rmethods as $rmethod) {
62
+			foreach ($reader->getMethodAnnotations($rmethod) as $annotation) {
63
+				if ($condition($annotation)) {
64 64
 					$hooks[] = [
65 65
 						'hook' => $annotation->hook,
66 66
 						'method' => $rmethod->getName(),
Please login to merge, or discard this patch.
src/Core/Annotations.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -8,27 +8,27 @@  discard block
 block discarded – undo
8 8
  * @Target({"METHOD"})
9 9
  */
10 10
 class Action {
11
-	/**
12
-	 * Hook to attach method to.
13
-	 *
14
-	 * @var string
15
-	 * @Required
16
-	 */
17
-	public $hook;
11
+    /**
12
+     * Hook to attach method to.
13
+     *
14
+     * @var string
15
+     * @Required
16
+     */
17
+    public $hook;
18 18
 
19
-	/**
20
-	 * Priority level for the hook.
21
-	 *
22
-	 * @var int
23
-	 */
24
-	public $priority = 10;
19
+    /**
20
+     * Priority level for the hook.
21
+     *
22
+     * @var int
23
+     */
24
+    public $priority = 10;
25 25
 
26
-	/**
27
-	 * Arguments to call the hook with.
28
-	 *
29
-	 * @var int
30
-	 */
31
-	public $args = 1;
26
+    /**
27
+     * Arguments to call the hook with.
28
+     *
29
+     * @var int
30
+     */
31
+    public $args = 1;
32 32
 }
33 33
 
34 34
 /**
@@ -38,25 +38,25 @@  discard block
 block discarded – undo
38 38
  * @Target({"METHOD"})
39 39
  */
40 40
 class Filter {
41
-	/**
42
-	 * Hook to attach method to.
43
-	 *
44
-	 * @var string
45
-	 * @Required
46
-	 */
47
-	public $hook;
41
+    /**
42
+     * Hook to attach method to.
43
+     *
44
+     * @var string
45
+     * @Required
46
+     */
47
+    public $hook;
48 48
 
49
-	/**
50
-	 * Priority level for the hook.
51
-	 *
52
-	 * @var int
53
-	 */
54
-	public $priority = 10;
49
+    /**
50
+     * Priority level for the hook.
51
+     *
52
+     * @var int
53
+     */
54
+    public $priority = 10;
55 55
 
56
-	/**
57
-	 * Arguments to call the hook with.
58
-	 *
59
-	 * @var int
60
-	 */
61
-	public $args = 1;
56
+    /**
57
+     * Arguments to call the hook with.
58
+     *
59
+     * @var int
60
+     */
61
+    public $args = 1;
62 62
 }
Please login to merge, or discard this patch.
src/Core/Annotatable.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,25 +11,25 @@
 block discarded – undo
11 11
  */
12 12
 trait Annotatable {
13 13
 
14
-	/**
15
-	 * Read the class methods and return the filter hooks.
16
-	 *
17
-	 * @return array
18
-	 */
19
-	public function filter_hooks() {
20
-		return HooksReader::read( $this, function( $annotation ) {
21
-			return $annotation instanceof Annotation\Filter;
22
-		});
23
-	}
14
+    /**
15
+     * Read the class methods and return the filter hooks.
16
+     *
17
+     * @return array
18
+     */
19
+    public function filter_hooks() {
20
+        return HooksReader::read( $this, function( $annotation ) {
21
+            return $annotation instanceof Annotation\Filter;
22
+        });
23
+    }
24 24
 
25
-	/**
26
-	 * Read the class methods and return the action hooks.
27
-	 *
28
-	 * @return array
29
-	 */
30
-	public function action_hooks() {
31
-		return HooksReader::read( $this, function( $annotation ) {
32
-			return $annotation instanceof Annotation\Action;
33
-		});
34
-	}
25
+    /**
26
+     * Read the class methods and return the action hooks.
27
+     *
28
+     * @return array
29
+     */
30
+    public function action_hooks() {
31
+        return HooksReader::read( $this, function( $annotation ) {
32
+            return $annotation instanceof Annotation\Action;
33
+        });
34
+    }
35 35
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	 * @return array
18 18
 	 */
19 19
 	public function filter_hooks() {
20
-		return HooksReader::read( $this, function( $annotation ) {
20
+		return HooksReader::read($this, function($annotation) {
21 21
 			return $annotation instanceof Annotation\Filter;
22 22
 		});
23 23
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @return array
29 29
 	 */
30 30
 	public function action_hooks() {
31
-		return HooksReader::read( $this, function( $annotation ) {
31
+		return HooksReader::read($this, function($annotation) {
32 32
 			return $annotation instanceof Annotation\Action;
33 33
 		});
34 34
 	}
Please login to merge, or discard this patch.