1010 */
1111namespace Magento \TestFramework \Helper ;
1212
13+ /**
14+ * Integration Test Framework memory management logic.
15+ */
1316class Memory
1417{
1518 /**
@@ -38,21 +41,21 @@ public function __construct(\Magento\Framework\Shell $shell)
3841 /**
3942 * Retrieve the effective memory usage of the current process
4043 *
41- * memory_get_usage() cannot be used because of the bug
42- * @link https://bugs.php.net/bug.php?id=62467
44+ * Function memory_get_usage() cannot be used because of the bug
4345 *
46+ * @link https://bugs.php.net/bug.php?id=62467
4447 * @return int Memory usage in bytes
4548 */
4649 public function getRealMemoryUsage ()
4750 {
4851 $ pid = getmypid ();
4952 try {
53+ // fall back to the Unix command line
54+ $ result = $ this ->_getUnixProcessMemoryUsage ($ pid );
55+ } catch (\Magento \Framework \Exception \LocalizedException $ e ) {
5056 // try to use the Windows command line
5157 // some ports of Unix commands on Windows, such as MinGW, have limited capabilities and cannot be used
5258 $ result = $ this ->_getWinProcessMemoryUsage ($ pid );
53- } catch (\Magento \Framework \Exception \LocalizedException $ e ) {
54- // fall back to the Unix command line
55- $ result = $ this ->_getUnixProcessMemoryUsage ($ pid );
5659 }
5760 return $ result ;
5861 }
@@ -100,9 +103,11 @@ protected function _getWinProcessMemoryUsage($pid)
100103 * @return int
101104 * @throws \InvalidArgumentException
102105 * @throws \OutOfBoundsException
106+ * phpcs:disable Magento2.Functions.StaticFunction
103107 */
104108 public static function convertToBytes ($ number )
105109 {
110+ // phpcs:enable Magento2.Functions.StaticFunction
106111 if (!preg_match ('/^(.*\d)\h*(\D)$/ ' , $ number , $ matches )) {
107112 throw new \InvalidArgumentException ("Number format ' {$ number }' is not recognized. " );
108113 }
@@ -132,12 +137,14 @@ public static function convertToBytes($number)
132137 * - but the value has only one delimiter, such as "234,56", then it is impossible to know whether it is decimal
133138 * separator or not. Only knowing the right format would allow this.
134139 *
135- * @param $number
140+ * @param string $number
136141 * @return string
137142 * @throws \InvalidArgumentException
143+ * phpcs:disable Magento2.Functions.StaticFunction
138144 */
139145 protected static function _convertToNumber ($ number )
140146 {
147+ // phpcs:enable Magento2.Functions.StaticFunction
141148 preg_match_all ('/(\D+)/ ' , $ number , $ matches );
142149 if (count (array_unique ($ matches [0 ])) > 1 ) {
143150 throw new \InvalidArgumentException (
@@ -152,9 +159,11 @@ protected static function _convertToNumber($number)
152159 *
153160 * @link http://php.net/manual/en/function.php-uname.php
154161 * @return boolean
162+ * phpcs:disable Magento2.Functions.StaticFunction
155163 */
156164 public static function isMacOs ()
157165 {
166+ // phpcs:enable Magento2.Functions.StaticFunction
158167 return strtoupper (PHP_OS ) === 'DARWIN ' ;
159168 }
160169}
0 commit comments