Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8850ff7

Browse filesBrowse files
committed
ACP2E-2977: Implement Static test which will check for no usage of object manager in .phtml files
1 parent 06a96f8 commit 8850ff7
Copy full SHA for 8850ff7

File tree

Expand file treeCollapse file tree

5 files changed

+29
-4
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+29
-4
lines changed

‎Magento2/Sniffs/Phtml/PhtmlTemplateObjectManagerSniff.php renamed to ‎Magento2/Sniffs/Templates/ObjectManagerSniff.php

Copy file name to clipboardExpand all lines: Magento2/Sniffs/Templates/ObjectManagerSniff.php
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@
1616
*/
1717
declare(strict_types = 1);
1818

19-
namespace Magento2\Sniffs\Phtml;
19+
namespace Magento2\Sniffs\Templates;
2020

2121
use PHP_CodeSniffer\Files\File;
2222
use PHP_CodeSniffer\Sniffs\Sniff;
2323

2424
/**
25-
* Class PhtmlTemplateObjectManagerSniff
26-
*
2725
* Templates must not instantiate new objects within their code.
2826
* All objects must be passed from the Block object.
2927
*
28+
* @see https://developer.adobe.com/commerce/php/coding-standards/technical-guidelines/#62-presentation-layer 6.2.6
29+
* @link https://developer.adobe.com/commerce/frontend-core/guide/layouts/xml-instructions/#obtain-arguments-examples-in-template
3030
* @link https://developer.adobe.com/commerce/frontend-core/guide/templates/override/#getting-argument-values-from-layout
3131
*/
3232
class PhtmlTemplateObjectManagerSniff implements Sniff
+25Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
/************************************************************************
3+
*
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*
7+
* NOTICE: All information contained herein is, and remains
8+
* the property of Adobe and its suppliers, if any. The intellectual
9+
* and technical concepts contained herein are proprietary to Adobe
10+
* and its suppliers and are protected by all applicable intellectual
11+
* property laws, including trade secret and copyright laws.
12+
* Dissemination of this information or reproduction of this material
13+
* is strictly forbidden unless prior written permission is obtained
14+
* from Adobe.
15+
* **********************************************************************
16+
*/
17+
18+
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
19+
?>
20+
21+
<div class="block test">
22+
</div>
23+
<script type="jquery/ui">
24+
</script>
25+

‎Magento2/ruleset.xml

Copy file name to clipboardExpand all lines: Magento2/ruleset.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@
350350
<severity>8</severity>
351351
<type>warning</type>
352352
</rule>
353-
<rule ref="Magento2.Phtml.PhtmlTemplateObjectManager">
353+
<rule ref="Magento2.Templates.ObjectManager">
354354
<include-pattern>*\.phtml$</include-pattern>
355355
<severity>8</severity>
356356
<type>warning</type>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.