@@ -24,128 +24,103 @@ public function getConfigTreeBuilder()
2424 {
2525 $ treeBuilder = new TreeBuilder ('sentry ' );
2626 /** @var ArrayNodeDefinition $rootNode */
27- $ rootNode = \method_exists (TreeBuilder::class, 'getRootNode ' ) ? $ treeBuilder ->getRootNode () : $ treeBuilder ->root ('sentry ' );
27+ $ rootNode = \method_exists (TreeBuilder::class, 'getRootNode ' )
28+ ? $ treeBuilder ->getRootNode ()
29+ : $ treeBuilder ->root ('sentry ' );
2830
2931 // Basic Sentry configuration
3032 $ rootNode ->children ()
3133 ->scalarNode ('dsn ' )
32- ->beforeNormalization ()
33- ->ifString ()
34- ->then ($ this ->getTrimClosure ())
35- ->end ()
36- ->defaultNull ()
37- ->end ();
34+ ->defaultNull ()
35+ ->beforeNormalization ()
36+ ->ifString ()
37+ ->then ($ this ->getTrimClosure ());
3838
3939 // Options array (to be passed to Sentry\Options constructor) -- please keep alphabetical order!
4040 $ optionsNode = $ rootNode ->children ()
4141 ->arrayNode ('options ' )
4242 ->addDefaultsIfNotSet ();
4343
4444 $ defaultValues = new Options ();
45-
46- $ optionsNode
47- ->children ()
48- ->booleanNode ('attach_stacktrace ' )->end ()
49- ->variableNode ('before_breadcrumb ' )
50- ->validate ()
51- ->ifTrue ($ this ->isNotAValidCallback ())
52- ->thenInvalid ('Expecting callable or service reference, got %s ' )
53- ->end ()
54- ->end ()
55- ->variableNode ('before_send ' )
56- ->validate ()
57- ->ifTrue ($ this ->isNotAValidCallback ())
58- ->thenInvalid ('Expecting callable or service reference, got %s ' )
59- ->end ()
60- ->end ()
61- ->booleanNode ('default_integrations ' )->end ()
62- ->integerNode ('context_lines ' )
63- ->min (0 )
64- ->max (99 )
65- ->end ()
66- ->booleanNode ('enable_compression ' )->end ()
67- ->scalarNode ('environment ' )
68- ->defaultValue ('%kernel.environment% ' )
69- ->cannotBeEmpty ()
70- ->end ()
71- ->scalarNode ('error_types ' )
72- ->end ()
73- ->arrayNode ('in_app_exclude ' )
74- ->defaultValue ([
75- '%kernel.cache_dir% ' ,
76- $ this ->getProjectRoot () . '/vendor ' ,
77- ])
78- ->prototype ('scalar ' )->end ()
79- ->end ()
80- ->arrayNode ('excluded_exceptions ' )
81- ->defaultValue ($ defaultValues ->getExcludedExceptions ())
82- ->prototype ('scalar ' )->end ()
83- ->end ()
84- ->scalarNode ('http_proxy ' )
85- ->end ()
86- ->arrayNode ('integrations ' )
87- ->prototype ('scalar ' )
88- ->validate ()
89- ->ifTrue (function ($ value ): bool {
90- if (! is_string ($ value )) {
91- return true ;
92- }
93-
94- return '@ ' !== substr ($ value , 0 , 1 );
95- })
96- ->thenInvalid ('Expecting service reference, got %s ' )
97- ->end ()
98- ->end ()
99- ->end ()
100- ->scalarNode ('logger ' )
101- ->end ()
102- ->integerNode ('max_breadcrumbs ' )
103- ->min (1 )
104- ->end ()
105- ->integerNode ('max_value_length ' )
106- ->min (1 )
107- ->end ()
108- ->arrayNode ('prefixes ' )
109- ->defaultValue ($ defaultValues ->getPrefixes ())
110- ->prototype ('scalar ' )->end ()
111- ->end ()
112- ->scalarNode ('project_root ' )
113- ->defaultValue ($ this ->getProjectRoot ())
114- ->end ()
115- ->scalarNode ('release ' )
116- ->end ()
117- ->floatNode ('sample_rate ' )
118- ->min (0.0 )
119- ->max (1.0 )
120- ->end ()
121- ->integerNode ('send_attempts ' )
122- ->min (1 )
123- ->end ()
124- ->booleanNode ('send_default_pii ' )->end ()
125- ->scalarNode ('server_name ' )
126- ->end ()
127- ->arrayNode ('tags ' )
128- ->normalizeKeys (false )
129- ->prototype ('scalar ' )
130- ->end ()
131- ;
45+ $ optionsChildNodes = $ optionsNode ->children ();
46+
47+ $ optionsChildNodes ->booleanNode ('attach_stacktrace ' );
48+ $ optionsChildNodes ->variableNode ('before_breadcrumb ' )
49+ ->validate ()
50+ ->ifTrue ($ this ->isNotAValidCallback ())
51+ ->thenInvalid ('Expecting callable or service reference, got %s ' );
52+ $ optionsChildNodes ->variableNode ('before_send ' )
53+ ->validate ()
54+ ->ifTrue ($ this ->isNotAValidCallback ())
55+ ->thenInvalid ('Expecting callable or service reference, got %s ' );
56+ $ optionsChildNodes ->integerNode ('context_lines ' )
57+ ->min (0 )
58+ ->max (99 );
59+ $ optionsChildNodes ->booleanNode ('default_integrations ' );
60+ $ optionsChildNodes ->booleanNode ('enable_compression ' );
61+ $ optionsChildNodes ->scalarNode ('environment ' )
62+ ->defaultValue ('%kernel.environment% ' )
63+ ->cannotBeEmpty ();
64+ $ optionsChildNodes ->scalarNode ('error_types ' );
65+ $ optionsChildNodes ->arrayNode ('in_app_exclude ' )
66+ ->defaultValue ([
67+ '%kernel.cache_dir% ' ,
68+ $ this ->getProjectRoot () . '/vendor ' ,
69+ ])
70+ ->prototype ('scalar ' );
71+ $ optionsChildNodes ->arrayNode ('excluded_exceptions ' )
72+ ->defaultValue ($ defaultValues ->getExcludedExceptions ())
73+ ->prototype ('scalar ' );
74+ $ optionsChildNodes ->scalarNode ('http_proxy ' );
75+ $ optionsChildNodes ->arrayNode ('integrations ' )
76+ ->prototype ('scalar ' )
77+ ->validate ()
78+ ->ifTrue (function ($ value ): bool {
79+ if (! is_string ($ value )) {
80+ return true ;
81+ }
82+
83+ return '@ ' !== substr ($ value , 0 , 1 );
84+ })
85+ ->thenInvalid ('Expecting service reference, got %s ' );
86+ $ optionsChildNodes ->scalarNode ('logger ' );
87+ $ optionsChildNodes ->integerNode ('max_breadcrumbs ' )
88+ ->min (1 );
89+ $ optionsChildNodes ->integerNode ('max_value_length ' )
90+ ->min (1 );
91+ $ optionsChildNodes ->arrayNode ('prefixes ' )
92+ ->defaultValue ($ defaultValues ->getPrefixes ())
93+ ->prototype ('scalar ' );
94+ $ optionsChildNodes ->scalarNode ('project_root ' )
95+ ->defaultValue ($ this ->getProjectRoot ());
96+ $ optionsChildNodes ->scalarNode ('release ' );
97+ $ optionsChildNodes ->floatNode ('sample_rate ' )
98+ ->min (0.0 )
99+ ->max (1.0 );
100+ $ optionsChildNodes ->integerNode ('send_attempts ' )
101+ ->min (1 );
102+ $ optionsChildNodes ->booleanNode ('send_default_pii ' );
103+ $ optionsChildNodes ->scalarNode ('server_name ' );
104+ $ optionsChildNodes ->arrayNode ('tags ' )
105+ ->normalizeKeys (false )
106+ ->prototype ('scalar ' );
132107
133108 // Bundle-specific configuration
134- $ rootNode ->children ()
109+ $ listenerPriorities = $ rootNode ->children ()
135110 ->arrayNode ('listener_priorities ' )
136- ->addDefaultsIfNotSet ()
137- ->children ()
138- ->scalarNode ('request ' )-> defaultValue ( 1 )-> end ( )
139- -> scalarNode ( ' console ' )-> defaultValue (1 )-> end ()
140- -> end ( )
141- ->end ( );
111+ ->addDefaultsIfNotSet ()
112+ ->children ();
113+ $ listenerPriorities ->scalarNode ('request ' )
114+ -> defaultValue (1 );
115+ $ listenerPriorities -> scalarNode ( ' console ' )
116+ ->defaultValue ( 1 );
142117
143118 return $ treeBuilder ;
144119 }
145120
146- private function getTrimClosure (): callable
121+ private function getTrimClosure (): \ Closure
147122 {
148- return function ($ str ) {
123+ return function ($ str ): ? string {
149124 $ value = trim ($ str );
150125 if ($ value === '' ) {
151126 return null ;
0 commit comments