From 623e201b78dda2ecdb19dc8c260bd51cfec76e6d Mon Sep 17 00:00:00 2001 From: Joan He Date: Fri, 28 Aug 2015 08:48:02 -0500 Subject: [PATCH 1/2] MAGETWO-41996: [GitHub] DI compilation fails on class keyword #1722 --- .../Integrity/_files/blacklist/namespace.txt | 1 + .../Integrity/_files/blacklist/reference.txt | 3 ++- .../Module/Di/Code/Scanner/PhpScanner.php | 8 ++++---- .../Module/Di/Code/Scanner/PhpScannerTest.php | 7 ++++++- .../Magento/SomeModule/Model/DoubleColon.php | 18 ++++++++++++++++++ 5 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Model/DoubleColon.php diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt index bddf077931048..f9e607a7a4716 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/namespace.txt @@ -98,3 +98,4 @@ setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/M setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Helper/Test.php setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Element.php setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/ElementFactory.php +setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Model/DoubleColon.php diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt index 9f59d0c66a3c6..8066aa44f192a 100644 --- a/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/_files/blacklist/reference.txt @@ -70,4 +70,5 @@ Model3 \Magento\Mtf\Client\Element \Magento\Mtf\TestSuite\AppState \Magento\Framework\A -\Magento\Framework\B \ No newline at end of file +\Magento\Framework\B +DoubleColon diff --git a/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php b/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php index 64f1a8ac90c20..d46cbe86b291e 100644 --- a/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php +++ b/setup/src/Magento/Setup/Module/Di/Code/Scanner/PhpScanner.php @@ -227,17 +227,17 @@ protected function _fetchClasses($namespace, $tokenIterator, $count, $tokens) protected function _getDeclaredClasses($file) { $classes = []; - $namespace = ""; + $namespace = ''; $tokens = token_get_all(file_get_contents($file)); $count = count($tokens); for ($tokenIterator = 0; $tokenIterator < $count; $tokenIterator++) { - if ($tokens[$tokenIterator][0] === T_NAMESPACE) { + if ($tokens[$tokenIterator][0] == T_NAMESPACE) { $namespace .= $this->_fetchNamespace($tokenIterator, $count, $tokens); } - if ($tokens[$tokenIterator][0] === T_CLASS - || $tokens[$tokenIterator][0] === T_INTERFACE + if (($tokens[$tokenIterator][0] == T_CLASS || $tokens[$tokenIterator][0] == T_INTERFACE) + && $tokens[$tokenIterator - 1][0] != T_DOUBLE_COLON ) { $classes = array_merge($classes, $this->_fetchClasses($namespace, $tokenIterator, $count, $tokens)); } diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PhpScannerTest.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PhpScannerTest.php index 6403592e0aaf1..e4942d9eeb47d 100644 --- a/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PhpScannerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/Code/Scanner/PhpScannerTest.php @@ -7,6 +7,8 @@ require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/Helper/Test.php'; require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/ElementFactory.php'; +require_once __DIR__ . '/../../_files/app/code/Magento/SomeModule/Model/DoubleColon.php'; + class PhpScannerTest extends \PHPUnit_Framework_TestCase { /** @@ -35,7 +37,10 @@ protected function setUp() $this->_logMock = $this->getMock('\Magento\Setup\Module\Di\Compiler\Log\Log', [], [], '', false) ); $this->_testDir = str_replace('\\', '/', realpath(__DIR__ . '/../../') . '/_files'); - $this->_testFiles = [$this->_testDir . '/app/code/Magento/SomeModule/Helper/Test.php']; + $this->_testFiles = [ + $this->_testDir . '/app/code/Magento/SomeModule/Helper/Test.php', + $this->_testDir . '/app/code/Magento/SomeModule/Model/DoubleColon.php' + ]; } public function testCollectEntities() diff --git a/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Model/DoubleColon.php b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Model/DoubleColon.php new file mode 100644 index 0000000000000..21b84f1535b8d --- /dev/null +++ b/setup/src/Magento/Setup/Test/Unit/Module/Di/_files/app/code/Magento/SomeModule/Model/DoubleColon.php @@ -0,0 +1,18 @@ + Date: Fri, 28 Aug 2015 21:14:27 -0500 Subject: [PATCH 2/2] MAGETWO-41792: Multiple stores at different paths rendering wrong store base_url --- .../Test/Unit/Block/CurrencyTest.php | 4 +- app/code/Magento/Store/etc/di.xml | 4 +- .../Wishlist/Test/Unit/Helper/DataTest.php | 5 +- app/etc/di.xml | 2 +- .../Magento/Framework/UrlInterface/Proxy.php | 212 ------------------ 5 files changed, 7 insertions(+), 220 deletions(-) delete mode 100644 lib/internal/Magento/Framework/UrlInterface/Proxy.php diff --git a/app/code/Magento/Directory/Test/Unit/Block/CurrencyTest.php b/app/code/Magento/Directory/Test/Unit/Block/CurrencyTest.php index 598dfb6777f5f..b20375ee93740 100644 --- a/app/code/Magento/Directory/Test/Unit/Block/CurrencyTest.php +++ b/app/code/Magento/Directory/Test/Unit/Block/CurrencyTest.php @@ -26,8 +26,8 @@ class CurrencyTest extends \PHPUnit_Framework_TestCase public function setUp() { $this->urlBuilder = $this->getMock( - '\Magento\Framework\UrlInterface\Proxy', - ['getUrl'], + '\Magento\Framework\UrlInterface', + [], [], '', false diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml index ecda7a87e6b85..f065cea681b43 100644 --- a/app/code/Magento/Store/etc/di.xml +++ b/app/code/Magento/Store/etc/di.xml @@ -92,7 +92,7 @@ Magento\Framework\Session\Generic\Proxy Magento\Store\Model\Store::CUSTOM_ENTRY_POINT_PARAM - Magento\Framework\UrlInterface\Proxy + Magento\Framework\UrlInterface @@ -249,7 +249,7 @@ - Magento\Framework\UrlInterface\Proxy + Magento\Framework\UrlInterface Magento\Framework\App\Request\Http\Proxy diff --git a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php index afe0a833e84b3..e1f76f56e8203 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php @@ -9,7 +9,7 @@ use Magento\Framework\App\Helper\Context; use Magento\Framework\Data\Helper\PostHelper; use Magento\Framework\Registry; -use Magento\Framework\UrlInterface\Proxy as UrlInterface; +use Magento\Framework\UrlInterface; use Magento\Store\Model\Store; use Magento\Store\Model\StoreManagerInterface; use Magento\Wishlist\Controller\WishlistProviderInterface; @@ -69,9 +69,8 @@ public function setUp() ->method('getStore') ->willReturn($this->store); - $this->urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface\Proxy') + $this->urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface') ->disableOriginalConstructor() - ->setMethods(['getUrl']) ->getMock(); $this->context = $this->getMockBuilder('Magento\Framework\App\Helper\Context') diff --git a/app/etc/di.xml b/app/etc/di.xml index 18e52f6b117b2..4f44dc23364d7 100644 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -1128,7 +1128,7 @@ - Magento\Framework\UrlInterface\Proxy + Magento\Framework\UrlInterface diff --git a/lib/internal/Magento/Framework/UrlInterface/Proxy.php b/lib/internal/Magento/Framework/UrlInterface/Proxy.php deleted file mode 100644 index 7ed1a1bbc7bff..0000000000000 --- a/lib/internal/Magento/Framework/UrlInterface/Proxy.php +++ /dev/null @@ -1,212 +0,0 @@ -_objectManager = $objectManager; - $this->_instanceName = $instanceName; - $this->_isShared = $shared; - } - - /** - * @return array - */ - public function __sleep() - { - return ['_subject', '_isShared']; - } - - /** - * Retrieve ObjectManager from global scope - * - * @return void - */ - public function __wakeup() - { - $this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); - } - - /** - * Clone proxied instance - * - * @return void - */ - public function __clone() - { - $this->_subject = clone $this->_getSubject(); - } - - /** - * Get proxied instance - * - * @return \Magento\Framework\UrlInterface - */ - protected function _getSubject() - { - if (!$this->_subject) { - $this->_subject = true === $this->_isShared - ? $this->_objectManager->get($this->_instanceName) - : $this->_objectManager->create($this->_instanceName); - } - return $this->_subject; - } - - /** - * {@inheritdoc} - */ - public function getUseSession() - { - return $this->_getSubject()->getUseSession(); - } - - /** - * {@inheritdoc} - */ - public function getBaseUrl($params = []) - { - return $this->_getSubject()->getBaseUrl($params); - } - - /** - * {@inheritdoc} - */ - public function getCurrentUrl() - { - return $this->_getSubject()->getCurrentUrl(); - } - - /** - * {@inheritdoc} - */ - public function getRouteUrl($routePath = null, $routeParams = null) - { - return $this->_getSubject()->getRouteUrl($routePath, $routeParams); - } - - /** - * {@inheritdoc} - */ - public function addSessionParam() - { - return $this->_getSubject()->addSessionParam(); - } - - /** - * {@inheritdoc} - */ - public function addQueryParams(array $data) - { - return $this->_getSubject()->addQueryParams($data); - } - - /** - * {@inheritdoc} - */ - public function setQueryParam($key, $data) - { - return $this->_getSubject()->setQueryParam($key, $data); - } - - /** - * {@inheritdoc} - */ - public function getUrl($routePath = null, $routeParams = null) - { - return $this->_getSubject()->getUrl($routePath, $routeParams); - } - - /** - * {@inheritdoc} - */ - public function escape($value) - { - return $this->_getSubject()->escape($value); - } - - /** - * {@inheritdoc} - */ - public function getDirectUrl($url, $params = []) - { - return $this->_getSubject()->getDirectUrl($url, $params); - } - - /** - * {@inheritdoc} - */ - public function sessionUrlVar($html) - { - return $this->_getSubject()->sessionUrlVar($html); - } - - /** - * {@inheritdoc} - */ - public function isOwnOriginUrl() - { - return $this->_getSubject()->isOwnOriginUrl(); - } - - /** - * {@inheritdoc} - */ - public function getRedirectUrl($url) - { - return $this->_getSubject()->getRedirectUrl($url); - } - - /** - * {@inheritdoc} - */ - public function setScope($params) - { - return $this->_getSubject()->setScope($params); - } -}