@@ -56,22 +56,8 @@ class ShortifyPunit
5656 */
5757 private static $ returnValues = [];
5858
59-
60- /**
61- * @var array of allowed friend classes, that could access private methods of this class
62- */
63- private static $ friendClasses = [
64- 'ShortifyPunit\ShortifyPunit ' ,
65- 'ShortifyPunit\Stub\WhenCase ' ,
66- 'ShortifyPunit\Mock\MockClassOnTheFly ' ,
67- 'ShortifyPunit\Stub\WhenChainCase ' ];
68-
6959 /**
7060 * Call static function is used to detect calls to protected & private methods
71- * only friend classes are allowed to call private methods (C++ Style)
72- *
73- * + Friend Classes are those who Implement the mocking interface (ShortifyPunitMockInterface)
74- * or is set in $friendClasses variable
7561 *
7662 * @param $name
7763 * @param $arguments
@@ -88,22 +74,6 @@ public static function __callStatic($name, $arguments)
8874 throw self ::generateException ("{$ class } has no such method! " );
8975 }
9076
91- $ namespace = self ::$ namespace ;
92- $ backTrace = debug_backtrace ();
93- $ callingClassName = $ backTrace [2 ]['class ' ];
94-
95- $ reflection = new \ReflectionClass ($ callingClassName );
96-
97- if ($ reflection ->implementsInterface ("{$ namespace }\\Mock \\MockInterface " ) &&
98- is_array ($ arguments )
99- ) {
100- $ arguments [0 ] = $ callingClassName ;
101- }
102-
103- if ( ! self ::isFriendClass ($ callingClassName , $ namespace )){
104- throw self ::generateException ("{$ class } is not a friend class! " );
105- }
106-
10777 return forward_static_call_array ('static:: ' .$ name , $ arguments );
10878 }
10979
@@ -267,7 +237,7 @@ protected static function _isMethodStubbed($className, $instanceId, $methodName)
267237 }
268238
269239 /**
270- * Setting up a chained mock response, function is called from mocked classes using `friend classes` style
240+ * Setting up a chained mock response, function is called from mocked classes
271241 *
272242 * @param $mockClassInstanceId
273243 * @param $mockClassType
@@ -315,7 +285,7 @@ protected static function _createChainResponse(
315285
316286
317287 /**
318- * Setting up a mock response, function is called from mocked classes using `friend classes` style
288+ * Setting up a mock response, function is called from mocked classes
319289 *
320290 * @param $className
321291 * @param $instanceId
@@ -341,7 +311,7 @@ protected static function _setWhenMockResponse(
341311 }
342312
343313 /**
344- * Generating instance id, function is called from mocked classes using `friend classes` style
314+ * Generating instance id, function is called from mocked classes
345315 * @return int
346316 */
347317 protected static function _generateInstanceId ()
@@ -350,7 +320,7 @@ protected static function _generateInstanceId()
350320 }
351321
352322 /**
353- * Create response is a private method which is called from the Mocked classes using `friend classes` style
323+ * Create response is a private method which is called from the Mocked classes
354324 * returns a value which was set before in the When() function otherwise returning NULL
355325 *
356326 * @param $className
@@ -417,23 +387,6 @@ private static function getMockReflection($mockedClass)
417387 return $ reflection ;
418388 }
419389
420- /**
421- * @param $callingClassName
422- * @param string $namespace
423- * @return bool
424- */
425- private static function isFriendClass ($ callingClassName , $ namespace )
426- {
427- $ reflection = new \ReflectionClass ($ callingClassName );
428-
429- if ( ! $ reflection ->implementsInterface ("{$ namespace }\\Mock \\MockInterface " ) &&
430- ! in_array ($ callingClassName , self ::$ friendClasses )) {
431- return false ;
432- }
433-
434- return true ;
435- }
436-
437390 /**
438391 * Returns the mock hierarchy response values
439392 *
0 commit comments