Merge branch 'master' into acl
This commit is contained in:
commit
22fd08531c
@ -9,6 +9,8 @@ timeline closely anyway.
|
|||||||
PR12 to beta1
|
PR12 to beta1
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
* The `File::getWebPath()` and `File::rename()` methods have been removed.
|
||||||
|
|
||||||
* The `session` configuration has been refactored:
|
* The `session` configuration has been refactored:
|
||||||
|
|
||||||
* The `class` option has been removed (use the `session.class` parameter
|
* The `class` option has been removed (use the `session.class` parameter
|
||||||
|
@ -33,7 +33,7 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
|
|||||||
/**
|
/**
|
||||||
* Returns whether Doctrine 2 metadata exists for that class
|
* Returns whether Doctrine 2 metadata exists for that class
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
protected function isMappedClass($class)
|
protected function isMappedClass($class)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,6 @@ class Configuration implements ConfigurationInterface
|
|||||||
->children()
|
->children()
|
||||||
->scalarNode('cache_warmer')->defaultValue(!$this->debug)->end()
|
->scalarNode('cache_warmer')->defaultValue(!$this->debug)->end()
|
||||||
->scalarNode('charset')->end()
|
->scalarNode('charset')->end()
|
||||||
->scalarNode('document_root')->end()
|
|
||||||
->scalarNode('error_handler')->end()
|
->scalarNode('error_handler')->end()
|
||||||
->scalarNode('exception_controller')->defaultValue('Symfony\\Bundle\\FrameworkBundle\\Controller\\ExceptionController::showAction')->end()
|
->scalarNode('exception_controller')->defaultValue('Symfony\\Bundle\\FrameworkBundle\\Controller\\ExceptionController::showAction')->end()
|
||||||
->scalarNode('ide')->defaultNull()->end()
|
->scalarNode('ide')->defaultNull()->end()
|
||||||
|
@ -65,10 +65,6 @@ class FrameworkExtension extends Extension
|
|||||||
$container->setParameter('kernel.charset', $config['charset']);
|
$container->setParameter('kernel.charset', $config['charset']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($config['document_root'])) {
|
|
||||||
$container->setParameter('document_root', $config['document_root']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($config['error_handler'])) {
|
if (isset($config['error_handler'])) {
|
||||||
if (false === $config['error_handler']) {
|
if (false === $config['error_handler']) {
|
||||||
$container->getDefinition('error_handler')->setMethodCalls(array());
|
$container->getDefinition('error_handler')->setMethodCalls(array());
|
||||||
|
@ -56,10 +56,6 @@ class FrameworkBundle extends Bundle
|
|||||||
$this->container->get('error_handler');
|
$this->container->get('error_handler');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->container->hasParameter('document_root')) {
|
|
||||||
File::setDocumentRoot($this->container->getParameter('document_root'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_exists($this->container->getParameter('kernel.cache_dir').'/autoload.php')) {
|
if (file_exists($this->container->getParameter('kernel.cache_dir').'/autoload.php')) {
|
||||||
$classloader = new MapFileClassLoader($this->container->getParameter('kernel.cache_dir').'/autoload.php');
|
$classloader = new MapFileClassLoader($this->container->getParameter('kernel.cache_dir').'/autoload.php');
|
||||||
$classloader->register(true);
|
$classloader->register(true);
|
||||||
|
@ -105,6 +105,6 @@ class GlobalVariables
|
|||||||
*/
|
*/
|
||||||
public function getDebug()
|
public function getDebug()
|
||||||
{
|
{
|
||||||
return (bool) $this->container->getParameter('kernel.debug');
|
return (Boolean) $this->container->getParameter('kernel.debug');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ class Cookie
|
|||||||
* @param string $expires The time the cookie expires
|
* @param string $expires The time the cookie expires
|
||||||
* @param string $path The path on the server in which the cookie will be available on
|
* @param string $path The path on the server in which the cookie will be available on
|
||||||
* @param string $domain The domain that the cookie is available
|
* @param string $domain The domain that the cookie is available
|
||||||
* @param bool $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
|
* @param Boolean $secure Indicates that the cookie should only be transmitted over a secure HTTPS connection from the client
|
||||||
* @param bool $httponly The cookie httponly flag
|
* @param Boolean $httponly The cookie httponly flag
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -126,7 +126,7 @@ class ArrayNode extends BaseNode implements PrototypeNodeInterface
|
|||||||
/**
|
/**
|
||||||
* Checks if the node has a default value.
|
* Checks if the node has a default value.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public function hasDefaultValue()
|
public function hasDefaultValue()
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ class PrototypedArrayNode extends ArrayNode
|
|||||||
/**
|
/**
|
||||||
* Checks if the node has a default value.
|
* Checks if the node has a default value.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public function hasDefaultValue()
|
public function hasDefaultValue()
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ class OutputFormatter implements OutputFormatterInterface
|
|||||||
/**
|
/**
|
||||||
* Initializes console output formatter.
|
* Initializes console output formatter.
|
||||||
*
|
*
|
||||||
* @param boolean $decorated Whether this formatter should actually decorate strings
|
* @param Boolean $decorated Whether this formatter should actually decorate strings
|
||||||
* @param array $styles Array of "name => FormatterStyle" instance
|
* @param array $styles Array of "name => FormatterStyle" instance
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
@ -87,7 +87,7 @@ class OutputFormatter implements OutputFormatterInterface
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
@ -217,7 +217,7 @@ class OutputFormatter implements OutputFormatterInterface
|
|||||||
*
|
*
|
||||||
* @param string $string
|
* @param string $string
|
||||||
*
|
*
|
||||||
* @return Symfony\Component\Console\Format\FormatterStyle|boolean false if string is not format string
|
* @return Symfony\Component\Console\Format\FormatterStyle|Boolean false if string is not format string
|
||||||
*/
|
*/
|
||||||
private function createStyleFromString($string)
|
private function createStyleFromString($string)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ interface OutputFormatterInterface
|
|||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
|
@ -97,7 +97,7 @@ interface InputInterface
|
|||||||
/**
|
/**
|
||||||
* Is this input means interactive?
|
* Is this input means interactive?
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
function isInteractive();
|
function isInteractive();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class Alias
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param string $id Alias identifier
|
* @param string $id Alias identifier
|
||||||
* @param boolean $public If this alias is public
|
* @param Boolean $public If this alias is public
|
||||||
*/
|
*/
|
||||||
public function __construct($id, $public = true)
|
public function __construct($id, $public = true)
|
||||||
{
|
{
|
||||||
@ -31,7 +31,7 @@ class Alias
|
|||||||
/**
|
/**
|
||||||
* Checks if this DI Alias should be public or not.
|
* Checks if this DI Alias should be public or not.
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public function isPublic()
|
public function isPublic()
|
||||||
{
|
{
|
||||||
@ -41,7 +41,7 @@ class Alias
|
|||||||
/**
|
/**
|
||||||
* Sets if this Alias is public.
|
* Sets if this Alias is public.
|
||||||
*
|
*
|
||||||
* @param boolean $boolean If this Alias should be public
|
* @param Boolean $boolean If this Alias should be public
|
||||||
*/
|
*/
|
||||||
public function setPublic($boolean)
|
public function setPublic($boolean)
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@ class AnalyzeServiceReferencesPass implements RepeatablePassInterface
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param boolean $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
|
* @param Boolean $onlyConstructorArguments Sets this Service Reference pass to ignore method calls
|
||||||
*/
|
*/
|
||||||
public function __construct($onlyConstructorArguments = false)
|
public function __construct($onlyConstructorArguments = false)
|
||||||
{
|
{
|
||||||
|
@ -106,7 +106,7 @@ class InlineServiceDefinitionsPass implements RepeatablePassInterface
|
|||||||
* @param ContainerBuilder $container
|
* @param ContainerBuilder $container
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param Definition $definition
|
* @param Definition $definition
|
||||||
* @return boolean If the definition is inlineable
|
* @return Boolean If the definition is inlineable
|
||||||
*/
|
*/
|
||||||
private function isInlinableDefinition(ContainerBuilder $container, $id, Definition $definition)
|
private function isInlinableDefinition(ContainerBuilder $container, $id, Definition $definition)
|
||||||
{
|
{
|
||||||
|
@ -69,7 +69,7 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface
|
|||||||
* Processes arguments to determine invalid references.
|
* Processes arguments to determine invalid references.
|
||||||
*
|
*
|
||||||
* @param array $arguments An array of Reference objects
|
* @param array $arguments An array of Reference objects
|
||||||
* @param boolean $inMethodCall
|
* @param Boolean $inMethodCall
|
||||||
*/
|
*/
|
||||||
private function processArguments(array $arguments, $inMethodCall = false)
|
private function processArguments(array $arguments, $inMethodCall = false)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ class ServiceReferenceGraphNode
|
|||||||
/**
|
/**
|
||||||
* Checks if the value of this node is an Alias.
|
* Checks if the value of this node is an Alias.
|
||||||
*
|
*
|
||||||
* @return boolean True if the value is an Alias instance
|
* @return Boolean True if the value is an Alias instance
|
||||||
*/
|
*/
|
||||||
public function isAlias()
|
public function isAlias()
|
||||||
{
|
{
|
||||||
@ -75,7 +75,7 @@ class ServiceReferenceGraphNode
|
|||||||
/**
|
/**
|
||||||
* Checks if the value of this node is a Definition.
|
* Checks if the value of this node is a Definition.
|
||||||
*
|
*
|
||||||
* @return boolean True if the value is a Definition instance
|
* @return Boolean True if the value is a Definition instance
|
||||||
*/
|
*/
|
||||||
public function isDefinition()
|
public function isDefinition()
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
* Checks if we have an extension.
|
* Checks if we have an extension.
|
||||||
*
|
*
|
||||||
* @param string $name The name of the extension
|
* @param string $name The name of the extension
|
||||||
* @return boolean If the extension exists
|
* @return Boolean If the extension exists
|
||||||
*/
|
*/
|
||||||
public function hasExtension($name)
|
public function hasExtension($name)
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ class GraphvizDumper extends Dumper
|
|||||||
*
|
*
|
||||||
* @param string $id The service id used to find edges
|
* @param string $id The service id used to find edges
|
||||||
* @param array $arguments An array of arguments
|
* @param array $arguments An array of arguments
|
||||||
* @param boolean $required
|
* @param Boolean $required
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return array An array of edges
|
* @return array An array of edges
|
||||||
*/
|
*/
|
||||||
|
@ -330,7 +330,7 @@ class PhpDumper extends Dumper
|
|||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param Definition $definition
|
* @param Definition $definition
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
private function isSimpleInstance($id, $definition)
|
private function isSimpleInstance($id, $definition)
|
||||||
{
|
{
|
||||||
@ -913,7 +913,7 @@ EOF;
|
|||||||
*
|
*
|
||||||
* @param string $id
|
* @param string $id
|
||||||
* @param array $arguments
|
* @param array $arguments
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
private function hasReference($id, array $arguments)
|
private function hasReference($id, array $arguments)
|
||||||
{
|
{
|
||||||
@ -936,7 +936,7 @@ EOF;
|
|||||||
* Dumps values.
|
* Dumps values.
|
||||||
*
|
*
|
||||||
* @param array $value
|
* @param array $value
|
||||||
* @param boolean $interpolate
|
* @param Boolean $interpolate
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function dumpValue($value, $interpolate = true)
|
private function dumpValue($value, $interpolate = true)
|
||||||
|
@ -61,7 +61,7 @@ class Reference
|
|||||||
/**
|
/**
|
||||||
* Returns true when this Reference is strict
|
* Returns true when this Reference is strict
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public function isStrict()
|
public function isStrict()
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Form\Exception\TransformationFailedException;
|
|||||||
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
use Symfony\Component\Form\Exception\UnexpectedTypeException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms between a boolean and a string.
|
* Transforms between a Boolean and a string.
|
||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||||
* @author Florian Eckerstorfer <florian@eckerstorfer.org>
|
* @author Florian Eckerstorfer <florian@eckerstorfer.org>
|
||||||
|
@ -37,7 +37,7 @@ class ResizeFormListener implements EventSubscriberInterface
|
|||||||
private $type;
|
private $type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var Boolean
|
||||||
*/
|
*/
|
||||||
private $resizeOnBind;
|
private $resizeOnBind;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class CheckboxType extends AbstractType
|
|||||||
public function buildView(FormView $view, FormInterface $form)
|
public function buildView(FormView $view, FormInterface $form)
|
||||||
{
|
{
|
||||||
$view->set('value', $form->getAttribute('value'));
|
$view->set('value', $form->getAttribute('value'));
|
||||||
$view->set('checked', (bool)$form->getData());
|
$view->set('checked', (Boolean) $form->getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getDefaultOptions(array $options)
|
public function getDefaultOptions(array $options)
|
||||||
|
@ -28,7 +28,7 @@ class RadioType extends AbstractType
|
|||||||
public function buildView(FormView $view, FormInterface $form)
|
public function buildView(FormView $view, FormInterface $form)
|
||||||
{
|
{
|
||||||
$view->set('value', $form->getAttribute('value'));
|
$view->set('value', $form->getAttribute('value'));
|
||||||
$view->set('checked', (bool)$form->getData());
|
$view->set('checked', (Boolean) $form->getData());
|
||||||
|
|
||||||
if ($view->hasParent()) {
|
if ($view->hasParent()) {
|
||||||
$view->set('name', $view->getParent()->get('name'));
|
$view->set('name', $view->getParent()->get('name'));
|
||||||
|
@ -44,7 +44,7 @@ interface CsrfProviderInterface
|
|||||||
*
|
*
|
||||||
* @param string $pageId The page ID used when generating the CSRF token
|
* @param string $pageId The page ID used when generating the CSRF token
|
||||||
* @param string $token The token supplied by the browser
|
* @param string $token The token supplied by the browser
|
||||||
* @return boolean Whether the token supplied by the browser is
|
* @return Boolean Whether the token supplied by the browser is
|
||||||
* correct
|
* correct
|
||||||
*/
|
*/
|
||||||
public function isCsrfTokenValid($pageId, $token);
|
public function isCsrfTokenValid($pageId, $token);
|
||||||
|
@ -104,7 +104,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
|
|||||||
/**
|
/**
|
||||||
* Returns whether the form is empty
|
* Returns whether the form is empty
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
function isEmpty();
|
function isEmpty();
|
||||||
|
|
||||||
|
@ -440,13 +440,6 @@ class File
|
|||||||
'x-world/x-vrml' => 'wrl',
|
'x-world/x-vrml' => 'wrl',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores the absolute path to the document root directory.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
static protected $documentRoot;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The absolute path to the file without dots.
|
* The absolute path to the file without dots.
|
||||||
*
|
*
|
||||||
@ -454,30 +447,6 @@ class File
|
|||||||
*/
|
*/
|
||||||
protected $path;
|
protected $path;
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the path to the document root directory.
|
|
||||||
*
|
|
||||||
* @param string $documentRoot
|
|
||||||
*/
|
|
||||||
static public function setDocumentRoot($documentRoot)
|
|
||||||
{
|
|
||||||
if (!is_dir($documentRoot)) {
|
|
||||||
throw new \LogicException($documentRoot . ' is not a directory.');
|
|
||||||
}
|
|
||||||
|
|
||||||
self::$documentRoot = realpath($documentRoot);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path to the document root directory.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
static public function getDocumentRoot()
|
|
||||||
{
|
|
||||||
return self::$documentRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a new file from the given path.
|
* Constructs a new file from the given path.
|
||||||
*
|
*
|
||||||
@ -491,7 +460,7 @@ class File
|
|||||||
throw new FileNotFoundException($path);
|
throw new FileNotFoundException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->path = $path;
|
$this->path = realpath($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -501,7 +470,7 @@ class File
|
|||||||
*/
|
*/
|
||||||
public function __toString()
|
public function __toString()
|
||||||
{
|
{
|
||||||
return null === $this->path ? '' : $this->path;
|
return (string) $this->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -522,7 +491,7 @@ class File
|
|||||||
public function getExtension()
|
public function getExtension()
|
||||||
{
|
{
|
||||||
if ($ext = pathinfo($this->getName(), PATHINFO_EXTENSION)) {
|
if ($ext = pathinfo($this->getName(), PATHINFO_EXTENSION)) {
|
||||||
return '.' . $ext;
|
return '.'.$ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
@ -531,19 +500,19 @@ class File
|
|||||||
/**
|
/**
|
||||||
* Returns the extension based on the mime type (with dot).
|
* Returns the extension based on the mime type (with dot).
|
||||||
*
|
*
|
||||||
* If the mime type is unknown, the actual extension is returned instead.
|
* If the mime type is unknown, returns null.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string|null The guessed extension or null if it cannot be guessed
|
||||||
*/
|
*/
|
||||||
public function getDefaultExtension()
|
public function guessExtension()
|
||||||
{
|
{
|
||||||
$type = $this->getMimeType();
|
$type = $this->getMimeType();
|
||||||
|
|
||||||
if (isset(self::$defaultExtensions[$type])) {
|
if (isset(self::$defaultExtensions[$type])) {
|
||||||
return '.' . self::$defaultExtensions[$type];
|
return '.'.self::$defaultExtensions[$type];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getExtension();
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -566,26 +535,6 @@ class File
|
|||||||
return $this->path;
|
return $this->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path relative to the document root.
|
|
||||||
*
|
|
||||||
* You can set the document root using the static method setDocumentRoot().
|
|
||||||
* If the file is outside of the document root, this method returns an
|
|
||||||
* empty string.
|
|
||||||
*
|
|
||||||
* @return string The relative file path
|
|
||||||
*/
|
|
||||||
public function getWebPath()
|
|
||||||
{
|
|
||||||
$root = self::$documentRoot;
|
|
||||||
|
|
||||||
if (false === strpos($this->path, $root)) {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return str_replace(array($root, DIRECTORY_SEPARATOR), array('', '/'), $this->path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the mime type of the file.
|
* Returns the mime type of the file.
|
||||||
*
|
*
|
||||||
@ -618,16 +567,14 @@ class File
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the file to a new directory and gives it a new filename
|
* Moves the file to a new location.
|
||||||
*
|
*
|
||||||
* @param string $directory The new directory
|
* @param string $directory The destination folder
|
||||||
* @param string $filename The new file name
|
* @param string $name The new file name
|
||||||
*
|
|
||||||
* @throws FileException When the file could not be moved
|
|
||||||
*/
|
*/
|
||||||
protected function doMove($directory, $filename)
|
public function move($directory, $name = null)
|
||||||
{
|
{
|
||||||
$newPath = $directory . DIRECTORY_SEPARATOR . $filename;
|
$newPath = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this->getName() : $name);
|
||||||
|
|
||||||
if (!@rename($this->getPath(), $newPath)) {
|
if (!@rename($this->getPath(), $newPath)) {
|
||||||
$error = error_get_last();
|
$error = error_get_last();
|
||||||
@ -636,29 +583,4 @@ class File
|
|||||||
|
|
||||||
$this->path = realpath($newPath);
|
$this->path = realpath($newPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Moves the file to a new location.
|
|
||||||
*
|
|
||||||
* @param string $directory The destination folder
|
|
||||||
* @param string $name The new file name
|
|
||||||
*/
|
|
||||||
public function move($directory, $name = null)
|
|
||||||
{
|
|
||||||
$this->doMove($directory, $this->getName());
|
|
||||||
|
|
||||||
if (null !== $name) {
|
|
||||||
$this->rename($name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renames the file.
|
|
||||||
*
|
|
||||||
* @param string $name The new file name
|
|
||||||
*/
|
|
||||||
public function rename($name)
|
|
||||||
{
|
|
||||||
$this->doMove($this->getDirectory(), $name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException;
|
|||||||
*
|
*
|
||||||
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
* @author Bernhard Schussek <bernhard.schussek@symfony.com>
|
||||||
* @author Florian Eckerstorfer <florian@eckerstorfer.org>
|
* @author Florian Eckerstorfer <florian@eckerstorfer.org>
|
||||||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class UploadedFile extends File
|
class UploadedFile extends File
|
||||||
{
|
{
|
||||||
@ -105,13 +106,33 @@ class UploadedFile extends File
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute file name without dots.
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @return string The file path
|
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getExtension()
|
||||||
{
|
{
|
||||||
return $this->moved ? parent::getName() : $this->originalName;
|
if ($this->moved) {
|
||||||
|
return parent::getExtension();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($ext = pathinfo($this->getOriginalName(), PATHINFO_EXTENSION)) {
|
||||||
|
return '.'.$ext;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the original uploaded name.
|
||||||
|
*
|
||||||
|
* Warning: This name is not safe as it can have been manipulated by the end-user.
|
||||||
|
* Moreover, it can contain characters that are not allowed in file names.
|
||||||
|
* Never use it in a path.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getOriginalName()
|
||||||
|
{
|
||||||
|
return $this->originalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -137,70 +158,23 @@ class UploadedFile extends File
|
|||||||
return $this->error === UPLOAD_ERR_OK;
|
return $this->error === UPLOAD_ERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the size of the uploaded file exceeds the
|
|
||||||
* upload_max_filesize directive in php.ini
|
|
||||||
*
|
|
||||||
* @return Boolean
|
|
||||||
*/
|
|
||||||
protected function isIniSizeExceeded()
|
|
||||||
{
|
|
||||||
return $this->error === UPLOAD_ERR_INI_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the size of the uploaded file exceeds the
|
|
||||||
* MAX_FILE_SIZE directive specified in the HTML form
|
|
||||||
*
|
|
||||||
* @return Boolean
|
|
||||||
*/
|
|
||||||
protected function isFormSizeExceeded()
|
|
||||||
{
|
|
||||||
return $this->error === UPLOAD_ERR_FORM_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the file was completely uploaded
|
|
||||||
*
|
|
||||||
* @return Boolean
|
|
||||||
*/
|
|
||||||
protected function isUploadComplete()
|
|
||||||
{
|
|
||||||
return $this->error !== UPLOAD_ERR_PARTIAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
protected function doMove($directory, $filename)
|
|
||||||
{
|
|
||||||
if ($this->moved) {
|
|
||||||
return parent::doMove($directory, $filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
$newPath = $directory . DIRECTORY_SEPARATOR . $filename;
|
|
||||||
|
|
||||||
if (!move_uploaded_file($this->getPath(), $newPath)) {
|
|
||||||
throw new FileException(sprintf('Could not move file %s to %s', $this->getPath(), $newPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->moved = true;
|
|
||||||
$this->path = realpath($newPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
public function move($directory, $name = null)
|
public function move($directory, $name = null)
|
||||||
{
|
{
|
||||||
if ($this->moved) {
|
if ($this->moved) {
|
||||||
return parent::move($directory, $name);
|
return parent::doMove($directory, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->doMove($directory, $this->originalName);
|
$newPath = $directory.DIRECTORY_SEPARATOR.(null === $name ? $this->getName() : $name);
|
||||||
|
|
||||||
if (null !== $name) {
|
if (!@move_uploaded_file($this->getPath(), $newPath)) {
|
||||||
$this->rename($name);
|
$error = error_get_last();
|
||||||
|
throw new FileException(sprintf('Could not move file %s to %s (%s)', $this->getPath(), $newPath, strip_tags($error['message'])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->moved = true;
|
||||||
|
$this->path = realpath($newPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,8 @@ class FileBag extends ParameterBag
|
|||||||
foreach (array_keys($data['name']) as $key) {
|
foreach (array_keys($data['name']) as $key) {
|
||||||
$files[$key] = $this->fixPhpFilesArray(array(
|
$files[$key] = $this->fixPhpFilesArray(array(
|
||||||
'error' => $data['error'][$key],
|
'error' => $data['error'][$key],
|
||||||
'name' => $data['name'][$key], 'type' => $data['type'][$key],
|
'name' => $data['name'][$key],
|
||||||
|
'type' => $data['type'][$key],
|
||||||
'tmp_name' => $data['tmp_name'][$key],
|
'tmp_name' => $data['tmp_name'][$key],
|
||||||
'size' => $data['size'][$key]
|
'size' => $data['size'][$key]
|
||||||
));
|
));
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
namespace Symfony\Component\HttpFoundation;
|
namespace Symfony\Component\HttpFoundation;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\SessionStorage\NativeSessionStorage;
|
use Symfony\Component\HttpFoundation\SessionStorage\NativeSessionStorage;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request represents an HTTP request.
|
* Request represents an HTTP request.
|
||||||
|
@ -188,7 +188,7 @@ class FullTransformer
|
|||||||
* Check if the first char of a string is a single quote
|
* Check if the first char of a string is a single quote
|
||||||
*
|
*
|
||||||
* @param string $quoteMatch The string to check
|
* @param string $quoteMatch The string to check
|
||||||
* @return bool true if matches, false otherwise
|
* @return Boolean true if matches, false otherwise
|
||||||
*/
|
*/
|
||||||
public function isQuoteMatch($quoteMatch)
|
public function isQuoteMatch($quoteMatch)
|
||||||
{
|
{
|
||||||
@ -257,7 +257,7 @@ class FullTransformer
|
|||||||
*
|
*
|
||||||
* @param DateTime $dateTime The DateTime object to be used to calculate the timestamp
|
* @param DateTime $dateTime The DateTime object to be used to calculate the timestamp
|
||||||
* @param array $options An array with the matched values to be used to calculate the timestamp
|
* @param array $options An array with the matched values to be used to calculate the timestamp
|
||||||
* @return bool|int The calculated timestamp or false if matched date is invalid
|
* @return Boolean|int The calculated timestamp or false if matched date is invalid
|
||||||
*/
|
*/
|
||||||
protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
|
protected function calculateUnixTimestamp(\DateTime $dateTime, array $options)
|
||||||
{
|
{
|
||||||
|
@ -98,7 +98,7 @@ class StubCollator
|
|||||||
* StubCollator::SORT_REGULAR - compare items normally (don't change types)
|
* StubCollator::SORT_REGULAR - compare items normally (don't change types)
|
||||||
* StubCollator::SORT_NUMERIC - compare items numerically
|
* StubCollator::SORT_NUMERIC - compare items numerically
|
||||||
* StubCollator::SORT_STRING - compare items as strings
|
* StubCollator::SORT_STRING - compare items as strings
|
||||||
* @return bool True on success or false on failure
|
* @return Boolean True on success or false on failure
|
||||||
*/
|
*/
|
||||||
public function asort(&$array, $sortFlag = self::SORT_REGULAR)
|
public function asort(&$array, $sortFlag = self::SORT_REGULAR)
|
||||||
{
|
{
|
||||||
@ -118,7 +118,7 @@ class StubCollator
|
|||||||
*
|
*
|
||||||
* @param string $str1 The first string to compare
|
* @param string $str1 The first string to compare
|
||||||
* @param string $str2 The second string to compare
|
* @param string $str2 The second string to compare
|
||||||
* @return bool|int Return the comparison result or false on failure:
|
* @return Boolean|int Return the comparison result or false on failure:
|
||||||
* 1 if $str1 is greater than $str2
|
* 1 if $str1 is greater than $str2
|
||||||
* 0 if $str1 is equal than $str2
|
* 0 if $str1 is equal than $str2
|
||||||
* -1 if $str1 is less than $str2
|
* -1 if $str1 is less than $str2
|
||||||
@ -134,7 +134,7 @@ class StubCollator
|
|||||||
* Get a value of an integer collator attribute
|
* Get a value of an integer collator attribute
|
||||||
*
|
*
|
||||||
* @param int $attr An attribute specifier, one of the attribute constants
|
* @param int $attr An attribute specifier, one of the attribute constants
|
||||||
* @return bool|int The attribute value on success or false on error
|
* @return Boolean|int The attribute value on success or false on error
|
||||||
* @see http://www.php.net/manual/en/collator.getattribute.php
|
* @see http://www.php.net/manual/en/collator.getattribute.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -190,7 +190,7 @@ class StubCollator
|
|||||||
/**
|
/**
|
||||||
* Get current collator's strenght
|
* Get current collator's strenght
|
||||||
*
|
*
|
||||||
* @return bool|int The current collator's strenght or false on failure
|
* @return Boolean|int The current collator's strenght or false on failure
|
||||||
* @see http://www.php.net/manual/en/collator.getstrength.php
|
* @see http://www.php.net/manual/en/collator.getstrength.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -204,7 +204,7 @@ class StubCollator
|
|||||||
*
|
*
|
||||||
* @param int $attr An attribute specifier, one of the attribute constants
|
* @param int $attr An attribute specifier, one of the attribute constants
|
||||||
* @param int $val The attribute value, one of the attribute value constants
|
* @param int $val The attribute value, one of the attribute value constants
|
||||||
* @return bool True on success or false on failure
|
* @return Boolean True on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/collator.setattribute.php
|
* @see http://www.php.net/manual/en/collator.setattribute.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -223,7 +223,7 @@ class StubCollator
|
|||||||
* StubCollator::QUATERNARY
|
* StubCollator::QUATERNARY
|
||||||
* StubCollator::IDENTICAL
|
* StubCollator::IDENTICAL
|
||||||
* StubCollator::DEFAULT
|
* StubCollator::DEFAULT
|
||||||
* @return bool True on success or false on failure
|
* @return Boolean True on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/collator.setstrength.php
|
* @see http://www.php.net/manual/en/collator.setstrength.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -236,7 +236,7 @@ class StubCollator
|
|||||||
* Sort array using specified collator and sort keys
|
* Sort array using specified collator and sort keys
|
||||||
*
|
*
|
||||||
* @param array &$arr Array of strings to sort
|
* @param array &$arr Array of strings to sort
|
||||||
* @return bool True on success or false on failure
|
* @return Boolean True on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/collator.sortwithsortkeys.php
|
* @see http://www.php.net/manual/en/collator.sortwithsortkeys.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -253,7 +253,7 @@ class StubCollator
|
|||||||
* StubCollator::SORT_REGULAR
|
* StubCollator::SORT_REGULAR
|
||||||
* StubCollator::SORT_NUMERIC
|
* StubCollator::SORT_NUMERIC
|
||||||
* StubCollator::SORT_STRING
|
* StubCollator::SORT_STRING
|
||||||
* @return bool True on success or false on failure
|
* @return Boolean True on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/collator.sort.php
|
* @see http://www.php.net/manual/en/collator.sort.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
|
@ -90,7 +90,7 @@ class StubIntlDateFormatter
|
|||||||
private $dateTimeZone;
|
private $dateTimeZone;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var Boolean
|
||||||
*/
|
*/
|
||||||
private $unitializedTimeZoneId = false;
|
private $unitializedTimeZoneId = false;
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ class StubIntlDateFormatter
|
|||||||
* Set the formatter's calendar
|
* Set the formatter's calendar
|
||||||
*
|
*
|
||||||
* @param string $calendar The calendar to use. Default is IntlDateFormatter::GREGORIAN.
|
* @param string $calendar The calendar to use. Default is IntlDateFormatter::GREGORIAN.
|
||||||
* @return bool true on success or false on failure
|
* @return Boolean true on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/intldateformatter.setcalendar.php
|
* @see http://www.php.net/manual/en/intldateformatter.setcalendar.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -337,8 +337,8 @@ class StubIntlDateFormatter
|
|||||||
* patterns, parsing as much as possible to obtain a value. Extra space, unrecognized tokens, or
|
* patterns, parsing as much as possible to obtain a value. Extra space, unrecognized tokens, or
|
||||||
* invalid values ("February 30th") are not accepted.
|
* invalid values ("February 30th") are not accepted.
|
||||||
*
|
*
|
||||||
* @param bool $lenient Sets whether the parser is lenient or not, default is false (strict)
|
* @param Boolean $lenient Sets whether the parser is lenient or not, default is false (strict)
|
||||||
* @return bool true on success or false on failure
|
* @return Boolean true on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/intldateformatter.setlenient.php
|
* @see http://www.php.net/manual/en/intldateformatter.setlenient.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -351,7 +351,7 @@ class StubIntlDateFormatter
|
|||||||
* Set the formatter's pattern
|
* Set the formatter's pattern
|
||||||
*
|
*
|
||||||
* @param string $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation
|
* @param string $pattern A pattern string in conformance with the ICU IntlDateFormatter documentation
|
||||||
* @return bool true on success or false on failure
|
* @return Boolean true on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/intldateformatter.setpattern.php
|
* @see http://www.php.net/manual/en/intldateformatter.setpattern.php
|
||||||
* @see http://userguide.icu-project.org/formatparse/datetime
|
* @see http://userguide.icu-project.org/formatparse/datetime
|
||||||
*/
|
*/
|
||||||
@ -370,7 +370,7 @@ class StubIntlDateFormatter
|
|||||||
* @param string $timeZoneId The time zone ID string of the time zone to use.
|
* @param string $timeZoneId The time zone ID string of the time zone to use.
|
||||||
* If NULL or the empty string, the default time zone for the
|
* If NULL or the empty string, the default time zone for the
|
||||||
* runtime is used.
|
* runtime is used.
|
||||||
* @return bool true on success or false on failure
|
* @return Boolean true on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/intldateformatter.settimezoneid.php
|
* @see http://www.php.net/manual/en/intldateformatter.settimezoneid.php
|
||||||
*/
|
*/
|
||||||
public function setTimeZoneId($timeZoneId)
|
public function setTimeZoneId($timeZoneId)
|
||||||
|
@ -369,7 +369,7 @@ class StubLocale
|
|||||||
*
|
*
|
||||||
* @param array $langtag A list of the language tags to compare to locale
|
* @param array $langtag A list of the language tags to compare to locale
|
||||||
* @param string $locale The locale to use as the language range when matching
|
* @param string $locale The locale to use as the language range when matching
|
||||||
* @param bool $canonicalize If true, the arguments will be converted to canonical form before matching
|
* @param Boolean $canonicalize If true, the arguments will be converted to canonical form before matching
|
||||||
* @param string $default The locale to use if no match is found
|
* @param string $default The locale to use if no match is found
|
||||||
* @see http://www.php.net/manual/en/locale.lookup.php
|
* @see http://www.php.net/manual/en/locale.lookup.php
|
||||||
* @throws RuntimeException When the intl extension is not loaded
|
* @throws RuntimeException When the intl extension is not loaded
|
||||||
@ -396,7 +396,7 @@ class StubLocale
|
|||||||
* Sets the default runtime locale
|
* Sets the default runtime locale
|
||||||
*
|
*
|
||||||
* @param string $locale The locale code
|
* @param string $locale The locale code
|
||||||
* @return bool true on success or false on failure
|
* @return Boolean true on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/locale.parselocale.php
|
* @see http://www.php.net/manual/en/locale.parselocale.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
|
@ -292,7 +292,7 @@ class StubNumberFormatter
|
|||||||
*
|
*
|
||||||
* @param number $value The value to format
|
* @param number $value The value to format
|
||||||
* @param int $type Type of the formatting, one of the format type constants
|
* @param int $type Type of the formatting, one of the format type constants
|
||||||
* @return bool|string The formatted value or false on error
|
* @return Boolean|string The formatted value or false on error
|
||||||
* @see http://www.php.net/manual/en/numberformatter.format.php
|
* @see http://www.php.net/manual/en/numberformatter.format.php
|
||||||
* @throws RuntimeException If the method is called with the class $style 'CURRENCY'
|
* @throws RuntimeException If the method is called with the class $style 'CURRENCY'
|
||||||
* @throws MethodArgumentNotImplementedException If the $type is different than TYPE_DEFAULT
|
* @throws MethodArgumentNotImplementedException If the $type is different than TYPE_DEFAULT
|
||||||
@ -327,7 +327,7 @@ class StubNumberFormatter
|
|||||||
* Returns an attribute value
|
* Returns an attribute value
|
||||||
*
|
*
|
||||||
* @param int $attr An attribute specifier, one of the numeric attribute constants
|
* @param int $attr An attribute specifier, one of the numeric attribute constants
|
||||||
* @return bool|int The attribute value on success or false on error
|
* @return Boolean|int The attribute value on success or false on error
|
||||||
* @see http://www.php.net/manual/en/numberformatter.getattribute.php
|
* @see http://www.php.net/manual/en/numberformatter.getattribute.php
|
||||||
*/
|
*/
|
||||||
public function getAttribute($attr)
|
public function getAttribute($attr)
|
||||||
@ -372,7 +372,7 @@ class StubNumberFormatter
|
|||||||
/**
|
/**
|
||||||
* Returns the formatter's pattern
|
* Returns the formatter's pattern
|
||||||
*
|
*
|
||||||
* @return bool|string The pattern string used by the formatter or false on error
|
* @return Boolean|string The pattern string used by the formatter or false on error
|
||||||
* @see http://www.php.net/manual/en/numberformatter.getpattern.php
|
* @see http://www.php.net/manual/en/numberformatter.getpattern.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -385,7 +385,7 @@ class StubNumberFormatter
|
|||||||
* Returns a formatter symbol value
|
* Returns a formatter symbol value
|
||||||
*
|
*
|
||||||
* @param int $attr A symbol specifier, one of the format symbol constants
|
* @param int $attr A symbol specifier, one of the format symbol constants
|
||||||
* @return bool|string The symbol value or false on error
|
* @return Boolean|string The symbol value or false on error
|
||||||
* @see http://www.php.net/manual/en/numberformatter.getsymbol.php
|
* @see http://www.php.net/manual/en/numberformatter.getsymbol.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -398,7 +398,7 @@ class StubNumberFormatter
|
|||||||
* Returns a formatter text attribute value
|
* Returns a formatter text attribute value
|
||||||
*
|
*
|
||||||
* @param int $attr An attribute specifier, one of the text attribute constants
|
* @param int $attr An attribute specifier, one of the text attribute constants
|
||||||
* @return bool|string The attribute value or false on error
|
* @return Boolean|string The attribute value or false on error
|
||||||
* @see http://www.php.net/manual/en/numberformatter.gettextattribute.php
|
* @see http://www.php.net/manual/en/numberformatter.gettextattribute.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -413,7 +413,7 @@ class StubNumberFormatter
|
|||||||
* @param string $value The value to parse
|
* @param string $value The value to parse
|
||||||
* @param string $currency Parameter to receive the currency name (reference)
|
* @param string $currency Parameter to receive the currency name (reference)
|
||||||
* @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended
|
* @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended
|
||||||
* @return bool|string The parsed numeric value of false on error
|
* @return Boolean|string The parsed numeric value of false on error
|
||||||
* @see http://www.php.net/manual/en/numberformatter.parsecurrency.php
|
* @see http://www.php.net/manual/en/numberformatter.parsecurrency.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -428,7 +428,7 @@ class StubNumberFormatter
|
|||||||
* @param string $value The value to parse
|
* @param string $value The value to parse
|
||||||
* @param string $type Type of the formatting, one of the format type constants. NumberFormatter::TYPE_DOUBLE by default
|
* @param string $type Type of the formatting, one of the format type constants. NumberFormatter::TYPE_DOUBLE by default
|
||||||
* @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended
|
* @param int $position Offset to begin the parsing on return this value will hold the offset at which the parsing ended
|
||||||
* @return bool|string The parsed value of false on error
|
* @return Boolean|string The parsed value of false on error
|
||||||
* @see http://www.php.net/manual/en/numberformatter.parse.php
|
* @see http://www.php.net/manual/en/numberformatter.parse.php
|
||||||
* @throws MethodArgumentValueNotImplementedException When $type equals to TYPE_INT64, behavior not implemented
|
* @throws MethodArgumentValueNotImplementedException When $type equals to TYPE_INT64, behavior not implemented
|
||||||
* @throws MethodArgumentNotImplementedException When $position different than null, behavior not implemented
|
* @throws MethodArgumentNotImplementedException When $position different than null, behavior not implemented
|
||||||
@ -468,7 +468,7 @@ class StubNumberFormatter
|
|||||||
*
|
*
|
||||||
* @param int $attr An attribute specifier, one of the numeric attribute constants
|
* @param int $attr An attribute specifier, one of the numeric attribute constants
|
||||||
* @param int $value The attribute value
|
* @param int $value The attribute value
|
||||||
* @return bool true on success or false on failure
|
* @return Boolean true on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/numberformatter.setattribute.php
|
* @see http://www.php.net/manual/en/numberformatter.setattribute.php
|
||||||
* @throws MethodArgumentValueNotImplementedException When the $attr is not supported
|
* @throws MethodArgumentValueNotImplementedException When the $attr is not supported
|
||||||
* @throws MethodArgumentValueNotImplementedException When the $value is not supported
|
* @throws MethodArgumentValueNotImplementedException When the $value is not supported
|
||||||
@ -510,7 +510,7 @@ class StubNumberFormatter
|
|||||||
* Set the formatter's pattern
|
* Set the formatter's pattern
|
||||||
*
|
*
|
||||||
* @param string $pattern A pattern string in conformance with the ICU DecimalFormat documentation
|
* @param string $pattern A pattern string in conformance with the ICU DecimalFormat documentation
|
||||||
* @return bool true on success or false on failure
|
* @return Boolean true on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/numberformatter.setpattern.php
|
* @see http://www.php.net/manual/en/numberformatter.setpattern.php
|
||||||
* @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
|
* @see http://www.icu-project.org/apiref/icu4c/classDecimalFormat.html#_details
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
@ -525,7 +525,7 @@ class StubNumberFormatter
|
|||||||
*
|
*
|
||||||
* @param int $attr A symbol specifier, one of the format symbol constants
|
* @param int $attr A symbol specifier, one of the format symbol constants
|
||||||
* @param string $value The value for the symbol
|
* @param string $value The value for the symbol
|
||||||
* @return bool true on success or false on failure
|
* @return Boolean true on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/numberformatter.setsymbol.php
|
* @see http://www.php.net/manual/en/numberformatter.setsymbol.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -539,7 +539,7 @@ class StubNumberFormatter
|
|||||||
*
|
*
|
||||||
* @param int $attr An attribute specifier, one of the text attribute constants
|
* @param int $attr An attribute specifier, one of the text attribute constants
|
||||||
* @param int $value The attribute value
|
* @param int $value The attribute value
|
||||||
* @return bool true on success or false on failure
|
* @return Boolean true on success or false on failure
|
||||||
* @see http://www.php.net/manual/en/numberformatter.settextattribute.php
|
* @see http://www.php.net/manual/en/numberformatter.settextattribute.php
|
||||||
* @throws MethodNotImplementedException
|
* @throws MethodNotImplementedException
|
||||||
*/
|
*/
|
||||||
@ -674,7 +674,7 @@ class StubNumberFormatter
|
|||||||
* Check if the attribute is initialized (value set by client code).
|
* Check if the attribute is initialized (value set by client code).
|
||||||
*
|
*
|
||||||
* @param string $attr The attribute name
|
* @param string $attr The attribute name
|
||||||
* @return bool true if the value was set by cliente, false otherwise
|
* @return Boolean true if the value was set by cliente, false otherwise
|
||||||
*/
|
*/
|
||||||
private function isInitializedAttribute($attr)
|
private function isInitializedAttribute($attr)
|
||||||
{
|
{
|
||||||
@ -719,7 +719,7 @@ class StubNumberFormatter
|
|||||||
* Check if the rounding mode is invalid.
|
* Check if the rounding mode is invalid.
|
||||||
*
|
*
|
||||||
* @param int $value The rounding mode value to check
|
* @param int $value The rounding mode value to check
|
||||||
* @return bool true if the rounding mode is invalid, false otherwise
|
* @return Boolean true if the rounding mode is invalid, false otherwise
|
||||||
*/
|
*/
|
||||||
private function isInvalidRoundingMode($value)
|
private function isInvalidRoundingMode($value)
|
||||||
{
|
{
|
||||||
@ -732,13 +732,13 @@ class StubNumberFormatter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the normalized value for the GROUPING_USED attribute. Any value that can be converted to int will be
|
* Returns the normalized value for the GROUPING_USED attribute. Any value that can be converted to int will be
|
||||||
* cast to boolean and then to int again. This way, negative values are converted to 1 and string values to 0.
|
* cast to Boolean and then to int again. This way, negative values are converted to 1 and string values to 0.
|
||||||
*
|
*
|
||||||
* @param mixed $value The value to be normalized
|
* @param mixed $value The value to be normalized
|
||||||
* @return int The normalized value for the attribute (0 or 1)
|
* @return int The normalized value for the attribute (0 or 1)
|
||||||
*/
|
*/
|
||||||
private function normalizeGroupingUsedValue($value) {
|
private function normalizeGroupingUsedValue($value) {
|
||||||
return (int) (bool) (int) $value;
|
return (int) (Boolean) (int) $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,7 +53,7 @@ class SecurityContext implements SecurityContextInterface
|
|||||||
* @throws AuthenticationCredentialsNotFoundException when the security context has no authentication token.
|
* @throws AuthenticationCredentialsNotFoundException when the security context has no authentication token.
|
||||||
* @param mixed $attributes
|
* @param mixed $attributes
|
||||||
* @param mixed|null $object
|
* @param mixed|null $object
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
public final function isGranted($attributes, $object = null)
|
public final function isGranted($attributes, $object = null)
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ interface SecurityContextInterface
|
|||||||
*
|
*
|
||||||
* @param array $attributes
|
* @param array $attributes
|
||||||
* @param mixed $object
|
* @param mixed $object
|
||||||
* @return boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
function isGranted($attributes, $object = null);
|
function isGranted($attributes, $object = null);
|
||||||
}
|
}
|
@ -201,7 +201,7 @@ class XmlEncoder extends AbstractEncoder implements DecoderInterface
|
|||||||
*
|
*
|
||||||
* @param DOMNode $parentNode
|
* @param DOMNode $parentNode
|
||||||
* @param array|object $data data
|
* @param array|object $data data
|
||||||
* @return bool
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
private function buildXml($parentNode, $data)
|
private function buildXml($parentNode, $data)
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@ class ValidatorFactory implements ValidatorContextInterface
|
|||||||
* @param array $mappingFiles A list of XML or YAML file names
|
* @param array $mappingFiles A list of XML or YAML file names
|
||||||
* where mapping information can be
|
* where mapping information can be
|
||||||
* found. Can be empty.
|
* found. Can be empty.
|
||||||
* @param boolean $annotations Whether to use annotations for
|
* @param Boolean $annotations Whether to use annotations for
|
||||||
* retrieving mapping information
|
* retrieving mapping information
|
||||||
* @param array $annotationNamespaces The annotation namespaces used
|
* @param array $annotationNamespaces The annotation namespaces used
|
||||||
* for finding the annotation classes.
|
* for finding the annotation classes.
|
||||||
|
@ -227,7 +227,7 @@ class ChoiceTypeTest extends TypeTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We need this functionality to create choice fields for boolean types,
|
* We need this functionality to create choice fields for Boolean types,
|
||||||
* e.g. false => 'No', true => 'Yes'
|
* e.g. false => 'No', true => 'Yes'
|
||||||
*/
|
*/
|
||||||
public function testSetDataSingleNonExpandedAcceptsBoolean()
|
public function testSetDataSingleNonExpandedAcceptsBoolean()
|
||||||
|
@ -23,7 +23,6 @@ use Symfony\Component\Form\HiddenField;
|
|||||||
use Symfony\Component\Form\Util\PropertyPath;
|
use Symfony\Component\Form\Util\PropertyPath;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
|
||||||
use Symfony\Component\Validator\ConstraintViolation;
|
use Symfony\Component\Validator\ConstraintViolation;
|
||||||
use Symfony\Component\Validator\ConstraintViolationList;
|
use Symfony\Component\Validator\ConstraintViolationList;
|
||||||
use Symfony\Component\Validator\ExecutionView;
|
use Symfony\Component\Validator\ExecutionView;
|
||||||
|
@ -33,28 +33,6 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(__DIR__.'/Fixtures/test.gif', (string) $this->file);
|
$this->assertEquals(__DIR__.'/Fixtures/test.gif', (string) $this->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetWebPathReturnsPathRelativeToDocumentRoot()
|
|
||||||
{
|
|
||||||
File::setDocumentRoot(__DIR__);
|
|
||||||
|
|
||||||
$this->assertEquals(__DIR__, File::getDocumentRoot());
|
|
||||||
$this->assertEquals('/Fixtures/test.gif', $this->file->getWebPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetWebPathReturnsEmptyPathIfOutsideDocumentRoot()
|
|
||||||
{
|
|
||||||
File::setDocumentRoot(__DIR__.'/Fixtures/directory');
|
|
||||||
|
|
||||||
$this->assertEquals('', $this->file->getWebPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testSetDocumentRootThrowsLogicExceptionWhenNotExists()
|
|
||||||
{
|
|
||||||
$this->setExpectedException('LogicException');
|
|
||||||
|
|
||||||
File::setDocumentRoot(__DIR__.'/Fixtures/not_here');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetNameReturnsNameWithExtension()
|
public function testGetNameReturnsNameWithExtension()
|
||||||
{
|
{
|
||||||
$this->assertEquals('test.gif', $this->file->getName());
|
$this->assertEquals('test.gif', $this->file->getName());
|
||||||
@ -85,21 +63,21 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('image/gif', $this->file->getMimeType());
|
$this->assertEquals('image/gif', $this->file->getMimeType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetDefaultExtensionWithoutGuesser()
|
public function testGuessExtensionWithoutGuesser()
|
||||||
{
|
{
|
||||||
$file = new File(__DIR__.'/Fixtures/directory/.empty');
|
$file = new File(__DIR__.'/Fixtures/directory/.empty');
|
||||||
|
|
||||||
$this->assertEquals('.empty', $file->getDefaultExtension());
|
$this->assertEquals(null, $file->guessExtension());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetDefaultExtensionIsBasedOnMimeType()
|
public function testGuessExtensionIsBasedOnMimeType()
|
||||||
{
|
{
|
||||||
$file = new File(__DIR__.'/Fixtures/test');
|
$file = new File(__DIR__.'/Fixtures/test');
|
||||||
$guesser = $this->createMockGuesser($file->getPath(), 'image/gif');
|
$guesser = $this->createMockGuesser($file->getPath(), 'image/gif');
|
||||||
|
|
||||||
MimeTypeGuesser::getInstance()->register($guesser);
|
MimeTypeGuesser::getInstance()->register($guesser);
|
||||||
|
|
||||||
$this->assertEquals('.gif', $file->getDefaultExtension());
|
$this->assertEquals('.gif', $file->guessExtension());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConstructWhenFileNotExists()
|
public function testConstructWhenFileNotExists()
|
||||||
@ -189,25 +167,6 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
|||||||
@unlink($targetPath);
|
@unlink($targetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRename()
|
|
||||||
{
|
|
||||||
$path = __DIR__.'/Fixtures/test.copy.gif';
|
|
||||||
$targetPath = realpath(__DIR__.'/Fixtures').DIRECTORY_SEPARATOR.'test.target.gif';
|
|
||||||
@unlink($path);
|
|
||||||
@unlink($targetPath);
|
|
||||||
copy(realpath(__DIR__.'/Fixtures/test.gif'), $path);
|
|
||||||
|
|
||||||
$file = new File($path);
|
|
||||||
$file->rename('test.target.gif');
|
|
||||||
|
|
||||||
$this->assertTrue(file_exists($targetPath));
|
|
||||||
$this->assertFalse(file_exists($path));
|
|
||||||
$this->assertEquals($targetPath, $file->getPath());
|
|
||||||
|
|
||||||
@unlink($path);
|
|
||||||
@unlink($targetPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function createMockGuesser($path, $mimeType)
|
protected function createMockGuesser($path, $mimeType)
|
||||||
{
|
{
|
||||||
$guesser = $this->getMock('Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface');
|
$guesser = $this->getMock('Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface');
|
||||||
|
@ -77,6 +77,6 @@ class UploadedFileTest extends \PHPUnit_Framework_TestCase
|
|||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals('original.gif', $file->getName());
|
$this->assertEquals('test.gif', $file->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
namespace Symfony\Tests\Component\HttpFoundation;
|
namespace Symfony\Tests\Component\HttpFoundation;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\File\UploadedFile;
|
|
||||||
|
|
||||||
class RequestTest extends \PHPUnit_Framework_TestCase
|
class RequestTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
@ -737,7 +737,7 @@ class KernelForTest extends Kernel
|
|||||||
|
|
||||||
public function setIsBooted($value)
|
public function setIsBooted($value)
|
||||||
{
|
{
|
||||||
$this->booted = (bool) $value;
|
$this->booted = (Boolean) $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ php: |
|
|||||||
---
|
---
|
||||||
test: Boolean
|
test: Boolean
|
||||||
brief: >
|
brief: >
|
||||||
You can use 'true' and 'false' for boolean values.
|
You can use 'true' and 'false' for Boolean values.
|
||||||
yaml: |
|
yaml: |
|
||||||
Is Gus a Liar?: true
|
Is Gus a Liar?: true
|
||||||
Do I rely on Gus for Sustenance?: false
|
Do I rely on Gus for Sustenance?: false
|
||||||
|
Reference in New Issue
Block a user