Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPStan level 10 part I #443

Merged
merged 24 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0ae54b7
Add TypedDatabase::fetchAll() and use it
spaze Nov 17, 2024
d179bbd
Add assert(), isset(), is_array(), docblocks etc. to narrow types
spaze Nov 17, 2024
2233248
Use assert() instead of ShouldNotHappenException in tests
spaze Nov 18, 2024
fb569d7
Use Composer\Pcre\Preg::split() instead of Nette\Utils\Strings::split…
spaze Nov 18, 2024
3cd3d36
Presenter action params can also be a list
spaze Nov 19, 2024
e297212
Ensure presenter action parameters are strings
spaze Nov 19, 2024
436ff50
Log only string values in training application logger
spaze Nov 20, 2024
64a8515
Add test for Pulse\Passwords\PasswordsSorting
spaze Nov 21, 2024
fe6552c
Ensure $collator is Collator
spaze Nov 21, 2024
f0bde60
Adding docblock
spaze Nov 21, 2024
213a6ec
Add assert()s to Passwords::addStorage()
spaze Nov 27, 2024
ad3180b
Slide filenames are always a string, the database column is not nullable
spaze Nov 29, 2024
2fc852b
Splitting a string, even if empty, will always return an array
spaze Nov 29, 2024
6b1dd08
Add assert() tests to narrow types and add tests
spaze Nov 29, 2024
0ac8391
Update Psalm's baseline
spaze Nov 18, 2024
f79ba26
Use Texy constants on the class, not on the object
spaze Nov 29, 2024
5134c44
Add assert()s to narrow types in (some) Forms
spaze Nov 30, 2024
19e8c6a
Disallow Form::getValues() instead of deprecating it in a child class
spaze Nov 30, 2024
0012003
Use form rule validator constants on the Form class, not on the object
spaze Nov 30, 2024
47445b8
Anchor form method
spaze Nov 30, 2024
14ac36e
Rename the skip method to needsInternet as that's what it marks anyway
spaze Dec 1, 2024
9af70cc
Add assert()s and tests to test those assert()s
spaze Nov 30, 2024
b0e83f1
Validate Register účtovných závierok API responses with nette/schema
spaze Dec 1, 2024
404e8a2
Adding assert() to forms, required a bit of refactoring here and there
spaze Dec 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/config/services.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ services:
cliArgs:
type: MichalSpacekCz\Application\Cli\CliArgs
imported: true
- MichalSpacekCz\Application\ComponentParameters
- MichalSpacekCz\Application\Error
- MichalSpacekCz\Application\LinkGenerator
localeLinkGenerator: MichalSpacekCz\Application\Locale\LocaleLinkGenerator(languages: %locales.languages%)
Expand Down Expand Up @@ -31,6 +32,7 @@ services:
create: MichalSpacekCz\Database\TypedDatabase
autowired: MichalSpacekCz\Database\TypedDatabase
typedDatabase.pulse: MichalSpacekCz\Database\TypedDatabase(@database.pulse.explorer)
typedDatabase.upcKeys: MichalSpacekCz\Database\TypedDatabase(@database.upcKeys.explorer)
dateTimeFactory: MichalSpacekCz\DateTime\DateTimeFactory
- MichalSpacekCz\DateTime\DateTimeFormatter(@translation.translator::getDefaultLocale())
- MichalSpacekCz\DateTime\DateTimeParser
Expand Down Expand Up @@ -94,15 +96,15 @@ services:
talkVideoThumbnails: MichalSpacekCz\Media\VideoThumbnails(mediaResources: @talkMediaResources)
interviewVideoThumbnails: MichalSpacekCz\Media\VideoThumbnails(mediaResources: @interviewMediaResources)
- MichalSpacekCz\Net\DnsResolver
- MichalSpacekCz\Pulse\Companies(@database.pulse.explorer)
- MichalSpacekCz\Pulse\Companies(@database.pulse.explorer, @typedDatabase.pulse)
- MichalSpacekCz\Pulse\Passwords\Algorithms\PasswordHashingAlgorithms(@database.pulse.explorer, @typedDatabase.pulse)
- MichalSpacekCz\Pulse\Passwords\Disclosures\PasswordHashingDisclosures(@database.pulse.explorer, @typedDatabase.pulse)
- MichalSpacekCz\Pulse\Passwords\Passwords(@database.pulse.explorer, @typedDatabase.pulse)
- MichalSpacekCz\Pulse\Passwords\PasswordsSorting
- MichalSpacekCz\Pulse\Passwords\Rating
- MichalSpacekCz\Pulse\Passwords\Storage\StorageAlgorithmAttributesFactory
- MichalSpacekCz\Pulse\Passwords\Storage\StorageRegistryFactory
- MichalSpacekCz\Pulse\Sites(@database.pulse.explorer)
- MichalSpacekCz\Pulse\Sites(@database.pulse.explorer, @typedDatabase.pulse)
- MichalSpacekCz\Tags\Tags
- MichalSpacekCz\Talks\Slides\TalkSlides
- MichalSpacekCz\Talks\TalkFactory(videoFactory: @talkVideoFactory)
Expand Down Expand Up @@ -157,7 +159,7 @@ services:
- MichalSpacekCz\Training\Venues\TrainingVenues
- MichalSpacekCz\Twitter\TwitterCards
- MichalSpacekCz\UpcKeys\Technicolor(@database.upcKeys.explorer, apiUrl: %awsLambda.upcKeys.url%, apiKey: %awsLambda.upcKeys.apiKey%)
- MichalSpacekCz\UpcKeys\Ubee(@database.upcKeys.explorer)
- MichalSpacekCz\UpcKeys\Ubee(@typedDatabase.upcKeys)
- MichalSpacekCz\UpcKeys\UpcKeys(routers: [@MichalSpacekCz\UpcKeys\Technicolor, @MichalSpacekCz\UpcKeys\Ubee])
- MichalSpacekCz\User\Manager(passwordEncryption: @passwordEncryption, permanentLoginInterval: %permanentLogin.interval%)
- MichalSpacekCz\Utils\Strings
Expand Down
2 changes: 2 additions & 0 deletions app/config/tests.neon
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ services:
database.pulse.explorer: @database.default.explorer
dateTimeFactory: MichalSpacekCz\Test\DateTime\DateTimeMachineFactory
httpClient: MichalSpacekCz\Test\Http\Client\HttpClientMock
- MichalSpacekCz\Test\Form\FormComponents
session.session: MichalSpacekCz\Test\Http\NullSession
http.request: MichalSpacekCz\Test\Http\Request
http.response: MichalSpacekCz\Test\Http\Response
- MichalSpacekCz\Test\Http\SecurityHeadersFactory
mail.mailer: MichalSpacekCz\Test\NullMailer
translation.translator: MichalSpacekCz\Test\NoOpTranslator(availableLocales: [cs_CZ, en_US], defaultLocale: cs_CZ)
tracy.logger: MichalSpacekCz\Test\NullLogger
security.userStorage: MichalSpacekCz\Test\Security\NullUserStorage
- MichalSpacekCz\Test\TestCaseRunner
trainingFilesStorage: MichalSpacekCz\Test\Training\TrainingFilesNullStorage
cache.storage: Nette\Caching\Storages\DevNullStorage
Expand Down
17 changes: 8 additions & 9 deletions app/disallowed-calls.neon
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ parameters:
method: 'Tester\Environment::skip()'
message: 'use TestCaseRunner::skip() instead, it can ignore skipping with an environment variable'
allowInMethods:
- 'MichalSpacekCz\Test\TestCaseRunner::skip()'
- 'MichalSpacekCz\Test\TestCaseRunner::needsInternet()'
-
method:
- 'Nette\Utils\Strings::match()'
- 'Nette\Utils\Strings::matchAll()'
- 'Nette\Utils\Strings::replace()'
- 'Nette\Utils\Strings::split()'
message: 'use the Preg or Regex class from composer/pcre for better static analysis'
disallowedMethodCalls:
-
Expand All @@ -55,6 +56,12 @@ parameters:
message: 'use MichalSpacekCz\DateTime\DateTimeZoneFactory::get() instead, throws a more specific exception'
allowInMethods:
- 'MichalSpacekCz\DateTime\DateTimeZoneFactory::get()'
-
method:
- 'Nette\Forms\Container::getValues()'
- 'Nette\Forms\Container::getUntrustedValues()'
message: 'use methods from MichalSpacekCz\Form\UiForm instead'

disallowedConstants:
-
constant: 'LIBXML_NOENT'
Expand All @@ -67,14 +74,6 @@ parameters:
- src/Application/ServerEnv.php
- tests/Application/ServerEnvTest.phpt
disallowedClasses:
-
class:
- 'Nette\Application\UI\Form'
- 'Nette\Forms\Form'
message: 'use MichalSpacekCz\Form\UiForm for better type declarations'
allowIn:
- src/Form/UiForm.php
- src/Form/Controls/TrainingControlsFactory.php
-
class:
- 'Spaze\PhpInfo\PhpInfo'
Expand Down
8 changes: 8 additions & 0 deletions app/phpstan-vendor.neon
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,13 @@ parameters:
message: 'use MichalSpacekCz\DateTime\DateTimeZoneFactory::get() instead, throws a more specific exception'
allowIn:
- vendor/*.php
-
method:
- 'Nette\Forms\Container::getValues()'
- 'Nette\Forms\Container::getUntrustedValues()'
message: 'use methods from MichalSpacekCz\Form\UiForm instead'
allowIn:
- vendor/nette/*.php
disallowedStaticCalls:
-
method: 'Tracy\Debugger::barDump()'
Expand All @@ -218,6 +225,7 @@ parameters:
- 'Nette\Utils\Strings::match()'
- 'Nette\Utils\Strings::matchAll()'
- 'Nette\Utils\Strings::replace()'
- 'Nette\Utils\Strings::split()'
allowIn:
- vendor/contributte/*.php
- vendor/nette/*.php
Expand Down
Loading
Loading