Skip to content

Commit

Permalink
minor #14123 CS: Use "self" keyword instead of class name if possible…
Browse files Browse the repository at this point in the history
… (gharlan)

This PR was merged into the 2.3 branch.

Discussion
----------

CS: Use "self" keyword instead of class name if possible

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Fixes provided by new fixer: PHP-CS-Fixer/PHP-CS-Fixer#1116

If this pr is merged I would change the level of the fixer to `symfony`.

Commits
-------

e72128f CS: Use "self" keyword instead of class name if possible
  • Loading branch information
nicolas-grekas committed Apr 5, 2015
2 parents f690cef + e72128f commit 89f6e1e
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
Expand Up @@ -224,7 +224,7 @@ public function end()
public static function buildExpressions(array $expressions)
{
foreach ($expressions as $k => $expr) {
if ($expr instanceof ExprBuilder) {
if ($expr instanceof self) {
$if = $expr->ifPart;
$then = $expr->thenPart;
$expressions[$k] = function ($v) use ($if, $then) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Config/Loader/FileLoader.php
Expand Up @@ -82,7 +82,7 @@ public function import($resource, $type = null, $ignoreErrors = false, $sourceRe
try {
$loader = $this->resolve($resource, $type);

if ($loader instanceof FileLoader && null !== $this->currentDir) {
if ($loader instanceof self && null !== $this->currentDir) {
// we fallback to the current locator to keep BC
// as some some loaders do not call the parent __construct()
// @deprecated should be removed in 3.0
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/File/File.php
Expand Up @@ -139,7 +139,7 @@ protected function getTargetFile($directory, $name = null)

$target = rtrim($directory, '/\\').DIRECTORY_SEPARATOR.(null === $name ? $this->getBasename() : $this->getName($name));

return new File($target, false);
return new self($target, false);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Intl/Intl.php
Expand Up @@ -117,7 +117,7 @@ public static function getCurrencyBundle()
{
if (null === self::$currencyBundle) {
self::$currencyBundle = new CurrencyBundle(
self::getDataDirectory().'/'.Intl::CURRENCY_DIR,
self::getDataDirectory().'/'.self::CURRENCY_DIR,
self::getEntryReader(),
self::getLocaleBundle()
);
Expand All @@ -135,11 +135,11 @@ public static function getLanguageBundle()
{
if (null === self::$languageBundle) {
self::$languageBundle = new LanguageBundle(
self::getDataDirectory().'/'.Intl::LANGUAGE_DIR,
self::getDataDirectory().'/'.self::LANGUAGE_DIR,
self::getEntryReader(),
self::getLocaleBundle(),
new ScriptDataProvider(
self::getDataDirectory().'/'.Intl::SCRIPT_DIR,
self::getDataDirectory().'/'.self::SCRIPT_DIR,
self::getEntryReader()
)
);
Expand All @@ -157,7 +157,7 @@ public static function getLocaleBundle()
{
if (null === self::$localeBundle) {
self::$localeBundle = new LocaleBundle(
self::getDataDirectory().'/'.Intl::LOCALE_DIR,
self::getDataDirectory().'/'.self::LOCALE_DIR,
self::getEntryReader()
);
}
Expand All @@ -174,7 +174,7 @@ public static function getRegionBundle()
{
if (null === self::$regionBundle) {
self::$regionBundle = new RegionBundle(
self::getDataDirectory().'/'.Intl::REGION_DIR,
self::getDataDirectory().'/'.self::REGION_DIR,
self::getEntryReader(),
self::getLocaleBundle()
);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/PropertyAccess/PropertyPath.php
Expand Up @@ -76,7 +76,7 @@ class PropertyPath implements \IteratorAggregate, PropertyPathInterface
public function __construct($propertyPath)
{
// Can be used as copy constructor
if ($propertyPath instanceof PropertyPath) {
if ($propertyPath instanceof self) {
/* @var PropertyPath $propertyPath */
$this->elements = $propertyPath->elements;
$this->singulars = $propertyPath->singulars;
Expand Down
Expand Up @@ -50,7 +50,7 @@ public function all()
*/
public function add($child)
{
if ($child instanceof DumperCollection) {
if ($child instanceof self) {
$child->setParent($this);
}
$this->children[] = $child;
Expand All @@ -64,7 +64,7 @@ public function add($child)
public function setAll(array $children)
{
foreach ($children as $child) {
if ($child instanceof DumperCollection) {
if ($child instanceof self) {
$child->setParent($this);
}
}
Expand Down
Expand Up @@ -66,7 +66,7 @@ public function addPrefixRoute(DumperRoute $route)

// Prefix starts with route's prefix
if ('' === $collection->prefix || 0 === strpos($prefix, $collection->prefix)) {
$child = new DumperPrefixCollection();
$child = new self();
$child->setPrefix(substr($prefix, 0, strlen($collection->prefix) + 1));
$collection->add($child);

Expand Down
Expand Up @@ -52,7 +52,7 @@ public function getRole()
*/
public function equals(SecurityIdentityInterface $sid)
{
if (!$sid instanceof RoleSecurityIdentity) {
if (!$sid instanceof self) {
return false;
}

Expand Down
Expand Up @@ -102,7 +102,7 @@ public function getClass()
*/
public function equals(SecurityIdentityInterface $sid)
{
if (!$sid instanceof UserSecurityIdentity) {
if (!$sid instanceof self) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraint.php
Expand Up @@ -154,7 +154,7 @@ public function __set($option, $value)
*/
public function addImplicitGroupName($group)
{
if (in_array(Constraint::DEFAULT_GROUP, $this->groups) && !in_array($group, $this->groups)) {
if (in_array(self::DEFAULT_GROUP, $this->groups) && !in_array($group, $this->groups)) {
$this->groups[] = $group;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Yaml/Parser.php
Expand Up @@ -91,7 +91,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
// array
if (!isset($values['value']) || '' == trim($values['value'], ' ') || 0 === strpos(ltrim($values['value'], ' '), '#')) {
$c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c);
$parser = new self($c);
$parser->refs = &$this->refs;
$data[] = $parser->parse($this->getNextEmbedBlock(null, true), $exceptionOnInvalidType, $objectSupport);
} else {
Expand All @@ -100,7 +100,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
) {
// this is a compact notation element, add to next block and parse
$c = $this->getRealCurrentLineNb();
$parser = new Parser($c);
$parser = new self($c);
$parser->refs = &$this->refs;

$block = $values['value'];
Expand Down Expand Up @@ -143,7 +143,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
$value = $this->getNextEmbedBlock();
}
$c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c);
$parser = new self($c);
$parser->refs = &$this->refs;
$parsed = $parser->parse($value, $exceptionOnInvalidType, $objectSupport);

Expand Down Expand Up @@ -180,7 +180,7 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
$data[$key] = null;
} else {
$c = $this->getRealCurrentLineNb() + 1;
$parser = new Parser($c);
$parser = new self($c);
$parser->refs = &$this->refs;
$data[$key] = $parser->parse($this->getNextEmbedBlock(), $exceptionOnInvalidType, $objectSupport);
}
Expand Down

0 comments on commit 89f6e1e

Please sign in to comment.