├── .github
├── CODEOWNERS
├── dependabot.yml
└── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
├── tests
├── Fixtures
│ ├── Symfony
│ │ ├── app
│ │ │ ├── data
│ │ │ │ └── .gitkeep
│ │ │ ├── .gitignore
│ │ │ ├── public
│ │ │ │ ├── robots.txt
│ │ │ │ └── favicon.ico
│ │ │ ├── config
│ │ │ │ ├── api
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── static
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── prod
│ │ │ │ │ └── parameters.yaml
│ │ │ │ ├── profiler
│ │ │ │ │ ├── framework.yaml
│ │ │ │ │ ├── web_profiler.yaml
│ │ │ │ │ └── routing
│ │ │ │ │ │ └── routing.yaml
│ │ │ │ ├── reactor
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── twig.yaml
│ │ │ │ ├── auto
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── blackfire_monitoring
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── exception_handler_symfony
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── cov
│ │ │ │ │ ├── swoole.yaml
│ │ │ │ │ └── parameters.yaml
│ │ │ │ ├── tideways
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── doctrine_migrations.yaml
│ │ │ │ ├── framework.yaml
│ │ │ │ ├── mime
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── access_log
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── non_reloadable_files
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── exception_handler_json
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── session
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── coroutines
│ │ │ │ │ └── framework.yaml
│ │ │ │ ├── coroutines_blackfire
│ │ │ │ │ └── framework.yaml
│ │ │ │ ├── swoole.yaml
│ │ │ │ ├── messenger
│ │ │ │ │ └── swoole.yaml
│ │ │ │ ├── monolog.php
│ │ │ │ ├── exception_handler_custom
│ │ │ │ │ └── swoole.yaml
│ │ │ │ └── doctrine.yaml
│ │ │ ├── routing.yml
│ │ │ ├── templates
│ │ │ │ └── base.html.twig
│ │ │ └── console
│ │ ├── TestBundle
│ │ │ ├── Resources
│ │ │ │ └── mapping
│ │ │ │ │ └── .gitkeep
│ │ │ ├── Message
│ │ │ │ ├── RunDummy.php
│ │ │ │ ├── CreateFileMessage.php
│ │ │ │ └── SleepAndAppend.php
│ │ │ ├── Service
│ │ │ │ ├── NonSharedExample.php
│ │ │ │ ├── ShouldBeProxified2.php
│ │ │ │ ├── RepositoryFactory.php
│ │ │ │ ├── UnusedServiceToRemove.php
│ │ │ │ ├── DummyService.php
│ │ │ │ ├── SleepingCounter.php
│ │ │ │ ├── AlwaysReset.php
│ │ │ │ ├── AlwaysResetSafe.php
│ │ │ │ ├── NoAutowiring
│ │ │ │ │ └── ResetCountingRegistry.php
│ │ │ │ ├── ShouldBeProxified.php
│ │ │ │ ├── InMemoryRepository.php
│ │ │ │ ├── DecorationTestDummyService.php
│ │ │ │ ├── AdvancedDoctrineUsage.php
│ │ │ │ └── SleepingCounterChecker.php
│ │ │ ├── TestBundle.php
│ │ │ ├── Controller
│ │ │ │ ├── LogController.php
│ │ │ │ ├── ReplacedContentTestController.php.tmpl
│ │ │ │ ├── ReplacedContentTestController.php
│ │ │ │ ├── TidewaysController.php
│ │ │ │ ├── BlackfireController.php
│ │ │ │ ├── IndexController.php
│ │ │ │ ├── ThrowableController.php
│ │ │ │ ├── TwigController.php
│ │ │ │ ├── TaskController.php
│ │ │ │ ├── EventsController.php
│ │ │ │ └── SessionController.php
│ │ │ ├── Resetter
│ │ │ │ └── CountingResetter.php
│ │ │ ├── Logging
│ │ │ │ └── InMemoryLogger.php
│ │ │ ├── DependencyInjection
│ │ │ │ └── CompilerPass
│ │ │ │ │ ├── OverrideDoctrineCompilerPass.php
│ │ │ │ │ └── SleepingCounterCompileProcessor.php
│ │ │ ├── ExceptionHandler
│ │ │ │ └── TestCustomExceptionHandler.php
│ │ │ ├── MessageHandler
│ │ │ │ ├── CreateFileMessageHandler.php
│ │ │ │ ├── RunDummyHandler.php
│ │ │ │ └── SleepAndAppendHandler.php
│ │ │ ├── Entity
│ │ │ │ ├── AdvancedTest.php
│ │ │ │ └── Test.php
│ │ │ └── Migrations
│ │ │ │ ├── Version20220920150015.php
│ │ │ │ └── Version20230117125728.php
│ │ ├── TestCacheKernel.php
│ │ └── CoverageBundle
│ │ │ ├── EventListeners
│ │ │ ├── CoverageStartOnConsoleCommandEventListener.php
│ │ │ └── CoverageFinishOnConsoleTerminate.php
│ │ │ ├── ServerLifecycle
│ │ │ ├── CoverageStartOnServerStart.php
│ │ │ ├── CoverageStartOnServerManagerStart.php
│ │ │ ├── CoverageStartOnServerWorkerStart.php
│ │ │ ├── CoverageFinishOnServerShutdown.php
│ │ │ └── CoverageStartOnServerManagerStop.php
│ │ │ ├── TaskHandler
│ │ │ └── CodeCoverageTaskHandler.php
│ │ │ └── RequestHandler
│ │ │ └── CodeCoverageRequestHandler.php
│ └── resources
│ │ └── .gitignore
├── k6
│ └── libs
│ │ └── shim
│ │ ├── urijs.js
│ │ ├── lodash.js
│ │ ├── cheerio.js
│ │ ├── crypto-js.js
│ │ ├── full.js
│ │ ├── expect.js
│ │ ├── xml2Json.js
│ │ └── jsonSchema.js
├── Unit
│ ├── Component
│ │ └── AtomicCounter
│ │ │ ├── AtomicStub.php
│ │ │ ├── AtomicSpy.php
│ │ │ └── AtomicCounterTest.php
│ ├── Server
│ │ ├── Configurator
│ │ │ ├── ConfiguratorDummy.php
│ │ │ ├── ConfiguratorSpy.php
│ │ │ ├── WithRequestHandlerTest.php
│ │ │ ├── WithWorkerExitHandlerTest.php
│ │ │ └── WithWorkerStopHandlerTest.php
│ │ ├── Runtime
│ │ │ └── HMR
│ │ │ │ ├── HMRSpy.php
│ │ │ │ └── NonReloadableFilesTest.php
│ │ ├── RequestHandler
│ │ │ └── RequestHandlerDummy.php
│ │ ├── IntMother.php
│ │ └── Php8
│ │ │ └── SwooleServerMock.php
│ ├── Bridge
│ │ └── Symfony
│ │ │ ├── ErrorHandler
│ │ │ └── ThrowableHandlerFactoryTest.php
│ │ │ └── HttpFoundation
│ │ │ └── SetRequestRuntimeConfigurationTest.php
│ ├── Client
│ │ └── HttpClientTest.php
│ └── Functions
│ │ ├── TestObject.php
│ │ └── GetObjectPropertyTest.php
├── Feature
│ ├── BlackfireProfilerRegisteredTest.php
│ └── BlackfireMonitoringRegisteredTest.php
└── run-feature-tests-code-coverage.sh
├── docs
├── img
│ └── blackfire-io.png
└── swoole-blackfire.md
├── src
├── Server
│ ├── Session
│ │ ├── Exception
│ │ │ ├── SessionExceptionInterface.php
│ │ │ ├── LogicException.php
│ │ │ └── RuntimeException.php
│ │ └── StorageInterface.php
│ ├── Middleware
│ │ ├── MiddlewareFactory.php
│ │ └── Middleware.php
│ ├── Configurator
│ │ ├── ConfiguratorInterface.php
│ │ ├── WithRequestHandler.php
│ │ ├── WithWorkerStartHandler.php
│ │ ├── WithServerShutdownHandler.php
│ │ ├── WithServerManagerStopHandler.php
│ │ ├── WithServerManagerStartHandler.php
│ │ ├── WithWorkerExitHandler.php
│ │ ├── WithWorkerStopHandler.php
│ │ ├── WithWorkerErrorHandler.php
│ │ ├── CallableChainConfigurator.php
│ │ ├── WithTaskHandler.php
│ │ ├── CallableChainConfiguratorFactory.php
│ │ ├── WithTaskFinishedHandler.php
│ │ ├── WithServerStartHandler.php
│ │ └── WithHttpServerConfiguration.php
│ ├── TaskHandler
│ │ ├── TaskHandlerInterface.php
│ │ ├── NoOpTaskHandler.php
│ │ ├── NoOpTaskFinishedHandler.php
│ │ └── TaskFinishedHandlerInterface.php
│ ├── LifecycleHandler
│ │ ├── ServerStartHandlerInterface.php
│ │ ├── ServerShutdownHandlerInterface.php
│ │ ├── NoOpServerStartHandler.php
│ │ ├── NoOpServerShutdownHandler.php
│ │ ├── NoOpServerManagerStopHandler.php
│ │ ├── NoOpServerManagerStartHandler.php
│ │ ├── ServerManagerStopHandlerInterface.php
│ │ ├── ServerManagerStartHandlerInterface.php
│ │ └── SigIntHandler.php
│ ├── Runtime
│ │ ├── HMR
│ │ │ └── HotModuleReloaderInterface.php
│ │ ├── BootableInterface.php
│ │ ├── CallableBootManager.php
│ │ └── CallableBootManagerFactory.php
│ ├── Exception
│ │ ├── NotRunningException.php
│ │ ├── UninitializedException.php
│ │ ├── IllegalInitializationException.php
│ │ ├── PortUnavailableException.php
│ │ └── UnexpectedPortException.php
│ ├── RequestHandler
│ │ ├── ExceptionHandler
│ │ │ ├── ExceptionHandlerInterface.php
│ │ │ ├── ProductionExceptionHandler.php
│ │ │ └── JsonExceptionHandler.php
│ │ ├── RequestHandlerInterface.php
│ │ └── ExceptionRequestHandler.php
│ ├── WorkerHandler
│ │ ├── NoOpWorkerErrorHandler.php
│ │ ├── NoOpWorkerExitHandler.php
│ │ ├── NoOpWorkerStartHandler.php
│ │ ├── NoOpWorkerStopHandler.php
│ │ ├── WorkerExitHandlerInterface.php
│ │ ├── WorkerStopHandlerInterface.php
│ │ ├── WorkerErrorHandlerInterface.php
│ │ ├── WorkerStartHandlerInterface.php
│ │ └── HMRWorkerStartHandler.php
│ └── Api
│ │ ├── ApiServerInterface.php
│ │ ├── ApiServerClientFactory.php
│ │ ├── WithApiServerConfiguration.php
│ │ └── ApiServerClient.php
├── Component
│ ├── Locking
│ │ ├── MutexFactory.php
│ │ ├── Mutex.php
│ │ ├── Channel
│ │ │ └── ChannelMutexFactory.php
│ │ ├── FirstTimeOnly
│ │ │ └── FirstTimeOnlyMutexFactory.php
│ │ └── RecursiveOwner
│ │ │ └── RecursiveOwnerMutexFactory.php
│ └── AtomicCounter.php
├── Bridge
│ ├── Symfony
│ │ ├── Container
│ │ │ ├── Resetter.php
│ │ │ ├── StabilityChecker.php
│ │ │ ├── ServicePool
│ │ │ │ ├── ServicePool.php
│ │ │ │ ├── ServicePoolContainer.php
│ │ │ │ └── UnmanagedFactoryServicePool.php
│ │ │ ├── SimpleResetter.php
│ │ │ ├── Modifier
│ │ │ │ └── Builder
│ │ │ │ │ └── Builder.php
│ │ │ ├── UsageBeforeInitialization.php
│ │ │ └── Proxy
│ │ │ │ ├── FileLocatorFactory.php
│ │ │ │ ├── ContextualProxy.php
│ │ │ │ ├── ProxyDirectoryHandler.php
│ │ │ │ ├── Instantiator.php
│ │ │ │ └── Generation
│ │ │ │ ├── MethodForwarderBuilder.php
│ │ │ │ └── MethodGenerator
│ │ │ │ └── GetWrappedServicePoolValue.php
│ │ ├── HttpFoundation
│ │ │ ├── RequestFactoryInterface.php
│ │ │ ├── ResponseProcessorInterface.php
│ │ │ ├── ResponseProcessorInjectorInterface.php
│ │ │ ├── ResponseProcessor.php
│ │ │ ├── NoOpStreamedResponseProcessor.php
│ │ │ ├── SetRequestRuntimeConfiguration.php
│ │ │ ├── ResponseProcessorInjector.php
│ │ │ ├── StreamedResponseProcessor.php
│ │ │ ├── AccessLogOnKernelTerminate.php
│ │ │ ├── CloudFrontRequestFactory.php
│ │ │ ├── SwooleRequestResponseContextManager.php
│ │ │ └── RequestFactory.php
│ │ ├── HttpKernel
│ │ │ ├── KernelPoolInterface.php
│ │ │ ├── SimpleKernelPool.php
│ │ │ ├── CoroutineKernelPool.php
│ │ │ └── ContextReleasingHttpKernelRequestHandler.php
│ │ ├── Bundle
│ │ │ ├── DependencyInjection
│ │ │ │ └── CompilerPass
│ │ │ │ │ └── StatefulServices
│ │ │ │ │ ├── CompileProcessor.php
│ │ │ │ │ ├── SafeStatefulServiceTag.php
│ │ │ │ │ ├── NonSharedSvcPoolConfigurator.php
│ │ │ │ │ ├── StatefulServiceTag.php
│ │ │ │ │ └── FinalClassesProcessor.php
│ │ │ ├── Command
│ │ │ │ ├── ServerRunCommand.php
│ │ │ │ └── ParametersHelperTrait.php
│ │ │ ├── Exception
│ │ │ │ ├── CouldNotCreatePidFileException.php
│ │ │ │ └── PidFileNotAccessibleException.php
│ │ │ └── EventDispatcher
│ │ │ │ ├── EventDispatchingServerStartHandler.php
│ │ │ │ ├── EventDispatchingWorkerErrorHandler.php
│ │ │ │ ├── EventDispatchingWorkerExitHandler.php
│ │ │ │ ├── EventDispatchingWorkerStopHandler.php
│ │ │ │ └── EventDispatchingWorkerStartHandler.php
│ │ ├── Event
│ │ │ ├── ServerStartedEvent.php
│ │ │ ├── RequestWithSessionFinishedEvent.php
│ │ │ ├── WorkerErrorEvent.php
│ │ │ ├── WorkerExitedEvent.php
│ │ │ ├── WorkerStartedEvent.php
│ │ │ └── WorkerStoppedEvent.php
│ │ ├── ErrorHandler
│ │ │ ├── ThrowableHandlerFactory.php
│ │ │ ├── ExceptionHandlerFactory.php
│ │ │ ├── ErrorResponder.php
│ │ │ └── ResponseDelayingExceptionHandler.php
│ │ └── Messenger
│ │ │ ├── Exception
│ │ │ └── ReceiverNotAvailableException.php
│ │ │ ├── ContextReleasingTransportHandler.php
│ │ │ ├── ServiceResettingTransportHandler.php
│ │ │ ├── SwooleServerTaskReceiver.php
│ │ │ ├── ExceptionLoggingTransportHandler.php
│ │ │ ├── SwooleServerTaskTransportHandler.php
│ │ │ ├── SwooleServerTaskSender.php
│ │ │ ├── SwooleServerTaskTransportFactory.php
│ │ │ └── SwooleServerTaskTransport.php
│ ├── Log
│ │ └── AccessLogFormatterInterface.php
│ ├── Tideways
│ │ └── Apm
│ │ │ ├── WithApm.php
│ │ │ ├── TidewaysMiddlewareFactory.php
│ │ │ ├── Apm.php
│ │ │ └── ProfilingMiddleware.php
│ ├── Upscale
│ │ └── Blackfire
│ │ │ ├── Profiling
│ │ │ ├── WithProfiler.php
│ │ │ └── ProfilerActivator.php
│ │ │ └── Monitoring
│ │ │ ├── WithApm.php
│ │ │ ├── BlackfireMiddlewareFactory.php
│ │ │ ├── Apm.php
│ │ │ └── MonitoringMiddleware.php
│ └── Doctrine
│ │ ├── ORM
│ │ ├── EntityManagerResetter.php
│ │ └── EntityManagerStabilityChecker.php
│ │ ├── ServicePooledRepositoryFactory.php
│ │ └── DBAL
│ │ └── ConnectionKeepAliveResetter.php
├── functions_include.php
└── Client
│ ├── Exception
│ ├── MissingContentTypeException.php
│ ├── UnsupportedHttpMethodException.php
│ ├── UnsupportedContentTypeException.php
│ └── ClientConnectionErrorException.php
│ └── Http.php
├── .gitignore
├── .dockerignore
├── mutagen.yml
├── .codecov.yml
├── .editorconfig
├── commitlint.config.js
├── Makefile
├── phpunit.xml
├── phpstan.neon.dist
├── phpstan.tests.neon
├── .codeclimate.yml
└── LICENSE
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @Rastusik
2 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/data/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/.gitignore:
--------------------------------------------------------------------------------
1 | /var
2 |
--------------------------------------------------------------------------------
/tests/Fixtures/resources/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 | !.gitignore
3 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Resources/mapping/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/public/robots.txt:
--------------------------------------------------------------------------------
1 | User-agent: *
2 | Disallow: /
3 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/api/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | api: true
4 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/static/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | static: default
4 |
--------------------------------------------------------------------------------
/docs/img/blackfire-io.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pixelfederation/swoole-bundle/HEAD/docs/img/blackfire-io.png
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/prod/parameters.yaml:
--------------------------------------------------------------------------------
1 | parameters:
2 | container.dumper.inline_factories: true
3 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/profiler/framework.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | profiler: { only_exceptions: false }
3 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/reactor/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | running_mode: reactor
4 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/routing.yml:
--------------------------------------------------------------------------------
1 | controller:
2 | resource: '@TestBundle/Controller'
3 | type: annotation
4 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/twig.yaml:
--------------------------------------------------------------------------------
1 | twig:
2 | debug: '%kernel.debug%'
3 | strict_variables: '%kernel.debug%'
4 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/profiler/web_profiler.yaml:
--------------------------------------------------------------------------------
1 | web_profiler:
2 | toolbar: true
3 | intercept_redirects: false
4 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/auto/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | static: auto
4 | hmr:
5 | enabled: auto
6 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/blackfire_monitoring/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | services:
4 | blackfire_monitoring: true
5 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/exception_handler_symfony/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | exception_handler:
4 | type: symfony
5 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pixelfederation/swoole-bundle/HEAD/tests/Fixtures/Symfony/app/public/favicon.ico
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/cov/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | settings:
4 | worker_count: 1
5 | reactor_count: 1
6 |
--------------------------------------------------------------------------------
/tests/k6/libs/shim/urijs.js:
--------------------------------------------------------------------------------
1 | /* global postman */
2 |
3 | import URI from '../urijs.js';
4 |
5 | const Extend = Symbol.for('extend');
6 |
7 | postman[Extend].module.urijs = URI;
8 |
--------------------------------------------------------------------------------
/tests/k6/libs/shim/lodash.js:
--------------------------------------------------------------------------------
1 | /* global postman */
2 |
3 | import lodash from '../lodash.js';
4 |
5 | const Extend = Symbol.for('extend');
6 |
7 | postman[Extend].module.lodash = lodash;
8 |
--------------------------------------------------------------------------------
/tests/k6/libs/shim/cheerio.js:
--------------------------------------------------------------------------------
1 | /* global postman */
2 |
3 | import cheerio from '../cheerio.js';
4 |
5 | const Extend = Symbol.for('extend');
6 |
7 | postman[Extend].module.cheerio = cheerio;
8 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/tideways/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | services:
4 | tideways_apm:
5 | enabled: true
6 | service_name: 'swoole_bundle_test'
7 |
--------------------------------------------------------------------------------
/tests/k6/libs/shim/crypto-js.js:
--------------------------------------------------------------------------------
1 | /* global postman */
2 |
3 | import cryptoJs from '../crypto-js.js';
4 |
5 | const Extend = Symbol.for('extend');
6 |
7 | postman[Extend].module['crypto-js'] = cryptoJs;
8 |
--------------------------------------------------------------------------------
/tests/k6/libs/shim/full.js:
--------------------------------------------------------------------------------
1 | import './core';
2 | import './cheerio';
3 | import './crypto-js.js';
4 | import './expect.js';
5 | import './jsonSchema.js';
6 | import './lodash.js';
7 | import './xml2Json';
8 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/doctrine_migrations.yaml:
--------------------------------------------------------------------------------
1 | doctrine_migrations:
2 | migrations_paths:
3 | TestBundleDoctrineMigrations: '%kernel.project_dir%/../TestBundle/Migrations'
4 | transactional: false
5 |
--------------------------------------------------------------------------------
/src/Server/Session/Exception/SessionExceptionInterface.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Welcome!
6 |
7 |
8 | Welcome to Swoole Server
9 |
10 |
11 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/framework.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | secret: ThisIsVeryNotSecret!
3 | default_locale: en
4 | php_errors:
5 | log: true
6 | test: ~
7 | session:
8 | enabled: false
9 | router:
10 | utf8: true
11 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/mime/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | static:
4 | strategy: 'advanced'
5 | public_dir: '%kernel.project_dir%/public'
6 | mime_types:
7 | txt: 'text/html'
8 |
--------------------------------------------------------------------------------
/src/Bridge/Log/AccessLogFormatterInterface.php:
--------------------------------------------------------------------------------
1 | {
6 | if (err) {
7 | throw err;
8 | }
9 | json = result;
10 | });
11 | return json;
12 | }
13 |
14 | global.xml2Json = xml2Json;
15 |
--------------------------------------------------------------------------------
/mutagen.yml:
--------------------------------------------------------------------------------
1 | sync:
2 | defaults:
3 | ignore:
4 | vcs: true
5 | paths:
6 | - .DS_Store # macOS files
7 | - .idea
8 | permissions:
9 | defaultFileMode: 644
10 | defaultDirectoryMode: 755
11 | swoolebundle:
12 | alpha: "."
13 | beta: "docker://app@swoole-bundle-cli-80/usr/src/app"
14 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Service/RepositoryFactory.php:
--------------------------------------------------------------------------------
1 | {$this->resetFn}();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Server/Exception/UninitializedException.php:
--------------------------------------------------------------------------------
1 | value;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/Command/ServerRunCommand.php:
--------------------------------------------------------------------------------
1 | setDescription('Run Swoole HTTP server.');
15 |
16 | parent::configure();
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/Exception/CouldNotCreatePidFileException.php:
--------------------------------------------------------------------------------
1 | counter;
15 | }
16 |
17 | public function getCounter(): int
18 | {
19 | return $this->counter;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/exception_handler_json/swoole.yaml:
--------------------------------------------------------------------------------
1 | swoole:
2 | http_server:
3 | exception_handler:
4 | type: json
5 | verbosity: default
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Container/Modifier/Builder/Builder.php:
--------------------------------------------------------------------------------
1 | tick = true;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/coroutines/framework.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | cache:
3 | app: cache.adapter.array
4 | system: cache.adapter.array
5 |
6 | messenger:
7 | enabled: true
8 | reset_on_message: true # do not forget this or an equivalent! :)
9 | transports:
10 | swoole: swoole://task
11 | routing:
12 | 'K911\Swoole\Tests\Fixtures\Symfony\TestBundle\Message\SleepAndAppend': swoole
13 | 'K911\Swoole\Tests\Fixtures\Symfony\TestBundle\Message\RunDummy': swoole
14 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/coroutines_blackfire/framework.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | cache:
3 | app: cache.adapter.array
4 | system: cache.adapter.array
5 |
6 | messenger:
7 | enabled: true
8 | reset_on_message: true # do not forget this or an equivalent! :)
9 | transports:
10 | swoole: swoole://task
11 | routing:
12 | 'K911\Swoole\Tests\Fixtures\Symfony\TestBundle\Message\SleepAndAppend': swoole
13 | 'K911\Swoole\Tests\Fixtures\Symfony\TestBundle\Message\RunDummy': swoole
14 |
--------------------------------------------------------------------------------
/tests/Unit/Server/RequestHandler/RequestHandlerDummy.php:
--------------------------------------------------------------------------------
1 | server;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/commitlint.config.js:
--------------------------------------------------------------------------------
1 | // https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-rules.md
2 | module.exports = {
3 | extends: ['@commitlint/config-conventional'],
4 | rules: {
5 | 'body-max-line-length': [1, 'always', 500],
6 | 'footer-max-line-length': [1, 'always', 200],
7 | 'header-max-length': [1, 'always', 100],
8 | 'scope-case': [2, 'always', ['lower-case', 'kebab-case']],
9 | 'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']]
10 | }
11 | };
12 |
--------------------------------------------------------------------------------
/tests/Unit/Server/Configurator/ConfiguratorSpy.php:
--------------------------------------------------------------------------------
1 | configured = true;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Service/AlwaysReset.php:
--------------------------------------------------------------------------------
1 | wasReset = true;
16 | }
17 |
18 | public function getWasReset(): bool
19 | {
20 | return $this->wasReset;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Component/Locking/FirstTimeOnly/FirstTimeOnlyMutexFactory.php:
--------------------------------------------------------------------------------
1 | wrapped->newMutex());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Component/Locking/RecursiveOwner/RecursiveOwnerMutexFactory.php:
--------------------------------------------------------------------------------
1 | wrapped->newMutex());
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Bridge/Tideways/Apm/WithApm.php:
--------------------------------------------------------------------------------
1 | apm->instrument($server);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Service/AlwaysResetSafe.php:
--------------------------------------------------------------------------------
1 | wasReset = true;
16 | }
17 |
18 | public function getWasReset(): bool
19 | {
20 | return $this->wasReset;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/Unit/Component/AtomicCounter/AtomicSpy.php:
--------------------------------------------------------------------------------
1 | incremented = 1 === $value;
21 |
22 | return $this->incremented ? 1 : 0;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Event/RequestWithSessionFinishedEvent.php:
--------------------------------------------------------------------------------
1 | sessionId;
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/HttpFoundation/ResponseProcessorInjectorInterface.php:
--------------------------------------------------------------------------------
1 | profiler);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Client/Exception/UnsupportedHttpMethodException.php:
--------------------------------------------------------------------------------
1 | fileName;
18 | }
19 |
20 | public function content(): string
21 | {
22 | return $this->content;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/swoole.yaml:
--------------------------------------------------------------------------------
1 | parameters:
2 | env(PORT): 9501
3 | env(HOST): 0.0.0.0
4 | env(TRUSTED_HOSTS): localhost,127.0.0.1,docker.stack
5 | env(TRUSTED_PROXIES): '*,192.168.0.0/16'
6 | env(WORKER_COUNT): 6
7 | env(REACTOR_COUNT): 3
8 |
9 | swoole:
10 | http_server:
11 | port: '%env(int:PORT)%'
12 | host: '%env(HOST)%'
13 | trusted_hosts: '%env(TRUSTED_HOSTS)%'
14 | trusted_proxies: '%env(TRUSTED_PROXIES)%'
15 | settings:
16 | worker_count: '%env(int:WORKER_COUNT)%'
17 | reactor_count: '%env(int:REACTOR_COUNT)%'
18 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/ErrorHandler/ThrowableHandlerFactory.php:
--------------------------------------------------------------------------------
1 | getMethod('handleThrowable');
15 | $method->setAccessible(true);
16 |
17 | return $method;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | .PHONY: clean/coverage
2 | clean/coverage:
3 | @rm -rf cov/*
4 | @rm -rf clover.xml
5 |
6 | .PHONY: clean/tests/resources
7 | clean/tests/resources:
8 | @rm -rf tests/Fixtures/resources/*.pid
9 | @rm -rf tests/Fixtures/resources/*.txt
10 |
11 | .PHONY: clean/fixtures/cache
12 | clean/fixtures/cache:
13 | @rm -rf tests/Fixtures/Symfony/app/var/cache/*
14 |
15 | .PHONY: clean/fixtures/logs
16 | clean/fixtures/logs:
17 | @rm -rf tests/Fixtures/Symfony/app/var/log/*
18 |
19 | .PHONY: clean
20 | clean: clean/coverage clean/fixtures/cache clean/fixtures/logs clean/tests/resources
21 |
--------------------------------------------------------------------------------
/src/Client/Exception/UnsupportedContentTypeException.php:
--------------------------------------------------------------------------------
1 | finish() is called.
11 | *
12 | * @see https://www.swoole.co.uk/docs/modules/swoole-server/callback-functions#onfinish
13 | */
14 | interface TaskFinishedHandlerInterface
15 | {
16 | /**
17 | * @param mixed $data
18 | */
19 | public function handle(Server $server, int $taskId, $data): void;
20 | }
21 |
--------------------------------------------------------------------------------
/src/Component/AtomicCounter.php:
--------------------------------------------------------------------------------
1 | counter->add(1);
18 | }
19 |
20 | public function get(): int
21 | {
22 | return $this->counter->get();
23 | }
24 |
25 | public static function fromZero(): self
26 | {
27 | return new self(new Atomic(0));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Service/NoAutowiring/ResetCountingRegistry.php:
--------------------------------------------------------------------------------
1 | resetCount;
16 | parent::reset();
17 | }
18 |
19 | public function getResetCount(): int
20 | {
21 | return $this->resetCount;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/DependencyInjection/CompilerPass/StatefulServices/SafeStatefulServiceTag.php:
--------------------------------------------------------------------------------
1 | tag['reset_on_each_request'] ?? null;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/tests/k6/libs/shim/jsonSchema.js:
--------------------------------------------------------------------------------
1 | /* global postman */
2 |
3 | import Ajv from '../ajv.js';
4 |
5 | const Extend = Symbol.for('extend');
6 |
7 | Object.assign(postman[Extend], {
8 | jsonSchema(store, schema, options) {
9 | const ajv = new Ajv(options);
10 | const validate = ajv.compile(schema);
11 | store.test.push(response => validate(store.response.body.json));
12 | },
13 |
14 | jsonSchemaNot(store, schema, options) {
15 | const ajv = new Ajv(options);
16 | const validate = ajv.compile(schema);
17 | store.test.push(response => !validate(store.response.body.json));
18 | },
19 | });
20 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | src/
7 |
8 |
9 |
10 |
11 | tests/Unit
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Service/ShouldBeProxified.php:
--------------------------------------------------------------------------------
1 | dummy->getWasReset();
18 | }
19 |
20 | public function getSafeDummy(): AlwaysResetSafe
21 | {
22 | return $this->safeDummy;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Server/Api/ApiServerInterface.php:
--------------------------------------------------------------------------------
1 | profilerActivator->activate($server);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithRequestHandler.php:
--------------------------------------------------------------------------------
1 | on('request', [$this->requestHandler, 'handle']);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Bridge/Upscale/Blackfire/Monitoring/WithApm.php:
--------------------------------------------------------------------------------
1 | apm = $apm;
17 | }
18 |
19 | /**
20 | * {@inheritdoc}
21 | */
22 | public function configure(Server $server): void
23 | {
24 | $this->apm->instrument($server);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithWorkerStartHandler.php:
--------------------------------------------------------------------------------
1 | on('WorkerStart', [$this->handler, 'handle']);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Bridge/Doctrine/ORM/EntityManagerResetter.php:
--------------------------------------------------------------------------------
1 | clear();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithServerShutdownHandler.php:
--------------------------------------------------------------------------------
1 | on('shutdown', [$this->handler, 'handle']);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Container/Proxy/FileLocatorFactory.php:
--------------------------------------------------------------------------------
1 | directoryHandler->ensureProxyDirExists();
19 |
20 | return new FileLocator($proxiesDirectory);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Bridge/Tideways/Apm/Apm.php:
--------------------------------------------------------------------------------
1 | injector->injectMiddlevare($server, $this->middlewareFactory);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithServerManagerStopHandler.php:
--------------------------------------------------------------------------------
1 | on('ManagerStop', [$this->handler, 'handle']);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "composer"
9 | directory: "/"
10 | schedule:
11 | interval: "daily"
12 | target-branch: "develop"
13 | ignore:
14 | - dependency-name: "*"
15 | update-types: [ "version-update:semver-major" ]
16 | open-pull-requests-limit: 1
17 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithServerManagerStartHandler.php:
--------------------------------------------------------------------------------
1 | on('ManagerStart', [$this->handler, 'handle']);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/tests/Unit/Bridge/Symfony/ErrorHandler/ThrowableHandlerFactoryTest.php:
--------------------------------------------------------------------------------
1 | getName();
16 |
17 | self::assertTrue('handleThrowable' === $methodName || 'handleException' === $methodName);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Controller/LogController.php:
--------------------------------------------------------------------------------
1 | server;
23 | }
24 |
25 | public function getWorkerId(): int
26 | {
27 | return $this->workerId;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Event/WorkerExitedEvent.php:
--------------------------------------------------------------------------------
1 | server;
23 | }
24 |
25 | public function getWorkerId(): int
26 | {
27 | return $this->workerId;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Event/WorkerStartedEvent.php:
--------------------------------------------------------------------------------
1 | server;
23 | }
24 |
25 | public function getWorkerId(): int
26 | {
27 | return $this->workerId;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Event/WorkerStoppedEvent.php:
--------------------------------------------------------------------------------
1 | server;
23 | }
24 |
25 | public function getWorkerId(): int
26 | {
27 | return $this->workerId;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Server/WorkerHandler/WorkerExitHandlerInterface.php:
--------------------------------------------------------------------------------
1 | taskworker) {
19 | * echo "Hello from task worker process";
20 | * }
21 | * ```
22 | */
23 | public function handle(Server $worker, int $workerId): void;
24 | }
25 |
--------------------------------------------------------------------------------
/src/Server/WorkerHandler/WorkerStopHandlerInterface.php:
--------------------------------------------------------------------------------
1 | taskworker) {
19 | * echo "Hello from task worker process";
20 | * }
21 | * ```
22 | */
23 | public function handle(Server $worker, int $workerId): void;
24 | }
25 |
--------------------------------------------------------------------------------
/tests/Unit/Server/Runtime/HMR/NonReloadableFilesTest.php:
--------------------------------------------------------------------------------
1 | createMock(Filesystem::class);
16 | $fsmock->expects($this->exactly(2))->method('dumpFile')->withAnyParameters();
17 | $nrf = new NonReloadableFiles('cache', '/var/www', $fsmock);
18 | $nrf->boot();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/phpstan.neon.dist:
--------------------------------------------------------------------------------
1 | parameters:
2 | inferPrivatePropertyTypeFromConstructor: true
3 | checkMissingIterableValueType: false
4 | excludePaths:
5 | - src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php
6 | - src/Bridge/Symfony/Container/ContainerModifier.php
7 | - src/Bridge/Monolog/StreamHandler.php
8 |
9 | # Internal error: Expected to find an ancestor with class name Swoole\Timer on Swoole\Server, but none was found.
10 | - src/Server/WorkerHandler/HMRWorkerStartHandler.php
11 | - hack
12 | ignoreErrors:
13 | # Put false positives here
14 | - '#PHPDoc tag @var for variable \$row contains unresolvable type#'
15 |
--------------------------------------------------------------------------------
/src/Bridge/Upscale/Blackfire/Monitoring/BlackfireMiddlewareFactory.php:
--------------------------------------------------------------------------------
1 | monitoring = $monitoring;
16 | }
17 |
18 | public function createMiddleware(callable $nextMiddleware): callable
19 | {
20 | return new MonitoringMiddleware($nextMiddleware, $this->monitoring);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithWorkerExitHandler.php:
--------------------------------------------------------------------------------
1 | handler = $handler;
17 | }
18 |
19 | /**
20 | * {@inheritdoc}
21 | */
22 | public function configure(Server $server): void
23 | {
24 | $server->on('WorkerExit', [$this->handler, 'handle']);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithWorkerStopHandler.php:
--------------------------------------------------------------------------------
1 | handler = $handler;
17 | }
18 |
19 | /**
20 | * {@inheritdoc}
21 | */
22 | public function configure(Server $server): void
23 | {
24 | $server->on('WorkerStop', [$this->handler, 'handle']);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Server/WorkerHandler/WorkerErrorHandlerInterface.php:
--------------------------------------------------------------------------------
1 | taskworker) {
19 | * echo "Hello from task worker process";
20 | * }
21 | * ```
22 | */
23 | public function handle(Server $worker, int $workerId): void;
24 | }
25 |
--------------------------------------------------------------------------------
/src/Server/WorkerHandler/WorkerStartHandlerInterface.php:
--------------------------------------------------------------------------------
1 | taskworker) {
19 | * echo "Hello from task worker process";
20 | * }
21 | * ```
22 | */
23 | public function handle(Server $worker, int $workerId): void;
24 | }
25 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Resetter/CountingResetter.php:
--------------------------------------------------------------------------------
1 | counter;
20 | $this->decorated->reset($service);
21 | }
22 |
23 | public function getCounter(): int
24 | {
25 | return $this->counter;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithWorkerErrorHandler.php:
--------------------------------------------------------------------------------
1 | handler = $handler;
17 | }
18 |
19 | /**
20 | * {@inheritdoc}
21 | */
22 | public function configure(Server $server): void
23 | {
24 | $server->on('WorkerError', [$this->handler, 'handle']);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/Command/ParametersHelperTrait.php:
--------------------------------------------------------------------------------
1 | parameterBag->get('kernel.project_dir');
17 |
18 | if (!\is_string($projectDir)) {
19 | throw new \UnexpectedValueException('Invalid project directory.');
20 | }
21 |
22 | return $projectDir;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Logging/InMemoryLogger.php:
--------------------------------------------------------------------------------
1 |
11 | */
12 | private static $messages = [];
13 |
14 | public static function logMessage(string $message): void
15 | {
16 | self::$messages[] = $message;
17 | print_r($message.PHP_EOL);
18 | }
19 |
20 | /**
21 | * @return array
22 | */
23 | public static function getAndClear(): array
24 | {
25 | $messages = self::$messages;
26 |
27 | return $messages;
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Message/SleepAndAppend.php:
--------------------------------------------------------------------------------
1 | fileName;
19 | }
20 |
21 | public function getSleepMs(): int
22 | {
23 | return $this->sleepMs;
24 | }
25 |
26 | public function getAppend(): string
27 | {
28 | return $this->append;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Container/Proxy/ContextualProxy.php:
--------------------------------------------------------------------------------
1 |
16 | */
17 | public function getServicePool(): ServicePool;
18 |
19 | /**
20 | * @param ServicePool $servicePool
21 | *
22 | * @return ContextualProxy&RealObjectType
23 | */
24 | public static function staticProxyConstructor(ServicePool $servicePool): object;
25 | }
26 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Controller/ReplacedContentTestController.php.tmpl:
--------------------------------------------------------------------------------
1 | 'text/plain']);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/Server/Configurator/CallableChainConfigurator.php:
--------------------------------------------------------------------------------
1 | $configurators
13 | */
14 | public function __construct(private iterable $configurators)
15 | {
16 | }
17 |
18 | /**
19 | * {@inheritdoc}
20 | */
21 | public function configure(Server $server): void
22 | {
23 | /** @var callable $configurator */
24 | foreach ($this->configurators as $configurator) {
25 | $configurator($server);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Controller/ReplacedContentTestController.php:
--------------------------------------------------------------------------------
1 | 'text/plain']);
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: kind/feature, priority/backlog
6 | assignees: k911
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/DependencyInjection/CompilerPass/OverrideDoctrineCompilerPass.php:
--------------------------------------------------------------------------------
1 | setParameter('doctrine.class', ResetCountingRegistry::class);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/messenger/swoole.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | messenger:
3 | enabled: true
4 | transports:
5 | swoole: swoole://task
6 | routing:
7 | 'K911\Swoole\Tests\Fixtures\Symfony\TestBundle\Message\CreateFileMessage': swoole
8 | swoole:
9 | task_worker:
10 | settings:
11 | worker_count: auto
12 |
13 | services:
14 | _defaults:
15 | autowire: true
16 | autoconfigure: true
17 | public: false
18 |
19 | 'K911\Swoole\Tests\Fixtures\Symfony\TestBundle\Controller\TaskController':
20 | tags:
21 | - controller.service_arguments
22 |
23 | 'K911\Swoole\Tests\Fixtures\Symfony\TestBundle\MessageHandler\CreateFileMessageHandler':
24 | tags:
25 | - messenger.message_handler
26 |
--------------------------------------------------------------------------------
/src/Bridge/Doctrine/ServicePooledRepositoryFactory.php:
--------------------------------------------------------------------------------
1 | decorated->getRepository($this->pooledEm, $entityName);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/phpstan.tests.neon:
--------------------------------------------------------------------------------
1 | parameters:
2 | inferPrivatePropertyTypeFromConstructor: true
3 | checkMissingIterableValueType: false
4 | excludePaths:
5 | - tests/Fixtures/Symfony/app/var
6 | - tests/Fixtures/Symfony/app/TestAppKernel
7 |
8 | # Internal error: Expected to find an ancestor with class name Swoole\Timer on Swoole\Server, but none was found.
9 | - tests/Unit/Server/SwooleHttpServerDummy.php
10 | - tests/Unit/Server/SwooleServerMock.php
11 | - tests/Unit/Server/Php8/SwooleServerMock.php
12 | - tests/Unit/Server/SwooleHttpServerMock.php
13 | ignoreErrors:
14 | # Put false positives here
15 |
16 | # Symfony configuration files
17 | - '#Variable \$container might not be defined#'
18 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Service/InMemoryRepository.php:
--------------------------------------------------------------------------------
1 | storedValue) {
17 | throw new \RuntimeException('Repository was not reset.');
18 | }
19 |
20 | $this->storedValue = $test;
21 | }
22 |
23 | public function reset(): void
24 | {
25 | $this->storedValue = null;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/ExceptionHandler/TestCustomExceptionHandler.php:
--------------------------------------------------------------------------------
1 | header(Http::HEADER_CONTENT_TYPE, Http::CONTENT_TYPE_TEXT_PLAIN);
17 | $response->status(500);
18 | $response->end('Very custom exception handler');
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/ErrorHandler/ExceptionHandlerFactory.php:
--------------------------------------------------------------------------------
1 | kernel,
22 | $request,
23 | $this->throwableHandler
24 | );
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/DependencyInjection/CompilerPass/StatefulServices/NonSharedSvcPoolConfigurator.php:
--------------------------------------------------------------------------------
1 | $servicePool
18 | */
19 | public function configure(BaseServicePool $servicePool): void
20 | {
21 | $this->container->addPool($servicePool);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/HttpKernel/SimpleKernelPool.php:
--------------------------------------------------------------------------------
1 | kernel->boot();
18 | }
19 |
20 | public function get(): KernelInterface
21 | {
22 | return $this->kernel;
23 | }
24 |
25 | /**
26 | * @SuppressWarnings(PHPMD.UnusedFormalParameter)
27 | */
28 | public function return(KernelInterface $kernel): void
29 | {
30 | // no need to be implemented
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/MessageHandler/CreateFileMessageHandler.php:
--------------------------------------------------------------------------------
1 | fileName(), '\\/');
16 | $result = file_put_contents($filePath, $message->content());
17 | Assertion::true(false !== $result, 'Could not create test file.');
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithTaskHandler.php:
--------------------------------------------------------------------------------
1 | configuration->getTaskWorkerCount() > 0) {
25 | $server->on('task', [$this->handler, 'handle']);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/EventDispatcher/EventDispatchingServerStartHandler.php:
--------------------------------------------------------------------------------
1 | eventDispatcher->dispatch(new ServerStartedEvent($server), ServerStartedEvent::NAME);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Server/RequestHandler/ExceptionHandler/ProductionExceptionHandler.php:
--------------------------------------------------------------------------------
1 | header(Http::HEADER_CONTENT_TYPE, Http::CONTENT_TYPE_TEXT_PLAIN);
18 | $response->status(500);
19 | $response->end(self::ERROR_MESSAGE);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/CoverageBundle/EventListeners/CoverageStartOnConsoleCommandEventListener.php:
--------------------------------------------------------------------------------
1 | getCommand()->getName());
19 | $this->coverageManager->start(sprintf('test_cmd_%s', $slug));
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Controller/TidewaysController.php:
--------------------------------------------------------------------------------
1 | Profiler::$wasStarted,
26 | 'stopped' => Profiler::$wasStopped,
27 | ]);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Client/Http.php:
--------------------------------------------------------------------------------
1 | eventDispatcher->dispatch(new WorkerErrorEvent($server, $workerId), WorkerErrorEvent::NAME);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/EventDispatcher/EventDispatchingWorkerExitHandler.php:
--------------------------------------------------------------------------------
1 | eventDispatcher->dispatch(new WorkerExitedEvent($server, $workerId), WorkerExitedEvent::NAME);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/EventDispatcher/EventDispatchingWorkerStopHandler.php:
--------------------------------------------------------------------------------
1 | eventDispatcher->dispatch(new WorkerStoppedEvent($server, $workerId), WorkerStoppedEvent::NAME);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/EventDispatcher/EventDispatchingWorkerStartHandler.php:
--------------------------------------------------------------------------------
1 | eventDispatcher->dispatch(new WorkerStartedEvent($server, $workerId), WorkerStartedEvent::NAME);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/app/config/monolog.php:
--------------------------------------------------------------------------------
1 | [
10 | 'type' => 'stream',
11 | 'path' => '%kernel.logs_dir%/%kernel.environment%.log',
12 | 'level' => 'debug',
13 | 'channels' => ['!event'],
14 | ],
15 | ];
16 |
17 | $container->addResource(new ClassExistenceResource(Application::class));
18 | if (\class_exists(Application::class)) {
19 | $handlers['console'] = [
20 | 'type' => 'console',
21 | 'process_psr_3_messages' => false,
22 | 'channels' => ['!event', '!console'],
23 | ];
24 | }
25 |
26 | $container->loadFromExtension('monolog', [
27 | 'handlers' => $handlers,
28 | ]);
29 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Messenger/ContextReleasingTransportHandler.php:
--------------------------------------------------------------------------------
1 | coWrapper->defer();
27 | $this->decorated->handle($server, $task);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/Server/Api/ApiServerClientFactory.php:
--------------------------------------------------------------------------------
1 | sockets->hasApiSocket(), 'Swoole HTTP Server is not configured properly. To access API trough HTTP interface, you must enable and provide proper address of configured API Server.');
20 |
21 | return new ApiServerClient(HttpClient::fromSocket(
22 | $this->sockets->getApiSocket(),
23 | $options
24 | ));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Server/Configurator/CallableChainConfiguratorFactory.php:
--------------------------------------------------------------------------------
1 | map(function ($configurator): callable {
17 | Assertion::isInstanceOf($configurator, ConfiguratorInterface::class);
18 |
19 | return [$configurator, 'configure'];
20 | })
21 | );
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Server/Configurator/WithTaskFinishedHandler.php:
--------------------------------------------------------------------------------
1 | configuration->getTaskWorkerCount() > 0) {
25 | $server->on('finish', [$this->handler, 'handle']);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/CoverageBundle/EventListeners/CoverageFinishOnConsoleTerminate.php:
--------------------------------------------------------------------------------
1 | coverageManager->stop();
19 |
20 | $slug = str_replace(['-', ':'], '_', $commandEvent->getCommand()->getName());
21 | $this->coverageManager->finish(sprintf('test_cmd_%s', $slug));
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/DependencyInjection/CompilerPass/SleepingCounterCompileProcessor.php:
--------------------------------------------------------------------------------
1 | proxifyService(SleepingCounter::class);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/Bridge/Doctrine/ORM/EntityManagerStabilityChecker.php:
--------------------------------------------------------------------------------
1 | isOpen();
20 | }
21 |
22 | public static function getSupportedClass(): string
23 | {
24 | return EntityManager::class;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Messenger/ServiceResettingTransportHandler.php:
--------------------------------------------------------------------------------
1 | resetter->reset();
27 | $this->decorated->handle($server, $task);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/tests/Fixtures/Symfony/TestBundle/Controller/BlackfireController.php:
--------------------------------------------------------------------------------
1 | \BlackfireProbe::wasStarted(), /* @phpstan-ignore-line */
25 | 'stopped' => \BlackfireProbe::wasStopped(), /* @phpstan-ignore-line */
26 | ]);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Bundle/DependencyInjection/CompilerPass/StatefulServices/StatefulServiceTag.php:
--------------------------------------------------------------------------------
1 | tag['limit'] ?? null;
19 | }
20 |
21 | public function getResetter(): ?string
22 | {
23 | return $this->tag['resetter'] ?? null;
24 | }
25 |
26 | public function getResetOnEachRequest(): ?bool
27 | {
28 | return $this->tag['reset_on_each_request'] ?? null;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/Bridge/Symfony/Container/ServicePool/ServicePoolContainer.php:
--------------------------------------------------------------------------------
1 | > $pools
11 | */
12 | public function __construct(private array $pools)
13 | {
14 | }
15 |
16 | /**
17 | * @param ServicePool