Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Koopzington committed Nov 16, 2016
1 parent 8f7b8f7 commit 138cd03
Show file tree
Hide file tree
Showing 39 changed files with 222 additions and 51 deletions.
1 change: 1 addition & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<!-- Paths to check -->
<file>src</file>
<file>test</file>
<exclude-pattern>*/_templates/*</exclude-pattern>
</ruleset>
2 changes: 2 additions & 0 deletions src/Helper/Doctype.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ public function __toString()
*/
protected static function registerDefaultDoctypes()
{
// @codingStandardsIgnoreStart
static::$registeredDoctypes = new ArrayObject([
'doctypes' => [
self::XHTML11 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
Expand All @@ -147,6 +148,7 @@ protected static function registerDefaultDoctypes()
self::HTML5 => '<!DOCTYPE html>',
],
]);
// @codingStandardsIgnoreEnd
}

/**
Expand Down
8 changes: 7 additions & 1 deletion src/Helper/HeadLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Zend\View;
use Zend\View\Exception;

// @codingStandardsIgnoreStart
/**
* Zend_Layout_View_Helper_HeadLink
*
Expand All @@ -28,6 +29,7 @@
* @method HeadLink prependAlternate($href, $type, $title, $extras = array())
* @method HeadLink setAlternate($href, $type, $title, $extras = array())
*/
// @codingStandardsIgnoreEnd
class HeadLink extends Placeholder\Container\AbstractStandalone
{
/**
Expand Down Expand Up @@ -143,7 +145,11 @@ public function __invoke(array $attributes = null, $placement = Placeholder\Cont
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<type>Stylesheet|Alternate|Prev|Next)$/', $method, $matches)) {
if (preg_match(
'/^(?P<action>set|(ap|pre)pend|offsetSet)(?P<type>Stylesheet|Alternate|Prev|Next)$/',
$method,
$matches
)) {
$argc = count($args);
$action = $matches['action'];
$type = $matches['type'];
Expand Down
6 changes: 5 additions & 1 deletion src/Helper/HeadMeta.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ public function __invoke(
*/
public function __call($method, $args)
{
if (preg_match('/^(?P<action>set|(pre|ap)pend|offsetSet)(?P<type>Name|HttpEquiv|Property|Itemprop)$/', $method, $matches)) {
if (preg_match(
'/^(?P<action>set|(pre|ap)pend|offsetSet)(?P<type>Name|HttpEquiv|Property|Itemprop)$/',
$method,
$matches
)) {
$action = $matches['action'];
$type = $this->normalizeType($matches['type']);
$argc = count($args);
Expand Down
2 changes: 1 addition & 1 deletion src/HelperPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class HelperPluginManager extends AbstractPluginManager
Helper\BasePath::class => InvokableFactory::class,
Helper\Cycle::class => InvokableFactory::class,
Helper\DeclareVars::class => InvokableFactory::class,
Helper\Doctype::class => InvokableFactory::class, // overridden by a factory in ViewHelperManagerFactory
Helper\Doctype::class => InvokableFactory::class, // overridden in ViewHelperManagerFactory
Helper\EscapeHtml::class => InvokableFactory::class,
Helper\EscapeHtmlAttr::class => InvokableFactory::class,
Helper\EscapeJs::class => InvokableFactory::class,
Expand Down
2 changes: 2 additions & 0 deletions src/Renderer/ConsoleRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
*/
class ConsoleRenderer implements RendererInterface, TreeRendererInterface
{
// @codingStandardsIgnoreStart
/**
* @var FilterChain
*/
protected $__filterChain;
// @codingStandardsIgnoreEnd

/**
* Constructor.
Expand Down
2 changes: 2 additions & 0 deletions src/Renderer/PhpRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Zend\View\Resolver\TemplatePathStack;
use Zend\View\Variables;

// @codingStandardsIgnoreStart
/**
* Class for Zend\View\Strategy\PhpRendererStrategy to help enforce private constructs.
*
Expand Down Expand Up @@ -131,6 +132,7 @@ class PhpRenderer implements Renderer, TreeRendererInterface
* @var array Temporary variable stack; used when variables passed to render()
*/
private $__varsCache = [];
// @codingStandardsIgnoreEnd

/**
* Constructor.
Expand Down
14 changes: 14 additions & 0 deletions src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ class Stream
* @param $opened_path
* @return bool
*/
// @codingStandardsIgnoreStart
public function stream_open($path, $mode, $options, &$opened_path)
{
// @codingStandardsIgnoreEnd
// get the view script source
$path = str_replace('zend.view://', '', $path);
$this->data = file_get_contents($path);
Expand Down Expand Up @@ -91,8 +93,10 @@ public function stream_open($path, $mode, $options, &$opened_path)
*
* @return array
*/
// @codingStandardsIgnoreStart
public function url_stat()
{
// @codingStandardsIgnoreEnd
return $this->stat;
}

Expand All @@ -102,8 +106,10 @@ public function url_stat()
* @param int $count
* @return string
*/
// @codingStandardsIgnoreStart
public function stream_read($count)
{
// @codingStandardsIgnoreEnd
$ret = substr($this->data, $this->pos, $count);
$this->pos += strlen($ret);
return $ret;
Expand All @@ -114,8 +120,10 @@ public function stream_read($count)
*
* @return int
*/
// @codingStandardsIgnoreStart
public function stream_tell()
{
// @codingStandardsIgnoreEnd
return $this->pos;
}

Expand All @@ -124,8 +132,10 @@ public function stream_tell()
*
* @return bool
*/
// @codingStandardsIgnoreStart
public function stream_eof()
{
// @codingStandardsIgnoreEnd
return $this->pos >= strlen($this->data);
}

Expand All @@ -134,8 +144,10 @@ public function stream_eof()
*
* @return array
*/
// @codingStandardsIgnoreStart
public function stream_stat()
{
// @codingStandardsIgnoreEnd
return $this->stat;
}

Expand All @@ -146,8 +158,10 @@ public function stream_stat()
* @param $whence
* @return bool
*/
// @codingStandardsIgnoreStart
public function stream_seek($offset, $whence)
{
// @codingStandardsIgnoreEnd
switch ($whence) {
case SEEK_SET:
if ($offset < strlen($this->data) && $offset >= 0) {
Expand Down
3 changes: 2 additions & 1 deletion test/Helper/DeclareVarsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ public function tearDown()
{
unset($this->view);
}

// @codingStandardsIgnoreStart
protected function _declareVars()
{
// @codingStandardsIgnoreEnd
$this->view->plugin('declareVars')->__invoke(
'varName1',
'varName2',
Expand Down
12 changes: 12 additions & 0 deletions test/Helper/DoctypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ public function testIsXhtmlReturnsTrueForXhtmlDoctypes()
$this->assertTrue($doctype->isXhtml());
}

// @codingStandardsIgnoreStart
$doctype = $this->helper->__invoke('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://framework.zend.com/foo/DTD/xhtml1-custom.dtd">');
// @codingStandardsIgnoreEnd
$this->assertEquals('CUSTOM_XHTML', $doctype->getDoctype());
$this->assertTrue($doctype->isXhtml());
}
Expand All @@ -100,7 +102,9 @@ public function testIsXhtmlReturnsFalseForNonXhtmlDoctypes()
$this->assertFalse($doctype->isXhtml());
}

// @codingStandardsIgnoreStart
$doctype = $this->helper->__invoke('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 10.0 Strict//EN" "http://framework.zend.com/foo/DTD/html10-custom.dtd">');
// @codingStandardsIgnoreEnd
$this->assertEquals('CUSTOM', $doctype->getDoctype());
$this->assertFalse($doctype->isXhtml());
}
Expand Down Expand Up @@ -156,8 +160,10 @@ public function testIsRdfa()
$this->assertFalse($this->helper->__invoke($type)->isRdfa());
}

// @codingStandardsIgnoreStart
// custom doctype
$doctype = $this->helper->__invoke('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 10.0 Strict//EN" "http://framework.zend.com/foo/DTD/html10-custom.dtd">');
// @codingStandardsIgnoreEnd
$this->assertFalse($doctype->isRdfa());
}

Expand All @@ -170,14 +176,18 @@ public function testCanRegisterCustomHtml5Doctype()

public function testCanRegisterCustomXhtmlDoctype()
{
// @codingStandardsIgnoreStart
$doctype = $this->helper->__invoke('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://framework.zend.com/foo/DTD/xhtml1-custom.dtd">');
// @codingStandardsIgnoreEnd
$this->assertEquals('CUSTOM_XHTML', $doctype->getDoctype());
$this->assertTrue($doctype->isXhtml());
}

public function testCanRegisterCustomHtmlDoctype()
{
// @codingStandardsIgnoreStart
$doctype = $this->helper->__invoke('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 10.0 Strict//EN" "http://framework.zend.com/foo/DTD/html10-custom.dtd">');
// @codingStandardsIgnoreEnd
$this->assertEquals('CUSTOM', $doctype->getDoctype());
$this->assertFalse($doctype->isXhtml());
}
Expand All @@ -195,6 +205,8 @@ public function testStringificationReturnsDoctypeString()
{
$doctype = $this->helper->__invoke(Helper\Doctype::XHTML1_STRICT);
$string = $doctype->__toString();
// @codingStandardsIgnoreStart
$this->assertEquals('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', $string);
// @codingStandardsIgnoreEnd
}
}
4 changes: 4 additions & 0 deletions test/Helper/FlashMessengerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ public function testCanDisplayListOfMessagesCustomisedByConfigSeparator()
$helperPluginManager = $services->get('ViewHelperManager');
$helper = $helperPluginManager->get('flashmessenger');

// @codingStandardsIgnoreStart
$displayInfoAssertion = '<div><ul><li class="foo-baz foo-bar">foo</li><li class="foo-baz foo-bar">bar</li></ul></div>';
// @codingStandardsIgnoreEnd
$displayInfo = $helper->render('default', ['foo-baz', 'foo-bar']);
$this->assertEquals($displayInfoAssertion, $displayInfo);
}
Expand All @@ -368,7 +370,9 @@ public function testCanDisplayListOfCurrentMessagesCustomisedByConfigSeparator()
$helperPluginManager = $services->get('ViewHelperManager');
$helper = $helperPluginManager->get('flashmessenger');

// @codingStandardsIgnoreStart
$displayInfoAssertion = '<div><ul><li class="foo-baz foo-bar">foo</li><li class="foo-baz foo-bar">bar</li></ul></div>';
// @codingStandardsIgnoreEnd
$displayInfo = $helper->renderCurrent('default', ['foo-baz', 'foo-bar']);
$this->assertEquals($displayInfoAssertion, $displayInfo);
}
Expand Down
8 changes: 7 additions & 1 deletion test/Helper/GravatarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,11 @@ public function testImgAttribs()
{
$this->assertRegExp(
'/class="gravatar" title="Gravatar"/',
$this->helper->__invoke("[email protected]", [], ['class' => 'gravatar', 'title' => 'Gravatar'])->__toString()
$this->helper->__invoke(
"[email protected]",
[],
['class' => 'gravatar', 'title' => 'Gravatar']
)->__toString()
);
}

Expand All @@ -179,8 +183,10 @@ public function testImgAttribs()
public function testGravatarOptions()
{
$this->assertRegExp(
// @codingStandardsIgnoreStart
'#src="http\&\#x3A\;\&\#x2F\;\&\#x2F\;www.gravatar.com\&\#x2F\;avatar\&\#x2F\;[a-z0-9]{32}&\#x3F;s&\#x3D;125&amp;d&\#x3D;wavatar&amp;r&\#x3D;pg"#',
$this->helper->__invoke("[email protected]", ['rating' => 'pg', 'imgSize' => 125, 'defaultImg' => 'wavatar', 'secure' => false])->__toString()
// @codingStandardsIgnoreEnd
);
}

Expand Down
6 changes: 5 additions & 1 deletion test/Helper/HeadLinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,11 @@ public function testSetAlternateWithExtras()

public function testAppendStylesheetWithExtras()
{
$this->helper->appendStylesheet(['href' => '/bar/baz', 'conditionalStylesheet' => false, 'extras' => ['id' => 'my_link_tag']]);
$this->helper->appendStylesheet([
'href' => '/bar/baz',
'conditionalStylesheet' => false,
'extras' => ['id' => 'my_link_tag']
]);
$test = $this->helper->toString();
$this->assertContains('id="my_link_tag"', $test);
}
Expand Down
23 changes: 20 additions & 3 deletions test/Helper/HeadMetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,20 @@ public function testAppendPrependAndSetThrowExceptionsWhenNonMetaValueProvided()
}
}

// @codingStandardsIgnoreStart
protected function _inflectAction($type)
{
// @codingStandardsIgnoreEnd
$type = str_replace('-', ' ', $type);
$type = ucwords($type);
$type = str_replace(' ', '', $type);
return $type;
}

// @codingStandardsIgnoreStart
protected function _testOverloadAppend($type)
{
// @codingStandardsIgnoreEnd
$action = 'append' . $this->_inflectAction($type);
$string = 'foo';
for ($i = 0; $i < 3; ++$i) {
Expand All @@ -122,8 +126,10 @@ protected function _testOverloadAppend($type)
}
}

// @codingStandardsIgnoreStart
protected function _testOverloadPrepend($type)
{
// @codingStandardsIgnoreEnd
$action = 'prepend' . $this->_inflectAction($type);
$string = 'foo';
for ($i = 0; $i < 3; ++$i) {
Expand All @@ -142,8 +148,10 @@ protected function _testOverloadPrepend($type)
}
}

// @codingStandardsIgnoreStart
protected function _testOverloadSet($type)
{
// @codingStandardsIgnoreEnd
$setAction = 'set' . $this->_inflectAction($type);
$appendAction = 'append' . $this->_inflectAction($type);
$string = 'foo';
Expand Down Expand Up @@ -312,7 +320,8 @@ public function testSetNameDoesntClobber()
$view->plugin('headMeta')->setName('keywords', 'bat');

$this->assertEquals(
'<meta http-equiv="pragma" content="bar" />' . PHP_EOL . '<meta http-equiv="Cache-control" content="baz" />' . PHP_EOL . '<meta name="keywords" content="bat" />',
'<meta http-equiv="pragma" content="bar" />' . PHP_EOL . '<meta http-equiv="Cache-control" content="baz" />'
. PHP_EOL . '<meta name="keywords" content="bat" />',
$view->plugin('headMeta')->toString()
);
}
Expand All @@ -330,7 +339,9 @@ public function testSetNameDoesntClobberPart2()
$view->plugin('headMeta')->setName('keywords', 'bar');

$this->assertEquals(
'<meta name="description" content="foo" />' . PHP_EOL . '<meta http-equiv="pragma" content="baz" />' . PHP_EOL . '<meta http-equiv="Cache-control" content="baz" />' . PHP_EOL . '<meta name="keywords" content="bar" />',
'<meta name="description" content="foo" />' . PHP_EOL . '<meta http-equiv="pragma" content="baz" />'
. PHP_EOL . '<meta http-equiv="Cache-control" content="baz" />' . PHP_EOL
. '<meta name="keywords" content="bar" />',
$view->plugin('headMeta')->toString()
);
}
Expand All @@ -343,7 +354,13 @@ public function testPlacesMetaTagsInProperOrder()
{
$view = new View();
$view->plugin('headMeta')->setName('keywords', 'foo');
$view->plugin('headMeta')->__invoke('some content', 'bar', 'name', [], \Zend\View\Helper\Placeholder\Container\AbstractContainer::PREPEND);
$view->plugin('headMeta')->__invoke(
'some content',
'bar',
'name',
[],
\Zend\View\Helper\Placeholder\Container\AbstractContainer::PREPEND
);

$this->assertEquals(
'<meta name="bar" content="some content" />' . PHP_EOL . '<meta name="keywords" content="foo" />',
Expand Down
Loading

0 comments on commit 138cd03

Please sign in to comment.