Doctrine2 behavior traits

Overview

Doctrine Behaviors

Downloads

This PHP library is a collection of traits and interfaces that add behaviors to Doctrine entities and repositories.

It currently handles:

Install

composer require knplabs/doctrine-behaviors

Usage

All you have to do is to define a Doctrine entity:

  • implemented interface
  • add a trait

For some behaviors like tree, you can use repository traits:

<?php

declare(strict_types=1);

namespace App\Repository;

use Doctrine\ORM\EntityRepository;
use Knp\DoctrineBehaviors\ORM\Tree\TreeTrait;

final class CategoryRepository extends EntityRepository
{
    use TreeTrait;
}

Voilà!

You now have a working Category that behaves like.

PHPStan

A PHPStan extension is available and provides the following features:

  • Provides correct return type for TranslatableInterface::getTranslations() and TranslatableInterface::getNewTranslations()
  • Provides correct return type for TranslatableInterface::translate()
  • Provides correct return type for TranslationInterface::getTranslatable()

Include phpstan-extension.neon in your project's PHPStan config:

# phpstan.neon
includes:
    - vendor/knplabs/doctrine-behaviors/phpstan-extension.neon

3 Steps to Contribute

  • 1 feature per pull-request

  • New feature needs tests

  • Tests and static analysis must pass:

    vendor/bin/phpunit
    composer fix-cs
    composer phpstan

Upgrade 1.x to 2

There have been many changes between 1 and 2, but don't worry. This package uses Rector, that handles upgrade for you.

composer require rector/rector --dev
vendor/bin/rector process src --config vendor/rector/rector/config/set/doctrine-behaviors-20.yaml
Comments
  • Search or filter results by translatable fields in Knplabs doctrine behaviors bundle (Symfony2)

    Search or filter results by translatable fields in Knplabs doctrine behaviors bundle (Symfony2)

    Hello, I have seen some questions about this topic but without good answers.

    I have entity Site with fields: ID, host, enabled and translatable entity SiteTranslations with fields name, description, keywords. (I use Knplabs translatable strategy)

    I would like to filter results in list table by name, host and enabled values. For host and enabled field it is working ok, because those fields are in Site repository. But I can't find a solution how to filter by "name" which is in SiteTranslatable repository and in table sitetranslation.

    Here is my form validation in controler:

    ….
    if ($form->isValid()) { // a check to see if the form is valid 
         // filter records
          if($form->get('filter')->isClicked{
               if ($filter->getHost() !== null) $criteria['host'] = $filter->gethost();
               if ($filter->getEnabled() !== null) $criteria['enabled'] = $filter->getEnabled(); 
          }
    }
    …
    $sites = $em->getRepository('PnetConlocoBundle:Site')->getList($criteria);
    

    And getList function in repository:

    public function getList($criteria = null)
    {
                 $qb = $this->createQueryBuilder('s')
                       ->select('s')
                       ->orderBy('s.root', 'ASC')
                       ->addOrderBy('s.lft', 'ASC'); 
             
                if($criteria !== null):
                    foreach ($criteria as $field => $value):
                        if (!$this->getClassMetadata()->hasField($field)):
                            continue; // Make sure we only use existing fields (avoid any injection)
                        endif;  
                       
                        if ($this->getClassMetadata()->getTypeOfField($field) === 'string'
                            || $this->getClassMetadata()->getTypeOfField($field) === 'text'):
                            $qb ->andWhere($qb->expr()->like('s.'.$field, ':s_'.$field))
                                ->setParameter('s_'.$field, '%'.$value.'%');    // search LIKE %value%
                        else:    
                            $qb ->andWhere($qb->expr()->eq('s.'.$field, ':s_'.$field))
                                ->setParameter('s_'.$field, $value);
                        endif;
                    endforeach;
                endif;        
            return $qb->getQuery()->getResult();
        }
    

    Does anybody know how update this code that it will work also for translatable fields?

    Thanks in advance.

    opened by kvaje 33
  • [Translatable] currentLocale = null

    [Translatable] currentLocale = null

    Using the trait \Knp\DoctrineBehaviors\Model\Translatable\Translation inside an Entity, I see that the property currentLocale is never setted , so we always obtain the default locale ('en') in all the calls to $this->translate().

    In my symfony2 controller I've setted correctly the locale and all the requests goes with the correct locale.

    If I change this getDefaultLocale, all the trasnlations are made correctly, so I think that is no problem with the fallback.

    bug 
    opened by sitobcn82 29
  • Symfony 5 compatibility

    Symfony 5 compatibility

    Hi,

    is it planned to ensure compatibility with Symfony 5 ?

    Here is the result when activating the bundle :

    Too few arguments to function Symfony\Component\Config\Definition\Builder\TreeBuilder::__construct(), 0 passed in \vendor\knplabs\doctrine-behaviors\src\Bundle\DependencyInjection\Configuration.php on line 12 and at least 1 expected

    Thanks for the feedback.

    opened by nicolashachet 21
  • New version using symplify/package-builder ^8.0

    New version using symplify/package-builder ^8.0

    I'm having trouble updating bolt/core to use ecs ^8, because of incompatible versions with doctrine behaviors. But I see you've already updated to symplify/package-builder ^8.0 on master.

    Can you tag a new release so that this issue is resolved for people? :) Thanks

    opened by I-Valchev 20
  • Using Timestampable throws an error when creating a new entity

    Using Timestampable throws an error when creating a new entity

    I changed the entity like described in @TomasVotruba blog https://www.tomasvotruba.com/blog/2020/01/06/migrate-gedmo-to-knplabs/ thinking it was very easy.

    I can change an existing record and it captures the updatedAt time. But when creating a new record, an error is shown.

    Can anyone help me with this?

    TypeError:
    Return value of App\Entity\Product::getCreatedAt() must implement interface DateTimeInterface, null returned
    
      at vendor/knplabs/doctrine-behaviors/src/Model/Timestampable/TimestampableMethodsTrait.php:16
      at App\Entity\Product->getCreatedAt()
         (vendor/symfony/property-access/PropertyAccessor.php:384)
      at Symfony\Component\PropertyAccess\PropertyAccessor->readProperty()
         (vendor/symfony/property-access/PropertyAccessor.php:93)
      at Symfony\Component\PropertyAccess\PropertyAccessor->getValue()
         (vendor/symfony/form/Extension/Core/DataMapper/PropertyPathMapper.php:49)
      at Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper->mapDataToForms()
         (vendor/symfony/form/Form.php:377)
      at Symfony\Component\Form\Form->setData()
         (vendor/symfony/form/Form.php:481)
      at Symfony\Component\Form\Form->initialize()
         (vendor/symfony/form/FormBuilder.php:206)
      at Symfony\Component\Form\FormBuilder->getForm()
         (vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php:842)
      at EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController->createEntityForm()
         (vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php:778)
      at EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController->createNewForm()
         (vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php:908)
      at EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController->executeDynamicMethod()
         (vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php:301)
      at EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController->newAction()
         (vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php:908)
      at EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController->executeDynamicMethod()
         (vendor/easycorp/easyadmin-bundle/src/Controller/AdminControllerTrait.php:86)
      at EasyCorp\Bundle\EasyAdminBundle\Controller\EasyAdminController->indexAction()
         (vendor/symfony/http-kernel/HttpKernel.php:157)
      at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
         (vendor/symfony/http-kernel/HttpKernel.php:79)
      at Symfony\Component\HttpKernel\HttpKernel->handle()
         (vendor/symfony/http-kernel/Kernel.php:191)
      at Symfony\Component\HttpKernel\Kernel->handle()
         (public/index.php:25)
      at require('/home/paul/www/test-knplabs/public/index.php')
         (/home/paul/.symfony/php/1f578ba6ccbb1add18b380021c9ebe0f3fd87e3c-router.php:29)   
    
    opened by parijke 20
  • Use interfaces instead of traits

    Use interfaces instead of traits

    With interfaces implementation code looks more clearer, readable and correct than with current trait implementation. Developers could easily override properties and methods with their customs. Also we get auto-completion by IDEs in code. More discusion was in PR https://github.com/KnpLabs/DoctrineBehaviors/pull/237 .

    There are a list of traits that should be refactored with interfaces:

    • [x] - tree (in https://github.com/KnpLabs/DoctrineBehaviors/pull/246)
    • [x] - translatable (in #322)
    • [x] - timestampable (in https://github.com/KnpLabs/DoctrineBehaviors/pull/242)
    • [x] - softDeletable (in https://github.com/KnpLabs/DoctrineBehaviors/pull/248)
    • [x] - blameable (in #323)
    • [x] - loggable (in #324)
    • [x] - geocodable (in #325)
    • [x] - filterable
    • [x] - sluggable (in https://github.com/KnpLabs/DoctrineBehaviors/pull/237)
    • [x] - sortable (in https://github.com/KnpLabs/DoctrineBehaviors/pull/249)
    opened by bocharsky-bw 19
  • [Translatable] doTranslate() should return self

    [Translatable] doTranslate() should return self

    Php intelephense give me some errors like this one, when I try to access to any setter of my translated entities:

    Undefined method 'setTitle'.
    

    This is due to doTranslate() and translate() method of TranslatableMethodsTrait which actually returns a TranslationInterface type and so don't have setTitle defined. If those two methods was returning self, that could fix the problem. Edit: I don't think it is a good idea to return self, but I don't have any other alternative solution.

    opened by Jupi007 18
  • Provide default locale for Translatable

    Provide default locale for Translatable

    Hello! I am searching for the way to set provide default locale for translate method. Unfortunately, I found out this in TranslatableMethods:

        public function getDefaultLocale()
        {
            return 'en';
        }
    

    So, I guess, there is no way to override it? :smile:

    opened by charlie-wasp 18
  • Removed Id from EnittyTranslation fixture.

    Removed Id from EnittyTranslation fixture.

    I removed $id from TranslatableEntityTranslation and now tests will fail.

    My question is, what should be a key for EntityTranslation classes. Should user manualy define it, or there should be some predefined (id of Translatable and locale for example)?

    opened by kuczek 18
  • [Translatable] Fix property access on twig

    [Translatable] Fix property access on twig

    This should fix this warning.

    An exception has been thrown during the rendering of a template ("Warning: call_user_func_array() expects parameter 1 to be a valid callback, class 'MyClassTranslation' does not have a method 'name' in ../vendor/knplabs/doctrine-behaviors/src/Knp/DoctrineBehaviors/Model/Translatable/TranslatableMethods.php line 140") in MyBundle:Default:index.html.twig at line 1.

    Twig calls 'name' instead 'getName'

    opened by asosso 17
  • Bugfix (doctrine:schema:update exception)

    Bugfix (doctrine:schema:update exception)

    It throws a DBALException with "Unknown database type point requested, MySqlPlatform may not support it." message when I use GeoLocation behavior and run doctrine:schema:update command.

    opened by fchris82 17
  • doc(translatable): Add a tips about Doctrine Migration

    doc(translatable): Add a tips about Doctrine Migration

    I'd like to add a small tip about Doctrine Migration and existing projects getting Translatable setup after some content have been contributed.

    It's just an easy thing to miss locally because fixtures are applied later, but that could be a shame once deployed to production :smiley_cat:

    opened by damienalexandre 0
  • doc(translatable): Improve the LocaleSubscriber implementation

    doc(translatable): Improve the LocaleSubscriber implementation

    Also fix some English / improve the flow of the document.

    At the start all I wanted to replace was the locale parsing / setLocale on the Request thing to use modern Symfony:

    $request->setLocale(
        $request->getPreferredLanguage($this->availableLocales)
    );
    $request->attributes->set('_vary_by_language', true);
    
    opened by damienalexandre 0
  • PHPStan failed using Translatable

    PHPStan failed using Translatable

    I there,

    I'm using translatable from Knp and I have this error :

    Uncaught Knp\DoctrineBehaviors\PHPStan\Exception\PHPStanTypeException: Unable to find the Translation class associated to the Translatable class "App\Entity\ExposeTranslatableFieldsInterface". in /dev/app/vendor/knplabs/doctrine-behaviors/utils/phpstan-behaviors/src/Type/StaticTranslationTypeHelper.php:45
    #0 /dev/app/vendor/knplabs/doctrine-behaviors/utils/phpstan-behaviors/src/Type/TranslatableTranslateDynamicMethodReturnTypeExtension.php(39): Knp\DoctrineBehaviors\PHPStan\Type\StaticTranslationTypeHelper::getTranslationClass(Object(PHPStan\Reflection\ReflectionProvider\MemoizingReflectionProvider), Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))
    #1 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(3574): Knp\DoctrineBehaviors\PHPStan\Type\TranslatableTranslateDynamicMethodReturnTypeExtension->getTypeFromMethodCall(Object(PHPStan\Reflection\ResolvedMethodReflection), Object(PhpParser\Node\Expr\MethodCall), Object(PHPStan\Analyser\MutatingScope))
    #2 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1413): PHPStan\Analyser\MutatingScope->methodCallReturnType(Object(PHPStan\Type\UnionType), 'translate', Object(PhpParser\Node\Expr\MethodCall))
    #3 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(1419): PHPStan\Analyser\MutatingScope->PHPStan\Analyser\{closure}()
    #4 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/MutatingScope.php(574): PHPStan\Analyser\MutatingScope->resolveType(Object(PhpParser\Node\Expr\MethodCall))
    #5 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1345): PHPStan\Analyser\MutatingScope->getType(Object(PhpParser\Node\Expr\MethodCall))
    #6 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1364): PHPStan\Analyser\NodeScopeResolver->ensureShallowNonNullability(Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Analyser\MutatingScope), Object(PhpParser\Node\Expr\MethodCall))
    #7 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1325): PHPStan\Analyser\NodeScopeResolver->PHPStan\Analyser\{closure}(Object(PHPStan\Analyser\MutatingScope), Object(PhpParser\Node\Expr\MethodCall))
    #8 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1330): PHPStan\Analyser\NodeScopeResolver->lookForExpressionCallback(Object(PHPStan\Analyser\MutatingScope), Object(PhpParser\Node\Expr\MethodCall), Object(Closure))
    #9 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1369): PHPStan\Analyser\NodeScopeResolver->lookForExpressionCallback(Object(PHPStan\Analyser\MutatingScope), Object(PhpParser\Node\Expr\PropertyFetch), Object(Closure))
    #10 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1928): PHPStan\Analyser\NodeScopeResolver->ensureNonNullability(Object(PHPStan\Analyser\MutatingScope), Object(PhpParser\Node\Expr\PropertyFetch))
    #11 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1460): PHPStan\Analyser\NodeScopeResolver->processExprNode(Object(PhpParser\Node\Expr\BinaryOp\Coalesce), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\ExpressionContext))
    #12 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(2716): PHPStan\Analyser\NodeScopeResolver->PHPStan\Analyser\{closure}(Object(PHPStan\Analyser\MutatingScope))
    #13 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(1468): PHPStan\Analyser\NodeScopeResolver->processAssignVar(Object(PHPStan\Analyser\MutatingScope), Object(PhpParser\Node\Expr\Variable), Object(PhpParser\Node\Expr\BinaryOp\Coalesce), Object(Closure), Object(PHPStan\Analyser\ExpressionContext), Object(Closure), true)
    #14 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(554): PHPStan\Analyser\NodeScopeResolver->processExprNode(Object(PhpParser\Node\Expr\Assign), Object(PHPStan\Analyser\MutatingScope), Object(Closure), Object(PHPStan\Analyser\ExpressionContext))
    #15 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(356): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Expression), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #16 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(710): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Foreach_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #17 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(356): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Foreach_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #18 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(710): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Foreach_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #19 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(356): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Foreach_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #20 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(517): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\ClassMethod), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #21 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(356): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\ClassMethod), Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
    #22 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(595): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Class_), Array, Object(PHPStan\Analyser\MutatingScope), Object(PHPStan\Node\ClassStatementsGatherer))
    #23 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(356): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Class_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #24 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(567): PHPStan\Analyser\NodeScopeResolver->processStmtNodes(Object(PhpParser\Node\Stmt\Namespace_), Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #25 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/NodeScopeResolver.php(326): PHPStan\Analyser\NodeScopeResolver->processStmtNode(Object(PhpParser\Node\Stmt\Namespace_), Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #26 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/FileAnalyser.php(175): PHPStan\Analyser\NodeScopeResolver->processNodes(Array, Object(PHPStan\Analyser\MutatingScope), Object(Closure))
    #27 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Analyser/Analyser.php(71): PHPStan\Analyser\FileAnalyser->analyseFile('/dev/app...', Array, Object(PHPStan\Rules\LazyRegistry), Object(PHPStan\Collectors\Registry), NULL)
    #28 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyserRunner.php(63): PHPStan\Analyser\Analyser->analyse(Array, Object(Closure), NULL, true, Array)
    #29 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(207): PHPStan\Command\AnalyserRunner->runAnalyser(Array, Array, Object(Closure), NULL, true, true, '/dev/app...', NULL, NULL, Object(_PHPStan_ff82193c2\Symfony\Component\Console\Input\ArgvInput))
    #30 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseApplication.php(101): PHPStan\Command\AnalyseApplication->runAnalyser(Array, Array, true, '/dev/app...', Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), Object(_PHPStan_ff82193c2\Symfony\Component\Console\Input\ArgvInput))
    #31 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php(168): PHPStan\Command\AnalyseApplication->analyse(Array, false, Object(PHPStan\Command\Symfony\SymfonyOutput), Object(PHPStan\Command\Symfony\SymfonyOutput), false, true, '/dev/app...', Array, Object(_PHPStan_ff82193c2\Symfony\Component\Console\Input\ArgvInput))
    #32 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php(259): PHPStan\Command\AnalyseCommand->execute(Object(_PHPStan_ff82193c2\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_ff82193c2\Symfony\Component\Console\Output\ConsoleOutput))
    #33 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(868): _PHPStan_ff82193c2\Symfony\Component\Console\Command\Command->run(Object(_PHPStan_ff82193c2\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_ff82193c2\Symfony\Component\Console\Output\ConsoleOutput))
    #34 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(259): _PHPStan_ff82193c2\Symfony\Component\Console\Application->doRunCommand(Object(PHPStan\Command\AnalyseCommand), Object(_PHPStan_ff82193c2\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_ff82193c2\Symfony\Component\Console\Output\ConsoleOutput))
    #35 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php(157): _PHPStan_ff82193c2\Symfony\Component\Console\Application->doRun(Object(_PHPStan_ff82193c2\Symfony\Component\Console\Input\ArgvInput), Object(_PHPStan_ff82193c2\Symfony\Component\Console\Output\ConsoleOutput))
    #36 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(124): _PHPStan_ff82193c2\Symfony\Component\Console\Application->run()
    #37 phar:///dev/app/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan(125): _PHPStan_ff82193c2\{closure}()
    #38 /dev/app/vendor/phpstan/phpstan/phpstan(8): require('phar:///dev/app...')
    #39 /dev/app/bin/phpstan(120): include('/dev/app...')
    #40 {main}
    

    I have this in my composer.json :

    ...
    "config": {
            "bin-dir": "bin",
            "preferred-install": {
                "*": "dist"
            },
            "sort-packages": true,
            "allow-plugins": {
                "phpstan/extension-installer": true,
                "symfony/flex": true,
                "symfony/runtime": true
            }
        },
    

    So the file vendor/knplabs/doctrine-behaviors/phpstan-extension.neon is already included (related to #516

    How can I fix it ?

    opened by Ciloe 1
  • Fallback to Translator's locale when there is no Request available

    Fallback to Translator's locale when there is no Request available

    When there is no Request available but a Translator instance is set, use it instead of returning null.

    We typically encountered this issue in Console commands: we set the current locale on the Translator and were expecting the translated entities to use it but they were falling back to the default locale.

    opened by sebb 0
  • Looking for a maintainer

    Looking for a maintainer

    Hello, everyone using this package :)

    I don't have time to maintain this package and give it the proper care it needs. I stepped up a few years ago when we used it at work and needed new PHP version support. Yet haven't used it since.

    I have another OS project I want to focus on, but I don't want to let this package be neglected.

    Saying that I'll be stepping down as maintainer and giving space someone to take over, who is actively using this package and has the will to grow it :hugs:

    opened by TomasVotruba 0
Releases(2.3.0)
  • 2.3.0(Aug 9, 2021)


    Min PHP 8.0

    PHP 7.3 is about to expire and PHP 7.4 is here for a while too. This release is bumping to PHP 8.0 as minimum version

    https://www.php.net/supported-versions.php

    image

    Source code(tar.gz)
    Source code(zip)
  • 2.2.0(Mar 8, 2021)


    Min PHP 7.3

    PHP 7.2 is not secure anymore, so this release is bumping to PHP 7.3 as minimum version

    image

    • See pull-request https://github.com/KnpLabs/DoctrineBehaviors/pull/617

    Travis to GitHub Actions

    Travis tests were actually not running for couple of months, as Travis does not support open-source for last ~3 months. Now we're up and runnin on GitHub Actions again :+1:

    • See pull-request https://github.com/KnpLabs/DoctrineBehaviors/pull/616
    Source code(tar.gz)
    Source code(zip)
  • v2.0.0(Jan 1, 2020)

  • 1.6.0(Nov 13, 2018)

    Changelog

    • [Translatable] Check trait usage for translation instead method check (will drop in v2 for interface)
    • [Tree] Add possibility to pass extra parameters in getTree
    • [Translatable] Do not persist new translations if empty
    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Oct 6, 2017)

  • 1.4.1(Sep 19, 2017)

  • v1.1.0(May 11, 2015)

  • v1.0.2(Sep 22, 2014)

    Commits on Jan 30, 2014 Aldo Chiecchia alch Parametrized translatable and translation Traits … f5132b9 Florian Klein docteurklein Merge pull request #89 from alch/parametrized-translation-traits … c6343d3 Commits on Feb 13, 2014 Jacek Siciarek siciarek issue Bug (typo+) in softDeletable doc #90 c9d45f5 Commits on Feb 28, 2014 Roman Marintšenko Inoryy Merge pull request #93 from siciarek/patch-1 … 1812ec0 Commits on Mar 23, 2014 gaydarov gaydarov ~ Separate trait methods from properties 1ff4891 gaydarov gaydarov ~ Separate trait methods and properties and allow parameterized traits e3c7997 Commits on May 26, 2014 bobvandevijver bobvandevijver Rename of parameter to comply with the rest of the parameters ca1b476 bobvandevijver bobvandevijver Adds a parameter for the fetch method used by doctrine for the … af4d28a Commits on May 27, 2014 bobvandevijver bobvandevijver Fixes the phpunit test. 8c26600 Florian Klein docteurklein Merge pull request #112 from bobvandevijver/fetchmode … f79d417 Commits on Jun 03, 2014 Florian Klein docteurklein Merge pull request #102 from gaydarov/master … e629e82 Commits on Jun 04, 2014 adrienrusso adrienrusso missing "%" for sluggable_trait argument 038a230 Florian Klein docteurklein Merge pull request #113 from adrienrusso/master … 8779e29 Commits on Jun 09, 2014 Tomáš Votruba TomasVotruba ClassAnalyzer::hasTrait returns false if not \ReflectionClass … f262a12 Commits on Jun 10, 2014 bobvandevijver bobvandevijver Merge branch 'master' into rename-param 83bca4e Florian Klein docteurklein Merge pull request #111 from bobvandevijver/rename-param … 4ec2236 Commits on Jun 17, 2014 Florian Klein docteurklein Merge pull request #114 from TomasVotruba/patch-1 … 3b9c1e4 Commits on Jun 29, 2014 Mondane Mondane Update README.md … 252ba7d Florian Klein docteurklein Merge pull request #119 from Mondane/patch-1 … 077b0f3 Commits on Jul 24, 2014 kimlai kimlai [Geocodable] Add a function to compute distances in meters. … a2b8dfc kimlai kimlai Replaced the DISTANCE function with the new DISTANCE_IN_METERS one. … 9d4b117 Florian Klein docteurklein Merge pull request #98 from kimlai/miles_kms … f2d424d Commits on Aug 23, 2014 akovalyov akovalyov Add doctrine default hints method mock 0feb265 Florian Klein docteurklein Merge pull request #126 from KnpLabs/fix/tests … f7f4ee0 Commits on Sep 17, 2014 Grégoire Paris greg0ire remove composer.lock from version control … 227d88e Grégoire Paris greg0ire install phpunit the bin folder … 3e92bc4 Grégoire Paris greg0ire Show how to easily run the test suite 359a800 Florian Klein docteurklein Merge pull request #131 from greg0ire/ease_contributions … 5fec068 Grégoire Paris greg0ire fix path 34a212a Florian Klein docteurklein Merge pull request #132 from greg0ire/ease_contributions … 87b7377 Grégoire Paris greg0ire use PSR-4 autoloading … 4846bf6 Florian Klein docteurklein Merge pull request #133 from greg0ire/psr-4 … 03ee008

    Source code(tar.gz)
    Source code(zip)
Owner
KNP Labs
Happy Awesome Developers
KNP Labs
Doctrine2 behavioral extensions, Translatable, Sluggable, Tree-NestedSet, Timestampable, Loggable, Sortable

Doctrine Behavioral Extensions This package contains extensions for Doctrine ORM and MongoDB ODM that offer new functionality or tools to use Doctrine

Doctrine Extensions 3.8k Jan 5, 2023
The BrowserKit component simulates the behavior of a web browser

BrowserKit Component The BrowserKit component simulates the behavior of a web browser, allowing you to make requests, click on links and submit forms

Symfony 2.7k Dec 29, 2022
Doctrine2 behavioral extensions, Translatable, Sluggable, Tree-NestedSet, Timestampable, Loggable, Sortable

Doctrine Behavioral Extensions This package contains extensions for Doctrine ORM and MongoDB ODM that offer new functionality or tools to use Doctrine

Doctrine Extensions 3.8k Jan 5, 2023
Doctrine2 behavioral extensions, Translatable, Sluggable, Tree-NestedSet, Timestampable, Loggable, Sortable

Doctrine Behavioral Extensions This package contains extensions for Doctrine ORM and MongoDB ODM that offer new functionality or tools to use Doctrine

Doctrine Extensions 3.8k Jan 5, 2023
A lightweight domain event pattern implementation for Doctrine2.

Knp Rad Domain Event A lightweight domain event pattern implementation for Doctrine2. Official maintainers: @Einenlum Installation With composer : $ c

KNP Labs 5 Sep 23, 2022
Experimental ActiveRecord layer on top of Doctrine2 using the Twig templating engine

This is an experiment for building ActiveRecord functionality on top of Doctrine2 using the Twig templating engine. Whether it is called Propel2 or not is irrelevant.

Francois Zaninotto 85 Dec 5, 2022
Doctrine2 behavioral extensions

SonataDoctrineExtensions Doctrine2 behavioral extensions Branch Github Actions Code Coverage 1.x 2.x Support For general support and questions, please

Sonata Project 263 Nov 28, 2022
Traits used primarily in the v6 package but also available as a helper package for applications

Phalcon Traits This package contains traits with methods that are used for Phalcon v6 onward. It can also be useful to others that want short snippets

The Phalcon PHP Framework 5 Oct 7, 2022
An opinionated support package for Laravel, that provides flexible and reusable helper methods and traits for commonly used functionality.

Support An opinionated support package for Laravel, that provides flexible and reusable helper methods and traits for commonly used functionality. Ins

Ian Olson 3 Apr 14, 2021
A collection of useful traits for working with PHP 8.1 Enums

A library of helper traits for working with PHP 8.1 enums This package provides a series of traits that allows you to: RestorableFromName Trait Create

Mark Baker 24 Nov 24, 2022
PSR Log - This repository holds all interfaces/classes/traits related to PSR-3.

PSR Log This repository holds all interfaces/classes/traits related to PSR-3. Note that this is not a logger of its own. It is merely an interface tha

PHP-FIG 10.1k Jan 3, 2023
This library can be used, among other things, to retrieve the classes, interfaces, traits, enums, functions and constants declared in a file

marijnvanwezel/reflection-file Library that allows reflection of files. This library can be used, among other things, to retrieve the classes, interfa

Marijn van Wezel 5 Apr 17, 2022
PHPStan rules for detecting usage of deprecated classes, methods, properties, constants and traits.

Rules for detecting usage of deprecated classes, methods, properties, constants and traits. PHPStan Installation To use this extension, require it in

PHPStan 247 Jan 2, 2023
This library provides a collection of native enum utilities (traits) which you almost always need in every PHP project.

This library provides a collection of native enum utilities (traits) which you almost always need in every PHP project.

DIVE 20 Nov 11, 2022
Package with small support traits and classes for the Laravel Eloquent models

Contains a set of traits for the eloquent model. In future can contain more set of classes/traits for the eloquent database.

Martin Kluska 3 Feb 10, 2022