Code enhancement and cleanup
This commit is contained in:
parent
2511f2a191
commit
325da3c0d8
@ -336,7 +336,7 @@ abstract class AbstractDoctrineExtension extends Extension
|
||||
$memcacheClass = !empty($cacheDriver['class']) ? $cacheDriver['class'] : '%'.$this->getObjectManagerElementName('cache.memcache.class').'%';
|
||||
$memcacheInstanceClass = !empty($cacheDriver['instance_class']) ? $cacheDriver['instance_class'] : '%'.$this->getObjectManagerElementName('cache.memcache_instance.class').'%';
|
||||
$memcacheHost = !empty($cacheDriver['host']) ? $cacheDriver['host'] : '%'.$this->getObjectManagerElementName('cache.memcache_host').'%';
|
||||
$memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%';
|
||||
$memcachePort = !empty($cacheDriver['port']) || (isset($cacheDriver['port']) && $cacheDriver['port'] === 0) ? $cacheDriver['port'] : '%'.$this->getObjectManagerElementName('cache.memcache_port').'%';
|
||||
$cacheDef = new Definition($memcacheClass);
|
||||
$memcacheInstance = new Definition($memcacheInstanceClass);
|
||||
$memcacheInstance->addMethodCall('connect', array(
|
||||
|
@ -140,7 +140,6 @@ EOF
|
||||
return;
|
||||
}
|
||||
if ($type === 'functions' || $type === 'filters') {
|
||||
$args = array();
|
||||
$cb = $entity->getCallable();
|
||||
if (is_null($cb)) {
|
||||
return;
|
||||
|
@ -85,7 +85,6 @@ EOF
|
||||
throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
|
||||
}
|
||||
|
||||
$files = array();
|
||||
if (is_file($filename)) {
|
||||
$files = array($filename);
|
||||
} elseif (is_dir($filename)) {
|
||||
|
@ -52,6 +52,8 @@ class ActionsExtension extends \Twig_Extension
|
||||
* @param string $uri A URI
|
||||
* @param array $options An array of options
|
||||
*
|
||||
* @return string|null The Response content or null when the Response is streamed
|
||||
*
|
||||
* @see FragmentHandler::render()
|
||||
*/
|
||||
public function renderUri($uri, array $options = array())
|
||||
|
@ -108,8 +108,6 @@ class WebDebugToolbarListener implements EventSubscriberInterface
|
||||
|
||||
/**
|
||||
* Injects the web debug toolbar into the given Response.
|
||||
*
|
||||
* @param Response $response A Response instance
|
||||
*/
|
||||
protected function injectToolbar(Response $response, Request $request)
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ class CookieTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException UnexpectedValueException
|
||||
* @expectedException \UnexpectedValueException
|
||||
* @expectedExceptionMessage The cookie expiration time "string" is not valid.
|
||||
*/
|
||||
public function testConstructException()
|
||||
|
@ -569,6 +569,8 @@ class Command
|
||||
* Add a command usage example.
|
||||
*
|
||||
* @param string $usage The usage, it'll be prefixed with the command name
|
||||
*
|
||||
* @return Command The current instance
|
||||
*/
|
||||
public function addUsage($usage)
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ class MarkdownDescriptor extends Descriptor
|
||||
.'* Description: '.($command->getDescription() ?: '<none>')."\n"
|
||||
.'* Usage:'."\n\n"
|
||||
.array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
|
||||
return $carry .= ' * `'.$usage.'`'."\n";
|
||||
return $carry.' * `'.$usage.'`'."\n";
|
||||
})
|
||||
);
|
||||
|
||||
|
@ -371,8 +371,6 @@ class ProgressHelper extends Helper
|
||||
}
|
||||
|
||||
if (isset($this->formatVars['bar'])) {
|
||||
$completeBars = 0;
|
||||
|
||||
if ($this->max > 0) {
|
||||
$completeBars = floor($percent * $this->barWidth);
|
||||
} else {
|
||||
|
@ -200,6 +200,7 @@ class QuestionHelper extends Helper
|
||||
*
|
||||
* @param OutputInterface $output
|
||||
* @param Question $question
|
||||
* @param resource $inputStream
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -316,7 +317,8 @@ class QuestionHelper extends Helper
|
||||
/**
|
||||
* Gets a hidden response from user.
|
||||
*
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param OutputInterface $output An Output instance
|
||||
* @param resource $inputStream The handler resource
|
||||
*
|
||||
* @return string The answer
|
||||
*
|
||||
|
@ -107,13 +107,6 @@ class HelperSetTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a generic mock for the helper interface. Optionally check for a call to setHelperSet with a specific
|
||||
* helperset instance.
|
||||
*
|
||||
* @param string $name
|
||||
* @param HelperSet $helperset allows a mock to verify a particular helperset set is being added to the Helper
|
||||
*/
|
||||
private function getGenericMockHelper($name, HelperSet $helperset = null)
|
||||
{
|
||||
$mock_helper = $this->getMock('\Symfony\Component\Console\Helper\HelperInterface');
|
||||
|
@ -68,9 +68,6 @@ class Translator implements TranslatorInterface
|
||||
*/
|
||||
private $attributeMatchingTranslators = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct(ParserInterface $parser = null)
|
||||
{
|
||||
$this->mainParser = $parser ?: new Parser();
|
||||
|
@ -349,10 +349,12 @@ class ErrorHandler
|
||||
/**
|
||||
* Handles errors by filtering then logging them according to the configured bit fields.
|
||||
*
|
||||
* @param int $type One of the E_* constants
|
||||
* @param int $type One of the E_* constants
|
||||
* @param string $message
|
||||
* @param string $file
|
||||
* @param int $line
|
||||
* @param array $context
|
||||
* @param array $backtrace
|
||||
*
|
||||
* @return bool Returns false when no handling happens so that the PHP engine can handle the error itself
|
||||
*
|
||||
|
@ -39,7 +39,7 @@ class ServiceReferenceGraphEdge
|
||||
/**
|
||||
* Returns the value of the edge.
|
||||
*
|
||||
* @return ServiceReferenceGraphNode
|
||||
* @return string
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
|
@ -169,7 +169,7 @@ class PhpDumperTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider provideInvalidFactories
|
||||
* @expectedException Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
|
||||
* @expectedExceptionMessage Cannot dump definition
|
||||
*/
|
||||
public function testInvalidFactories($factory)
|
||||
|
@ -60,6 +60,10 @@ class TokenStream
|
||||
|
||||
/**
|
||||
* Tests a token.
|
||||
*
|
||||
* @param array|int $type The type to test
|
||||
* @param string|null $value The token value
|
||||
* @param string|null $message The syntax error message
|
||||
*/
|
||||
public function expect($type, $value = null, $message = null)
|
||||
{
|
||||
|
@ -285,6 +285,8 @@ class Filesystem
|
||||
*
|
||||
* @param string $filename Path to the file
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws IOException When windows path is longer than 258 characters
|
||||
*/
|
||||
private function isReadable($filename)
|
||||
|
@ -183,12 +183,13 @@ class ArrayChoiceList implements ChoiceListInterface
|
||||
/**
|
||||
* Flattens an array into the given output variables.
|
||||
*
|
||||
* @param array $choices The array to flatten
|
||||
* @param callable $value The callable for generating choice values
|
||||
* @param array $choicesByValues The flattened choices indexed by the
|
||||
* corresponding values
|
||||
* @param array $keysByValues The original keys indexed by the
|
||||
* corresponding values
|
||||
* @param array $choices The array to flatten
|
||||
* @param callable $value The callable for generating choice values
|
||||
* @param array $choicesByValues The flattened choices indexed by the
|
||||
* corresponding values
|
||||
* @param array $keysByValues The original keys indexed by the
|
||||
* corresponding values
|
||||
* @param array $structuredValues The values indexed by the original keys
|
||||
*
|
||||
* @internal Must not be used by user-land code
|
||||
*/
|
||||
|
@ -153,12 +153,13 @@ class ArrayKeyChoiceList extends ArrayChoiceList
|
||||
/**
|
||||
* Flattens and flips an array into the given output variable.
|
||||
*
|
||||
* @param array $choices The array to flatten
|
||||
* @param callable $value The callable for generating choice values
|
||||
* @param array $choicesByValues The flattened choices indexed by the
|
||||
* corresponding values
|
||||
* @param array $keysByValues The original keys indexed by the
|
||||
* corresponding values
|
||||
* @param array $choices The array to flatten
|
||||
* @param callable $value The callable for generating choice values
|
||||
* @param array $choicesByValues The flattened choices indexed by the
|
||||
* corresponding values
|
||||
* @param array $keysByValues The original keys indexed by the
|
||||
* corresponding values
|
||||
* @param array $structuredValues The values indexed by the original keys
|
||||
*
|
||||
* @internal Must not be used by user-land code
|
||||
*/
|
||||
|
@ -178,8 +178,6 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
|
||||
/**
|
||||
* Checks if the pattern contains only a date.
|
||||
*
|
||||
* @param string $pattern The input pattern
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function isPatternDateOnly()
|
||||
|
@ -23,14 +23,8 @@ use Symfony\Component\Validator\ConstraintViolationInterface;
|
||||
*/
|
||||
class FormDataExtractor implements FormDataExtractorInterface
|
||||
{
|
||||
/**
|
||||
* @var ValueExporter
|
||||
*/
|
||||
private $valueExporter;
|
||||
|
||||
/**
|
||||
* Constructs a new data extractor.
|
||||
*/
|
||||
public function __construct(ValueExporter $valueExporter = null)
|
||||
{
|
||||
$this->valueExporter = $valueExporter ?: new ValueExporter();
|
||||
|
@ -2040,7 +2040,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
|
||||
'An empty string empty_value is used if placeholder is also an empty string when required [maintains BC]' => array(false, false, true, '', '', ''),
|
||||
'A non-empty string empty_value is used if placeholder is an empty string when required [maintains BC]' => array(false, false, true, '', 'bar', 'bar'),
|
||||
'A non-empty string placeholder takes precedence over an empty_value set to false when required' => array(false, false, true, 'foo', false, 'foo'),
|
||||
'A non-empty string placeholder takes precedence over a not set empty_value' => array(false, false, true, 'foo', null, 'foo'),
|
||||
'A non-empty string placeholder takes precedence over a not set empty_value when required' => array(false, false, true, 'foo', null, 'foo'),
|
||||
'A non-empty string placeholder takes precedence over an empty string empty_value when required' => array(false, false, true, 'foo', '', 'foo'),
|
||||
'A non-empty string placeholder takes precedence over a non-empty string empty_value when required' => array(false, false, true, 'foo', 'bar', 'foo'),
|
||||
// single expanded, not required
|
||||
|
@ -50,7 +50,18 @@ class JsonResponse extends Response
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Factory method for chainability.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* return JsonResponse::create($data, 200)
|
||||
* ->setSharedMaxAge(300);
|
||||
*
|
||||
* @param mixed $data The json response data
|
||||
* @param int $status The response status code
|
||||
* @param array $headers An array of response headers
|
||||
*
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public static function create($data = null, $status = 200, $headers = array())
|
||||
{
|
||||
|
@ -72,6 +72,8 @@ interface FlashBagInterface extends SessionBagInterface
|
||||
|
||||
/**
|
||||
* Sets all flash messages.
|
||||
*
|
||||
* @param array $messages
|
||||
*/
|
||||
public function setAll(array $messages);
|
||||
|
||||
|
@ -214,6 +214,8 @@ class MongoDbSessionHandler implements \SessionHandlerInterface
|
||||
* Return an instance of a MongoDate or \MongoDB\BSON\UTCDateTime
|
||||
*
|
||||
* @param int $seconds An integer representing UTC seconds since Jan 1 1970. Defaults to now.
|
||||
*
|
||||
* @return \MongoDate|\MongoDB\BSON\UTCDateTime
|
||||
*/
|
||||
private function createDateTime($seconds = null)
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ class LazyLoadingFragmentHandler extends FragmentHandler
|
||||
/**
|
||||
* Adds a service as a fragment renderer.
|
||||
*
|
||||
* @param string $name The service name
|
||||
* @param string $renderer The render service id
|
||||
*/
|
||||
public function addRendererService($name, $renderer)
|
||||
|
@ -78,7 +78,7 @@ class Profiler
|
||||
*
|
||||
* @param Response $response A Response instance
|
||||
*
|
||||
* @return Profile A Profile instance
|
||||
* @return Profile|false A Profile instance
|
||||
*/
|
||||
public function loadProfileFromResponse(Response $response)
|
||||
{
|
||||
@ -149,7 +149,7 @@ class Profiler
|
||||
*
|
||||
* @param string $data A data string as exported by the export() method
|
||||
*
|
||||
* @return Profile A Profile instance
|
||||
* @return Profile|false A Profile instance
|
||||
*/
|
||||
public function import($data)
|
||||
{
|
||||
|
@ -21,7 +21,7 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
||||
class ValidateRequestListenerTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @expectedException Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
|
||||
* @expectedException \Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException
|
||||
*/
|
||||
public function testListenerThrowsWhenMasterRequestHasInconsistentClientIps()
|
||||
{
|
||||
|
@ -272,7 +272,7 @@ class HttpKernelTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
|
||||
*/
|
||||
public function testInconsistentClientIpsOnMasterRequests()
|
||||
{
|
||||
|
@ -98,7 +98,7 @@ class UriSigner
|
||||
$host = isset($url['host']) ? $url['host'] : '';
|
||||
$port = isset($url['port']) ? ':'.$url['port'] : '';
|
||||
$user = isset($url['user']) ? $url['user'] : '';
|
||||
$pass = isset($url['pass']) ? ':'.$url['pass'] : '';
|
||||
$pass = isset($url['pass']) ? ':'.$url['pass'] : '';
|
||||
$pass = ($user || $pass) ? "$pass@" : '';
|
||||
$path = isset($url['path']) ? $url['path'] : '';
|
||||
$query = isset($url['query']) && $url['query'] ? '?'.$url['query'] : '';
|
||||
|
@ -564,7 +564,7 @@ class IntlDateFormatter
|
||||
try {
|
||||
$this->dateTimeZone = new \DateTimeZone($timeZoneId);
|
||||
if ('GMT' !== $timeZoneId && $this->dateTimeZone->getName() !== $timeZoneId) {
|
||||
$timeZoneId = $timeZone = $this->getTimeZoneId();
|
||||
$timeZone = $this->getTimeZoneId();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
if (PHP_VERSION_ID >= 50500 || (extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
|
||||
|
@ -42,6 +42,7 @@ class LanguageBundle extends LanguageDataProvider implements LanguageBundleInter
|
||||
* @param string $path
|
||||
* @param BundleEntryReaderInterface $reader
|
||||
* @param LocaleDataProvider $localeProvider
|
||||
* @param ScriptDataProvider $scriptProvider
|
||||
*/
|
||||
public function __construct($path, BundleEntryReaderInterface $reader, LocaleDataProvider $localeProvider, ScriptDataProvider $scriptProvider)
|
||||
{
|
||||
|
@ -943,7 +943,7 @@ class ProcessTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @dataProvider provideMethodsThatNeedATerminatedProcess
|
||||
* @expectedException Symfony\Component\Process\Exception\LogicException
|
||||
* @expectedException \Symfony\Component\Process\Exception\LogicException
|
||||
* @expectedExceptionMessage Process must be terminated before calling
|
||||
*/
|
||||
public function testMethodsThatNeedATerminatedProcess($method)
|
||||
|
@ -101,7 +101,7 @@ class RememberMeListenerTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Security\Core\Exception\AuthenticationException
|
||||
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
|
||||
* @expectedExceptionMessage Authentication failed.
|
||||
*/
|
||||
public function testOnCoreSecurityIgnoresAuthenticationOptionallyRethrowsExceptionThrownAuthenticationManagerImplementation()
|
||||
|
@ -142,6 +142,7 @@ class PhpEngine implements EngineInterface, \ArrayAccess
|
||||
throw new \InvalidArgumentException('Invalid parameter (view)');
|
||||
}
|
||||
|
||||
// the view variable is exposed to the require file below
|
||||
$view = $this;
|
||||
if ($this->evalTemplate instanceof FileStorage) {
|
||||
extract($this->evalParameters, EXTR_SKIP);
|
||||
|
@ -108,7 +108,7 @@ class DataCollectorTranslator implements TranslatorInterface, TranslatorBagInter
|
||||
* @param string|null $locale
|
||||
* @param string|null $domain
|
||||
* @param string $id
|
||||
* @param string $trans
|
||||
* @param string $translation
|
||||
*/
|
||||
private function collectMessage($locale, $domain, $id, $translation)
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ class MoFileDumper extends FileDumper
|
||||
*/
|
||||
public function format(MessageCatalogue $messages, $domain = 'messages')
|
||||
{
|
||||
$output = $sources = $targets = $sourceOffsets = $targetOffsets = '';
|
||||
$sources = $targets = $sourceOffsets = $targetOffsets = '';
|
||||
$offsets = array();
|
||||
$size = 0;
|
||||
|
||||
|
@ -117,7 +117,7 @@ class MoFileLoader extends ArrayLoader
|
||||
$messages = array();
|
||||
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$singularId = $pluralId = null;
|
||||
$pluralId = null;
|
||||
$translated = null;
|
||||
|
||||
fseek($stream, $offsetId + $i * 8);
|
||||
|
@ -40,6 +40,7 @@ abstract class Abstract2Dot5ApiTest extends AbstractValidatorTest
|
||||
|
||||
/**
|
||||
* @param MetadataFactoryInterface $metadataFactory
|
||||
* @param array $objectInitializers
|
||||
*
|
||||
* @return ValidatorInterface
|
||||
*/
|
||||
|
@ -25,7 +25,6 @@ class VarCloner extends AbstractCloner
|
||||
protected function doClone($var)
|
||||
{
|
||||
$useExt = $this->useExt;
|
||||
$i = 0; // Current iteration position in $queue
|
||||
$len = 1; // Length of $queue
|
||||
$pos = 0; // Number of cloned items past the first level
|
||||
$refsCounter = 0; // Hard references counter
|
||||
|
@ -168,8 +168,9 @@ abstract class AbstractDumper implements DataDumperInterface, DumperInterface
|
||||
/**
|
||||
* Generic line dumper callback.
|
||||
*
|
||||
* @param string $line The line to write
|
||||
* @param int $depth The recursive depth in the dumped structure
|
||||
* @param string $line The line to write
|
||||
* @param int $depth The recursive depth in the dumped structure
|
||||
* @param string $indentPad The line indent pad
|
||||
*/
|
||||
protected function echoLine($line, $depth, $indentPad)
|
||||
{
|
||||
|
Reference in New Issue
Block a user