Completed
Push — master ( 479d34...76ed5d )
by James
16s queued 14s
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.
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.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -10,73 +10,73 @@
 block discarded – undo
10 10
  */
11 11
 final class HooksReader {
12 12
 
13
-	/**
14
-	 * Reader instance.
15
-	 *
16
-	 * @var AnnotationReader
17
-	 */
18
-	private $reader;
13
+    /**
14
+     * Reader instance.
15
+     *
16
+     * @var AnnotationReader
17
+     */
18
+    private $reader;
19 19
 
20
-	/**
21
-	 * Construct a new HooksReader instance.
22
-	 */
23
-	private function __construct() {
24
-		$this->reader = new AnnotationReader();
25
-		AnnotationRegistry::registerFile(
26
-			__DIR__ . '/Annotations.php'
27
-		);
28
-	}
20
+    /**
21
+     * Construct a new HooksReader instance.
22
+     */
23
+    private function __construct() {
24
+        $this->reader = new AnnotationReader();
25
+        AnnotationRegistry::registerFile(
26
+            __DIR__ . '/Annotations.php'
27
+        );
28
+    }
29 29
 
30
-	/**
31
-	 * Get the Annotation reader.
32
-	 *
33
-	 * @return AnnotationReader
34
-	 */
35
-	private function reader() {
36
-		return $this->reader;
37
-	}
30
+    /**
31
+     * Get the Annotation reader.
32
+     *
33
+     * @return AnnotationReader
34
+     */
35
+    private function reader() {
36
+        return $this->reader;
37
+    }
38 38
 
39
-	/**
40
-	 * Get the shared reader instance.
41
-	 *
42
-	 * @return HooksReader
43
-	 */
44
-	static private function instance() {
45
-		static $instance;
39
+    /**
40
+     * Get the shared reader instance.
41
+     *
42
+     * @return HooksReader
43
+     */
44
+    static private function instance() {
45
+        static $instance;
46 46
 
47
-		if ( ! $instance ) {
48
-			$instance = new HooksReader();
49
-		}
47
+        if ( ! $instance ) {
48
+            $instance = new HooksReader();
49
+        }
50 50
 
51
-		return $instance;
52
-	}
51
+        return $instance;
52
+    }
53 53
 
54
-	/**
55
-	 * Shared implementation of hook reading logic.
56
-	 *
57
-	 * @param  object   $target    Object to read annotations from.
58
-	 * @param  \Closure $condition Whether the annotation should be registered.
59
-	 * @return array
60
-	 */
61
-	static public function read( $target, $condition ) {
62
-		$reader = static::instance()->reader();
63
-		$rmethods = (new ReflectionClass( $target ))->getMethods();
54
+    /**
55
+     * Shared implementation of hook reading logic.
56
+     *
57
+     * @param  object   $target    Object to read annotations from.
58
+     * @param  \Closure $condition Whether the annotation should be registered.
59
+     * @return array
60
+     */
61
+    static public function read( $target, $condition ) {
62
+        $reader = static::instance()->reader();
63
+        $rmethods = (new ReflectionClass( $target ))->getMethods();
64 64
 
65
-		$hooks = [];
65
+        $hooks = [];
66 66
 
67
-		foreach ( $rmethods as $rmethod ) {
68
-			foreach ( $reader->getMethodAnnotations( $rmethod ) as $annotation ) {
69
-				if ( $condition( $annotation ) ) {
70
-					$hooks[] = [
71
-						'hook' => $annotation->hook,
72
-						'method' => $rmethod->getName(),
73
-						'priority' => $annotation->priority,
74
-						'args' => $annotation->args,
75
-					];
76
-				}
77
-			}
78
-		}
67
+        foreach ( $rmethods as $rmethod ) {
68
+            foreach ( $reader->getMethodAnnotations( $rmethod ) as $annotation ) {
69
+                if ( $condition( $annotation ) ) {
70
+                    $hooks[] = [
71
+                        'hook' => $annotation->hook,
72
+                        'method' => $rmethod->getName(),
73
+                        'priority' => $annotation->priority,
74
+                        'args' => $annotation->args,
75
+                    ];
76
+                }
77
+            }
78
+        }
79 79
 
80
-		return $hooks;
81
-	}
80
+        return $hooks;
81
+    }
82 82
 }
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.