I hereby claim:
- I am j7mbo on github.
- I am j7mbo (https://keybase.io/j7mbo) on keybase.
- I have a public key ASDbtkEn9HZOO_qCjM4QyDf0M0xl6ykUUXMoA4-U8XTXngo
To claim this, I am signing this object:
protected function build(ContainerBuilder $container) | |
{ | |
$container->addCompilerPass(new ControllersAsServices, PassConfig::TYPE_BEFORE_OPTIMIZATION, -1); | |
parent::build($container); | |
} |
<?php | |
namespace App; | |
use Symfony\Component\DependencyInjection\{Compiler\CompilerPassInterface, ContainerBuilder}; | |
class ControllersAsServices implements CompilerPassInterface | |
{ | |
public function process(ContainerBuilder $container) | |
{ |
#config/services.yaml | |
services: | |
_instanceof: | |
App\Contract\ControllerInterface: | |
tags: ['controller.service_arguments'] |
// Found some configuration with "controller.service_arguments" in its tags... | |
foreach ($container->findTaggedServiceIds($this->controllerTag, true) as $id => $tags) { | |
// Do all the rest of the dependency injection stuff... | |
} |
App\SomeOtherDirectory\Controller: | |
resource: '../src/SomeOtherDirectory/Controller' | |
tags: ['controller.service_arguments'] |
I hereby claim:
To claim this, I am signing this object:
// Service Package | |
type Service interface { | |
CountNumUsers() int | |
} | |
type service struct { | |
Repository *UserRepository | |
} | |
func (s service) CountNumUsers() int { | |
return s.Repository.Count() | |
} |
type Service struct { | |
Repository *UserRepository | |
} | |
func (s *Service) CountNumUsers() int { | |
if s == nil || s.Repository == nil { | |
return 0 | |
} | |
return s.Repository.Count() | |
} |
type Service struct { | |
Repository *UserRepository | |
} | |
func (s Service) CountNumUsers() int { | |
return s.Repository.Count() | |
} | |
s := Service{} | |
s.CountNumUsers() // SIGSEGV nil pointer |
func main() { | |
manager := make(chan struct{}) | |
_ = publisher(manager) | |
time.Sleep(10 * time.Second) | |
close(manager) | |
} | |
func publisher(manager chan struct{}) chan<- struct{} { | |
pubch := make(chan struct{}) |