8000 [2.3] Static Code Analysis for Components by kalessil · Pull Request #17085 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[2.3] Static Code Analysis for Components #17085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Php Inspections (EA Extended): continue 2 -> break, exceptions messag…
…es made consistent
  • Loading branch information
kalessil committed Dec 23, 2015
commit 4bdc26bd9a690ff0c23d5629f10aa3369ff36eb3
2 changes: 1 addition & 1 deletion src/Symfony/Component/ClassLoader/ClassMapGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static function findClasses($path)
}

if ($isClassConstant) {
continue 2;
break;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure about this change? continue relates to the for loop while break only leaves the switch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, continue inside switch behaves differently in PHP than in other languages.

http://php.net/manual/en/control-structures.continue.php

Note: In PHP the switch statement is considered a looping structure for the purposes of continue. continue behaves like break (when no arguments are passed). If a switch is inside a loop, continue 2 will continue with the next iteration of the outer loop.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh god PHP :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fully understand =)

Or take in account finally-blocks introduced in 5.5 - if you get an exception inside (even handled) you can have variety of miss-behaviors of code in different PHP versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But at least I can warn people using my plugin that something might go wrong and they can concentrate on right things instead of long debugging hours.

}

// Find the classname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct($savePath = null)
}

if ($baseDir && !is_dir($baseDir) && !@mkdir($baseDir, 0777, true) && !is_dir($baseDir)) {
throw new \RuntimeException(sprintf('The Session Storage was not able to create a directory: %s', $baseDir));
throw new \RuntimeException(sprintf('Session Storage was not able to create a directory: %s', $baseDir));
}

ini_set('session.save_path', $savePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct($savePath = null, $name = 'MOCKSESSID', MetadataBag
}

if (!is_dir($savePath) && !@mkdir($savePath, 0777, true) && !is_dir($savePath)) {
throw new \RuntimeException(sprintf('The Session Storage was not able to create a directory: %s', $savePath));
throw new \RuntimeException(sprintf('Session Storage was not able to create a directory: %s', $savePath));
}

$this->savePath = $savePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function dump(MessageCatalogue $messages, $options = array())
$path = $options['path'].'/'.$domain.'/';

if (!is_dir($path) && !@mkdir($path) && !is_dir($path)) {
throw new \RuntimeException(sprintf('The File Dumper was not able to create a directory: %s', $path));
throw new \RuntimeException(sprintf('File Dumper was not able to create a directory: %s', $path));
}

// backup
Expand Down
0