Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
coding style: fixes in code
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Jul 11, 2017
1 parent fe9a47b commit b12327e
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 39 deletions.
8 changes: 4 additions & 4 deletions src/Reflection/AnnotationsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static function parseComment($comment)

$res = [];
$comment = preg_replace('#^\s*\*\s?#ms', '', trim($comment, '/*'));
$parts = preg_split('#^\s*(?=@'.self::RE_IDENTIFIER.')#m', $comment, 2);
$parts = preg_split('#^\s*(?=@' . self::RE_IDENTIFIER . ')#m', $comment, 2);

$description = trim($parts[0]);
if ($description !== '') {
Expand All @@ -198,9 +198,9 @@ private static function parseComment($comment)
$matches = Strings::matchAll(
isset($parts[1]) ? $parts[1] : '',
'~
(?<=\s|^)@('.self::RE_IDENTIFIER.')[ \t]* ## annotation
(?<=\s|^)@(' . self::RE_IDENTIFIER . ')[ \t]* ## annotation
(
\((?>'.self::RE_STRING.'|[^\'")@]+)+\)| ## (value)
\((?>' . self::RE_STRING . '|[^\'")@]+)+\)| ## (value)
[^(@\r\n][^@\r\n]*|) ## value
~xi'
);
Expand Down Expand Up @@ -267,7 +267,7 @@ private static function parseComment($comment)
*/
public static function parsePhp($code)
{
if (Strings::match($code, '#//nette'.'loader=(\S*)#')) {
if (Strings::match($code, '#//nette' . 'loader=(\S*)#')) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Reflection/Annotations.GlobalFunction.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function boo($a, $b)
*/
test(function () {
$function = new Reflection\GlobalFunction('sort');
Assert::same([], $function->getAnnotations());
Assert::same([], $function->getAnnotations());
Assert::null($function->getDescription());
});

Expand Down
28 changes: 14 additions & 14 deletions tests/Reflection/Annotations.commentParsing.1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,30 @@ test(function () use ($rc) { // Class annotations

$tmp = $rc->getAnnotations();

Assert::same('This is my favorite class.', $tmp['description'][0]);
Assert::same("Johno's addendum", $tmp['title'][0]->value);
Assert::same('This is my favorite class.', $tmp['description'][0]);
Assert::same("Johno's addendum", $tmp['title'][0]->value);
Assert::true($tmp['title'][0]->mode);
Assert::same('One, Two', $tmp['title'][1]->value);
Assert::same('true or false', $tmp['title'][1]->mode);
Assert::same('Three (Four)', $tmp['title'][2]->value);
Assert::same('false', $tmp['title'][2]->mode);
Assert::same('item 1', $tmp['components'][0]);
Assert::same('One, Two', $tmp['title'][1]->value);
Assert::same('true or false', $tmp['title'][1]->mode);
Assert::same('Three (Four)', $tmp['title'][2]->value);
Assert::same('false', $tmp['title'][2]->mode);
Assert::same('item 1', $tmp['components'][0]);
Assert::true($tmp['persistent'][0]);
Assert::false($tmp['persistent'][1]);
Assert::null($tmp['persistent'][2]);
Assert::true($tmp['author'][0]);
Assert::false($tmp['author'][1]);
Assert::null($tmp['author'][2]);
Assert::true($tmp['author'][3]);
Assert::same('John Doe', $tmp['author'][4]);
Assert::same('John Doe', $tmp['author'][4]);
Assert::true($tmp['renderable'][0]);

Assert::same($tmp, $rc->getAnnotations());
Assert::notSame($tmp, Reflection\ClassType::from('ReflectionClass')->getAnnotations());

Assert::true($rc->hasAnnotation('title'), "has('title')');
Assert::same('Three (Four)", $rc->getAnnotation('title')->value);
Assert::same('false', $rc->getAnnotation('title')->mode);
Assert::same('Three (Four)", $rc->getAnnotation('title')->value);
Assert::same('false', $rc->getAnnotation('title')->mode);

$tmp = $rc->getAnnotations('title');
/*
Expand Down Expand Up @@ -104,8 +104,8 @@ test(function () use ($rc) { // Method annotations
$rm = $rc->getMethod('foo');
$tmp = $rm->getAnnotations();

Assert::same('admin', $tmp['RolesAllowed'][0][0]);
Assert::same('web editor', $tmp['RolesAllowed'][0][1]);
Assert::same('admin', $tmp['RolesAllowed'][0][0]);
Assert::same('web editor', $tmp['RolesAllowed'][0][1]);
});


Expand All @@ -114,6 +114,6 @@ test(function () use ($rc) { // Property annotations
$rp = $rc->getProperty('foo');
$tmp = $rp->getAnnotations();

Assert::same('admin', $tmp['secured'][0]->role);
Assert::same(2, $tmp['secured'][0]->level);
Assert::same('admin', $tmp['secured'][0]->role);
Assert::same(2, $tmp['secured'][0]->level);
});
14 changes: 7 additions & 7 deletions tests/Reflection/Annotations.inheritance.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ require __DIR__ . '/../bootstrap.php';
interface IA
{
/** This is IA */
function __construct();
public function __construct();

/**
* This is IA
* @return mixed
* @author John
*/
function foo();
public function foo();
}

class A implements IA
{
/** @inheritdoc */
function __construct()
public function __construct()
{
}

/** @inheritdoc */
function foo()
public function foo()
{
}

Expand All @@ -42,19 +42,19 @@ class A implements IA
}

/** @inheritdoc */
function foobar()
public function foobar()
{
}
}

class B extends A
{
function __construct()
public function __construct()
{
}

/** This is B */
function foo()
public function foo()
{
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Reflection/Annotations.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ test(function () use ($rc) { // Class annotations

$tmp = $rc->getAnnotations();

Assert::same('John Doe', $tmp['author'][0]);
Assert::same('John Doe', $tmp['author'][0]);
Assert::true($tmp['renderable'][0]);

Assert::true($rc->hasAnnotation('author'), "has('author')');
Assert::same('John Doe", $rc->getAnnotation('author'));
Assert::same('John Doe", $rc->getAnnotation('author'));
});


Expand Down
2 changes: 1 addition & 1 deletion tests/Reflection/ClassType.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Bar extends Foo implements Countable
{
public $var;

function count()
public function count()
{
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Reflection/Method.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ require __DIR__ . '/../bootstrap.php';

class A
{
static function foo($a, $b)
public static function foo($a, $b)
{
return $a + $b;
}
}

class B extends A
{
function bar($a, $b)
public function bar($a, $b)
{
return $a - $b;
}
Expand Down
14 changes: 7 additions & 7 deletions tests/Reflection/Parameter.defaultValues.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ function check($name, $args)

class Test
{
function func1($a, $b, $c)
public function func1($a, $b, $c)
{
}
function func2($a, $b = null, $c)
public function func2($a, $b = null, $c)
{
}
function func3($a, $b = null, $c = null)
public function func3($a, $b = null, $c = null)
{
}
function func4($a, array $b = null, array $c)
public function func4($a, array $b = null, array $c)
{
}
function func5($a, $b = null, array $c = null)
public function func5($a, $b = null, array $c = null)
{
}
function func6($a, Exception $b = null, Exception $c)
public function func6($a, Exception $b = null, Exception $c)
{
}
function func7($a, $b = null, Exception $c = null)
public function func7($a, $b = null, Exception $c = null)
{
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Reflection/Parameter.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test(function () {
test(function () {
class Foo
{
function myMethod($test, $test2 = null)
public function myMethod($test, $test2 = null)
{
echo $test;
}
Expand Down

0 comments on commit b12327e

Please sign in to comment.