🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Disable zend.assertions as suggested by PHPParser - #6021

Merged
staabm merged 2 commits into
phpstan:2.2.xfrom
staabm:dis-zend
Jul 8, 2026
Merged

Disable zend.assertions as suggested by PHPParser#6021
staabm merged 2 commits into
phpstan:2.2.xfrom
staabm:dis-zend

Conversation

@staabm

@staabm staabm commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

nikic/PHP-Parser Performance.markdown suggests to use zend.assertions=0 at runtime.

at best the php.ini of the php binary beeing used would define zend.assertions=-1, but thats neither the default php ships with in development nor is it likely people will adjust this setting in a environment in which PHPStan is running

quoting the php.ini:

; Switch whether to compile assertions at all (to have no overhead at run-time)
; -1: Do not compile at all
;  0: Jump over assertion at run-time
;  1: Execute assertions
; Changing from or to a negative value is only possible in php.ini!
; (For turning assertions on and off at run-time, toggle zend.assertions between the values 1 and 0)
; Default Value: 1
; Development Value: 1
; Production Value: -1
; https://php.net/zend.assertions
;zend.assertions = -1

so with this PR we disable zend-asserts at runtime in case they are not disabled entirely by the used php.ini setting already.

testing on https://github.com/TomasVotruba/php-parser-speed-comparison-2026 suggests this has some small benefit

@staabm
staabm marked this pull request as ready for review July 8, 2026 09:14
@phpstan-bot

Copy link
Copy Markdown
Collaborator

This pull request has been marked as ready for review.

@staabm
staabm requested a review from VincentLanglet July 8, 2026 09:37

@VincentLanglet VincentLanglet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth having the go from ondrej

@staabm
staabm merged commit c59b442 into phpstan:2.2.x Jul 8, 2026
670 of 671 checks passed
@staabm
staabm deleted the dis-zend branch July 8, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants