Completed
Push — master ( 55ca36...9148b5 )
by Andrey
01:37
created
php/class-core.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 	/**
12 12
 	 * @param array $values Optional array of services/options.
13 13
 	 */
14
-	public function __construct( $values = array() ) {
14
+	public function __construct($values = array()) {
15 15
 
16 16
 		global $wp_version;
17 17
 
@@ -20,19 +20,19 @@  discard block
 block discarded – undo
20 20
 		$defaults['twig.directories'] = [];
21 21
 
22 22
 		// This needs to be lazy or theme switchers and alike explode it.
23
-		$defaults['twig.loader'] = function ( $meadow ) {
23
+		$defaults['twig.loader'] = function($meadow) {
24 24
 
25 25
 			$stylesheet_dir  = get_stylesheet_directory();
26 26
 			$template_dir    = get_template_directory();
27 27
 			$calculated_dirs = array(
28 28
 				$stylesheet_dir,
29 29
 				$template_dir,
30
-				plugin_dir_path( __DIR__ ) . 'twig',
30
+				plugin_dir_path(__DIR__) . 'twig',
31 31
 			);
32 32
 
33 33
 			// Enables explicit inheritance from parent theme in child.
34
-			if ( $stylesheet_dir !== $template_dir ) {
35
-				$calculated_dirs[] = dirname( $template_dir );
34
+			if ($stylesheet_dir !== $template_dir) {
35
+				$calculated_dirs[] = dirname($template_dir);
36 36
 			}
37 37
 
38 38
 			$directories = array_unique(
@@ -42,43 +42,43 @@  discard block
 block discarded – undo
42 42
 				)
43 43
 			);
44 44
 
45
-			return new \Twig_Loader_Filesystem( $directories );
45
+			return new \Twig_Loader_Filesystem($directories);
46 46
 		};
47 47
 
48
-		$defaults['twig.undefined_function'] = array( __CLASS__, 'undefined_function' );
49
-		$defaults['twig.undefined_filter']   = array( __CLASS__, 'undefined_filter' );
48
+		$defaults['twig.undefined_function'] = array(__CLASS__, 'undefined_function');
49
+		$defaults['twig.undefined_filter']   = array(__CLASS__, 'undefined_filter');
50 50
 
51
-		$defaults['twig.environment'] = function ( $meadow ) {
52
-			$environment      = new \Twig_Environment( $meadow['twig.loader'], $meadow['twig.options'] );
51
+		$defaults['twig.environment'] = function($meadow) {
52
+			$environment      = new \Twig_Environment($meadow['twig.loader'], $meadow['twig.options']);
53 53
 			$meadow_extension = new Extension();
54
-			$environment->addExtension( $meadow_extension );
55
-			$environment->registerUndefinedFunctionCallback( $meadow['twig.undefined_function'] );
56
-			$environment->registerUndefinedFilterCallback( $meadow['twig.undefined_filter'] );
54
+			$environment->addExtension($meadow_extension);
55
+			$environment->registerUndefinedFunctionCallback($meadow['twig.undefined_function']);
56
+			$environment->registerUndefinedFilterCallback($meadow['twig.undefined_filter']);
57 57
 
58
-			if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
58
+			if (defined('WP_DEBUG') && WP_DEBUG) {
59 59
 				$debug_extension = new \Twig_Extension_Debug();
60
-				$environment->addExtension( $debug_extension );
60
+				$environment->addExtension($debug_extension);
61 61
 				$environment->enableDebug();
62 62
 			}
63 63
 
64 64
 			return $environment;
65 65
 		};
66 66
 
67
-		if ( version_compare( rtrim( $wp_version, '-src' ), '4.7', '>=' ) ) {
67
+		if (version_compare(rtrim($wp_version, '-src'), '4.7', '>=')) {
68 68
 
69
-			$defaults['hierarchy'] = function () {
69
+			$defaults['hierarchy'] = function() {
70 70
 				return new Type_Template_Hierarchy();
71 71
 			};
72 72
 		} else {
73 73
 
74
-			trigger_error( 'Pre–WP 4.7 implementation of Meadow hierarchy is deprecated and will be removed in 1.0.', E_USER_DEPRECATED );
74
+			trigger_error('Pre–WP 4.7 implementation of Meadow hierarchy is deprecated and will be removed in 1.0.', E_USER_DEPRECATED);
75 75
 
76
-			$defaults['hierarchy'] = function () {
76
+			$defaults['hierarchy'] = function() {
77 77
 				return new Template_Hierarchy();
78 78
 			};
79 79
 		}
80 80
 
81
-		parent::__construct( array_merge( $defaults, $values ) );
81
+		parent::__construct(array_merge($defaults, $values));
82 82
 	}
83 83
 
84 84
 	/**
@@ -88,20 +88,20 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return bool|\Twig_SimpleFunction
90 90
 	 */
91
-	public static function undefined_function( $function_name ) {
91
+	public static function undefined_function($function_name) {
92 92
 
93
-		if ( function_exists( $function_name ) ) {
93
+		if (function_exists($function_name)) {
94 94
 			return new \Twig_SimpleFunction(
95 95
 				$function_name,
96
-				function () use ( $function_name ) {
96
+				function() use ($function_name) {
97 97
 
98 98
 					ob_start();
99
-					$return = call_user_func_array( $function_name, func_get_args() );
99
+					$return = call_user_func_array($function_name, func_get_args());
100 100
 					$echo   = ob_get_clean();
101 101
 
102
-					return empty( $echo ) ? $return : $echo;
102
+					return empty($echo) ? $return : $echo;
103 103
 				},
104
-				array( 'is_safe' => array( 'all' ) )
104
+				array('is_safe' => array('all'))
105 105
 			);
106 106
 		}
107 107
 
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
 	 *
116 116
 	 * @return bool|\Twig_SimpleFilter
117 117
 	 */
118
-	public static function undefined_filter( $filter_name ) {
118
+	public static function undefined_filter($filter_name) {
119 119
 
120 120
 		return new \Twig_SimpleFilter(
121 121
 			$filter_name,
122
-			function () use ( $filter_name ) {
122
+			function() use ($filter_name) {
123 123
 
124
-				return apply_filters( $filter_name, func_get_arg( 0 ) );
124
+				return apply_filters($filter_name, func_get_arg(0));
125 125
 			},
126
-			array( 'is_safe' => array( 'all' ) )
126
+			array('is_safe' => array('all'))
127 127
 		);
128 128
 	}
129 129
 
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
 		/** @var Template_Hierarchy $hierarchy */
133 133
 		$hierarchy = $this['hierarchy'];
134 134
 		$hierarchy->enable();
135
-		add_filter( 'template_include', array( $this, 'template_include' ) );
136
-		add_filter( 'get_search_form', array( $this, 'get_search_form' ), 9 );
135
+		add_filter('template_include', array($this, 'template_include'));
136
+		add_filter('get_search_form', array($this, 'get_search_form'), 9);
137 137
 	}
138 138
 
139 139
 	public function disable() {
@@ -141,8 +141,8 @@  discard block
 block discarded – undo
141 141
 		/** @var Template_Hierarchy $hierarchy */
142 142
 		$hierarchy = $this['hierarchy'];
143 143
 		$hierarchy->disable();
144
-		remove_filter( 'template_include', array( $this, 'template_include' ) );
145
-		remove_filter( 'get_search_form', array( $this, 'get_search_form' ), 9 );
144
+		remove_filter('template_include', array($this, 'template_include'));
145
+		remove_filter('get_search_form', array($this, 'get_search_form'), 9);
146 146
 	}
147 147
 
148 148
 	/**
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @return string|bool
152 152
 	 */
153
-	public function template_include( $template ) {
153
+	public function template_include($template) {
154 154
 
155
-		if ( '.twig' === substr( $template, - 5 ) ) {
155
+		if ('.twig' === substr($template, - 5)) {
156 156
 			/** @var \Twig_Environment $twig */
157 157
 			$twig = $this['twig.environment'];
158 158
 
159
-			echo $twig->render( basename( $template ), apply_filters( 'meadow_context', array() ) );
159
+			echo $twig->render(basename($template), apply_filters('meadow_context', array()));
160 160
 
161 161
 			return false;
162 162
 		}
@@ -169,14 +169,14 @@  discard block
 block discarded – undo
169 169
 	 *
170 170
 	 * @return string
171 171
 	 */
172
-	public function get_search_form( $form ) {
172
+	public function get_search_form($form) {
173 173
 
174 174
 		// Because first time it's an action.
175
-		if ( ! empty( $form ) ) {
175
+		if ( ! empty($form)) {
176 176
 			/** @var \Twig_Environment $twig */
177 177
 			$twig = $this['twig.environment'];
178 178
 
179
-			return $twig->render( 'searchform.twig', array() );
179
+			return $twig->render('searchform.twig', array());
180 180
 		}
181 181
 
182 182
 		return $form;
Please login to merge, or discard this patch.