<commit_before><?php

/*
 * This file is part of the Sonata package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sonata\CoreBundle\Validator\Constraints;

use Symfony\Component\Validator\Constraint;

class InlineConstraint extends Constraint
{
    protected $service;

    protected $method;

    protected $serializingWarning;

    /**
     * {@inheritdoc}
     */
    public function __construct($options = null)
    {
        parent::__construct($options);

        if ((!is_string($this->service) || !is_string($this->method)) && $this->serializingWarning !== true) {
            throw new \RuntimeException('You are using a closure with the `InlineConstraint`, this constraint'.
                ' cannot be serialized. You need to re-attach the `InlineConstraint` on each request.'.
                ' Once done, you can set the `serializingWarning` option to `true` to avoid this message.');
        }
    }

    /**
     * {@inheritdoc}
     */
    public function validatedBy()
    {
        return 'sonata.core.validator.inline';
    }

    /**
     * @return bool
     */
    public function isClosure()
    {
        return $this->method instanceof \Closure;
    }

    /**
     * @return mixed
     */
    public function getClosure()
    {
        return $this->method;
    }

    /**
     * {@inheritdoc}
     */
    public function getTargets()
    {
        return self::CLASS_CONSTRAINT;
    }

    /**
     * {@inheritdoc}
     */
    public function getRequiredOptions()
    {
        return array(
            'service',
            'method',
        );
    }

    /**
     * @return string
     */
    public function getMethod()
    {
        return $this->method;
    }

    /**
     * @return mixed
     */
    public function getService()
    {
        return $this->service;
    }

    /**
     * @return mixed
     */
    public function getSerializingWarning()
    {
        return $this->serializingWarning;
    }

    /**
     * {@inheritdoc}
     */
    public function __sleep()
    {
        if (!is_string($this->service) || !is_string($this->method)) {
            return array();
        }

        return parent::__sleep();
    }

    /**
     * {@inheritdoc}
     */
    public function __wakeup()
    {
        if (is_string($this->service) && is_string($this->method)) {<commit_msg>fix regression with sf < 2.6<commit_after><?php

/*
 * This file is part of the Sonata package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Sonata\CoreBundle\Validator\Constraints;

use Symfony\Component\Validator\Constraint;

class InlineConstraint extends Constraint
{
    protected $service;

    protected $method;

    protected $serializingWarning;

    /**
     * {@inheritdoc}
     */
    public function __construct($options = null)
    {
        parent::__construct($options);

        if ((!is_string($this->service) || !is_string($this->method)) && $this->serializingWarning !== true) {
            throw new \RuntimeException('You are using a closure with the `InlineConstraint`, this constraint'.
                ' cannot be serialized. You need to re-attach the `InlineConstraint` on each request.'.
                ' Once done, you can set the `serializingWarning` option to `true` to avoid this message.');
        }
    }

    /**
     * {@inheritdoc}
     */
    public function validatedBy()
    {
        return 'sonata.core.validator.inline';
    }

    /**
     * @return bool
     */
    public function isClosure()
    {
        return $this->method instanceof \Closure;
    }

    /**
     * @return mixed
     */
    public function getClosure()
    {
        return $this->method;
    }

    /**
     * {@inheritdoc}
     */
    public function getTargets()
    {
        return self::CLASS_CONSTRAINT;
    }

    /**
     * {@inheritdoc}
     */
    public function getRequiredOptions()
    {
        return array(
            'service',
            'method',
        );
    }

    /**
     * @return string
     */
    public function getMethod()
    {
        return $this->method;
    }

    /**
     * @return mixed
     */
    public function getService()
    {
        return $this->service;
    }

    /**
     * @return mixed
     */
    public function getSerializingWarning()
    {
        return $this->serializingWarning;
    }

    /**
     * {@inheritdoc}
     */
    public function __sleep()
    {
        if (!is_string($this->service) || !is_string($this->method)) {
            return array();
        }

        // Initialize "groups" option if it is not set
        $this->groups;

        return array_keys(get_object_vars($this));
    }

    /**
     * {@inheritdoc}
     */
    public function __wakeup()
    {
        if (is_string($this->service) && is_string($this->method)) {
{'fraction_non_alphanumeric': 0.12796965462168097, 'fraction_numerical': 0.0003992812936713915, 'mean_word_length': 1.9592439456585942, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6015039', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1400, 'n_words': 353}