1: <?php
2:
3: /*
4: * This file is part of the Symfony package.
5: *
6: * (c) Fabien Potencier <fabien@symfony.com>
7: *
8: * For the full copyright and license information, please view the LICENSE
9: * file that was distributed with this source code.
10: */
11:
12: namespace Symfony\Component\Config\Definition;
13:
14: use Symfony\Component\Config\Definition\VariableNode;
15: use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
16:
17: /**
18: * This node represents a scalar value in the config tree.
19: *
20: * The following values are considered scalars:
21: * * booleans
22: * * strings
23: * * null
24: * * integers
25: * * floats
26: *
27: * @author Johannes M. Schmitt <schmittjoh@gmail.com>
28: */
29: class ScalarNode extends VariableNode
30: {
31: /**
32: * {@inheritDoc}
33: */
34: protected function validateType($value)
35: {
36: if (!is_scalar($value) && null !== $value) {
37: $ex = new InvalidTypeException(sprintf(
38: 'Invalid type for path "%s". Expected scalar, but got %s.',
39: $this->getPath(),
40: gettype($value)
41: ));
42: $ex->setPath($this->getPath());
43:
44: throw $ex;
45: }
46: }
47: }
48: