Nếu bạn đang sử dụng FormBuilder [bên ngoài bảng quản trị] cùng với PHPStan, bạn có thể gặp lỗi
Access to an undefined property App\Http\Livewire\MyLivewireComponentWithForm::$form.
Để giải quyết vấn đề này, bạn có thể thêm khối tài liệu sau vào thành phần Livewire của mình
use Filament\Forms\ComponentContainer;
use Filament\Forms\Contracts\HasForms;
* @property ComponentContainer $form
class MyLivewireComponentWithForm extends Component implements HasForms
Vui lòng đánh dấu vào mục có thể điền vào User model
nếu nó đã vượt qua contact_name
Ngoài ra, bạn có thể làm dd[$request->all[]];
và xem liệu contact_name
có được thông qua hay không
-Công nghệ Skynet
Cập nhật lần cuối 7 tháng trước
thanx. rất xin lỗi vì sự chậm trễ. tôi sẽ thử nó
Vấn đề là không có bất kỳ định nghĩa nào cho biến contact_name
của bạn theo yêu cầu
Tôi nghi ngờ bạn có thể thay đổi nó để sử dụng phương thức nhập liệu theo yêu cầu
$user = User::create[[ 'contact_name' => $request->input['contact_name'], ]];
Đăng nhập để tham gia vào chủ đề này
Xin lưu ý rằng một số lỗi nghiêm trọng đã chọn [như sự cố tự động tải, không tìm thấy lớp cha, lỗi phân tích cú pháp, v.v. ] không thể bỏ qua và phải được giải quyết để không có lỗi khi chạy PHPStan
Bỏ qua mã bằng PHPDocs
Lỗi có thể được bỏ qua bên cạnh dòng mã vi phạm bằng cách sử dụng thẻ PHPDoc trong nhận xét
@phpstan-ignore-line
0parameters:
reportUnmatchedIgnoredErrors: false
Tất cả các kiểu chú thích PHP [
parameters:
reportUnmatchedIgnoredErrors: false
1, parameters:
reportUnmatchedIgnoredErrors: false
2, parameters:
reportUnmatchedIgnoredErrors: false
3] đều có thể được sử dụngBỏ qua trong tập tin cấu hình
Có thể bỏ qua lỗi bằng cách thêm biểu thức chính quy vào tệp cấu hình bên dưới khóa
parameters:
reportUnmatchedIgnoredErrors: false
4. Để bỏ qua một lỗi bởi một biểu thức chính quy trong toàn bộ dự án, hãy thêm một mục nhập chuỗi________số 8_______Để bỏ qua các lỗi chỉ bằng một biểu thức chính quy trong một tệp cụ thể, hãy thêm mục nhập bằng các phím
parameters:
reportUnmatchedIgnoredErrors: false
5 hoặc parameters:
reportUnmatchedIgnoredErrors: false
6 và parameters:
reportUnmatchedIgnoredErrors: false
7 hoặc parameters:
reportUnmatchedIgnoredErrors: false
8. Các mẫu ký tự đại diện tương thích với PHP parameters:
reportUnmatchedIgnoredErrors: false
9 cũng được hỗ trợ. Bạn có thể chỉ định số lần dự kiến xảy ra lỗi bằng cách sử dụng parameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#This message will not be reported as unmatched#'
- '#This message will not be reported as unmatched either#'
-
message: '#But this one will be reported#'
reportUnmatched: true
0 [tùy chọn, chỉ áp dụng cho parameters:
reportUnmatchedIgnoredErrors: false
5 chứ không phải parameters:
reportUnmatchedIgnoredErrors: false
6 và parameters:
reportUnmatchedIgnoredErrors: false
7, không phải parameters:
reportUnmatchedIgnoredErrors: false
8]Các đường dẫn tương đối trong khóa
parameters:
reportUnmatchedIgnoredErrors: false
7 và parameters:
reportUnmatchedIgnoredErrors: false
8 được giải quyết dựa trên thư mục của tệp cấu hình nằm trong. Vì vậy, nếu parameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#This message will not be reported as unmatched#'
- '#This message will not be reported as unmatched either#'
-
message: '#But this one will be reported#'
reportUnmatched: true
7 của bạn nằm trong thư mục gốc của dự án và bạn muốn bỏ qua một lỗi trong parameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#This message will not be reported as unmatched#'
- '#This message will not be reported as unmatched either#'
-
message: '#But this one will be reported#'
reportUnmatched: true
8, khóa đường dẫn của bạn có thể đơn giản là parameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#This message will not be reported as unmatched#'
- '#This message will not be reported as unmatched either#'
-
message: '#But this one will be reported#'
reportUnmatched: true
8Sử dụng các trường bên dưới, bạn có thể tạo một mục nhập mà bạn có thể đặt vào phần
parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
0 trong tệp cấu hình của mình. Nó đề cập đến sự phức tạp của việc viết một biểu thức chính quy phù hợp từ một chuỗi đơn giản và mã hóa biểu thức chính quy đó thành định dạng neonSao chép phần sau vào phpstan của bạn. đèn neon
Đã xảy ra lỗi. Vui lòng thử lại sau
đường cơ sở
Nếu bạn muốn bỏ qua tất cả các lỗi hiện tại và chỉ tập trung vào mã mới và mã đã thay đổi kể từ bây giờ, hãy đi và tìm hiểu về tính năng cơ bản
Nếu một số lỗi bị bỏ qua [cả từ cấu hình và PHPDocs] không xuất hiện trong kết quả nữa, PHPStan sẽ cho bạn biết và bạn sẽ phải xóa mẫu khỏi cấu hình. Bạn có thể tắt hành vi này bằng cách đặt
parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
1 thành parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
2 trong cấu hìnhparameters:
reportUnmatchedIgnoredErrors: false
Bạn có thể bật/tắt báo cáo bỏ qua không sử dụng một cách rõ ràng cho mỗi mục trong
parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
3. Điều này ghi đè cài đặt parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
1 toàn cầuparameters:
reportUnmatchedIgnoredErrors: false
ignoreErrors:
- '#This message will not be reported as unmatched#'
- '#This message will not be reported as unmatched either#'
-
message: '#But this one will be reported#'
reportUnmatched: true
parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
Loại trừ toàn bộ tệp
Nếu cơ sở mã của bạn chứa một số tệp cố ý bị hỏng [e. g. để kiểm tra hành vi của ứng dụng của bạn trên các tệp có mã PHP không hợp lệ], bạn có thể loại trừ chúng bằng cách sử dụng khóa
parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
5. Mỗi mục nhập được sử dụng làm mẫu cho hàm parameters:
reportUnmatchedIgnoredErrors: false
9parameters:
excludePaths:
- tests/*/data/*
Đây là một phím tắt cho
parameters:
excludePaths:
analyseAndScan:
- tests/*/data/*
Nếu cấu trúc thư mục của dự án kết hợp mã của riêng bạn [mã mà bạn muốn phân tích và sửa lỗi] và mã của bên thứ ba [mà bạn đang sử dụng để khám phá các ký hiệu nhưng không muốn phân tích], thì cấu trúc tệp có thể giống như
├── phpstan.neon
└── src
├── foo.php
├── ...
└── thirdparty
└── bar.php
Trong trường hợp này, bạn muốn phân tích toàn bộ thư mục
parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
7, nhưng muốn loại trừ parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
8 khỏi phân tích. Đây là cách cấu hình PHPStanparameters:
paths:
- src
excludePaths:
analyse:
- src/thirdparty
Ngoài ra, có thể có một thư mục
parameters:
reportUnmatchedIgnoredErrors: true
ignoreErrors:
- '#This message will be reported as unmatched#'
- '#This message will be reported as unmatched too#'
-
message: '#But this one will not be reported#'
reportUnmatched: false
9 chứa các tệp mà bạn không muốn phân tích hoặc sử dụng để khám phá các biểu tượng. Bạn có thể sửa đổi cấu hình để đạt được hiệu ứng đó